From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/33209 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Guillaume Dehaene Newsgroups: gmane.text.pandoc Subject: Re: User story: typst multiline math in pandoc markdown and pandoc AST Date: Fri, 20 Oct 2023 12:25:29 -0700 (PDT) Message-ID: References: <672a5917-b04d-4eb9-966d-75b54df97837n@googlegroups.com> <464EF7B5-5A64-495A-A195-CC62A3D2A637@gmail.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_7060_1192004648.1697829929254" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32512"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBC7JVCW5SUMBBKVIZOUQMGQEGHBNR6I-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri Oct 20 21:25:34 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oo1-f64.google.com ([209.85.161.64]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1qtv7m-0008DL-IQ for gtp-pandoc-discuss@m.gmane-mx.org; Fri, 20 Oct 2023 21:25:34 +0200 Original-Received: by mail-oo1-f64.google.com with SMTP id 006d021491bc7-581e0686355sf1620384eaf.2 for ; Fri, 20 Oct 2023 12:25:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1697829933; x=1698434733; darn=m.gmane-mx.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :sender:from:to:cc:subject:date:message-id:reply-to; bh=labKj7Yl1+s58xj0+XSi52BD3F7fRpgr7LywDm3aotI=; b=ZskIjfxghsfRWa4HBi/bGpkhh0rroSU1l7kp7pMgsnDNbDAfhVS1Xj1TZnuE4kk8eR csYoKhrEkeryXdB/UfFTUgRr0c9wbsfpCQlqjxQa6qseQ6H3qyysJQHV/+4nWdfk6IQD WrWmuHUWvk7rahh8AZbCZNnmCWwsjTH5iL9XAqYE0hkpBQHLRtzWZBRChtf6ijuQcaOb yOSUX90lg9CYvHqbW3DovshUETXB4kk/mPftSu5Rba07gk2Ic7S6eirG5P+e59TmVJ3q blb19tZ/j9ao4CtMOJTASQp+1UniPBrNjh5D5hV9pj6RPJ+3RJcD9J32jo0k65glYawG rBKQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697829933; x=1698434733; darn=m.gmane-mx.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=labKj7Yl1+s58xj0+XSi52BD3F7fRpgr7LywDm3aotI=; b=RfeAczRdgNZKelpn1psqXU+yrCDAVjkqY5nScSYpEs3I96KbBbmzuhoE/0sDAAsad3 4m7tzif/RLz30Xi3UsxfuzXlpY0I1XN//ExB+HMw3qnj2lfDtJCqthV6YaBn5cAIkFCD qpt/anb8U4Irxvkyi+YOSp7/MN2BPNij2zXjJxbHJeJQQ4+2LTLEuqfQ0yGnZD6+5E4q GkP+6iTO5C4qVO/SNU+l8qsRgJGxKfM7z2WJ6ZD+hDgjtRvp7qfo37fyKTbpdy9cb651 4kb+8w1I8YZrguQbLOj5J/WVb3+GZgqm54eBM4JMarHAqj7SYfKomRyOzKmrw2NGmHXR BbHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697829933; x=1698434733; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-sender:mime-version:subject:references:in-reply-to :message-id:to:from:date:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=labKj7Yl1+s58xj0+XSi52BD3F7fRpgr7LywDm3aotI=; b=UOyqZPexI53i+s0GtMY41mSIweXigsIwR08Rtb6nD4jLv/R7RoiHKOyn4H4TBKaUXS bV7xF7AK7/8M1VI3lJXDmzWkISPo1vH0ZSfipNT/e59yopHRvT9pOS6eGWhktSiMGAAm TYWxl5fYos05kiHyubwooteTN0/p36zroW7TWBXXOCi76mMf8FY8HWlLraRfQIstneKd BkvufnuUolvY+BbTa8cqR3yItbmbBXLjst9LeWDClsbA28AuLUrjLSi1lV/YpTBIfh+6 bPTo1w1bKM1J1v3DL8hXRMyG2zx52WSPtVxGd2ecI0JjT+UyAD Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOJu0Yz3G5CHXoGD7HM7jrDb3xlqm+v84var0dRxQjJTErelWSYnjtRO Q9r1gzLv5AUBnGQx032Foyc= X-Google-Smtp-Source: AGHT+IGwuYLsC8eJDorKK+uMWp906975zsrkKbrgrVjauLmdrDXA60DjjiA8QO0zTs7O+jhtDE7OAA== X-Received: by 2002:a4a:c891:0:b0:57b:f285:ae41 with SMTP id t17-20020a4ac891000000b0057bf285ae41mr2897224ooq.9.1697829933326; Fri, 20 Oct 2023 12:25:33 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a4a:4956:0:b0:581:e344:d93 with SMTP id z83-20020a4a4956000000b00581e3440d93ls761829ooa.1.-pod-prod-06-us; Fri, 20 Oct 2023 12:25:30 -0700 (PDT) X-Received: by 2002:a05:6808:1b12:b0:3a7:56ad:cb9e with SMTP id bx18-20020a0568081b1200b003a756adcb9emr1038730oib.9.1697829929877; Fri, 20 Oct 2023 12:25:29 -0700 (PDT) In-Reply-To: <464EF7B5-5A64-495A-A195-CC62A3D2A637-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> X-Original-Sender: guillaume.dehaene-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:33209 Archived-At: ------=_Part_7060_1192004648.1697829929254 Content-Type: multipart/alternative; boundary="----=_Part_7061_173719094.1697829929254" ------=_Part_7061_173719094.1697829929254 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sorry for my lack of clarity. I'm asking too many questions at the same=20 time and it must be hard to follow. I should have rewritten that last email= =20 before sending it. 1. My question about aligned. I see in the code that the typst reader parses typst multilines into this= =20 DisplayMath begin{aligned} structure. Is that how you / the pandoc team has decided to handle multiline math in= =20 the future? 2. You propose to wrap align. This is not working on my side, but I might be doing something wrong? Here are some minimal examples: ``` $$ \begin{align} x & =3D 5\\ y &=3D 3 \end{align} $$ ``` parses into latex as (with pandoc test.md --to latex; on pandoc 3.1.8) ``` \[ \begin{align} x & =3D 5\\ y &=3D 3 \end{align} \] ``` which fails to compile to pdf (with pandoc test.md --to pdf -o test.pdf ``` Error producing PDF. ! Package amsmath Error: Erroneous nesting of equation structures; (amsmath) trying to recover with `aligned'. See the amsmath package documentation for explanation. Type H for immediate help. ... =20 =20 l.62 \end{align} ``` removing the $$ ``` \begin{align} x & =3D 5\\ y &=3D 3 \end{align} ``` parses as is into latex and works Am I missing something? 3. I'm surprised at how easy it actually is to write down a filter. This is a really great feature of pandoc Thank you for all the great work on this project, and thank you for your=20 help Best Guillaume On Friday, October 20, 2023 at 7:27:05=E2=80=AFPM UTC+2 John MacFarlane wro= te: > > > > On Oct 20, 2023, at 12:40 AM, Guillaume Dehaene = =20 > wrote: > >=20 > >=20 > > Thank you for your insight. > >=20 > > 1. I'm not 100% satisfied with your solution since it does not work wit= h=20 > latex environments which open math-mode (such as a align). These produce= =20 > errors because of the double-opening of math-mode. It's also pretty=20 > cumbersome compared to usual md. > >=20 > > I see that this is how pandoc parses typst equations (I should have=20 > looked!) > > [ Math > > DisplayMath > > "\\begin{aligned}\n1 + 1 & =3D 2 \\\\\n1 + 1 & =3D 2\n\\end{aligned}" > > ] > >=20 > > Is that now going to be the accepted format for multiline equations? > > I'm not sure I understand. This has always been possible in pandoc (and= =20 > LaTeX); we use it here because it's the way to get equivalent LaTeX math = to=20 > the typst formula. > > > Side note: > > in pandoc you can also do > > $$ > \begin{align} > x & =3D 5\\ > y &=3D 3 > \end{align} > $$ > > even though this isn't possible in LaTeX. Pandoc will do the right thing= =20 > the output format. Try it. > > > 2. I had overlooked the possibility of writing a filter. > > The principle of the filter would then be: > >=20 > > parse DisplayMath > > if there are & and/or \\ present, modify the block > > depending on writer: > > - latex, HTML: transform to align > > - everything else: transform to accepted format(??) \begin{aligned} > >=20 > > Is that correct? If so, I'll start hacking at it in the near future. > > Yes, something like that. > > --=20 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 e= mail 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/e9222236-9514-4cdc-b986-ae8e7e198576n%40googlegroups.com. ------=_Part_7061_173719094.1697829929254 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Sorry for my lack of clarity. I'm asking too many questions at the sam= e time and it must be hard to follow. I should have rewritten that last ema= il before sending it.

1. My question about= aligned.
I see in the code that the typst reader parses typst mu= ltilines into this DisplayMath begin{aligned} structure.
Is that how y= ou / the pandoc team has decided to handle multiline math in the future?

2. You propose to wrap align.
This is no= t working on my side, but I might be doing something wrong?
Here = are some minimal examples:
```
$$
\begin{align}x & =3D 5\\
y &=3D 3
\end{align}
$$
```=
parses into latex as (with pandoc test.md --to latex; on p= andoc 3.1.8)
```
\[
\begin{align}
x & =3D= 5\\
y &=3D 3
\end{align}
\]
```
whi= ch fails to compile to pdf (with pandoc test.md --to pdf -o test.pdf
<= /div>
```
Error producing PDF.
! Package amsmath Error: = Erroneous nesting of equation structures;
(amsmath) =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0trying to recover with `aligned'.

See the amsmath package documentation for explanation.
Type = =C2=A0H <return> =C2=A0for immediate help.
=C2=A0... =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0
l.62 \end{align}
```

removing the $$
```
\begi= n{align}
x & =3D 5\\
y &=3D 3
\end{align}
= ```
parses as is into latex and works

= Am I missing something?

3. I'm surprised at how = easy it actually is to write down a filter.
This is a really grea= t feature of pandoc

Thank you for all the great = work on this project, and thank you for your help
Best
= Guillaume

On Friday, October 20, 2023 at 7:27:05=E2=80= =AFPM UTC+2 John MacFarlane wrote:


> On Oct 20, 2023, at 12:40 AM, Guillaume Dehaene <guillaum...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>=20
>=20
> Thank you for your insight.
>=20
> 1. I'm not 100% satisfied with your solution since it does not= work with latex environments which open math-mode (such as a align). These= produce errors because of the double-opening of math-mode. It's also p= retty cumbersome compared to usual md.
>=20
> I see that this is how pandoc parses typst equations (I should hav= e looked!)
> [ Math
> DisplayMath
> "\\begin{aligned}\n1 + 1 & =3D 2 \\\\\n1 + 1 &= ; =3D 2\n\\end{aligned}"
> ]
>=20
> Is that now going to be the accepted format for multiline equation= s?

I'm not sure I understand. This has always been possible in pandoc= (and LaTeX); we use it here because it's the way to get equivalent LaT= eX math to the typst formula.


Side note:

in pandoc you can also do

$$
\begin{align}
x & =3D 5\\
y &=3D 3
\end{align}
$$

even though this isn't possible in LaTeX. Pandoc will do the right= thing the output format. Try it.

> 2. I had overlooked the possibility of writing a filter.
> The principle of the filter would then be:
>=20
> parse DisplayMath
> if there are & and/or \\ present, modify the block
> depending on writer:
> - latex, HTML: transform to align
> - everything else: transform to accepted format(??) \begin{aligned= }
>=20
> Is that correct? If so, I'll start hacking at it in the near f= uture.

Yes, something like that.

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d= /msgid/pandoc-discuss/e9222236-9514-4cdc-b986-ae8e7e198576n%40googlegroups.= com.
------=_Part_7061_173719094.1697829929254-- ------=_Part_7060_1192004648.1697829929254--