Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Math support (a.k.a. tex_math_dollars) #20

Closed
Omikhleia opened this issue Nov 13, 2022 · 3 comments · Fixed by #23
Closed

Math support (a.k.a. tex_math_dollars) #20

Omikhleia opened this issue Nov 13, 2022 · 3 comments · Fixed by #23
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@Omikhleia
Copy link
Owner

Omikhleia commented Nov 13, 2022

We'd need:

  • Support for Pandoc's tex_math_dollars extension in Lunamark (= Support tex_math_dollars extension jgm/lunamark#50) to extract the formula and invoke the writer.
  • The path then for SILE has to be clarified
    • Either we assume its TeX-like math is kind of OK, though with restrictions (at this time of writing) on the supported syntax subset...
    • Or we go to the mathml route (which at the time of writing again, seems a bit better in SILE), but that would mean converting the (La)TeX formula to MathML. We are not going, certainly, to reinvent the wheel here1, so likely use something existing, e.g. TEMML, although it implies a dependency on NodeJS and forking an external process... And MathML in SILE also has some restrictions (at the time of writing again, such as MathML msqrt not supported sile-typesetter/sile#1604, so I am unsure it's worth the effort going that route.
    • However, SILE math is not even an inputter, though I've a few doubts regarding the actual implementation, esp. with AST dumping and round-tripping... (Should we include an outputter that would just write out the output from inputter.markdown.parse(…)? #15)

Footnotes

  1. The Lua ecosystem is so non-existent that the very choice of Lua for SILE could be questioned. And IMHO, Rust is not even better -- said with a grain of salt, to those in the SILE community who might argue otherwise, heh! 😸

@Omikhleia Omikhleia added this to the 1.1 milestone Nov 13, 2022
@Omikhleia Omikhleia changed the title Math support Math support (a.k.a. tex_math_dollars) Nov 13, 2022
@Omikhleia Omikhleia added the enhancement New feature or request label Nov 13, 2022
@Omikhleia
Copy link
Owner Author

Blocker: As of 0.14.4, packages markdown and pandocast can no longer be used together in a single document such as the demo/showcase document if they both load the math package... It will hit sile-typesetter/sile#1607, so this will have to wait for resolution...

Other than that, going the "TeX-like math" route seems satisfying enough:

image

TeX-like math between `$` ("inline mode") or `$$` ("display mode") decently works
Note that $20,000 and $30,000 don't parse as math, while $e^{i\pi}=-1$ does.
There is an important constraint, though: you have to restrict yourself to the syntax subset supported
by SILE. This being said, some nice fomulas may be achieved:

::: {custom-style=center}
$$\pi=\sum_{k=0}^\infty\frac{1}{16^k}(\frac{4}{8k+1}-\frac{2}{8k+4}-\frac{1}{8k+5}-\frac{1}{8k+6})$$
:::

At the time of writing, obtained via the Pandoc AST route -- My quick'n dirty attempt on the Lunamark-native route currently breaks severely on the "note that..." test case. But I spent more time today debugging the blocker issue, and another weird one (worked-around) than seriously trying to implement the pattern right :(

@Omikhleia Omikhleia self-assigned this Nov 14, 2022
@alerque
Copy link
Contributor

alerque commented Nov 15, 2022

Given that it has its own unique language, can we refactor the math language a bit to be an inputter?

@Omikhleia
Copy link
Owner Author

#23 has the experimental code for both inline and display math, supported both with the markdown and pandocast packages.

Looks nice:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants