Skip to content

fig-alt not propagated to Typst image alt text for PDF/UA-1 compliance #14108

@gordonwoodhull

Description

@gordonwoodhull

Description

fig-alt attributes on figures are not propagated to Typst's image(alt: "...") parameter. This causes PDF/UA-1 validation failures when using pdf-standard: ua-1 with Typst output.

Root Cause

In src/resources/filters/quarto-pre/figures.lua, the fig-alt propagation in quarto_pre_figures() only handles HTML and LaTeX output formats. The Typst format is missing:

-- propagate fig-alt
if _quarto.format.isHtmlOutput() then
  -- handles HTML
elseif _quarto.format.isLatexOutput() then
  -- handles LaTeX
end
-- No Typst branch!

The Typst post-filter in quarto-post/typst.lua (render_typst_fixups) correctly looks for image.attributes["alt"] and generates image(alt: "..."), but the attribute is never set for Typst output because figures.lua doesn't propagate fig-alt to the Image node's alt attribute.

Steps to Reproduce

  1. Create a Quarto document with a figure that has fig-alt:
    ---
    format:
      typst:
        pdf-standard: ua-1
        keep-typ: true
    ---
    
    ```{r}
    #| label: fig-cars
    #| fig-cap: "A plot of the cars dataset"
    #| fig-alt: "Scatter plot of speed versus stopping distance"
    plot(cars)
    ```
  2. Render with quarto render
  3. Inspect the generated .typ file — the image has no alt: parameter
  4. Typst compilation fails with PDF/UA-1 error: missing alt text

Expected Behavior

The generated Typst should include:

#box(image("figure.svg", alt: "Scatter plot of speed versus stopping distance"))

Fix

Add a Typst branch to the fig-alt propagation in figures.lua, similar to the LaTeX branch, that sets image.attributes["alt"] from the fig-alt attribute.

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions