+
+
+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?
+ return output
+
+HtmlFormat.renderers.register(core.Div, 'defined', DivDefined('dt', {'style': 'display: inline-block'}))
+
+
+class DivImage(NaturalText):
+ def render(self, element, ctx):
+ output = super(DivImage, self).render(element, ctx)
+ src = element.attrib.get('src', '')
+ if src.startswith('file://'):
+ src = ctx.files_path + src[7:]
+ output[0].attrib['src'] = src
+ output[0].attrib['style'] = 'display: block; width: 60%; margin: 3em auto'
+ return output
+
+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'))
+