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

brace tables with typst:no-figure and typst:text attributes #10563

Merged
merged 2 commits into from
Jan 24, 2025

Conversation

gordonwoodhull
Copy link
Contributor

@gordonwoodhull gordonwoodhull commented Jan 24, 2025

The combination of #9648 typst:text:* property output and #9778 typst:no-figure can cause fonts, text sizes, etc. to spill out of tables in Typst output.

This is because setting Typst text properties across a table requires #set text(...) outside the table, and previously we were relying on the figure to provide a scope.

Example:

<p>Paragraph before.</p>

<table typst:text:size="3em">
  <tr>
    <td>A</td>
    <td>B</td>
    <td>C</td>
  </tr>
</table>

<p>Paragraph after. Oops.</p>

produces

Paragraph before.

#set text(size: 3em); #table(
  columns: 3,
  align: (auto,auto,auto,),
  [A], [B], [C],
)
Paragraph after. Oops.
image

This PR provides the minimal fix, only adding an extra #[...] when the table has class typst:no-figure and also has typst:text:* attributes.

We work around this bug in Quarto in quarto-dev/quarto-cli#11113, but it would be better to have the fix in Pandoc because it could affect other users of these features.

Ref quarto-dev/quarto-cli#11093

@cscheid

@gordonwoodhull gordonwoodhull force-pushed the typst-no-figure-font-spill branch from 79087f7 to cc6d13e Compare January 24, 2025 04:28
The combination of jgm#9648 Typst property output and jgm#9778
`typst:no-figure` can cause fonts to spill out of tables.

This is because setting Typst text properties across a table
requires `#set text(...)` outside the table, and previously we
were relying on the figure to provide a scope.

This adds an extra `#[...]` when the table has class `typst:no-figure`
and also has `typst:text:*` attributes.
@gordonwoodhull gordonwoodhull force-pushed the typst-no-figure-font-spill branch from cc6d13e to 271a4cb Compare January 24, 2025 04:29
@jgm
Copy link
Owner

jgm commented Jan 24, 2025

This looks good. But instead of

#[#set text(size: 3em); #table(
  columns: 3,
  align: (auto,auto,auto,),
  [A], [B], [C],
)]

why not

#{set text(size: 3em); table(
  columns: 3,
  align: (auto,auto,auto,),
  [A], [B], [C],
)}

Isn't this a bit cleaner?

for a more succinct output in code mode instead of content mode
@gordonwoodhull
Copy link
Contributor Author

gordonwoodhull commented Jan 24, 2025

Sure! The rest of the output uses content mode as a reasonable convention, but I'm a big fan of code mode in Typst.

Done.

P.S. I still think Haskell must have an abstraction to make the repeated logic of checking for empty lists in every function simpler?

@gordonwoodhull gordonwoodhull changed the title bracket tables with typst:no-figure and typst:text attributes brace tables with typst:no-figure and typst:text attributes Jan 24, 2025
@jgm jgm merged commit 220dde4 into jgm:main Jan 24, 2025
10 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants