Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typst: wrap image with attributes in a Para with a #box([]). #7019

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/resources/filters/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ local quarto_post_filters = {
-- format fixups post rendering
{ name = "post-render-html-fixups", filter = render_html_fixups() },
{ name = "post-render-ipynb-fixups", filter = render_ipynb_fixups() },
{ name = "post-render-typst-fixups", filter = render_typst_fixups() },

{ name = "post-userAfterQuartoFilters", filters = make_wrapped_user_filters("afterQuartoFilters") },
}
Expand Down
19 changes: 19 additions & 0 deletions src/resources/filters/quarto-post/typst.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,23 @@ function render_typst()
end
end
}
end

function render_typst_fixups()
return {
Para = function(para)
return para:walk({
Image = function(image)
if image.attributes["width"] == nil and image.attributes["height"] == nil then
return nil
end
return pandoc.Inlines({
pandoc.RawInline("typst", "#box(["),
image,
pandoc.RawInline("typst", "])"),
})
end
})
end
}
end
16 changes: 16 additions & 0 deletions tests/docs/smoke-all/2023/09/26/6977.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
format: typst
# FIXME no _quarto tests support yet
---

This is a paragraph with an inline image ![](./page-menu-icon.jpg){height="1em"}.

::: {#fig-1}

![](./page-menu-icon.jpg)

A caption

:::

See @fig-1.