From ce9ec5e341b14f7ee8bc9de0b81c5ee38620ae9d Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Thu, 6 Aug 2020 22:32:20 +1000 Subject: [PATCH] Allow styling images --- wikinote/markup_custom.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wikinote/markup_custom.py b/wikinote/markup_custom.py index ba39e38..fcf5f0f 100644 --- a/wikinote/markup_custom.py +++ b/wikinote/markup_custom.py @@ -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