Run-in Headings wrapped in Paragraph tags trigger PAC Logical Structure "Inappropriate Use"' warnings

Aperta
#9,033 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

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
25/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
documentation

Direzione di ricerca

The warning comes from PDF tag resolution in the Typst PDF crate; the reporter's patch targets the tags/resolve mod.rs logic that wraps heading nodes inside paragraph tags. Start by reproducing the snippet with a heading.where(level: 2) show rule and checking the PAC 2026 Logical Structure output. Done when run-in headings no longer trigger the warning and the strong-styled variant also passes the checker.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

accessibility bug
Description

By run-in headings I mean the ones from APA Style (sections of level 4 and 5; see https://apastyle.apa.org/style-grammar-guidelines/paper-format/headings).

The following reproduces such warning:

#show heading.where(level: 2): it => {
  box(strong(it.body))
  h(0.5em, weak: true)
}

#set document(title: [Hola])

= hola
hola

== adios
adios

== spaced

wrong!!!11111111

#heading(level: 2)[with function.] might this work?

Causing:

Image

I tried to compare it with Microsoft Word, which passes, but does so by just styling the heading, stripping its value:

Image

I tried to fix it in my fork with the following patch:

// This is mod.rs from tags/resolve in the Typst PDF crate.
    if matches!(tag, TagKind::P(_))
        && nodes.iter().any(|node| {
            matches!(node, Node::Group(group) if matches!(group.tag, TagKind::Hn(_)))
        })
    {
        let mut paragraph = Vec::new();
        for mut node in nodes {
            if let Node::Group(heading) = &mut node
                && matches!(heading.tag, TagKind::Hn(_))
            {
                if !paragraph.is_empty() {
                    accum.push(Node::Group(kt::TagGroup::with_children(
                        tag.clone(),
                        std::mem::take(&mut paragraph),
                    )));
                }
                if heading.tag.lang().is_none() {
                    heading.tag.set_lang(tag.lang().map(str::to_owned));
                }
                accum.push(node);
            } else {
                paragraph.push(node);
            }
        }
        if !paragraph.is_empty() {
            accum.push(Node::Group(kt::TagGroup::with_children(tag, paragraph)));
        }
    } else {
        accum.push(Node::Group(kt::TagGroup::with_children(tag, nodes)));
    }

Which produces:

Image

Fixes the warning, although its integrated AI checker still complains about the last 2 headings (excluding the first run-in for some reason).

Image

The second one has a 0.02 score.

The AI warnings seem to be triggered by using strong:

#[ // Warning
  #show heading.where(level: 2): it => {
    strong(it.body)
    h(0.5em, weak: true)
  }
  == Run-in heading.
  Following paragraph text.
]

#[ // Pass
  #show heading.where(level: 2): it => {
    it.body
    h(0.5em, weak: true)
  }
  == Run-in heading.
  Following paragraph text.
]
Operating system

Windows

Typst version
  • I am using the latest version of Typst
Lingua principale
Rust
Stelle
57.2k
Fork
1.8k
Merge medio
1g 17h
PR unite (30g)
22

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di typst/typst

Tutte le issue di typst/typst

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.