Skip to content

Commit 00d595a

Browse files
fix(typst): left-align cross-ref callouts (#14130)
* fix: typst format's callouts show different text alignment with Prefix Fixes #12803 --------- Co-authored-by: Gordon Woodhull <gordon.woodhull@posit.co>
1 parent 3f3f341 commit 00d595a

3 files changed

Lines changed: 30 additions & 5 deletions

File tree

news/changelog-1.9.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ All changes included in 1.9:
5757

5858
### `typst`
5959

60+
- ([#12803](https://github.com/quarto-dev/quarto-cli/issues/12803)): Fix callout text being centered instead of left-aligned when callout has a cross-reference ID prefix (e.g., `#tip-abc`).
6061
- ([#13249](https://github.com/quarto-dev/quarto-cli/pull/13249)): Update to Pandoc's Typst template following Pandoc 3.8.3 and Typst 0.14.2 support:
6162
- Code syntax highlighting now uses Skylighting by default.
6263
- New template variables `mathfont`, `codefont`, and `linestretch` for font and line spacing customization.

src/resources/formats/typst/pandoc/quarto/definitions.typ

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,14 @@
4141
)
4242

4343
#let block_with_new_content(old_block, new_content) = {
44-
let d = (:)
4544
let fields = old_block.fields()
46-
fields.remove("body")
45+
let _ = fields.remove("body")
4746
if fields.at("below", default: none) != none {
4847
// TODO: this is a hack because below is a "synthesized element"
4948
// according to the experts in the typst discord...
5049
fields.below = fields.below.abs
5150
}
52-
return block.with(..fields)(new_content)
51+
block.with(..fields)(new_content)
5352
}
5453

5554
#let empty(v) = {
@@ -163,9 +162,9 @@
163162
children.at(0) + new_title // with icon: preserve icon block + new title
164163
}))
165164

166-
block_with_new_content(old_callout,
165+
align(left, block_with_new_content(old_callout,
167166
block(below: 0pt, new_title_block) +
168-
old_callout.body.children.at(1))
167+
old_callout.body.children.at(1)))
169168
}
170169

171170
// 2023-10-09: #fa-icon("fa-info") is not working, so we'll eval "#fa-info()" instead
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
title: "Callout Paragraph Alignment"
3+
format:
4+
typst:
5+
keep-typ: true
6+
_quarto:
7+
tests:
8+
typst:
9+
ensurePdfTextPositions:
10+
- # Paragraphs inside cross-referenced callout should be left-aligned
11+
- subject: "ShortLine"
12+
relation: leftAligned
13+
object: "LongerParagraph with additional words"
14+
tolerance: 2
15+
- []
16+
noErrors: default
17+
---
18+
19+
::: {.callout-tip #tip-alignment}
20+
## Alignment Test
21+
22+
ShortLine
23+
24+
LongerParagraph with additional words filling out this line.
25+
:::

0 commit comments

Comments
 (0)