Add tweet embeds.
This commit is contained in:
parent
8906ad4123
commit
cfea2bda07
2 changed files with 15 additions and 4 deletions
|
@ -222,10 +222,10 @@ class Subnode:
|
||||||
def render(self):
|
def render(self):
|
||||||
# hack hack
|
# hack hack
|
||||||
if self.uri.endswith('md') or self.uri.endswith('MD'):
|
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'):
|
if self.uri.endswith('org') or self.uri.endswith('ORG'):
|
||||||
print("trying to render org-mode")
|
content = render.orgmode(self.content)
|
||||||
return render.orgmode(self.content)
|
return render.postprocess(content)
|
||||||
|
|
||||||
def go(self):
|
def go(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -49,5 +49,16 @@ class Wikilinks():
|
||||||
markdown = Markdown(extensions=[Wikilinks])
|
markdown = Markdown(extensions=[Wikilinks])
|
||||||
|
|
||||||
|
|
||||||
# Org-mode goes here.
|
# Org-mode -- simple but, well, bad for now.
|
||||||
orgmode = to_html
|
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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue