diff --git a/app/lib/babycode.py b/app/lib/babycode.py
index a41c96b..3cc0e0e 100644
--- a/app/lib/babycode.py
+++ b/app/lib/babycode.py
@@ -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
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
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":