quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.89k stars 320 forks source link

Font family and size can spill out of Typst raw html blocks #11093

Open gordonwoodhull opened 1 week ago

gordonwoodhull commented 1 week ago

Since we use typst:no-figure on our tables (implemented in jgm/pandoc#9778), Pandoc may not enclose tables in blocks.

Unfortunately, when the Pandoc Typst writer encounters typst:text:fontor typst:text:size on a table, it emits #set text(...) before the table, which will affect the entire scope.

E.g.

---
format: typst
---

Normal paragraph text.

```{=html}
<table style="font-size: 8px;">
    <tr><td>A</td><td>B</td></tr>
</table>

Normal paragraph text.


produces

```typst
Normal paragraph text.

#set text(size: 6pt); #table(
  columns: 2,
  align: (auto,auto,),
  [A], [B],
)
Normal paragraph text.

Image

Oops!

One way to correct the Typst output is to wrap the set text + table in #[...]:

Normal paragraph text.

#[#set text(size: 6pt); #table(
  columns: 2,
  align: (auto,auto,),
  [A], [B],
)]
Normal paragraph text.

Plan:

https://github.com/quarto-dev/quarto-cli/blob/412ea639aec65a500d83134bd3202a8b799aca55/src/resources/filters/quarto-post/typst.lua#L122-L126

gordonwoodhull commented 2 days ago

Reopening because we have our temporary fix for 1.6 there is still work to clean this up in 1.7.