This commit is contained in:
2026-07-14 18:42:41 +02:00
parent 62e66948e4
commit 3f680b5e22
5 changed files with 246 additions and 12 deletions
+91
View File
@@ -76,6 +76,97 @@ print_html :: proc(token: ^Token) {
}
fmt.print("</strike>")
case TokenType.Table:
fmt.print("<table>\n")
for child in token.children {
print_html(child)
}
fmt.print("</table>\n")
case TokenType.TableHeaderRow:
fmt.print("<tr>")
for child in token.children {
align := ""
if len(child.children) > 0 {
first_child := child.children[0]
if first_child.type == .Left {
align = "left"
} else if first_child.type == .Right {
align = "right"
} else if first_child.type == .Middle {
align = "center"
}
}
if align != "" {
fmt.printf("<th align=\"%s\">", align)
for grandchild in child.children[0].children {
print_html(grandchild)
}
} else {
fmt.print("<th>")
for grandchild in child.children {
print_html(grandchild)
}
}
fmt.print("</th>")
}
fmt.print("</tr>\n")
case TokenType.TableRow:
fmt.print("<tr>")
for child in token.children {
print_html(child)
}
fmt.print("</tr>\n")
case TokenType.TableCell:
align := ""
if len(token.children) > 0 {
first_child := token.children[0]
if first_child.type == .Left {
align = "left"
} else if first_child.type == .Right {
align = "right"
} else if first_child.type == .Middle {
align = "center"
}
}
if align != "" {
fmt.printf("<td align=\"%s\">", align)
for child in token.children[0].children {
print_html(child)
}
} else {
fmt.print("<td>")
for child in token.children {
print_html(child)
}
}
fmt.print("</td>")
case TokenType.TableSeparator:
fmt.print("<tr class=\"table-sep\"><td colspan=\"100\"></td></tr>\n")
case TokenType.Left:
fmt.print("<div align=\"left\">")
for child in token.children {
print_html(child)
}
fmt.print("</div>")
case TokenType.Right:
fmt.print("<div align=\"right\">")
for child in token.children {
print_html(child)
}
fmt.print("</div>")
case TokenType.Middle:
fmt.print("<div align=\"center\">")
for child in token.children {
print_html(child)
}
fmt.print("</div>")
case TokenType.BreakLine:
fmt.print("<br>\n")