From f314c4016090c562266333e9804f84cdc6bea5dd Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 12 Jan 2014 21:48:10 +0100 Subject: [PATCH] Closes #1299: Make behavior of the :rst:dir:`math` directive more consistent and avoid producing empty environments in LaTeX output. --- CHANGES | 3 +++ sphinx/ext/mathbase.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/CHANGES b/CHANGES index e76554f57..5b9c53ebd 100644 --- a/CHANGES +++ b/CHANGES @@ -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 ------------- diff --git a/sphinx/ext/mathbase.py b/sphinx/ext/mathbase.py index b7d0d997d..0c5eaf8bc 100644 --- a/sphinx/ext/mathbase.py +++ b/sphinx/ext/mathbase.py @@ -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}'