diff --git a/src/resources/filters/main.lua b/src/resources/filters/main.lua index f238504dbd..a073585f8c 100644 --- a/src/resources/filters/main.lua +++ b/src/resources/filters/main.lua @@ -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") }, } diff --git a/src/resources/filters/quarto-post/typst.lua b/src/resources/filters/quarto-post/typst.lua index 91c125b099..399c8e3792 100644 --- a/src/resources/filters/quarto-post/typst.lua +++ b/src/resources/filters/quarto-post/typst.lua @@ -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 \ No newline at end of file diff --git a/tests/docs/smoke-all/2023/09/26/6977.qmd b/tests/docs/smoke-all/2023/09/26/6977.qmd new file mode 100644 index 0000000000..e8f79ec3bd --- /dev/null +++ b/tests/docs/smoke-all/2023/09/26/6977.qmd @@ -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. \ No newline at end of file