Commits

Anonymous committed 2987901

Small fixes to math-output=HTML.

Comments (0)

Files changed (4)

docutils/docutils/utils/math/math2html.py

 
 import sys
 
-if sys.version_info < (2,4):
-  def reversed(sequence):
-    i = len(sequence)
-    while i > 0:
-        i = i - 1
-        yield sequence[i]
-
-
 class Trace(object):
   "A tracing class"
 
       u'\\int':u'∫', u'\\intop':u'∫', u'\\lim':u'lim', u'\\prod':u'∏', 
       u'\\smallint':u'∫', u'\\sum':u'∑', 
       }
+  # TODO: setting for simple enlarged vs. piecewise  symbols
+  for key in (u'\\int', u'\\intop', u'\\prod', u'\\sum'):
+    limitcommands[key] = '<span class="symbol">%s</span>' % limitcommands[key]
 
   misccommands = {
       u'\\limits':u'LimitPreviousCommand', u'\\newcommand':u'MacroDefinition', 

docutils/docutils/writers/html4css1/math.css

 /* Formulas */
 .formula {
 	text-align: center;
-	font-family: "DejaVu Serif", serif;
+	font-family: "Droid Serif", "DejaVu Serif", "STIX", serif;
 	margin: 1.2em 0;
 }
 span.formula {
 	vertical-align: middle;
 }
 span.symbol {
+	line-height: 125%;
 	font-size: 125%;
 }
 span.bigsymbol {
+	line-height: 150%;
 	font-size: 150%;
 }
 span.largesymbol {
 }
 .limit {
 	display: table-row;
-	line-height: 95%;
+	line-height: 99%;
 }
 sup.limit, sub.limit {
-	line-height: 150%;
+	line-height: 100%;
 }
 span.symbolover {
 	display: inline-block;

docutils/test/functional/expected/math_output_html.html

 <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">
-<span class="limits"><span class="limit">∫</span></span><span class="scripts"><sup class="script">1</sup><sub class="script">0</sub></span><i>x</i><sup><i>n</i></sup><i>dx</i> = <span class="fraction"><span class="ignored">(</span><span class="numerator">1</span><span class="ignored">)/(</span><span class="denominator"><i>n</i> + 1</span><span class="ignored">)</span></span>
+<span class="limits"><sup class="limit">1</sup><span class="limit"><span class="symbol">∫</span></span><sub class="limit">0</sub></span><i>x</i><sup><i>n</i></sup><i>dx</i> = <span class="fraction"><span class="ignored">(</span><span class="numerator">1</span><span class="ignored">)/(</span><span class="denominator"><i>n</i> + 1</span><span class="ignored">)</span></span>
 </div>
 <div class="formula">
-<span class="limits"><span class="limit">∑</span></span><span class="scripts"><sup class="script"><i>m</i></sup><sub class="script"><i>n</i> = 1</sub></span><i>n</i> = <span class="fraction"><span class="ignored">(</span><span class="numerator"><i>m</i>(<i>m</i> + 1)</span><span class="ignored">)/(</span><span class="denominator">2</span><span class="ignored">)</span></span>
+<span class="limits"><sup class="limit"><i>m</i></sup><span class="limit"><span class="symbol">∑</span></span><sub class="limit"><i>n</i> = 1</sub></span><i>n</i> = <span class="fraction"><span class="ignored">(</span><span class="numerator"><i>m</i>(<i>m</i> + 1)</span><span class="ignored">)/(</span><span class="denominator">2</span><span class="ignored">)</span></span>
 </div>
 <p>LaTeX-supported Unicode math symbols can be used in math roles and
 directives:</p>
 \widehat{xxx} -->
 <p>Modulation Transfer Function:</p>
 <div class="formula">
-<span class="text">MTF</span> = <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>s</i>(<i>x</i>)}</span><span class="ignored">)/(</span><span class="denominator">ℱ{<i>s</i>(<i>x</i>)}|<sub><i>ω</i><sub><i>x</i></sub> = 0</sub></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 class="mathrm"> abs</span><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"><span class="limits"><span class="limit">∫</span></span><span class="scripts"><sup class="script">∞</sup><sub class="script"> − ∞</sub></span><i>s</i>(<i>x</i>)<span class="mathrm">e</span><sup><span class="mathrm">i</span><i>ω</i><sub><i>x</i></sub><i>x</i></sup><span class="mathrm">d</span><i>x</i></span><span class="ignored">)/(</span><span class="denominator"><span class="limits"><span class="limit">∫</span></span><span class="scripts"><sup class="script">∞</sup><sub class="script"> − ∞</sub></span><i>s</i>(<i>x</i>)<span class="mathrm">d</span><i>x</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 class="text">MTF</span> = <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>s</i>(<i>x</i>)}</span><span class="ignored">)/(</span><span class="denominator">ℱ{<i>s</i>(<i>x</i>)}|<sub><i>ω</i><sub><i>x</i></sub> = 0</sub></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 class="mathrm"> abs</span><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"><span class="limits"><span class="limit"><span class="symbol">∫</span></span></span><span class="scripts"><sup class="script">∞</sup><sub class="script"> − ∞</sub></span><i>s</i>(<i>x</i>)<span class="mathrm">e</span><sup><span class="mathrm">i</span><i>ω</i><sub><i>x</i></sub><i>x</i></sup><span class="mathrm">d</span><i>x</i></span><span class="ignored">)/(</span><span class="denominator"><span class="limits"><span class="limit"><span class="symbol">∫</span></span></span><span class="scripts"><sup class="script">∞</sup><sub class="script"> − ∞</sub></span><i>s</i>(<i>x</i>)<span class="mathrm">d</span><i>x</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>.
 </div>
 <p>Math split over two lines: If a double backslash is detected outside a
 <tt class="docutils literal"><span class="pre">\begin{...}</span> <span class="pre">\end{...}</span></tt> pair, the math code is wrapped in an <a class="reference external" href="ftp://ftp.ams.org/ams/doc/amsmath/short-math-guide.pdf">AMSmath</a>
 
 </span>
 <span class="arraycell align-l">
- = <span class="limits"><span class="limit">∫</span></span><i>s</i><sub><span class="mathrm">in</span></sub>(<i>x</i>’)<i>s</i><sub><i>δ</i></sub>(<i>x</i> − <i>x</i>’)<span class="mathrm">d</span><i>x</i>’
+ = <span class="limits"><span class="limit"><span class="symbol">∫</span></span></span><i>s</i><sub><span class="mathrm">in</span></sub>(<i>x</i>’)<i>s</i><sub><i>δ</i></sub>(<i>x</i> − <i>x</i>’)<span class="mathrm">d</span><i>x</i>’
 </span>
 
 </span>

docutils/test/functional/input/data/math.css

 /* Formulas */
 .formula {
 	text-align: center;
-	font-family: "DejaVu Serif", serif;
+	font-family: "Droid Serif", "DejaVu Serif", "STIX", serif;
 	margin: 1.2em 0;
 }
 span.formula {
 	vertical-align: middle;
 }
 span.symbol {
+	line-height: 125%;
 	font-size: 125%;
 }
 span.bigsymbol {
+	line-height: 150%;
 	font-size: 150%;
 }
 span.largesymbol {
 }
 .limit {
 	display: table-row;
-	line-height: 95%;
+	line-height: 99%;
 }
 sup.limit, sub.limit {
-	line-height: 150%;
+	line-height: 100%;
 }
 span.symbolover {
 	display: inline-block;