diff options
author | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2014-05-28 16:02:56 +0000 |
---|---|---|
committer | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2014-05-28 16:02:56 +0000 |
commit | 184c9db56bba770a25beb41c52b0e7e412fb7168 (patch) | |
tree | de970ccc55dde3b1fe7e85fe9fdb3ea3736e9322 | |
parent | 67ac23d5c8092cadbb32c4e3a4f150b2af76a072 (diff) | |
download | docutils-184c9db56bba770a25beb41c52b0e7e412fb7168.tar.gz |
Do not add newline after inline math (produces unwanted whitespace).
Thanks to Yury G. Kudryashov for the patch.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@7749 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
-rw-r--r-- | HISTORY.txt | 11 | ||||
-rw-r--r-- | docutils/writers/html4css1/__init__.py | 6 | ||||
-rw-r--r-- | test/functional/expected/math_output_html.html | 46 | ||||
-rw-r--r-- | test/functional/expected/math_output_latex.html | 48 | ||||
-rw-r--r-- | test/functional/expected/math_output_mathjax.html | 48 | ||||
-rw-r--r-- | test/functional/expected/standalone_rst_html4css1.html | 3 |
6 files changed, 60 insertions, 102 deletions
diff --git a/HISTORY.txt b/HISTORY.txt index 7820573f6..95c60f630 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -25,11 +25,16 @@ Changes Since 0.11 - Improve error report when a non-ASCII character is specified as delimiter, quote or escape character under Python 2. Fixes [ 249 ] and [ 250 ]. - + +* docutils/writers/html4css1/__init__.py + + - Don't add newline after inline math. + Thanks to Yury G. Kudryashov for the patch. + * docutils/writers/latex2e/__init__.py - Fix [ 239 ] Latex writer glues paragraphs with figure floats. - - Apply [ 116 ] by Kirill Smelkov. Don't hardcode \large for subtitle. + - Apply [ 116 ] by Kirill Smelkov. Don't hardcode \large for subtitle. * docutils/writers/odf_odt/__init__.py @@ -42,7 +47,7 @@ Changes Since 0.11 * test/test_nodes.py - Apply [ 115 ] respect fixed 2to3 string literal conversion behavior. - + Release 0.11 (2013-07-22) ========================= diff --git a/docutils/writers/html4css1/__init__.py b/docutils/writers/html4css1/__init__.py index f91a24983..15b649710 100644 --- a/docutils/writers/html4css1/__init__.py +++ b/docutils/writers/html4css1/__init__.py @@ -1245,10 +1245,12 @@ class HTMLTranslator(nodes.NodeVisitor): suffix='\n'*bool(math_env), CLASS=clsarg)) self.body.append(math_code) - if math_env: + if math_env: # block mode (equation, display) self.body.append('\n') if tag: - self.body.append('</%s>\n' % tag) + self.body.append('</%s>' % tag) + if math_env: + self.body.append('\n') # Content already processed: raise nodes.SkipNode diff --git a/test/functional/expected/math_output_html.html b/test/functional/expected/math_output_html.html index b0db72258..5e32481a9 100644 --- a/test/functional/expected/math_output_html.html +++ b/test/functional/expected/math_output_html.html @@ -13,9 +13,7 @@ <h1 class="title">Mathematics</h1> <p>Docutils supports inline math with the prefix or postfix <tt class="docutils literal">:math:</tt> -role specificator, <span class="formula"><i>n</i>! + sin(<i>x</i><span class="scripts"><sup class="script">2</sup><sub class="script"><i>n</i></sub></span>)</span> - and <span class="formula"><i>A</i><sub><span class="text">c</span></sub> = <span class="fraction"><span class="ignored">(</span><span class="numerator"><i>π</i></span><span class="ignored">)/(</span><span class="denominator">4</span><span class="ignored">)</span></span><i>d</i><sup>2</sup></span> -, as well as displayed math via the +role specificator, <span class="formula"><i>n</i>! + sin(<i>x</i><span class="scripts"><sup class="script">2</sup><sub class="script"><i>n</i></sub></span>)</span> and <span class="formula"><i>A</i><sub><span class="text">c</span></sub> = <span class="fraction"><span class="ignored">(</span><span class="numerator"><i>π</i></span><span class="ignored">)/(</span><span class="denominator">4</span><span class="ignored">)</span></span><i>d</i><sup>2</sup></span>, as well as displayed math via the <cite>math</cite> directive:</p> <div class="formula"> <i>f</i>(<i>ϵ</i>) = <span class="fraction"><span class="ignored">(</span><span class="numerator">1</span><span class="ignored">)/(</span><span class="denominator">1 + exp<span class="array"><span class="arrayrow"><span class="bracket align-left">⎛</span></span><span class="arrayrow"><span class="bracket align-left">⎝</span></span></span><span class="fraction"><span class="ignored">(</span><span class="numerator"><i>ε</i></span><span class="ignored">)/(</span><span class="denominator"><i>k</i><sub><span class="text">B</span></sub><i>T</i></span><span class="ignored">)</span></span><span class="array"><span class="arrayrow"><span class="bracket align-right">⎞</span></span><span class="arrayrow"><span class="bracket align-right">⎠</span></span></span></span><span class="ignored">)</span></span> @@ -57,8 +55,7 @@ See <a class="reference internal" href="#eq-m">eq:M</a> and <a class="reference </span> </span><span class="array"><span class="arrayrow"><span class="bracket align-right">⎞</span></span><span class="arrayrow"><span class="bracket align-right">⎟</span></span><span class="arrayrow"><span class="bracket align-right">⎠</span></span></span> </div> -<p>is <span class="formula">|<b>M</b>| = <i>ad</i> − <i>bc</i></span> -.</p> +<p>is <span class="formula">|<b>M</b>| = <i>ad</i> − <i>bc</i></span>.</p> <p>More than one display math block can be put in one math directive. For example, the following sum and integral with limits:</p> <div class="formula"> @@ -73,8 +70,7 @@ directives:</p> <div class="formula" id="eq-schrodinger"> <i>i</i>ℏ<span class="fraction"><span class="ignored">(</span><span class="numerator">∂</span><span class="ignored">)/(</span><span class="denominator">∂<i>t</i></span><span class="ignored">)</span></span>Ψ = <i>Ĥ</i>Ψ, </div> -<p>with the <em>wave function</em> <span class="formula">Ψ</span> -, describes how the quantum state of a +<p>with the <em>wave function</em> <span class="formula">Ψ</span>, describes how the quantum state of a physical system changes in time.</p> <dl class="docutils"> <dt>Math-Accents:</dt> @@ -85,33 +81,21 @@ physical system changes in time.</p> <col width="33%" /> </colgroup> <tbody valign="top"> -<tr><td><span class="formula"><i>á</i></span> - <tt class="docutils literal">\acute{a}</tt></td> -<td><span class="formula"><i>ṫ</i></span> - <tt class="docutils literal">\dot{t}</tt></td> -<td><span class="formula"><i>γ̂</i></span> - <tt class="docutils literal"><span class="pre">\hat{\gamma}</span></tt></td> +<tr><td><span class="formula"><i>á</i></span> <tt class="docutils literal">\acute{a}</tt></td> +<td><span class="formula"><i>ṫ</i></span> <tt class="docutils literal">\dot{t}</tt></td> +<td><span class="formula"><i>γ̂</i></span> <tt class="docutils literal"><span class="pre">\hat{\gamma}</span></tt></td> </tr> -<tr><td><span class="formula"><i>à</i></span> - <tt class="docutils literal">\grave{a}</tt></td> -<td><span class="formula"><i>ẗ</i></span> - <tt class="docutils literal">\ddot{t}</tt></td> -<td><span class="formula"><i>α̃</i></span> - <tt class="docutils literal"><span class="pre">\tilde{\alpha}</span></tt></td> +<tr><td><span class="formula"><i>à</i></span> <tt class="docutils literal">\grave{a}</tt></td> +<td><span class="formula"><i>ẗ</i></span> <tt class="docutils literal">\ddot{t}</tt></td> +<td><span class="formula"><i>α̃</i></span> <tt class="docutils literal"><span class="pre">\tilde{\alpha}</span></tt></td> </tr> -<tr><td><span class="formula"><i>x̆</i></span> - <tt class="docutils literal">\breve{x}</tt></td> -<td><span class="formula"><i>t⃛</i></span> - <tt class="docutils literal">\dddot{t}</tt></td> -<td><span class="formula"><i>ı⃗</i></span> - <tt class="docutils literal"><span class="pre">\vec{\imath}</span></tt></td> +<tr><td><span class="formula"><i>x̆</i></span> <tt class="docutils literal">\breve{x}</tt></td> +<td><span class="formula"><i>t⃛</i></span> <tt class="docutils literal">\dddot{t}</tt></td> +<td><span class="formula"><i>ı⃗</i></span> <tt class="docutils literal"><span class="pre">\vec{\imath}</span></tt></td> </tr> -<tr><td><span class="formula"><i>ǎ</i></span> - <tt class="docutils literal">\check{a}</tt></td> -<td><span class="formula"><span class="bar"><i>a</i></span></span> - <tt class="docutils literal">\bar{a}</tt></td> -<td><span class="formula"><i>R⃗</i></span> - <tt class="docutils literal">\vec{R}</tt></td> +<tr><td><span class="formula"><i>ǎ</i></span> <tt class="docutils literal">\check{a}</tt></td> +<td><span class="formula"><span class="bar"><i>a</i></span></span> <tt class="docutils literal">\bar{a}</tt></td> +<td><span class="formula"><i>R⃗</i></span> <tt class="docutils literal">\vec{R}</tt></td> </tr> </tbody> </table> diff --git a/test/functional/expected/math_output_latex.html b/test/functional/expected/math_output_latex.html index 8ef54b806..b4712f5e2 100644 --- a/test/functional/expected/math_output_latex.html +++ b/test/functional/expected/math_output_latex.html @@ -12,10 +12,8 @@ <h1 class="title">Mathematics</h1> <p>Docutils supports inline math with the prefix or postfix <tt class="docutils literal">:math:</tt> -role specificator, <tt class="math">n! + \sin(x_n^2)</tt> - and <tt class="math">A_\text{c} = -\frac{\pi}{4} d^2</tt> -, as well as displayed math via the +role specificator, <tt class="math">n! + \sin(x_n^2)</tt> and <tt class="math">A_\text{c} = +\frac{\pi}{4} d^2</tt>, as well as displayed math via the <cite>math</cite> directive:</p> <pre class="math"> f(\epsilon) = \frac{1}{1 + \exp\left(\frac{\varepsilon}{k_\text{B}T}\right)} @@ -30,8 +28,7 @@ See <a class="reference internal" href="#eq-m">eq:M</a> and <a class="reference <pre class="math" id="eq-m"> \mathbf{M} = \left(\begin{matrix}a&b\\c&d\end{matrix}\right) </pre> -<p>is <tt class="math">|\mathbf{M}| = ad - bc</tt> -.</p> +<p>is <tt class="math">|\mathbf{M}| = ad - bc</tt>.</p> <p>More than one display math block can be put in one math directive. For example, the following sum and integral with limits:</p> <pre class="math"> @@ -46,8 +43,7 @@ directives:</p> <pre class="math" id="eq-schrodinger"> i\hbar \frac{\partial }{\partial t}\Psi = \hat{H}\Psi , </pre> -<p>with the <em>wave function</em> <tt class="math">\Psi </tt> -, describes how the quantum state of a +<p>with the <em>wave function</em> <tt class="math">\Psi </tt>, describes how the quantum state of a physical system changes in time.</p> <dl class="docutils"> <dt>Math-Accents:</dt> @@ -58,33 +54,21 @@ physical system changes in time.</p> <col width="33%" /> </colgroup> <tbody valign="top"> -<tr><td><tt class="math">\acute{a}</tt> - <tt class="docutils literal">\acute{a}</tt></td> -<td><tt class="math">\dot{t}</tt> - <tt class="docutils literal">\dot{t}</tt></td> -<td><tt class="math">\hat{\gamma}</tt> - <tt class="docutils literal"><span class="pre">\hat{\gamma}</span></tt></td> +<tr><td><tt class="math">\acute{a}</tt> <tt class="docutils literal">\acute{a}</tt></td> +<td><tt class="math">\dot{t}</tt> <tt class="docutils literal">\dot{t}</tt></td> +<td><tt class="math">\hat{\gamma}</tt> <tt class="docutils literal"><span class="pre">\hat{\gamma}</span></tt></td> </tr> -<tr><td><tt class="math">\grave{a}</tt> - <tt class="docutils literal">\grave{a}</tt></td> -<td><tt class="math">\ddot{t}</tt> - <tt class="docutils literal">\ddot{t}</tt></td> -<td><tt class="math">\tilde{\alpha}</tt> - <tt class="docutils literal"><span class="pre">\tilde{\alpha}</span></tt></td> +<tr><td><tt class="math">\grave{a}</tt> <tt class="docutils literal">\grave{a}</tt></td> +<td><tt class="math">\ddot{t}</tt> <tt class="docutils literal">\ddot{t}</tt></td> +<td><tt class="math">\tilde{\alpha}</tt> <tt class="docutils literal"><span class="pre">\tilde{\alpha}</span></tt></td> </tr> -<tr><td><tt class="math">\breve{x}</tt> - <tt class="docutils literal">\breve{x}</tt></td> -<td><tt class="math">\dddot{t}</tt> - <tt class="docutils literal">\dddot{t}</tt></td> -<td><tt class="math">\vec{\imath}</tt> - <tt class="docutils literal"><span class="pre">\vec{\imath}</span></tt></td> +<tr><td><tt class="math">\breve{x}</tt> <tt class="docutils literal">\breve{x}</tt></td> +<td><tt class="math">\dddot{t}</tt> <tt class="docutils literal">\dddot{t}</tt></td> +<td><tt class="math">\vec{\imath}</tt> <tt class="docutils literal"><span class="pre">\vec{\imath}</span></tt></td> </tr> -<tr><td><tt class="math">\check{a}</tt> - <tt class="docutils literal">\check{a}</tt></td> -<td><tt class="math">\bar{a}</tt> - <tt class="docutils literal">\bar{a}</tt></td> -<td><tt class="math">\vec{R}</tt> - <tt class="docutils literal">\vec{R}</tt></td> +<tr><td><tt class="math">\check{a}</tt> <tt class="docutils literal">\check{a}</tt></td> +<td><tt class="math">\bar{a}</tt> <tt class="docutils literal">\bar{a}</tt></td> +<td><tt class="math">\vec{R}</tt> <tt class="docutils literal">\vec{R}</tt></td> </tr> </tbody> </table> diff --git a/test/functional/expected/math_output_mathjax.html b/test/functional/expected/math_output_mathjax.html index b2bd3d74e..27af59567 100644 --- a/test/functional/expected/math_output_mathjax.html +++ b/test/functional/expected/math_output_mathjax.html @@ -13,10 +13,8 @@ <h1 class="title">Mathematics</h1> <p>Docutils supports inline math with the prefix or postfix <tt class="docutils literal">:math:</tt> -role specificator, <span class="math">\(n! + \sin(x_n^2)\)</span> - and <span class="math">\(A_\text{c} = -\frac{\pi}{4} d^2\)</span> -, as well as displayed math via the +role specificator, <span class="math">\(n! + \sin(x_n^2)\)</span> and <span class="math">\(A_\text{c} = +\frac{\pi}{4} d^2\)</span>, as well as displayed math via the <cite>math</cite> directive:</p> <div class="math"> \begin{equation*} @@ -37,8 +35,7 @@ See <a class="reference internal" href="#eq-m">eq:M</a> and <a class="reference \mathbf{M} = \left(\begin{matrix}a&b\\c&d\end{matrix}\right) \end{equation*} </div> -<p>is <span class="math">\(|\mathbf{M}| = ad - bc\)</span> -.</p> +<p>is <span class="math">\(|\mathbf{M}| = ad - bc\)</span>.</p> <p>More than one display math block can be put in one math directive. For example, the following sum and integral with limits:</p> <div class="math"> @@ -59,8 +56,7 @@ directives:</p> i\hbar \frac{\partial }{\partial t}\Psi = \hat{H}\Psi , \end{equation*} </div> -<p>with the <em>wave function</em> <span class="math">\(\Psi \)</span> -, describes how the quantum state of a +<p>with the <em>wave function</em> <span class="math">\(\Psi \)</span>, describes how the quantum state of a physical system changes in time.</p> <dl class="docutils"> <dt>Math-Accents:</dt> @@ -71,33 +67,21 @@ physical system changes in time.</p> <col width="33%" /> </colgroup> <tbody valign="top"> -<tr><td><span class="math">\(\acute{a}\)</span> - <tt class="docutils literal">\acute{a}</tt></td> -<td><span class="math">\(\dot{t}\)</span> - <tt class="docutils literal">\dot{t}</tt></td> -<td><span class="math">\(\hat{\gamma}\)</span> - <tt class="docutils literal"><span class="pre">\hat{\gamma}</span></tt></td> +<tr><td><span class="math">\(\acute{a}\)</span> <tt class="docutils literal">\acute{a}</tt></td> +<td><span class="math">\(\dot{t}\)</span> <tt class="docutils literal">\dot{t}</tt></td> +<td><span class="math">\(\hat{\gamma}\)</span> <tt class="docutils literal"><span class="pre">\hat{\gamma}</span></tt></td> </tr> -<tr><td><span class="math">\(\grave{a}\)</span> - <tt class="docutils literal">\grave{a}</tt></td> -<td><span class="math">\(\ddot{t}\)</span> - <tt class="docutils literal">\ddot{t}</tt></td> -<td><span class="math">\(\tilde{\alpha}\)</span> - <tt class="docutils literal"><span class="pre">\tilde{\alpha}</span></tt></td> +<tr><td><span class="math">\(\grave{a}\)</span> <tt class="docutils literal">\grave{a}</tt></td> +<td><span class="math">\(\ddot{t}\)</span> <tt class="docutils literal">\ddot{t}</tt></td> +<td><span class="math">\(\tilde{\alpha}\)</span> <tt class="docutils literal"><span class="pre">\tilde{\alpha}</span></tt></td> </tr> -<tr><td><span class="math">\(\breve{x}\)</span> - <tt class="docutils literal">\breve{x}</tt></td> -<td><span class="math">\(\dddot{t}\)</span> - <tt class="docutils literal">\dddot{t}</tt></td> -<td><span class="math">\(\vec{\imath}\)</span> - <tt class="docutils literal"><span class="pre">\vec{\imath}</span></tt></td> +<tr><td><span class="math">\(\breve{x}\)</span> <tt class="docutils literal">\breve{x}</tt></td> +<td><span class="math">\(\dddot{t}\)</span> <tt class="docutils literal">\dddot{t}</tt></td> +<td><span class="math">\(\vec{\imath}\)</span> <tt class="docutils literal"><span class="pre">\vec{\imath}</span></tt></td> </tr> -<tr><td><span class="math">\(\check{a}\)</span> - <tt class="docutils literal">\check{a}</tt></td> -<td><span class="math">\(\bar{a}\)</span> - <tt class="docutils literal">\bar{a}</tt></td> -<td><span class="math">\(\vec{R}\)</span> - <tt class="docutils literal">\vec{R}</tt></td> +<tr><td><span class="math">\(\check{a}\)</span> <tt class="docutils literal">\check{a}</tt></td> +<td><span class="math">\(\bar{a}\)</span> <tt class="docutils literal">\bar{a}</tt></td> +<td><span class="math">\(\vec{R}\)</span> <tt class="docutils literal">\vec{R}</tt></td> </tr> </tbody> </table> diff --git a/test/functional/expected/standalone_rst_html4css1.html b/test/functional/expected/standalone_rst_html4css1.html index db9d0fbfd..680b00120 100644 --- a/test/functional/expected/standalone_rst_html4css1.html +++ b/test/functional/expected/standalone_rst_html4css1.html @@ -862,8 +862,7 @@ directly (the code will not be parsed/tagged, as the language is not known) or as base for special code roles, e.g. the LaTeX code in the next paragraph.</p> <p>Docutils uses LaTeX syntax for math directives and roles: -<code class="tex">\alpha = f(x)</code> prints <span class="formula"><i>α</i> = <i>f</i>(<i>x</i>)</span> -.</p> +<code class="tex">\alpha = f(x)</code> prints <span class="formula"><i>α</i> = <i>f</i>(<i>x</i>)</span>.</p> <p>The <tt class="docutils literal">:code:</tt> option of the <cite>include</cite> directive sets the included content as a code block, here the rst file <tt class="docutils literal">header_footer.txt</tt> with line numbers:</p> <pre class="code rst literal-block"> |