re-add babycode guide
This commit is contained in:
@ -7,6 +7,7 @@ from .constants import (
|
||||
PermissionLevel, permission_level_string,
|
||||
InfoboxKind, InfoboxIcons, InfoboxHTMLClass
|
||||
)
|
||||
from .lib.babycode import babycode_to_html, EMOJI
|
||||
from datetime import datetime
|
||||
import os
|
||||
import time
|
||||
@ -103,6 +104,7 @@ def create_app():
|
||||
"InfoboxHTMLClass": InfoboxHTMLClass,
|
||||
"InfoboxKind": InfoboxKind,
|
||||
"__commit": commit,
|
||||
"__emoji": EMOJI,
|
||||
}
|
||||
|
||||
@app.context_processor
|
||||
@ -124,4 +126,18 @@ def create_app():
|
||||
def permission_string(term):
|
||||
return permission_level_string(term)
|
||||
|
||||
@app.template_filter('babycode')
|
||||
def babycode_filter(markup):
|
||||
return babycode_to_html(markup)
|
||||
|
||||
@app.template_filter('extract_h2')
|
||||
def extract_h2(content):
|
||||
import re
|
||||
pattern = r'<h2\s+id="([^"]+)"[^>]*>(.*?)<\/h2>'
|
||||
matches = re.findall(pattern, content, re.IGNORECASE | re.DOTALL)
|
||||
return [
|
||||
{'id': id_.strip(), 'text': text.strip()}
|
||||
for id_, text in matches
|
||||
]
|
||||
|
||||
return app
|
||||
|
Reference in New Issue
Block a user