nitc :: InlineDecorator :: defaultinit
# Decorator for span elements.
#
# Because inline comments can appear as span elements,
# InlineDecorator do not decorate things like paragraphs or headers.
class InlineDecorator
super NitdocDecorator
redef fun add_paragraph(v, block) do
v.emit_in block
end
redef fun add_headline(v, block) do
# save headline
var line = block.block.first_line
if line == null then return
var txt = line.value
var id = strip_id(txt)
var lvl = block.depth
headlines[id] = new HeadLine(id, txt, lvl)
v.emit_in block
end
redef fun add_code(v, block) do
# Try to parse code
var ast = toolcontext.parse_something(block.block.text.to_s)
if ast isa AError then
v.add "<code>"
v.emit_in block
v.add "</code>"
return
end
v.add "<code class=\"nitcode\">"
var hl = new HtmlightVisitor
hl.highlight_node(ast)
v.add(hl.html)
v.add "</code>"
end
end
src/doc/templates/html_model.nit:514,1--552,3