class BlockCode
super Block
+ # Any string found after fence token.
+ var meta: nullable Text
+
# Number of char to skip at the beginning of the line.
#
# Block code lines start at 4 spaces.
class BlockFence
super BlockCode
- # Any string found after fence token.
- var meta: nullable Text
-
# Fence code lines start at 0 spaces.
redef var line_start = 0
end
var toolcontext = new ToolContext
redef fun add_code(v, block) do
- var meta = "nit"
- if block isa BlockFence and block.meta != null then
- meta = block.meta.to_s
- end
+ var meta = block.meta or else "nit"
+
# Do not try to highlight non-nit code.
if meta != "nit" and meta != "nitish" then
v.add "<pre class=\"{meta}\"><code>"
redef fun add_code(v, block) do
var code = block.raw_content
- var meta = "nit"
- if block isa BlockFence and block.meta != null then
- meta = block.meta.to_s
- end
+ var meta = block.meta or else "nit"
# Do not try to test non-nit code.
if meta != "nit" then return
# Try to parse code blocks