HTML 4.01 embeds
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
TypoML
|
||||
src.bin
|
||||
typoml
|
||||
preview.html
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam blandit dolor nibh,
|
||||
^ Links with no alt text
|
||||
|
||||
$[https://krzak.org/krzak-icon.png|img]
|
||||
$[https://frokfrdk.com/projects/staircase/staircase.wav]
|
||||
$[/staircase.mp3]
|
||||
$(https://9front.org/movies/no.mp4)
|
||||
|
||||
*italic*
|
||||
|
||||
@@ -35,5 +35,5 @@ script='
|
||||
</script>'
|
||||
end="$script</body></html>"
|
||||
output="$start$input$end"
|
||||
echo "$output" > /tmp/preview.html
|
||||
nohup xdg-open /tmp/preview.html > /dev/null 2>&1 &
|
||||
echo "$output" > preview.html
|
||||
nohup xdg-open preview.html > /dev/null 2>&1 &
|
||||
|
||||
+37
-8
@@ -256,12 +256,21 @@ print_html :: proc(token: ^Token) {
|
||||
|
||||
case TokenType.FootnoteRef:
|
||||
if id, ok := token.value.(string); ok {
|
||||
fmt.printf("<a href=\"#fn-%s\" id=\"ref-%s\"><sup>%s</sup></a>", escape_html(id), escape_html(id), escape_html(id))
|
||||
fmt.printf(
|
||||
"<a href=\"#fn-%s\" id=\"ref-%s\"><sup>%s</sup></a>",
|
||||
escape_html(id),
|
||||
escape_html(id),
|
||||
escape_html(id),
|
||||
)
|
||||
}
|
||||
|
||||
case TokenType.FootnoteDef:
|
||||
if id, ok := token.value.(string); ok {
|
||||
fmt.printf("<div class=\"footnote\" id=\"fn-%s\"><a href=\"#ref-%s\">^</a> ", escape_html(id), escape_html(id))
|
||||
fmt.printf(
|
||||
"<div class=\"footnote\" id=\"fn-%s\"><a href=\"#ref-%s\">^</a> ",
|
||||
escape_html(id),
|
||||
escape_html(id),
|
||||
)
|
||||
for child in token.children {
|
||||
print_html(child)
|
||||
}
|
||||
@@ -346,20 +355,40 @@ print_html :: proc(token: ^Token) {
|
||||
|
||||
case TokenType.Audio:
|
||||
if url, ok := token.value.(string); ok {
|
||||
fmt.printf("<audio controls src=\"%s\">", escape_html(url))
|
||||
mime := detect_mime_type(url)
|
||||
b := strings.builder_make(context.temp_allocator)
|
||||
for child in token.children {
|
||||
print_html(child)
|
||||
get_text_content(child, &b)
|
||||
}
|
||||
fmt.print("</audio>")
|
||||
alt_text := strings.to_string(b)
|
||||
if alt_text == "" {
|
||||
alt_text = url
|
||||
}
|
||||
fmt.printf("<object data=\"%s\" type=\"%s\">\n", escape_html(url), escape_html(mime))
|
||||
fmt.printf("<param name=\"src\" value=\"%s\">\n", escape_html(url))
|
||||
fmt.printf("<param name=\"autoplay\" value=\"false\">\n")
|
||||
fmt.printf("<param name=\"controller\" value=\"true\">\n")
|
||||
fmt.printf("<a href=\"%s\">%s</a>\n", escape_html(url), escape_html(alt_text))
|
||||
fmt.print("</object>\n")
|
||||
}
|
||||
|
||||
case TokenType.Video:
|
||||
if url, ok := token.value.(string); ok {
|
||||
fmt.printf("<video controls src=\"%s\">", escape_html(url))
|
||||
mime := detect_mime_type(url)
|
||||
b := strings.builder_make(context.temp_allocator)
|
||||
for child in token.children {
|
||||
print_html(child)
|
||||
get_text_content(child, &b)
|
||||
}
|
||||
fmt.print("</video>")
|
||||
alt_text := strings.to_string(b)
|
||||
if alt_text == "" {
|
||||
alt_text = url
|
||||
}
|
||||
fmt.printf("<object data=\"%s\" type=\"%s\">\n", escape_html(url), escape_html(mime))
|
||||
fmt.printf("<param name=\"src\" value=\"%s\">\n", escape_html(url))
|
||||
fmt.printf("<param name=\"autoplay\" value=\"false\">\n")
|
||||
fmt.printf("<param name=\"controller\" value=\"true\">\n")
|
||||
fmt.printf("<a href=\"%s\">%s</a>\n", escape_html(url), escape_html(alt_text))
|
||||
fmt.print("</object>\n")
|
||||
}
|
||||
|
||||
case TokenType.Iframe:
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user