Codeblocks

This commit is contained in:
2026-07-14 19:21:35 +02:00
parent 91671995d3
commit 5c35ce4408
4 changed files with 107 additions and 0 deletions
+23
View File
@@ -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")