Add tweet embeds.

This commit is contained in:
Flancian 2021-01-10 15:20:34 +01:00
parent 8906ad4123
commit cfea2bda07
2 changed files with 15 additions and 4 deletions

View File

@ -222,10 +222,10 @@ class Subnode:
def render(self):
# hack hack
if self.uri.endswith('md') or self.uri.endswith('MD'):
return render.markdown(self.content)
content = render.markdown(self.content)
if self.uri.endswith('org') or self.uri.endswith('ORG'):
print("trying to render org-mode")
return render.orgmode(self.content)
content = render.orgmode(self.content)
return render.postprocess(content)
def go(self):
"""

View File

@ -49,5 +49,16 @@ class Wikilinks():
markdown = Markdown(extensions=[Wikilinks])
# Org-mode goes here.
# Org-mode -- simple but, well, bad for now.
orgmode = to_html
# Twitter embeds.
def add_twitter_embeds(content):
TWITTER_REGEX='(https://twitter.com/\w+/status/[0-9]+)'
TWITTER_EMBED='<blockquote class="twitter-tweet" data-dnt="true" data-theme="dark"><a href="\\1"></blockquote><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>'
return re.sub(TWITTER_REGEX, TWITTER_EMBED, content)
# "Pipeline"
postprocess = add_twitter_embeds