Skip to content

Conversation

@mcanouil
Copy link
Collaborator

@mcanouil mcanouil commented Jan 11, 2026

Important

For the Typst tests to pass on CI/CD, Typst >= 0.14 is required.

Implement alt-text functionality for math equations to comply with the PDF UA-1 accessibility standard.

This enhancement allows users to specify alternative text for equations using the alt attribute in Typst 0.14 and above.

This PR also adds support for the div-syntax.

$$
E = mc^2
$$ {#eq-einstein}

::: {#eq-einstein}

$$
E = mc^2
$$

:::

$$
E = mc^2
$$ {#eq-einstein alt="Einsteins mass-energy equivalence equation"}

::: {#eq-einstein alt="Einsteins mass-energy equivalence equation"}

$$
E = mc^2
$$

:::

Additionally, refactor the code to reduce duplication (brought by div processing).

Fixes #13870

mcanouil and others added 3 commits January 6, 2026 19:12
…uarto-dev#13847)

* fix: change meta selector from "name" to "property"

* chore: update changelog for version 1.9

* chore: update changelog for og:site_name meta tags clarification

Clarified the description of the change regarding the `og:site_name` meta tags to ensure proper metadata markdown processing.

* chore: Update changelog for version 1.9

* test: check if og:site_name in generated HTML correctly uses variable in site title

* test - use ensureHtmlElements instead of regex to check for HTML elements in tests

---------

Co-authored-by: Christophe Dervieux <christophe.dervieux@gmail.com>
@mcanouil mcanouil self-assigned this Jan 11, 2026
@posit-snyk-bot
Copy link
Collaborator

posit-snyk-bot commented Jan 11, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@mcanouil
Copy link
Collaborator Author

Because to trigger the use of math.equation a cross-reference is required, it means alt can be added only when a cross-reference.
It's possible to allow to set alt text independently of the cross-reference, if deemed appropriate.

@mcanouil mcanouil marked this pull request as ready for review January 11, 2026 12:29
gordonwoodhull added a commit that referenced this pull request Jan 11, 2026
LaTeX with tagging=on + unicode-math auto-generates MathML for accessible
math. Typst requires explicit alt text and correctly errors at compile time
when it's missing.

Also adds test for equation alt text syntax from PR #13872 (both attribute
and div syntax). Currently expects Typst to fail since the feature isn't
merged yet - update to noErrors once #13872 lands.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@cderv
Copy link
Collaborator

cderv commented Jan 12, 2026

For the Typst tests to pass on CI/CD, Typst >= 0.14 is required.

Does this mean it requires #13249?

You could make this PR against that branch, that way we'll benefit the updated version. and we'll be sure to merge after.

@mcanouil mcanouil changed the base branch from main to deps/pandoc-2025-08 January 12, 2026 08:23
@mcanouil
Copy link
Collaborator Author

Done

@cderv cderv self-requested a review January 12, 2026 08:30
@mcanouil
Copy link
Collaborator Author

The PR is a bit noisy because it contains commits from main not in the new base branch.

Copy link
Collaborator

@cderv cderv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot !

I reviewed with mostly some questions because this PR touches functions in Lua that are used for all crossref.

So it is indeed adding support for Typst, but we should verify the side effect for other cases and formats where the function are used - possibly by adding more tests than equations as all crossref will be impacted.

Also, if we do add support for alt in equation for typst, do we need to try add support for other format ? usually when we add a feature we try to cover all formats, so I am wondering.

At least we'll need a companion Documentation PR that explains the limitations.

So maybe former is better.

Again, thanks for the feature!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comes from a commit we already merged on main.
We'll sort out while merging to keep PR scoped and clean.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this test folder. We'll remove from this PR before merging to get clean PR as it does not belong to this one.

@mcanouil mcanouil marked this pull request as draft January 12, 2026 12:44
@mcanouil
Copy link
Collaborator Author

mcanouil commented Jan 12, 2026

Also, if we do add support for alt in equation for typst, do we need to try add support for other format ? usually when we add a feature we try to cover all formats, so I am wondering.

Briefly, I don't believe LaTeX/OpenXML care about this and if there is even a way. I did not take a deep look at those, so I might have missed something.
For HTML, it's usually the math library that is responsible of accessibility and it's not really doable to do something unless the team officially choose one library to support over the others.
Typst on the other hand has the right tooling and it is actually making us do it. Using math.equation() without alternative text is not possible if one wants to be compliant with UA-1.

For the context, I was playing around with my template when I hit those issues, instead of making myself a Lua workaround, I started this PR as it's mandatory for UA-1.


Thanks for the review and comments about other functions/tools defined elsewhere in the codebase.
I'll check and revise.

@cderv
Copy link
Collaborator

cderv commented Jan 12, 2026

Also, if we do add support for alt in equation for typst, do we need to try add support for other format ? usually when we add a feature we try to cover all formats, so I am wondering.

Briefly, I don't believe LaTeX/OpenXML care about this and if there is even a way. I did not take a deep look at those, so I might have missed something. For HTML, it's usually the math library that is responsible of accessibility and it's not really doable to do something unless the team officially choose one library to support over the others. Typst on the other hand has the right tooling and it is actually making us do it. Using math.equation() without alternative text is not possible if one wants to be compliant with UA-1.

Ok it makes sense, so maybe this something to document only at Typst doc level as an exception, and be sure that we don't impact other format with this.

For LaTeX, I am aware of the following package for accessibility (https://ctan.org/pkg/axessibility), but I have never tried it. Just overall with the new accessibility requirement, maybe there is something with new standard that we don't know yet about.

For HTML, yes this is the library, but we do know which one is used html-math-method. So it is our job to pass the information the right way for those method if they support alt text. Do you see what I mean?
That is why I am wondering what we can do (and maybe it is pandoc as we rely on Pandoc writer for the equation rendering I think - which we don't for Typst).

@mcanouil
Copy link
Collaborator Author

For HTML, yes this is the library, but we do know which one is used html-math-method. So it is our job to pass the information the right way for those method if they support alt text. Do you see what I mean?
That is why I am wondering what we can do (and maybe it is pandoc as we rely on Pandoc writer for the equation rendering I think - which we don't for Typst).

I meant, I'm not aware of them using alternative text, for example MathJax https://docs.mathjax.org/en/latest/basic/accessibility.html

@mcanouil
Copy link
Collaborator Author

@cderv I'll refocus this PR and open a separate feature request for the div syntax.
This will simplify this PR and "address" your concerns.

@mcanouil mcanouil marked this pull request as ready for review January 12, 2026 21:31
gordonwoodhull added a commit that referenced this pull request Jan 13, 2026
LaTeX with tagging=on + unicode-math auto-generates MathML for accessible
math. Typst requires explicit alt text and correctly errors at compile time
when it's missing.

Also adds test for equation alt text syntax from PR #13872 (both attribute
and div syntax). Currently expects Typst to fail since the feature isn't
merged yet - update to noErrors once #13872 lands.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

Alt-text for math equations in Typst

3 participants