aboutsummaryrefslogtreecommitdiff
path: root/mammoth
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-12-14 15:08:26 +0000
committerMichael Williamson <mike@zwobble.org>2013-12-14 15:08:26 +0000
commit14ca5c4d6993806b568ba5a9befb81326d9ed806 (patch)
tree8af24e08693787cc9d3e8de61ef377903fa5f420 /mammoth
parent75f454157737e34567a2325dc1c8fd7ca7b6e9a6 (diff)
Add attributes to start tags
Diffstat (limited to 'mammoth')
-rw-r--r--mammoth/html_generation.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/mammoth/html_generation.py b/mammoth/html_generation.py
index 52f9f92..c2d0240 100644
--- a/mammoth/html_generation.py
+++ b/mammoth/html_generation.py
@@ -11,8 +11,8 @@ class HtmlGenerator(object):
self._write_all()
self._fragments.append(_escape_html(text))
- def start(self, name):
- self._stack.append(_Element(name))
+ def start(self, name, attributes=None):
+ self._stack.append(_Element(name, attributes))
def end(self):
element = self._stack.pop()
@@ -34,15 +34,17 @@ class HtmlGenerator(object):
self._write_element(element)
def _write_element(self, element):
- self._fragments.append("<{0}>".format(element.name))
+ attribute_string = _generate_attribute_string(element.attributes)
+ self._fragments.append("<{0}{1}>".format(element.name, attribute_string))
def html_string(self):
return "".join(self._fragments)
class _Element(object):
- def __init__(self, name):
+ def __init__(self, name, attributes):
self.name = name
+ self.attributes = attributes
self.written = False