Add interlink support
This commit is contained in:
parent
6cddcbbc1b
commit
f663291067
|
@ -6,6 +6,7 @@ import json
|
|||
import logging
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import string
|
||||
|
||||
from flask import (
|
||||
|
@ -44,6 +45,14 @@ def inject_edit():
|
|||
return {'edit': current_app.config['edit']}
|
||||
|
||||
|
||||
@app.template_filter('interlink')
|
||||
def interlink_filter(value):
|
||||
return re.sub(
|
||||
r'\[\[([^|]+)\|([^|]+)\]\]',
|
||||
lambda match: f'<a href="{match[2]}">{match[1]}</a>',
|
||||
value)
|
||||
|
||||
|
||||
@app.route('/', methods=['GET'])
|
||||
def root():
|
||||
return redirect(url_for('index'))
|
||||
|
|
|
@ -63,10 +63,11 @@ window.onload = function () {
|
|||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{# TODO: tag.interlink #}
|
||||
{% macro make_tag_value(tag) -%}
|
||||
{%- if tag.options.hyperlink -%}
|
||||
<a href="{{ tag.value }}">{{ tag.value }}</a>
|
||||
{%- elif tag.options.interlink -%}
|
||||
{{ tag.value|interlink }}
|
||||
{%- else -%}
|
||||
{{ tag.value }}
|
||||
{%- endif -%}
|
||||
|
|
Loading…
Reference in New Issue