Closes #1299: Make behavior of the :rst:dir:math directive more consistent and avoid producing empty environments in LaTeX output.

This commit is contained in:
Georg Brandl
2014-01-12 21:48:10 +01:00
parent b1936aa1f3
commit f314c40160
2 changed files with 7 additions and 0 deletions

View File

@@ -85,6 +85,9 @@ Bugs fixed
* #1072: In the JS search, fix issues searching for upper-cased words by
lowercasing words before stemming.
* #1299: Make behavior of the :rst:dir:`math` directive more consistent and
avoid producing empty environments in LaTeX output.
Documentation
-------------

View File

@@ -30,11 +30,15 @@ def wrap_displaymath(math, label):
parts = math.split('\n\n')
ret = []
for i, part in enumerate(parts):
if not part.strip():
continue
if label is not None and i == 0:
ret.append('\\begin{split}%s\\end{split}' % part +
(label and '\\label{'+label+'}' or ''))
else:
ret.append('\\begin{split}%s\\end{split}\\notag' % part)
if not ret:
return ''
return '\\begin{gather}\n' + '\\\\'.join(ret) + '\n\\end{gather}'