Fix heading anchors and add anchor links

Fixes #460
This commit is contained in:
rubenwardy
2025-06-19 18:37:03 +01:00
parent 2ddcbfb5ab
commit 21ef5f9b84
6 changed files with 25 additions and 3 deletions

View File

@@ -57,12 +57,16 @@ def allow_class(_tag, name, value):
return name == "class" and value in ALLOWED_CSS
def allow_a(_tag, name, value):
return name in ["href", "title", "data-username"] or (name == "class" and value == "header-anchor")
ALLOWED_ATTRIBUTES = {
"h1": ["id"],
"h2": ["id"],
"h3": ["id"],
"h4": ["id"],
"a": ["href", "title", "data-username"],
"a": allow_a,
"img": ["src", "title", "alt"],
"code": allow_class,
"div": allow_class,