[feat] MFM, see if we can use Latex input #828

Open
opened 2024-08-18 09:02:41 +00:00 by ilja · 1 comment
Contributor

The idea

For Markdown parser, we use Earmark. Earmark uses EarmarkParser. EarmarkParser turns the Markdown string into a tree, Earmark then turns that tree into HTML.

I noticed that there's a (default false) math option in EarmarkParser, https://github.com/RobertDober/earmark_parser/tree/master?tab=readme-ov-file#mathematical-expressions

I haven't tried yet, and I'm unsure if Earmark can handle it properly. But if it can turn latex into FEP-dc88 compliant HTML, and in a way that's compatible with MFM, then we could use this and don't even need extra dependencies. Note, however, that there is currently a warning "math syntax within Markdown is not standardized, so this option is a subject to change in future releases".

Related:

  • [feat] Implement FEP-dc88: Formatting Mathematics #641

The reasoning

MFM is one the the features that sets Akkoma apart from the other non-*key implementations, and I assume general something Akko people like to have. Having proper Latex (Katex) support could bring us closer to feature parity, and compatibility, with *key implementations like e.g. Foundkey.

Have you searched for this feature request?

  • I have double-checked and have not found this feature request mentioned anywhere.
  • This feature is related to the Akkoma backend specifically, and not pleroma-fe.
### The idea For Markdown parser, we use Earmark. Earmark uses EarmarkParser. EarmarkParser turns the Markdown string into a tree, Earmark then turns that tree into HTML. I noticed that there's a (default `false`) `math` option in EarmarkParser, https://github.com/RobertDober/earmark_parser/tree/master?tab=readme-ov-file#mathematical-expressions I haven't tried yet, and I'm unsure if Earmark can handle it properly. But if it can turn latex into FEP-dc88 compliant HTML, and in a way that's compatible with MFM, then we could use this and don't even need extra dependencies. Note, however, that there is currently a warning "math syntax within Markdown is not standardized, so this option is a subject to change in future releases". Related: * [feat] Implement FEP-dc88: Formatting Mathematics https://akkoma.dev/AkkomaGang/akkoma/issues/641 ### The reasoning MFM is one the the features that sets Akkoma apart from the other non-*key implementations, and I assume general something Akko people like to have. Having proper Latex (Katex) support could bring us closer to feature parity, and compatibility, with *key implementations like e.g. Foundkey. ### Have you searched for this feature request? - [x] I have double-checked and have not found this feature request mentioned anywhere. - [x] This feature is related to the Akkoma backend specifically, and not pleroma-fe.
ilja added the
feature request
label 2024-08-18 09:02:41 +00:00
Member

documenting remarks from IRC:

atm earmark only puts math in a <code> block (with a special class) to a avoid e.g. * and _s in math getting interpreted as Markdown markup mangling the output.
It also uses TeX-style $inline math$ and $$math block$$ instead of LaTeX-style \(inline math\) and \[math block\] like MFM.

We could tape our own pre and postprocessing on to workaround this, but upstreaming at least some changes would be ideal. E.g. if earmark doesn’t want to pull in a dependency for or itself implement MathML it could let users configure callbacks for transforming math markup into a HTML node defaulting to the current <code> node if unspecified.

documenting remarks from IRC: atm earmark only puts math in a `<code>` block (with a special class) to a avoid e.g. `*` and `_`s in math getting interpreted as Markdown markup mangling the output. It also uses TeX-style `$inline math$` and `$$math block$$` instead of LaTeX-style `\(inline math\)` and `\[math block\]` like MFM. We could tape our own pre and postprocessing on to workaround this, but upstreaming at least some changes would be ideal. E.g. if earmark doesn’t want to pull in a dependency for or itself implement MathML it could let users configure callbacks for transforming math markup into a HTML node defaulting to the current `<code>` node if unspecified.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: AkkomaGang/akkoma#828
No description provided.