-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c2e5d8
commit cf877ef
Showing
2 changed files
with
67 additions
and
15 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 |
---|---|---|
@@ -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") | ||
} |
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,16 +1,23 @@ | ||
|
||
#image.decode(``` | ||
<svg viewBox="0 0 1024 768" xmlns="http://www.w3.org/2000/svg"> | ||
<foreignObject width="641px" height="361px"> | ||
<iframe | ||
src="https://player.bilibili.com/player.html?aid=80433022&bvid=BV1GJ411x7h7&cid=137649199&page=1&danmaku=0" | ||
scrolling="no" | ||
border="0" | ||
width="640px" | ||
height="360px" | ||
frameborder="no" | ||
framespacing="0" | ||
allowfullscreen="true" | ||
></iframe | ||
></foreignObject> | ||
</svg>```.text, alt: "!typst-inlined-svg") | ||
#import "/contrib/templates/xhtml/lib.typ": xhtml | ||
|
||
#set page(height: auto, width: auto) | ||
|
||
= Multi-media in Typst | ||
|
||
This is a embed video. | ||
|
||
#xhtml(outer-width: 640pt, outer-height: 360pt, ```html | ||
<iframe | ||
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" | ||
></iframe> | ||
```) | ||
|
||
That is a embed video. |