add [lb], [rb], and [@] tags
This commit is contained in:
@@ -141,6 +141,12 @@ TAGS = {
|
||||
"spoiler": tag_spoiler,
|
||||
}
|
||||
|
||||
VOID_TAGS = {
|
||||
'lb': lambda attr: '[',
|
||||
'rb': lambda attr: ']',
|
||||
'@': lambda attr: '@',
|
||||
}
|
||||
|
||||
# [img] is considered block for the purposes of collapsing whitespace,
|
||||
# despite being potentially inline (since the resulting <img> tag is inline, but creates a block container around itself and sibling images).
|
||||
# [code] has a special case in is_inline().
|
||||
@@ -260,6 +266,7 @@ def babycode_to_html(s, banned_tags=[]):
|
||||
subj = sanitize(s)
|
||||
parser = Parser(subj)
|
||||
parser.valid_bbcode_tags = allowed_tags
|
||||
parser.void_bbcode_tags = set(VOID_TAGS)
|
||||
parser.bbcode_tags_only_text_children = TEXT_ONLY
|
||||
parser.mentions_allowed = '@mention' not in banned_tags
|
||||
parser.valid_emotes = EMOJI.keys()
|
||||
@@ -296,6 +303,8 @@ def babycode_to_html(s, banned_tags=[]):
|
||||
c = c + Markup(fold(child, _nobr, _surrounding))
|
||||
res = TAGS[element['name']](c, element['attr'], surrounding)
|
||||
return res
|
||||
case "bbcode_void":
|
||||
return VOID_TAGS[element['name']](element['attr'])
|
||||
case "link":
|
||||
return f"<a href=\"{element['url']}\">{element['url']}</a>"
|
||||
case 'emote':
|
||||
|
||||
Reference in New Issue
Block a user