public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* User story: typst multiline math in pandoc markdown and pandoc AST
@ 2023-10-19 13:47 Guillaume Dehaene
       [not found] ` <672a5917-b04d-4eb9-966d-75b54df97837n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Guillaume Dehaene @ 2023-10-19 13:47 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 3177 bytes --]

Hello everyone,

Here is a "user story" in which I would like to discuss how math is handled 
by pandoc AST and pandoc markdown.
I haven't been able to find existing discussion on this topic. I hope I'm 
not retreading something that has been discussed before.
I'm sorry for any issues with clarity: this is my first time submitting 
something like this to a floss project.

I write this as a mathematician, somewhat familiar with latex but 
frustrated by its opacity and how ugly .tex files look.
I thus want to edit documents in a lighter markup while still having the 
following latex features:
- math shortcodes: to simplify source code and for faster typing
- multi-line equations
- cross-references for a given equation line
- cross-references for text blocks, for theorems
I'd like to author documents in HTML, since it is the standard output 
format for the web, and PDF, if possible via latex, for back-compatibility 
with editors.

Pandoc provides a solution for almost all of these. The only issue is 
multi-line equations.
A work-around I am aware of is to just use raw latex code like:
```latex
\begin{align}
1 + 1 &= 2 \label{first_line} \\
1 + 2 &= 3  \label{second_line}
\end{align}
```
which works fine when exporting to both HTML and latex: it is added as is 
to the HTML where it is parsed by both mathjax and katex.

However, I propose that formatting equations like typst might be a good way 
to make multiline math native to Pandoc, instead of piggy-backing on raw 
latex.

Multiline equations could be written as in latex, wrapped in `$$ $$`:
```
$$
1 + 1 &= 2 \\
1 + 2 &= 3 
$$
```

which could be parsed as a new DisplayMathMultiline type in the AST.
(This is a mockup: I really don't understand how the AST is written)
```
[ Math DisplayMathMultiline
    [
        Math DisplayMathLine ["1+1", "=2"]
        Math DisplayMathLine ["1+2", "=3"]
    ]
]
```

This type can be written to:
- HTML and latex: as an `align` block
- typst: as a multiline math block
- pandoc markdown: as a multiline math block
- other: as multiple successive displayMath blocks

I do not see how modifying the AST in this way would produce an issue: it's 
an additive feature as far as I can tell. It can always default down to 
multiple displayMath blocks
For pandoc markdown, this makes the characters `&` and `\\` take on special 
meaning in math mode. I'm not familiar enough with math in markdown to know 
whether that could cause issues. If the behavior is implemented as an 
extension that the user can enable/disable, then this remains backwards 
compatible. It's also possible to use other characters, but this would mean 
that the syntax differs from latex.

Do you believe that this is an interesting feature to have for pandoc?

Best regards
Guillaume

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/672a5917-b04d-4eb9-966d-75b54df97837n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 3780 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-10-22 19:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-19 13:47 User story: typst multiline math in pandoc markdown and pandoc AST Guillaume Dehaene
     [not found] ` <672a5917-b04d-4eb9-966d-75b54df97837n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-10-19 16:11   ` John MacFarlane
     [not found]     ` <E89C2FED-79B7-4150-B015-D11C177D3F9B-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2023-10-20  7:40       ` Guillaume Dehaene
     [not found]         ` <daaf510b-50a3-4f9d-b7d5-58609d3821c6n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-10-20 17:26           ` John MacFarlane
     [not found]             ` <464EF7B5-5A64-495A-A195-CC62A3D2A637-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2023-10-20 19:25               ` Guillaume Dehaene
     [not found]                 ` <e9222236-9514-4cdc-b986-ae8e7e198576n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-10-20 22:00                   ` John MacFarlane
     [not found]                     ` <73813E01-A490-4C3E-8B23-8952A80487DD-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2023-10-22 19:18                       ` Guillaume Dehaene
2023-10-20 19:08       ` Gwern Branwen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).