Footnotes
This commit is contained in:
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user