Emit `class` attributes in MathML Output
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 56.1k
- Forks
- 1.7k
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 22
Description
Description
Currently, I noticed that multiline-equation was added in MathML output classes and used in CSS selectors. For styling purposes. I propose that gives each typst element a unique class when render into MathML. like a math.mat() might produce
<mrow class="matrix">
<mo>(</mo>
<mtable>
...
</mtable>
<mo>)</mo>
<mrow>
Use Case
If not. It is not very easy to apply a custom css style for matrix. e.g. if I'd like to adjust the rows gap and columns gap of a matrix, I have to set
math mrow > mtable mtr:not(:last-child) mtd {
padding-bottom: 0.2em !important;
}
math mrow > mtable mtr mtd:not(:last-child) {
padding-right: 0.5em !important;
}
currently. Note that the !important is to prevent these styles from overloading by the Typst default MathML stylesheets. To be specific, the following styles are designed to insert a lead between multiline equations. But it will effect the metrics within a multiline equation.
math > mtable.multiline-equation mtr:not(:last-child) mtd {
padding-bottom: 0.5em;
}
My current approach is not quite robust(e.g. cases cannot get excluded). if we have a unique class name, it will be much easier select matrix.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the MathML output implementation and the handling of math.mat() and multiline-equation. Determine how Typst elements are represented in the emitted MathML, then define consistent unique class names for the relevant elements and verify that matrix-specific CSS selectors can target them without affecting cases or multiline equations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100