Codeblocks
This commit is contained in:
@@ -187,6 +187,29 @@ print_html :: proc(token: ^Token) {
|
||||
fmt.print("</div>\n")
|
||||
}
|
||||
|
||||
case TokenType.CodeBlock:
|
||||
lang := ""
|
||||
if v, ok := token.value.(string); ok && v != "" {
|
||||
lang = v
|
||||
}
|
||||
if lang != "" {
|
||||
fmt.printf("<pre><code class=\"lang-%s\">", lang)
|
||||
} else {
|
||||
fmt.print("<pre><code>")
|
||||
}
|
||||
for i := 0; i < len(token.children); i += 1 {
|
||||
print_html(token.children[i])
|
||||
if i + 1 < len(token.children) {
|
||||
fmt.print("\n")
|
||||
}
|
||||
}
|
||||
fmt.print("\n</code></pre>\n")
|
||||
|
||||
case TokenType.InlineCode:
|
||||
if code, ok := token.value.(string); ok {
|
||||
fmt.printf("<code>%s</code>", code)
|
||||
}
|
||||
|
||||
case TokenType.BreakLine:
|
||||
fmt.print("<br>\n")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user