-
Notifications
You must be signed in to change notification settings - Fork 403
fix(typst): prevent breaking inside definition items #13978
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
fix(typst): prevent breaking inside definition items #13978
Conversation
Ensure that terms and their descriptions remain together by setting the block to be non-breakable.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Verifies that definition list terms and descriptions stay on the same page and that descriptions are indented from terms. Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
I added a test using ensurePdfTextPositions. Without the fix, it reports |
cderv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
I see this is added in definitions.typ and concerns Definition block which is a Pandoc blocks initially.
Would that be worth also making a PR in Pandoc for this fix to be upstream too ?
|
The terms rule is already different from Pandoc, should it be part of the PR? Edit: in fact the rule is incompatible with how Pandoc writes terms definition. #show terms: it => {
it
.children
.map(child => block(breakable: false)[
#text(weight: "bold")[#child.term]
#block(inset: (left: 1.5em, top: -0.4em))[#child.description]
])
.join()
}Question is: should we update upstream and use the above rule instead of the two? |
|
I'll let @gordonwoodhull reply. I see it was adapted on our side for PDF accessibility so we need to keep ours, but maybe that would be worth reporting upstream this PDF accessibility improvement then 🤔 Commit: 9525c1b Keeping our template improvement with upstream is best when we can. And when they don't accept it, then we'll need to patch at each update (and remember why we are different). |
|
The rule I'm showing is a mixed between our fix and Pandoc current implementation. |
|
To be clear, 9525c1b was a switch to what you see in Pandoc's template to a new way that pass PDF accessibility. Are you offering a third way? I was thinking of sharing this resulting PR code to Pandoc upstream to report
|
Yes, one that fits with the two rules. The initial suggestion was a simpler rule as it relied on implicit block, but that's also why it then needed a second rule to change |
|
Ok so doing would avoid the @gordonwoodhull what do you think ? |
|
Yes, it would ---
title: "Quarto Playground"
format:
typst:
keep-typ: true
---
```{=typst}
#show terms: it => {
it
.children
.map(child => block(breakable: false)[
#text(weight: "bold")[#child.term]
#block(inset: (left: 1.5em, top: -0.4em))[#child.description]
])
.join()
}
```
## Introduction
{{< lipsum 4 >}}
Multi-format output
: Generate HTML, PDF, Word, ePub, and more from one source. |
|
I'm in favor of a unified rule, and contributing upstream. However, you'll want to test with as the above proposal fails Typst's validation: It does pass the Interestingly, the previous code (from this PR) does pass UA-1. |
|
New variant that actually does not messed up the list structure as Pandoc code does. #show terms.item: it => block(breakable: false)[
#text(weight: "bold")[#it.term]
#block(inset: (left: 1.5em, top: -0.4em))[#it.description]
]This passed UA-1 Typst validation. |
|
Much cleaner! We should definitely upstream this. |
Ensure terms and their descriptions remain together by preventing breaks within definition items.
The rule needs to be separate from the content rule, because here we play on the implicit block generated by Typst.
As this is a visual change, there are no tests, but I believe non breaking term/definition is a sensible default.