Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions ooxml/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import six
import collections
from dwml import omml
from lxml import etree


class Style(object):
Expand Down Expand Up @@ -476,11 +478,24 @@ class Math(Element):

Math elements are not supported at the moment. We just parse them and create empty element."""

def __init__(self):
pass
def __init__(self, element, tag):
mathml = etree.tostring(element).decode()
if tag == 'oMath':
mathml = """<m:oMathPara
xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"
xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
xmlns:w="http://schemas.openxmlformats.org/wordparseingml/2006/main">
%s
</m:oMathPara>""" % mathml

latexs = [i.latex for i in omml.load_string(mathml)]
if latexs:
self.latex = '${0}$'.format(latexs[0])
else:
self.latex = ''

def value(self):
return ''
return self.latex


class SmartTag(Element):
Expand Down
4 changes: 2 additions & 2 deletions ooxml/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,11 @@ def parse_paragraph(document, par):
parse_text(document, paragraph, elem)

if elem.tag == _name('{{{m}}}oMath'):
_m = doc.Math()
_m = doc.Math(elem, tag='oMath')
paragraph.elements.append(_m)

if elem.tag == _name('{{{m}}}oMathPara'):
_m = doc.Math()
_m = doc.Math(elem, tag='oMathPara')
paragraph.elements.append(_m)

if elem.tag == _name('{{{w}}}commentRangeStart'):
Expand Down