babycode: handle code tag being inline or block explicitly in is_inline
This commit is contained in:
@ -116,8 +116,9 @@ TAGS = {
|
||||
"spoiler": tag_spoiler,
|
||||
}
|
||||
|
||||
# [img] and [code] are considered block for the purposes of collapsing whitespace,
|
||||
# despite being potentially inline ([img] is particularly egregious, since the resulting <img> tag is inline, but creates a block container around itself and sibling images)
|
||||
# [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().
|
||||
INLINE_TAGS = {
|
||||
'b', 'i', 's', 'u', 'color', 'big', 'small', 'url'
|
||||
}
|
||||
@ -186,6 +187,9 @@ def is_inline(e):
|
||||
return True
|
||||
|
||||
if is_tag(e):
|
||||
if is_tag(e, 'code'): # special case, since [code] can be inline OR block
|
||||
return '\n' not in e['children']
|
||||
|
||||
return e['name'] in INLINE_TAGS
|
||||
|
||||
return e['type'] != 'rule'
|
||||
@ -238,7 +242,6 @@ def babycode_to_html(s):
|
||||
)
|
||||
_nobr = element['name'] == "code" or element['name'] == "ul" or element['name'] == "ol"
|
||||
c = c + fold(child, _nobr, _surrounding)
|
||||
|
||||
res = TAGS[element['name']](c, element['attr'], surrounding)
|
||||
return res
|
||||
case "link":
|
||||
|
Reference in New Issue
Block a user