19 lines
473 B
Python
19 lines
473 B
Python
#!/usr/bin/env python3
|
|
"""
|
|
Jinja2 template filters.
|
|
"""
|
|
import re
|
|
|
|
from markupsafe import Markup
|
|
|
|
def quotelink(line, post):
|
|
"""Checks if the quotelink is valid and adds an anchor tag if so."""
|
|
links = re.findall(r'>>(\d+)', line)
|
|
for link in links:
|
|
if int(link) in post['link_tos']:
|
|
span = f'<a class="quotelink" href="#{link}">>>{link}</a>'
|
|
else:
|
|
span = f'<span class="deadlink">>>{link}</span>'
|
|
line = line.replace('>>' + link, span)
|
|
return Markup(line)
|