Merge pull request #6845 from jfbu/latex_do_not_escape_verticalbarchar

LaTeX: stop escaping | to LaTeX macro, except if in an index entry
This commit is contained in:
Jean-François B 2019-11-18 21:39:43 +01:00 committed by GitHub
commit 9f7c7a34db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 3 deletions

View File

@ -35,8 +35,6 @@ tex_replacements = [
('`', r'{}`'), ('`', r'{}`'),
('<', r'\textless{}'), ('<', r'\textless{}'),
('>', r'\textgreater{}'), ('>', r'\textgreater{}'),
# map char for some unknown reason. TODO: remove this?
('|', r'\textbar{}'),
# map special Unicode characters to TeX commands # map special Unicode characters to TeX commands
('', r'\(\checkmark\)'), ('', r'\(\checkmark\)'),
('', r'\(\pmb{\checkmark}\)'), ('', r'\(\pmb{\checkmark}\)'),

View File

@ -1816,6 +1816,7 @@ class LaTeXTranslator(SphinxTranslator):
value = value.replace('"', '""') value = value.replace('"', '""')
value = value.replace('@', '"@') value = value.replace('@', '"@')
value = value.replace('!', '"!') value = value.replace('!', '"!')
value = value.replace('|', r'\textbar{}')
return value return value
def style(string): def style(string):

View File

@ -315,7 +315,7 @@ def test_numref_with_prefix2(app, status, warning):
assert ('\\hyperref[\\detokenize{baz:table22}]' assert ('\\hyperref[\\detokenize{baz:table22}]'
'{Table:\\ref{\\detokenize{baz:table22}}}') in result '{Table:\\ref{\\detokenize{baz:table22}}}') in result
assert ('\\hyperref[\\detokenize{index:code-1}]{Code-\\ref{\\detokenize{index:code-1}} ' assert ('\\hyperref[\\detokenize{index:code-1}]{Code-\\ref{\\detokenize{index:code-1}} '
'\\textbar{} }') in result '| }') in result
assert ('\\hyperref[\\detokenize{baz:code22}]' assert ('\\hyperref[\\detokenize{baz:code22}]'
'{Code-\\ref{\\detokenize{baz:code22}}}') in result '{Code-\\ref{\\detokenize{baz:code22}}}') in result
assert ('\\hyperref[\\detokenize{foo:foo}]' assert ('\\hyperref[\\detokenize{foo:foo}]'