Allow styling images

This commit is contained in:
RunasSudo 2020-08-06 22:32:20 +10:00
parent 05e239b9ff
commit ce9ec5e341
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -110,10 +110,15 @@ roles['Ref'] = make_role_ref(True)
class RoleImage(Role):
def render(self):
image = self.content[:self.content.index(';')] if ';' in self.content else self.content
style = self.content[self.content.index(';')+1:] if ';' in self.content else None
el = RoleElement('a')
el.set('href', flask.url_for('image_about', name=self.content))
el.set('href', flask.url_for('image_about', name=image))
img = ET.SubElement(el, 'img')
img.set('src', flask.url_for('image_view', name=self.content))
img.set('src', flask.url_for('image_view', name=image))
if style:
img.set('style', style)
return el
roles['image'] = RoleImage