Footnotes

This commit is contained in:
2026-07-14 18:59:50 +02:00
parent 3f680b5e22
commit 91671995d3
5 changed files with 120 additions and 3 deletions
+19
View File
@@ -5,7 +5,12 @@ import "core:fmt"
print_html :: proc(token: ^Token) {
switch token.type {
case TokenType.Root:
has_footnotes := false
for child in token.children {
if child.type == .FootnoteDef && !has_footnotes {
fmt.print("<hr class=\"footnotes-sep\">\n")
has_footnotes = true
}
print_html(child)
}
@@ -168,6 +173,20 @@ print_html :: proc(token: ^Token) {
}
fmt.print("</div>")
case TokenType.FootnoteRef:
if id, ok := token.value.(string); ok {
fmt.printf("<a href=\"#fn-%s\" id=\"ref-%s\"><sup>%s</sup></a>", id, id, id)
}
case TokenType.FootnoteDef:
if id, ok := token.value.(string); ok {
fmt.printf("<div class=\"footnote\" id=\"fn-%s\"><a href=\"#ref-%s\">^</a> ", id, id)
for child in token.children {
print_html(child)
}
fmt.print("</div>\n")
}
case TokenType.BreakLine:
fmt.print("<br>\n")