Embeds
This commit is contained in:
@@ -278,6 +278,39 @@ print_html :: proc(token: ^Token) {
|
||||
fmt.print("</a>")
|
||||
}
|
||||
|
||||
case TokenType.Image:
|
||||
if url, ok := token.value.(string); ok {
|
||||
b := strings.builder_make(context.temp_allocator)
|
||||
for child in token.children {
|
||||
get_text_content(child, &b)
|
||||
}
|
||||
alt_text := strings.to_string(b)
|
||||
fmt.printf("<img src=\"%s\" alt=\"%s\">", url, alt_text)
|
||||
}
|
||||
|
||||
case TokenType.Audio:
|
||||
if url, ok := token.value.(string); ok {
|
||||
fmt.printf("<audio controls src=\"%s\">", url)
|
||||
for child in token.children {
|
||||
print_html(child)
|
||||
}
|
||||
fmt.print("</audio>")
|
||||
}
|
||||
|
||||
case TokenType.Video:
|
||||
if url, ok := token.value.(string); ok {
|
||||
fmt.printf("<video controls src=\"%s\">", url)
|
||||
for child in token.children {
|
||||
print_html(child)
|
||||
}
|
||||
fmt.print("</video>")
|
||||
}
|
||||
|
||||
case TokenType.Iframe:
|
||||
if url, ok := token.value.(string); ok {
|
||||
fmt.printf("<iframe src=\"%s\"></iframe>", url)
|
||||
}
|
||||
|
||||
case TokenType.BreakLine:
|
||||
fmt.print("<br>\n")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user