1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-01-18 04:58:51 +02:00

Escape special characters in latex when not in a code block.

A number of common characters are not allowed in latex without being escaped.

Also convert some HTML-specific codes that are used in the documentation.

Contributed by Cynthia Shang.
This commit is contained in:
Cynthia Shang 2018-12-19 19:13:26 +02:00 committed by David Steele
parent 23b583336f
commit 8cf8d29f12
2 changed files with 35 additions and 0 deletions

View File

@ -890,6 +890,33 @@ sub processText
$strBuffer =~ s/\<\=/\$\\leq\$/g;
$strBuffer =~ s/\>\=/\$\\geq\$/g;
# $strBuffer =~ s/\_/\\_/g;
# If not a code-block, which is to be taken AS IS, then escape special characters in latex
if ($oText->nameGet() ne 'code-block')
{
# If the previous character is not already a slash (e.g. not already escaped) then insert a slash
$strBuffer =~ s/(?<!\\)\#/\\#/g;
$strBuffer =~ s/(?<!\\)\%/\\%/g;
$strBuffer =~ s/(?<!\\)\_/\\_/g;
# $strBuffer =~ s/(?<!\\)\$/\\\$/g;
# Escape square brackest in list items since they are used for reformatting the bullet item with what is in brackets,
# which is not the intention.
if ($oText->nameGet() eq 'list-item')
{
$strBuffer =~ s/\[/\{\[/g;
$strBuffer =~ s/\]/\]\}/g;
}
$strBuffer =~ s/\&copy\;/{\\textcopyright}/g;
$strBuffer =~ s/\&trade\;/{\\texttrademark}/g;
$strBuffer =~ s/\&reg\;/{\\textregistered}/g;
$strBuffer =~ s/\&rarr\;/{\\textrightarrow}/g;
# Escape all ampersands after making any other conversions above
$strBuffer =~ s/(?<!\\)\&/\\&/g;
}
}
if ($strType eq 'text')

View File

@ -251,6 +251,14 @@
<p>Add HTML table rendering and update PDF/Markdown renderers to support header-less tables.</p>
</release-item>
<release-item>
<release-item-contributor-list>
<release-item-contributor id="cynthia.shang"/>
</release-item-contributor-list>
<p>Escape special characters in latex when not in a code block.</p>
</release-item>
<release-item>
<release-item-contributor-list>
<release-item-contributor id="cynthia.shang"/>