-
- # Extracts code as String from a `BlockCode`.
- fun code_from_block(block: BlockCode): String do
- var infence = block isa BlockFence
- var text = new FlatBuffer
- var line = block.block.first_line
- while line != null do
- if not line.is_empty then
- var str = line.value
- if not infence and str.has_prefix(" ") then
- text.append str.substring(4, str.length - line.trailing)
- else
- text.append str
- end
- end
- text.append "\n"
- line = line.next
- end
- return text.write_to_string
- end