You can subscribe to this list here.
2002 
_{Jan}

_{Feb}

_{Mar}

_{Apr}
(5) 
_{May}
(27) 
_{Jun}
(22) 
_{Jul}
(72) 
_{Aug}
(82) 
_{Sep}
(86) 
_{Oct}
(138) 
_{Nov}
(100) 
_{Dec}
(62) 

2003 
_{Jan}
(122) 
_{Feb}
(147) 
_{Mar}
(92) 
_{Apr}
(82) 
_{May}
(101) 
_{Jun}
(153) 
_{Jul}
(37) 
_{Aug}
(34) 
_{Sep}
(46) 
_{Oct}
(46) 
_{Nov}
(6) 
_{Dec}
(38) 
2004 
_{Jan}
(64) 
_{Feb}
(81) 
_{Mar}
(36) 
_{Apr}
(194) 
_{May}
(329) 
_{Jun}
(272) 
_{Jul}
(68) 
_{Aug}
(74) 
_{Sep}
(150) 
_{Oct}
(57) 
_{Nov}
(62) 
_{Dec}
(63) 
2005 
_{Jan}
(78) 
_{Feb}
(30) 
_{Mar}
(137) 
_{Apr}
(78) 
_{May}
(54) 
_{Jun}
(122) 
_{Jul}
(72) 
_{Aug}
(110) 
_{Sep}
(80) 
_{Oct}
(75) 
_{Nov}
(125) 
_{Dec}
(79) 
2006 
_{Jan}
(100) 
_{Feb}
(15) 
_{Mar}
(41) 
_{Apr}
(67) 
_{May}
(30) 
_{Jun}
(11) 
_{Jul}
(14) 
_{Aug}
(22) 
_{Sep}
(20) 
_{Oct}
(14) 
_{Nov}
(11) 
_{Dec}
(15) 
2007 
_{Jan}
(17) 
_{Feb}
(16) 
_{Mar}
(35) 
_{Apr}
(21) 
_{May}
(33) 
_{Jun}
(50) 
_{Jul}
(12) 
_{Aug}
(7) 
_{Sep}
(2) 
_{Oct}
(6) 
_{Nov}
(5) 
_{Dec}
(2) 
2008 
_{Jan}
(14) 
_{Feb}
(20) 
_{Mar}
(35) 
_{Apr}
(9) 
_{May}
(57) 
_{Jun}
(21) 
_{Jul}
(42) 
_{Aug}
(4) 
_{Sep}
(13) 
_{Oct}
(76) 
_{Nov}
(40) 
_{Dec}
(55) 
2009 
_{Jan}
(26) 
_{Feb}
(15) 
_{Mar}
(3) 
_{Apr}
(67) 
_{May}
(32) 
_{Jun}
(39) 
_{Jul}
(59) 
_{Aug}
(31) 
_{Sep}
(59) 
_{Oct}
(64) 
_{Nov}
(21) 
_{Dec}
(10) 
2010 
_{Jan}
(21) 
_{Feb}
(3) 
_{Mar}
(116) 
_{Apr}
(33) 
_{May}
(9) 
_{Jun}
(28) 
_{Jul}
(21) 
_{Aug}
(23) 
_{Sep}
(146) 
_{Oct}
(70) 
_{Nov}
(31) 
_{Dec}
(57) 
2011 
_{Jan}
(33) 
_{Feb}
(22) 
_{Mar}
(11) 
_{Apr}
(21) 
_{May}
(51) 
_{Jun}
(47) 
_{Jul}
(35) 
_{Aug}
(26) 
_{Sep}
(25) 
_{Oct}
(34) 
_{Nov}
(61) 
_{Dec}
(51) 
2012 
_{Jan}
(75) 
_{Feb}
(31) 
_{Mar}
(26) 
_{Apr}
(16) 
_{May}
(24) 
_{Jun}
(24) 
_{Jul}
(31) 
_{Aug}
(46) 
_{Sep}
(36) 
_{Oct}
(28) 
_{Nov}
(37) 
_{Dec}
(21) 
2013 
_{Jan}
(16) 
_{Feb}
(56) 
_{Mar}
(31) 
_{Apr}
(44) 
_{May}
(45) 
_{Jun}
(29) 
_{Jul}
(38) 
_{Aug}
(18) 
_{Sep}
(12) 
_{Oct}
(16) 
_{Nov}
(21) 
_{Dec}
(11) 
2014 
_{Jan}
(13) 
_{Feb}
(14) 
_{Mar}
(28) 
_{Apr}
(7) 
_{May}
(72) 
_{Jun}
(33) 
_{Jul}
(21) 
_{Aug}
(1) 
_{Sep}
(6) 
_{Oct}
(14) 
_{Nov}
(18) 
_{Dec}
(22) 
2015 
_{Jan}
(23) 
_{Feb}
(108) 
_{Mar}
(76) 
_{Apr}
(114) 
_{May}
(60) 
_{Jun}
(9) 
_{Jul}
(8) 
_{Aug}
(9) 
_{Sep}
(42) 
_{Oct}
(9) 
_{Nov}

_{Dec}

S  M  T  W  T  F  S 







1

2

3
(1) 
4

5

6

7
(1) 
8

9

10

11

12

13

14
(1) 
15
(1) 
16
(1) 
17
(1) 
18

19
(3) 
20
(8) 
21

22
(1) 
23
(2) 
24
(3) 
25
(2) 
26

27
(1) 
28
(2) 
29
(2) 
30
(2) 
31
(2) 





From: Paul Tremblay <paulhtremblay@gm...>  20111023 22:04:15

On 10/22/11 9:43 AM, Guenter Milde wrote: > On 20111020, Paul Tremblay wrote: >> On 10/20/11 6:14 AM, Guenter Milde wrote: >>>>>>>> MathML is pretty essential for XML. Can it be put in the XML >>>>>>>> writer? > ... > >>> The idea would be to define a new transform >>> (transforms.math.latex2mathml, in a file >>> docutils/docutils/transforms/math.py say) that would >>> replace the content of math and mathblock nodes. >>> The code would be a mixture of examples from other transforms and the >>> visit_math() method in the html writer. (to avoid duplicating code, >>> once it is in place and tested, the html writer should be modified to >>> use it as well) >> Following your directions, I created math.py in the docutils/transform >> directory. To the __init__ .py in writers, I added: >> from docutils.transforms import math > ... > >> def get_transforms(self): >> return Component.get_transforms(self) + [ >> universal.Messages, >> universal.FilterMessages, >> universal.StripClassesAndElements, >> math.Math_Block, > this should go into /docutils/writers/docutils_xml.py, otherwise it > affects all writers (inheriting from docutils.writers.Writer). > >> math.py looks like this; >> """ >> math used by writers > I'd use something like """math related transformations""" as docstring > for the transforms.math module. > >> from docutils import writers >> from docutils.transforms import writers >> """ > What is this for? > >> __docformat__ = 'reStructuredText' >> from docutils import nodes, utils, languages >> from docutils.transforms import Transform >> from docutils.math.latex2mathml import parse_latex_math >> class Math_Block(Transform): > Do we need separate classes for Math_Block vs. Math_Role or could these be > put into one class? > > Considering that `transforms.math` might be used for several mathrelated > transforms (equation numbering comes to my mind), I'd use a more telling > name, `LaTeXmath2MathML`, say. > >> """ >> Change the text in the math_block from plain text in LaTeX to >> a MathML tree >> """ >> default_priority = 910 # not sure if this needs to be loaded >> earlier or not >> def apply(self): >> for math_block in self.document.traverse(nodes.math_block): >> math_code = math_block.astext() >> mathml_tree = parse_latex_math(math_code, inline=False) >> # need to append the mathml_tree to math_block >> I have a few questions. >> (1) How do you get just the text from a node.Element? In my code, the >> math_block.astext actually returns a text representation of the node, >> including the elements tags, etc. I looked everywhere in >> docutils/nodes.py for a method to get just text, but could not find one. >> Somehow, feeding the string with the tags to parse_latex_math worked >> anyway (following the example in the html writer). > Strange. How can I reproduce this? > > I did a small test inserting > > print node.astext().encode('utf8') > > in the visit_math_block() method of the html writer and did get just the > content, no tags. > >> (2) How do I append the resulting tee to the math_block? I tried >> math_block.append() and other methods, but it seems the latext2mathml.py >> returns a different type of tree then that already created. > I think so. Remember that latext2mathml is taken from a usercontributed > addon in the sandbox and is only intended to produce an MathML > representation to put into HTML pages. > >> I could convert the mathml tree to an XML string and then create a tree >> from that, and then append the tree? I'm just not sure how to do this. > I see several ways forward from here: > > * your proposal (convert to string and parse this to a compatible tree). > Is there a XML parser in the minidom module? > > * modify latex2mathml to use "compatible" tree nodes based on Docutils' > nodes. > >> (3) How do I make this transformation optional, depending on an options >> by the user. The user might have put asciimath in the math_block >> element, in which case it should not be transformed by the >> latex2mathml.py modulel. > Here, you can look at examples for customizable transforms. E.g. the > sectnum_xform setting is defined in frontend.py and works on the > SectNum(Transform) in transforms/parts.py. > > Günter > > > Okay, I've followed all of your suggestions. docutils/writers/docutils.xml now has the following changes: from docutils.transforms import math ^^^^^^^^^^^^ import math class Writer(writers.Writer, Component): ^^^^^ subclassing Component in order to add the transformation supported = ('xml',) """Formats this writer supports.""" settings_spec = ( '"Docutils XML" Writer Options', 'Warning: the newlines and indents options may adversely affect ' 'whitespace; use them only for reading convenience.', (('Generate XML with newlines before and after tags.', ['newlines'], {'action': 'store_true', 'validator': frontend.validate_boolean}), ('Generate XML with indents and newlines.', ['indents'], {'action': 'store_true', 'validator': frontend.validate_boolean}), ('Omit the XML declaration. Use with caution.', ['noxmldeclaration'], {'dest': 'xml_declaration', 'default': 1, 'action': 'store_false', 'validator': frontend.validate_boolean}), ('Omit the DOCTYPE declaration.', ['nodoctype'], {'dest': 'doctype_declaration', 'default': 1, 'action': 'store_false', 'validator': frontend.validate_boolean}), ('Convert LaTeX math in math_block and math to MathML', ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Add an option for latexmathml ['latexmathml'], {'dest': 'latex_mathml', 'default':False, 'action': 'store_true', 'validator': frontend.validate_boolean}), ('Convert ASCII math in math_block and math to MathML', ^^^^^^^^^^^^^^^^^^^ Add an option for ASCII math ['asciimathml'], {'dest': 'ascii_mathml', 'default':False, 'action': 'store_true', 'validator': frontend.validate_boolean}), )) def get_transforms(self): return Component.get_transforms(self) + [ universal.Messages, universal.FilterMessages, universal.StripClassesAndElements, math.LaTeXmath2MathML, math.Asciimath2MathML, ^^^^^^^^^^^^^^^^ add 2 new writers ] ============================================= The file docutils/transforms/math.py, looks like this: # $Id: writer_aux.py 6433 20100928 08:21:25Z milde $ # Author: Lea Wiemann <LeWiemann@...> # Copyright: This module has been placed in the public domain. """ math used by writers """ __docformat__ = 'reStructuredText' from docutils import nodes, utils, languages from docutils.transforms import Transform from docutils.math.latex2mathml import parse_latex_math from xml.dom.minidom import parse, parseString, Node import sys class LaTeXmath2MathML(Transform): """ Change the text in the math_block and math from plain text in LaTeX to a MathML tree """ default_priority = 910 # not sure if this needs to be loaded earlier or not def apply(self): latex_mathml = self.document.settings.latex_mathml if not latex_mathml: return for math_block in self.document.traverse(nodes.math_block): math_code = math_block.astext() try: mathml_tree = parse_latex_math(math_code, inline=False) math_xml = ''.join(mathml_tree.xml()) except SyntaxError, err: err_node = self.document.reporter.error(err, base_node=math_block) math_block.append(err_node) return new_math_block = nodes.Element(rawsource=math_code) new_math_block.tagname = 'math_block' math_block.replace_self(new_math_block) convert_string_to_docutils_tree(math_xml, new_math_block) for math in self.document.traverse(nodes.math): math_code = math.astext() try: mathml_tree = parse_latex_math(math_code, inline=True) math_xml = ''.join(mathml_tree.xml()) except SyntaxError, err: err_node = self.document.reporter.error(err, base_node=math) math.append(err_node) return new_math = nodes.Element(rawsource=math_code) new_math.tagname = 'math' math.replace_self(new_math) convert_string_to_docutils_tree(math_xml, new_math) class Asciimath2MathML(Transform): """ Change the text in the math_block and math from plain text in ASCII to a MathML tree """ default_priority = 910 # not sure if this needs to be loaded earlier or not def apply(self): ascii_mathml = self.document.settings.ascii_mathml if not ascii_mathml: return try: import asciimathml from xml.etree.ElementTree import Element, tostring except ImportError as msg: err_node = self.document.reporter.error(msg, base_node=self.document) return for math_block in self.document.traverse(nodes.math_block): math_code = math_block.astext() math_tree = asciimathml.parse(math_code) math_tree.set('xmlns' ,'http://www.w3.org/1998/Math/MathML';) math_xml = tostring(math_tree, encoding="utf8") math_xml = math_xml.decode('utf8') new_math_block = nodes.Element(rawsource=math_code) new_math_block.tagname = 'math_block' math_block.replace_self(new_math_block) convert_string_to_docutils_tree(math_xml, new_math_block) for math in self.document.traverse(nodes.math): math_code = math.astext() math_tree = asciimathml.parse(math_code) math_tree.set('xmlns' ,'http://www.w3.org/1998/Math/MathML';) math_xml = tostring(math_tree, encoding="utf8") math_xml = math_xml.decode('utf8') new_math = nodes.Element(rawsource=math_code) new_math.tagname = 'math' math.replace_self(new_math) convert_string_to_docutils_tree(math_xml, new_math) def convert_string_to_docutils_tree(xml_string, docutils_node): minidom_dom = parseString(xml_string.encode('utf8')) _convert_tree(minidom_dom, docutils_node) def _convert_tree(minidom_node, docutils_node): for child_node in minidom_node.childNodes: if child_node.nodeType == Node.ELEMENT_NODE: tag_name = child_node.nodeName node_text = '' for grand_child in child_node.childNodes: if grand_child.nodeType == Node.TEXT_NODE: node_text += grand_child.nodeValue if node_text.strip() != '': Element = nodes.TextElement(text=node_text) else: Element = nodes.Element() Element.tagname = tag_name attrs = child_node.attributes if attrs: for attrName in attrs.keys(): attrNode = attrs.get(attrName) attrValue = attrNode.nodeValue attr_string_name = attrNode.nodeName Element[attr_string_name] = attrValue docutils_node.append(Element) if len(child_node.childNodes) != 0: _convert_tree(child_node, Element) ============================== I've done simple tests with the math.txt in test/functional/input/data/math.txt, as well as with my own math_ascii.rst file, and the code seems to work. It obviously needs some documentation. Also, there is apparently a bug with minidom when using python 3. I could write another simple function to supplement _convert_tree(minidom_node, docutils_node):, except use the xml.etree module, which is considered more uptodate than minidom, but which does not work with python older than 2.5. Paul 
From: Paul Tremblay <paulhtremblay@gm...>  20111023 03:49:16

On 10/22/11 9:43 AM, Guenter Milde wrote: > On 20111020, Paul Tremblay wrote: >> On 10/20/11 6:14 AM, Guenter Milde wrote: >>>>>>>> MathML is pretty essential for XML. Can it be put in the XML >>>>>>>> writer? > ... > >>> The idea would be to define a new transform >>> (transforms.math.latex2mathml, in a file >>> docutils/docutils/transforms/math.py say) that would >>> replace the content of math and mathblock nodes. >>> The code would be a mixture of examples from other transforms and the >>> visit_math() method in the html writer. (to avoid duplicating code, >>> once it is in place and tested, the html writer should be modified to >>> use it as well) >> Following your directions, I created math.py in the docutils/transform >> directory. To the __init__ .py in writers, I added: >> from docutils.transforms import math > ... > >> def get_transforms(self): >> return Component.get_transforms(self) + [ >> universal.Messages, >> universal.FilterMessages, >> universal.StripClassesAndElements, >> math.Math_Block, > this should go into /docutils/writers/docutils_xml.py, otherwise it > affects all writers (inheriting from docutils.writers.Writer). > >> math.py looks like this; >> """ >> math used by writers > I'd use something like """math related transformations""" as docstring > for the transforms.math module. > >> from docutils import writers >> from docutils.transforms import writers >> """ > What is this for? > >> __docformat__ = 'reStructuredText' >> from docutils import nodes, utils, languages >> from docutils.transforms import Transform >> from docutils.math.latex2mathml import parse_latex_math >> class Math_Block(Transform): > Do we need separate classes for Math_Block vs. Math_Role or could these be > put into one class? > > Considering that `transforms.math` might be used for several mathrelated > transforms (equation numbering comes to my mind), I'd use a more telling > name, `LaTeXmath2MathML`, say. > >> """ >> Change the text in the math_block from plain text in LaTeX to >> a MathML tree >> """ >> default_priority = 910 # not sure if this needs to be loaded >> earlier or not >> def apply(self): >> for math_block in self.document.traverse(nodes.math_block): >> math_code = math_block.astext() >> mathml_tree = parse_latex_math(math_code, inline=False) >> # need to append the mathml_tree to math_block >> I have a few questions. >> (1) How do you get just the text from a node.Element? In my code, the >> math_block.astext actually returns a text representation of the node, >> including the elements tags, etc. I looked everywhere in >> docutils/nodes.py for a method to get just text, but could not find one. >> Somehow, feeding the string with the tags to parse_latex_math worked >> anyway (following the example in the html writer). > Strange. How can I reproduce this? > > I did a small test inserting > > print node.astext().encode('utf8') > > in the visit_math_block() method of the html writer and did get just the > content, no tags. Thanks for your detailed reply. I'll try to work through many of these problems. However, I just want to quickly reply that I was wrong; node.astext() does return just the string. My mistake! > >> (2) How do I append the resulting tee to the math_block? I tried >> math_block.append() and other methods, but it seems the latext2mathml.py >> returns a different type of tree then that already created. > I think so. Remember that latext2mathml is taken from a usercontributed > addon in the sandbox and is only intended to produce an MathML > representation to put into HTML pages. > >> I could convert the mathml tree to an XML string and then create a tree >> from that, and then append the tree? I'm just not sure how to do this. > I see several ways forward from here: > > * your proposal (convert to string and parse this to a compatible tree). > Is there a XML parser in the minidom module? > > * modify latex2mathml to use "compatible" tree nodes based on Docutils' > nodes. > >> (3) How do I make this transformation optional, depending on an options >> by the user. The user might have put asciimath in the math_block >> element, in which case it should not be transformed by the >> latex2mathml.py modulel. > Here, you can look at examples for customizable transforms. E.g. the > sectnum_xform setting is defined in frontend.py and works on the > SectNum(Transform) in transforms/parts.py. > > Günter > > >  > The demand for IT networking professionals continues to grow, and the > demand for specialized networking skills is growing even more rapidly. > Take a complimentary Learning@... SelfAssessment and learn > about Cisco certifications, training, and career opportunities. > http://p.sf.net/sfu/ciscodev2dev > _______________________________________________ > Docutilsdevelop mailing list > Docutilsdevelop@... > https://lists.sourceforge.net/lists/listinfo/docutilsdevelop > > Please use "Reply All" to reply to the list. 