-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: multimedia support with sanitization (#78)
- Loading branch information
1 parent
4dc4fe3
commit 63b1b03
Showing
11 changed files
with
245 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[submodule "assets/artifacts"] | ||
path = assets/artifacts | ||
url = https://github.com/Myriad-Dreamin/typst/ | ||
branch = assets-book-v0.1.4 | ||
branch = assets-book-v0.2.0 | ||
shallow = true |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
#import "xcommand.typ": xcommand | ||
|
||
#let xhtml(..args, tag: none, attributes: (:)) = xcommand( | ||
..args, | ||
{ | ||
"html," | ||
json.encode(( | ||
tag: tag, | ||
attributes: attributes, | ||
)) | ||
}, | ||
) | ||
|
||
#let iframe = xhtml.with(tag: "iframe") | ||
#let video = xhtml.with(tag: "video") | ||
#let audio = xhtml.with(tag: "audio") | ||
#let div = xhtml.with(tag: "div") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
/// HTML extension | ||
#let xcommand(outer-width: 1024pt, outer-height: 768pt, inner-width: none, inner-height: none, content) = { | ||
let content = if type(content) == str { | ||
content | ||
} else 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()) | ||
"\"><!-- embedded-content " | ||
content | ||
" embedded-content --></foreignObject>" | ||
"</svg>" | ||
} | ||
|
||
image.decode(html-embed, alt: "!typst-embed-command") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,24 @@ | ||
#import "/github-pages/docs/book.typ": book-page | ||
#import "/github-pages/docs/book.typ": book-page, media | ||
|
||
#show: book-page.with(title: "Typst Supports - Multimedia components") | ||
|
||
= Multi-media in Typst | ||
|
||
This is a embed video. | ||
|
||
#media.iframe( | ||
outer-width: 640pt, | ||
outer-height: 360pt, | ||
attributes: ( | ||
src: "https://player.bilibili.com/player.html?aid=80433022&bvid=BV1GJ411x7h7&cid=137649199&page=1&danmaku=0&autoplay=0", | ||
scrolling: "no", | ||
border: "0", | ||
width: "100%", | ||
height: "100%", | ||
frameborder: "no", | ||
framespacing: "0", | ||
allowfullscreen: "true", | ||
), | ||
) | ||
|
||
That is a embed video. |