Skip to content

Commit

Permalink
dev: move xhtml example
Browse files Browse the repository at this point in the history
  • Loading branch information
Myriad-Dreamin committed Oct 3, 2023
1 parent 516d2d6 commit 0f1e3bf
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 44 deletions.
45 changes: 45 additions & 0 deletions contrib/templates/xhtml/lib.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

/// HTML extension
#let xhtml(outer-width: 1024pt, outer-height: 768pt, inner-width: none, inner-height: none, content) = {
let t = content.func()
let content = if content.func() == raw {
content.text
} else {
content
}

let inner-width = if inner-width == none {
outer-width
} else {
inner-width
}

let inner-height = if inner-height == none {
outer-height
} else {
inner-height
}

let html-embed = {
"<svg viewBox=\"0 0 "
str(inner-width.pt())
" "
str(inner-height.pt())
"\""
" width=\""
str(outer-width.pt())
"\" height=\""
str(outer-height.pt())
"\" xmlns=\"http://www.w3.org/2000/svg\">"
"<foreignObject width=\""
str(inner-width.pt())
"\" height=\""
str(inner-height.pt())
"\">"
content
"</foreignObject>"
"</svg>"
}

image.decode(html-embed, alt: "!typst-inlined-svg")
}
45 changes: 1 addition & 44 deletions fuzzers/corpora/visualize/video_00.typ
Original file line number Diff line number Diff line change
@@ -1,48 +1,5 @@

/// HTML extension
#let xhtml(outer-width: 1024pt, outer-height: 768pt, inner-width: none, inner-height: none, content) = {
let t = content.func()
let content = if content.func() == raw {
content.text
} else {
content
}

let inner-width = if inner-width == none {
outer-width
} else {
inner-width
}

let inner-height = if inner-height == none {
outer-height
} else {
inner-height
}

let html-embed = {
"<svg viewBox=\"0 0 "
str(inner-width.pt())
" "
str(inner-height.pt())
"\""
" width=\""
str(outer-width.pt())
"\" height=\""
str(outer-height.pt())
"\" xmlns=\"http://www.w3.org/2000/svg\">"
"<foreignObject width=\""
str(inner-width.pt())
"\" height=\""
str(inner-height.pt())
"\">"
content
"</foreignObject>"
"</svg>"
}

image.decode(html-embed, alt: "!typst-inlined-svg")
}
#import "/contrib/templates/xhtml/lib.typ": xhtml

#set page(height: auto, width: auto)

Expand Down

0 comments on commit 0f1e3bf

Please sign in to comment.