Skip to content

refactor(typst): improve terms accessibility#11436

Merged
jgm merged 1 commit intojgm:mainfrom
mcanouil:refactor/typst-accessibility
Feb 3, 2026
Merged

refactor(typst): improve terms accessibility#11436
jgm merged 1 commit intojgm:mainfrom
mcanouil:refactor/typst-accessibility

Conversation

@mcanouil
Copy link
Contributor

@mcanouil mcanouil commented Feb 3, 2026

Refactor the terms display in Typst to enhance accessibility by using a more semantic structure.

The current code basically reconstruct the list making it fail UA-1 accessibility check from Typst 0.14.

The new rule is simpler, keep the structure of the list.
it also add an explicit breakable: false to ensure definition and term stay together.

For reference, the current Typst check error:

#set document(title: "Demo Document")

#show terms: it => {
  it
    .children
    .map(child => [
      #strong[#child.term]
      #block(inset: (left: 1.5em, top: -0.4em))[#child.description]
    ])
    .join()
}

/ term: #block[
    definition
  ]
typst compile demo.typ --pdf-standard=ua-1
error: PDF/UA-1 error: invalid list (L) structure
   ┌─ demo.typ:13:2
   │
13 │ / term: #block[
   │   ^^^^
   │
   = hint: list (L) may not contain paragraph (P)
   = hint: this is probably caused by a show rule

error: PDF/UA-1 error: invalid list (L) structure
   ┌─ demo.typ:13:0
   │  
13 │ ╭ / term: #block[
14 │ │     definition
15 │ │   ]
   │ ╰───^
   │  
   = hint: list (L) may not contain marked content directly
   = hint: this is probably caused by a show rule

@mcanouil mcanouil changed the title refactor: improve terms accessibility refactor(typst): improve terms accessibility Feb 3, 2026
@mcanouil mcanouil marked this pull request as ready for review February 3, 2026 15:15
@jgm
Copy link
Owner

jgm commented Feb 3, 2026

A more direct way to reproduce the issue:

% pandoc -t typst -o my.pdf  --pdf-engine-opt='--pdf-standard=ua-1'
term

:    definition
^D
error: PDF/UA-1 error: invalid list (L) structure
    ┌─ toPdfViaTempFile51510-0.typ:152:2
    │
152 │ / term: #block[
    │   ^^^^
    │
    = hint: list (L) may not contain paragraph (P)
    = hint: this is probably caused by a show rule

error: PDF/UA-1 error: invalid list (L) structure
    ┌─ toPdfViaTempFile51510-0.typ:152:0
    │  
152 │ ╭ / term: #block[
153 │ │ definition
154 │ │ ]
    │ ╰─^
    │  
    = hint: list (L) may not contain marked content directly
    = hint: this is probably caused by a show rule

Error producing PDF.

@jgm
Copy link
Owner

jgm commented Feb 3, 2026

But I don't yet understand what is wrong with what we're doing now.
List may not contain Paragraph? But certainly in general lists do contain paragraphs, and no error is raised with e.g.

- one

  second paragraph

- two

@jgm jgm merged commit 65f0b49 into jgm:main Feb 3, 2026
8 of 11 checks passed
@jgm
Copy link
Owner

jgm commented Feb 3, 2026

Oh, I see, the list needs "items" as direct children and we were destroying that structure.

@mcanouil
Copy link
Contributor Author

mcanouil commented Feb 3, 2026

Oh, I see, the list needs "items" as direct children and we were destroying that structure.

Yes, that's it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants