A blank line between two `set text(lang: ..)` rules changes the PDF's language
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- rust
- Ambito
- backend, internationalization
Direzione di ricerca
Start by reading eval_markup in crates/typst-eval/src/markup.rs, then trace how StyledElem styles are merged in crates/typst-library/src/foundations/content/mod.rs and how visit_styled calls populate_locale in crates/typst-realize/src/lib.rs. Reproduce the adjacent and blank-line cases with PDF output and add regression coverage for both. Done means the declared PDF language is consistent regardless of the blank line.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
A blank line between two set text(lang: ..) rules changes the language the PDF declares, though the page is the same.
#set text(lang: "de")
#set text(lang: "en")
"Hallo"
declares en. With a blank line between the two rules, it declares de, though every word is still set in English: the quotes are “Hallo”, where German's are „Hallo“.
It turns up when a document sets its language at its start, as the accessibility guide says to, and then applies a template that sets one too:
#let template(body) = { set text(lang: "en"); body }
#set text(lang: "de")
#show: template
"Hallo"
declares en, and de with a blank line before #show.
Compiled, as adjacent.typ and template.typ, and apart.typ and template-apart.typ with the blank line:
for f in adjacent apart template template-apart; do
typst compile $f.typ
printf '%-15s %s %s %s\n' $f "$(pdftotext $f.pdf - | grep Hallo)" \
"$(tr -d '\n' < $f.pdf | grep -a -o '/Type */Catalog[^>]*/Lang *([a-z]*)' | grep -o '/Lang.*')" \
"$(grep -a -o '<dc:language><rdf:Bag><rdf:li>[a-z]*' $f.pdf | sed 's/.*<rdf:li>/dc:language /')"
done
adjacent “Hallo” /Lang(en) dc:language en
apart “Hallo” /Lang(de) dc:language de
template “Hallo” /Lang(en) dc:language en
template-apart “Hallo” /Lang(de) dc:language de
typst 0.14.0 prints the same.
What I can see of the cause: eval_markup styles the rest of the markup with each set rule, and styled_with_map merges the styles into the rest when the rest is a single StyledElem. Adjacent, the two rules become one style list, and the locale is read from that list, where the later rule wins:
With a blank line, the rest starts with the paragraph break, so each rule keeps its own StyledElem and the first one's language is taken. On main, visit_styled passes populate_locale the local styles chained with the outer ones, and the merged list is still among them. I haven't built main.
Operating system
Linux
Typst version
- I am using the latest version of Typst (0.15.1)
- Lingua principale
- Rust
- Stelle
- 57.2k
- Fork
- 1.8k
- Merge medio
- 1g 17h
- PR unite (30g)
- 22
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di typst/typst
-
feature request
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 2 giorni
-
bug foundations
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
typst/typst#9047 · 2 commenti · 2 reazioni ·
I maintainer di solito rispondono entro 2 giorni
-
`h3` font size is too smallApertadocs-infra
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
typst/typst#9020 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
typst/typst#8987 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
docs-infra
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
typst/typst#8934 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
Issue simili
-
[Bug]: opencode_go chat route drops reasoning_effort (even 'none'), while the same endpoint honors it via custom_llm_provider=openaiForse già presa @arvindkumar-ship-it l’ha presa oggi. Apertallm translation
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
BerriAI/litellm#51871 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
comp-formats
Difficoltà 2/5 Mezza giornata Idoneità per principianti 64/100
ClickHouse/ClickHouse#131694 ·
I maintainer di solito rispondono entro 1 giorno
-
cli: `execCargoMetadata` decodes stdout per chunk, corrupting non-ASCII paths across pipe boundariesAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
C-Bug S-Needs-Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
bevyengine/bevy#26558 ·
I maintainer di solito rispondono entro 2 giorni