Skip to content

Commit

Permalink
better html out
Browse files Browse the repository at this point in the history
  • Loading branch information
jpn-- committed Feb 7, 2017
1 parent 381e31d commit be6703f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
12 changes: 8 additions & 4 deletions py/model_reporter/art.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,14 +490,18 @@ def xml(self, table_attrib=None, headlevel=2):
try:
headlevel = int(headlevel)
except:
div = XML_Builder("div", attrib={'class':'larch_art'})
# div = XML_Builder("div", attrib={'class':'larch_art'})
div = Elem("div", attrib={'class':'larch_art'})
div << table
return div.close()
# return div.close()
return div
else:
div = XML_Builder("div", attrib={'class':'larch_art'})
# div = XML_Builder("div", attrib={'class':'larch_art'})
div = Elem("div", attrib={'class':'larch_art'})
div.hn(headlevel, self.title, anchor=self.short_title or self.title, attrib={'class':'larch_art'})
div << table
return div.close()
# return div.close()
return div
return table

__xml__ = xml
Expand Down
12 changes: 11 additions & 1 deletion py/util/xhtml.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ def save(self, filename, overwrite=True):
with XHTML(filename, overwrite=overwrite, view_on_exit=False) as f:
f << self

def anchor(self, ref, reftxt, cls, toclevel):
self.put("a",{'name':ref, 'reftxt':reftxt, 'class':cls, 'toclevel':toclevel})

def hn(self, n, content, attrib={}, anchor=None, **extra):
if anchor:
h_elem = self.put("h{}".format(n),attrib, **extra)
h_elem.put("a",{'name':_uid(), 'reftxt':anchor if isinstance(anchor, str) else content, 'class':'toc', 'toclevel':'{}'.format(n)}, tail=content)
else:
self.put("h{}".format(n),attrib, text=content, **extra)


def ElemTableFromDict(dictionary, toptag='div'):
e = Elem(tag=toptag)
Expand All @@ -198,7 +208,7 @@ def __init__(self, tag=None, attrib={}, **extra):
if tag is None:
tag="div"
if tag is not None:
self.start(tag,attrib,**extra)
self.topdiv = self.start(tag,attrib,**extra)
def __getattr__(self, name):
if len(name)>2 and name[-1]=="_" and name[-2]!="_" and name[0]!="_":
return self.block(name[:-1])
Expand Down

0 comments on commit be6703f

Please sign in to comment.