aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorrebecca <ubq323@ubq323.website>2026-11-08 11:14:04 +0000
committerrebecca <ubq323@ubq323.website>2026-11-08 11:14:04 +0000
commitc6732551f1d9d015f62cf87bfcdcf4bb20889b4a (patch)
treefa2a7ef80de372fb888d04100076a359d91ba4c4
parent6865ddcfd4c723bcc31142a7ac9b5f358771fb73 (diff)
make hacky global slightly less hacky
-rw-r--r--apioforum/mdrender.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/apioforum/mdrender.py b/apioforum/mdrender.py
index 0d75b2f..8d23be7 100644
--- a/apioforum/mdrender.py
+++ b/apioforum/mdrender.py
@@ -2,7 +2,7 @@ import bleach
from bleach._vendor.html5lib.filters.base import Filter
from .csscolors import csscolors
from .wiki import normalize_page_name
-from flask import url_for
+from flask import url_for, g
allowed_tags = [
'p',
@@ -88,13 +88,12 @@ cleaner = bleach.sanitizer.Cleaner(
css_sanitizer=IFrameCSS(),
filters=[IFrameSandboxFilter])
-g_forum_id = None
def wikilink_url(label, base, end):
- if g_forum_id is None:
+ if g.forum_id is None:
return "#"
else:
normalized = normalize_page_name(label)
- return url_for('forum.view_wiki_page', forum_id=g_forum_id, path=normalized)
+ return url_for('forum.view_wiki_page', forum_id=g.forum_id, path=normalized)
import markdown
@@ -110,8 +109,7 @@ md = markdown.Markdown(extensions=[
])
def render(text, forum_id):
- global g_forum_id #blegh
- g_forum_id = forum_id
+ g.forum_id = forum_id
text = md.reset().convert(text)
text = cleaner.clean(text)
return text