From 88b257eec30b5e84c133191c1feeb3d6834f4e18 Mon Sep 17 00:00:00 2001 From: milde Date: Wed, 29 Jun 2011 16:24:09 +0000 Subject: [PATCH] math update latex2e writer: set label if node has a name attribute html4css1 writer: do not wrap inline functional test: adapt expected output to last changes git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@7061 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docs/user/config.txt | 3 ++- docutils/writers/html4css1/__init__.py | 8 +++++--- docutils/writers/latex2e/__init__.py | 2 ++ test/functional/expected/math_output_mathml.xhtml | 18 ++++++++++++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/docs/user/config.txt b/docs/user/config.txt index 618d20dad..6bebf143b 100644 --- a/docs/user/config.txt +++ b/docs/user/config.txt @@ -737,7 +737,8 @@ _`math_output` Pro: Works 'out of the box' across multiple browsers and platforms. - Supports a large subset of LaTeX math commands and constructs. + Supports a large subset of LaTeX math commands and constructs + (see http://www.mathjax.org/docs/1.1/tex.html). Con: Requires an Internet connection or a local MathJax diff --git a/docutils/writers/html4css1/__init__.py b/docutils/writers/html4css1/__init__.py index 54376f5a8..81490d388 100644 --- a/docutils/writers/html4css1/__init__.py +++ b/docutils/writers/html4css1/__init__.py @@ -1136,7 +1136,7 @@ class HTMLTranslator(nodes.NodeVisitor): # # HTML container tags = {# math_output: (block, inline, class-arguments) - 'mathml': ('div', 'span', ''), + 'mathml': ('div', '', ''), 'html': ('div', 'span', 'formula'), 'mathjax': ('div', 'span', 'math'), 'latex': ('pre', 'tt', 'math'), @@ -1183,11 +1183,13 @@ class HTMLTranslator(nodes.NodeVisitor): self.depart_system_message(err_node) raise nodes.SkipNode # append to document body - self.body.append(self.starttag(node, tag, CLASS=clsarg)) + if tag: + self.body.append(self.starttag(node, tag, CLASS=clsarg)) self.body.append(math_code) if math_env: self.body.append('\n') - self.body.append('\n' % tag) + if tag: + self.body.append('\n' % tag) # Content already processed: raise nodes.SkipNode diff --git a/docutils/writers/latex2e/__init__.py b/docutils/writers/latex2e/__init__.py index 8de5447fd..66e2549bb 100644 --- a/docutils/writers/latex2e/__init__.py +++ b/docutils/writers/latex2e/__init__.py @@ -2431,6 +2431,8 @@ class LaTeXTranslator(nodes.NodeVisitor): self.visit_inline(node) self.requirements['amsmath'] = r'\usepackage{amsmath}' math_code = node.astext().translate(unimathsymbols2tex.uni2tex_table) + if node.get('id') == node.get('name'): # explicite label + math_code = '\n'.join([math_code] + self.ids_to_labels(node)) if math_env == '$': wrapper = u'$%s$' else: diff --git a/test/functional/expected/math_output_mathml.xhtml b/test/functional/expected/math_output_mathml.xhtml index 27d738121..1e949a0a5 100644 --- a/test/functional/expected/math_output_mathml.xhtml +++ b/test/functional/expected/math_output_mathml.xhtml @@ -18,6 +18,7 @@ role specificator, π 4d2, as well as displayed math via the math directive:

+
@@ -27,14 +28,18 @@ role specificator, ε kBT +

A display formula can also be given as directive argument, e.g.

+
N= number of apples 7 +

The determinant of the matrix

+
@@ -48,17 +53,21 @@ role specificator, c d +

is | M|=ad-bc.

More than one display math block can be put in one math directive. For example, the following sum and integral with limits:

+
01xndx= 1 n+1 +
+
@@ -66,9 +75,11 @@ For example, the following sum and integral with limits:

n=1mn= m(m+1) 2
+

LaTeX-supported Unicode math symbols can be used in math roles and directives:

The Schrödinger equation

+
@@ -76,6 +87,7 @@ directives:

tΨ= H^Ψ,
+

with the wave function Ψ, describes how the quantum state of a physical system changes in time.

@@ -135,6 +147,7 @@ physical system changes in time.

Modulation Transfer Function:

+
@@ -155,9 +168,11 @@ physical system changes in time.

- s(x)d x.
+

Math split over two lines: If a double backslash is detected outside a \begin{...} \end{...} pair, the math code is wrapped in an AMSmath align environment:

+
@@ -169,7 +184,9 @@ physical system changes in time.

=s in(x')sδ(x-x')dx'
+

Cases ("manually", with matrix environment):

+
@@ -182,6 +199,7 @@ physical system changes in time.

1 x>0
+

Cases with the AMSmath cases environment (not (yet) supported by HTML writers with --math-output=MathML):

-- 2.11.4.GIT