Hotfix to stop subreddit and redditor rules inside links.
This commit is contained in:
parent
50d6b5b71e
commit
bb8618b414
1 changed files with 13 additions and 0 deletions
|
@ -204,9 +204,22 @@ class VoussoirInline(mistune.InlineLexer):
|
||||||
return self.output_supers(m)
|
return self.output_supers(m)
|
||||||
|
|
||||||
def output_subreddit(self, m):
|
def output_subreddit(self, m):
|
||||||
|
# Hotfix. I'd like to be able to include /r/ and /u/ inside links
|
||||||
|
# without having to escape it. But since these rules are processed after
|
||||||
|
# the link rules, the m object doesn't contain anything that would help
|
||||||
|
# us know we're inside a link. Need to think about this problem but for
|
||||||
|
# now here's a stopgap solution.
|
||||||
|
import inspect
|
||||||
|
for x in inspect.stack():
|
||||||
|
if x.function == '_process_link':
|
||||||
|
return m.group(0)
|
||||||
return f'<a href="https://old.reddit.com{m.group(0)}">{m.group(0)}</a>'
|
return f'<a href="https://old.reddit.com{m.group(0)}">{m.group(0)}</a>'
|
||||||
|
|
||||||
def output_redditor(self, m):
|
def output_redditor(self, m):
|
||||||
|
import inspect
|
||||||
|
for x in inspect.stack():
|
||||||
|
if x.function == '_process_link':
|
||||||
|
return m.group(0)
|
||||||
return f'<a href="https://old.reddit.com{m.group(0)}">{m.group(0)}</a>'
|
return f'<a href="https://old.reddit.com{m.group(0)}">{m.group(0)}</a>'
|
||||||
|
|
||||||
def output_dash_spacer(self, m):
|
def output_dash_spacer(self, m):
|
||||||
|
|
Loading…
Reference in a new issue