diff --git a/sphinx/util/texescape.py b/sphinx/util/texescape.py index f490c25c1..b7928ce37 100644 --- a/sphinx/util/texescape.py +++ b/sphinx/util/texescape.py @@ -35,8 +35,6 @@ tex_replacements = [ ('`', r'{}`'), ('<', r'\textless{}'), ('>', r'\textgreater{}'), - # map char for some unknown reason. TODO: remove this? - ('|', r'\textbar{}'), # map special Unicode characters to TeX commands ('✓', r'\(\checkmark\)'), ('✔', r'\(\pmb{\checkmark}\)'), diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index fbdef1f4c..345350a63 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1816,6 +1816,7 @@ class LaTeXTranslator(SphinxTranslator): value = value.replace('"', '""') value = value.replace('@', '"@') value = value.replace('!', '"!') + value = value.replace('|', r'\textbar{}') return value def style(string): diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 38e99f48a..8c023b8e4 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -315,7 +315,7 @@ def test_numref_with_prefix2(app, status, warning): assert ('\\hyperref[\\detokenize{baz:table22}]' '{Table:\\ref{\\detokenize{baz:table22}}}') in result assert ('\\hyperref[\\detokenize{index:code-1}]{Code-\\ref{\\detokenize{index:code-1}} ' - '\\textbar{} }') in result + '| }') in result assert ('\\hyperref[\\detokenize{baz:code22}]' '{Code-\\ref{\\detokenize{baz:code22}}}') in result assert ('\\hyperref[\\detokenize{foo:foo}]'