render: keep literal text from continuing an embedded expression - #1503
Merged
developer0hye merged 1 commit intoSep 2, 2026
Merged
Conversation
Typst keeps parsing an embedded code expression after its closing bracket. Following markup that starts with `(` is an argument list, `[` a trailing content argument, and `.name` a field access, so a cell that reads "New York" over "(07) Western" produced `#linebreak()(07)` and failed the whole document with "expected function, found content". Two places let bare text follow a call. Inside one escaped string the hard break now ends with a semicolon, the terminator the code-mode space strings already use. At a run boundary the existing `#[...]` safety wrap only looked for a preceding `]`; it now also covers `)`, which closes `#linebreak()`, `#h(..)`, and the PowerPoint grid words. Assisted-by: LLM (Claude) Signed-off-by: Aktan Azat <aktanaazat@gmail.com>
aktanazat
force-pushed
the
fix/linebreak-terminator
branch
from
September 1, 2026 23:28
8de7c08 to
3586736
Compare
Owner
|
Thank you for this fix, and for the precise diagnosis. Merged as 151e0fd. What I verified before merging:
One note for the record, not a request: the guard also fires after a literal |
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Typst keeps parsing an embedded code expression after its closing bracket. Markup that starts with
(becomes an argument list,[a trailing content argument, and.namea field access. A spreadsheet cell reading "New York" over "(07) Western" produced#linebreak()(07)and the whole document failed withTypst compilation failed: expected function, found content.Two places let bare text follow a call:
escape_typstnow ends the hard break with a semicolon (#linebreak();), the same terminator the code-mode space strings already use.#[...]safety wrap inwrite_run_contentonly looked for a preceding]. It now also covers), which closes#linebreak(),#h(..),#o2p-pptx-space(), and the PowerPoint grid words.Related issue
None filed. Reproduced on a public spreadsheet (VA VALERI fee cost schedule, cell "New York\n(07) Western").
Testing
cargo test -p office2pdf --lib(2780 passed)cargo fmt --all --check,cargo clippy -p office2pdf --all-targets(only the pre-existingeffective_last_resort_familydead-code warning)test_escape_typst_terminates_hard_linebreak_before_parenthesis,test_escape_typst_terminates_hard_linebreak_before_field_access,test_render_document_hard_linebreak_before_parenthesis(asserts the terminator never renders),test_fixed_page_text_box_soft_line_break_before_parenthesis_compiles,test_fixed_page_text_box_grid_word_before_parenthesised_run_compiles. All five fail onmainand pass here.A#linebreak().5 percentcompiles (a leading.5is a number),A#linebreak().NETfails withlinebreak does not have field "NET", andA#h(1em)(07) Bfails withexpected function, found content.Visual impact
#[...]wrap are consumed by the parser; documents that compiled before produce byte-identical Typst layout, and documents that failed before now compile. The render test asserts no;reaches the text layer.Checklist
Signed-off-byline