t.find('.//div[@id="content"]').extend(
self.render(self.doc.edoc.getroot(), ctx))
- #t.find('.//div[@id="toc"]').append(ctx.toc.render())
+ # t.find('.//div[@id="toc"]').append(ctx.toc.render())
t.find('.//div[@id="footnotes"]').extend(ctx.footnotes.output)
return OutputFile.from_string(etree.tostring(
def append(self, item):
self.counter += 1
- e = etree.Element("a",
+ e = etree.Element(
+ "a",
href="#footnote-anchor-%d" % self.counter,
id="footnote-%d" % self.counter,
style="float:left;margin-right:1em")
e.tail = " "
self.output.append(e)
self.output.extend(item)
- anchor = etree.Element("a",
+ anchor = etree.Element(
+ "a",
id="footnote-anchor-%d" % self.counter,
href="#footnote-%d" % self.counter)
anchor.text = "[%d]" % self.counter
HtmlFormat.renderers.register(core.Aside, None, NaturalText('aside'))
HtmlFormat.renderers.register(core.Aside, 'comment', Silent())
+
class AsideFootnote(NaturalText):
def render(self, element, ctx):
output = super(AsideFootnote, self).render(element, ctx)
else:
root[0].tag = 'h2'
if root[0].text:
- d = etree.SubElement(root[0], 'a', {'id': root[0].text, 'style': 'pointer: hand; color:#ddd; font-size:.8em'})
- #d.text = "per"
+ d = etree.SubElement(
+ root[0], 'a', {'id': root[0].text, 'style': 'pointer: hand; color:#ddd; font-size:.8em'})
+ # d.text = "per"
return root
-
+
HtmlFormat.renderers.register(core.Header, None, Header('h1'))
HtmlFormat.renderers.register(core.Div, None, NaturalText('div'))
+
class DivDefined(NaturalText):
def render(self, element, ctx):
output = super(DivDefined, self).render(element, ctx)
output[0].text = (output[0].text or '') + ':'
- output[0].attrib['id'] = output[0].text # not so cool?
+ output[0].attrib['id'] = output[0].text # not so cool?
return output
HtmlFormat.renderers.register(core.Div, 'defined', DivDefined('dt', {'style': 'display: inline-block'}))
HtmlFormat.renderers.register(core.Div, 'img', DivImage('img'))
+
+class DivVideo(NaturalText):
+ def render(self, element, ctx):
+ output = super(DivVideo, self).render(element, ctx)
+ video_id = element.attrib.get('videoid', '')
+ attribs = {
+ 'width': '854',
+ 'height': '480',
+ 'src': '//www.youtube.com/embed/%s?controls=2&rel=0&showinfo=0&theme=light' % video_id,
+ 'frameborder': '0',
+ 'allowfullscreen': '',
+ }
+ for attrib, value in attribs.iteritems():
+ output[0].attrib[attrib] = value
+ return output
+
+HtmlFormat.renderers.register(core.Div, 'video', DivVideo('iframe'))
+
HtmlFormat.renderers.register(core.Div, 'item', NaturalText('li'))
+HtmlFormat.renderers.register(core.Span, 'item', NaturalText('li'))
HtmlFormat.renderers.register(core.Div, 'list', NaturalText('ul'))
HtmlFormat.renderers.register(core.Div, 'list.enum', NaturalText('ol'))
+
class DivListDefinitions(NaturalText):
def render(self, element, ctx):
output = super(DivListDefinitions, self).render(element, ctx)
- #if ctx.toc_level > 2:
- # output[0].attrib['style'] = 'float: right'
+ # if ctx.toc_level > 2:
+ # output[0].attrib['style'] = 'float: right'
return output
HtmlFormat.renderers.register(core.Div, 'list.definitions', DivListDefinitions('ul'))
HtmlFormat.renderers.register(core.Span, 'emph', NaturalText('em'))
HtmlFormat.renderers.register(core.Span, 'emp', NaturalText('strong'))
+
class SpanUri(LiteralText):
def render(self, element, ctx):
root = super(SpanUri, self).render(element, ctx)
return root
HtmlFormat.renderers.register(core.Span, 'uri', SpanUri('a'))
+
class SpanLink(LiteralText):
def render(self, element, ctx):
root = super(SpanLink, self).render(element, ctx)
root[0].attrib['href'] = src
return root
HtmlFormat.renderers.register(core.Span, 'link', SpanLink('a'))
-