Merged revisions 65566-65567,65623,65625 via svnmerge from

svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x

........
  r65566 | georg.brandl | 2008-08-07 09:11:11 +0000 (Thu, 07 Aug 2008) | 2 lines

  Clarification for the ref role.
........
  r65567 | georg.brandl | 2008-08-07 09:11:25 +0000 (Thu, 07 Aug 2008) | 2 lines

  Rebuild everything if extensions change.
........
  r65623 | georg.brandl | 2008-08-10 11:18:42 +0000 (Sun, 10 Aug 2008) | 2 lines

  Unify handling of LaTeX escaping, and add some more replacements.
........
  r65625 | georg.brandl | 2008-08-10 11:25:41 +0000 (Sun, 10 Aug 2008) | 2 lines

  Make tex escapes a module.
........
This commit is contained in:
Georg Brandl
2008-08-10 16:59:27 +00:00
parent ac8a346f45
commit e93af0e57c
8 changed files with 184 additions and 66 deletions

View File

@@ -63,10 +63,14 @@ def verify_re(rst, html_expected, latex_expected):
latex_translator.first_document = -1 # don't write \begin{document}
document.walkabout(latex_translator)
latex_translated = ''.join(latex_translator.body).strip()
assert re.match(latex_expected, latex_translated), 'from ' + rst
assert re.match(latex_expected, latex_translated), 'from ' + repr(rst)
def verify(rst, html_expected, latex_expected):
verify_re(rst, re.escape(html_expected) + '$', re.escape(latex_expected) + '$')
if html_expected:
html_expected = re.escape(html_expected) + '$'
if latex_expected:
latex_expected = re.escape(latex_expected) + '$'
verify_re(rst, html_expected, latex_expected)
def test_inline():
@@ -85,7 +89,7 @@ def test_inline():
# interpolation of arrows in menuselection
verify(':menuselection:`a --> b`',
u'<p><em>a \N{TRIANGULAR BULLET} b</em></p>',
'\\emph{a $\\rightarrow$ b}')
'\\emph{a \\(\\rightarrow\\) b}')
# non-interpolation of dashes in option role
verify_re(':option:`--with-option`',
@@ -99,3 +103,12 @@ def test_inline():
'<p><tt class="docutils literal"><span class="pre">'
'&quot;John&quot;</span></tt></p>',
'\\code{"John"}')
def test_latex_escaping():
# correct escaping in normal mode
verify(u'Γ\\\\∞$', None, ur'\(\Gamma\)\textbackslash{}\(\infty\)\$')
# in verbatim code fragments
verify(u'::\n\n\\∞$[]', None,
u'\\begin{Verbatim}[commandchars=@\\[\\]]\n'
u'@at[]@(@Gamma@)\\@(@infty@)@$@lb[]@rb[]\n'
u'\\end{Verbatim}')