public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* align environment with commonmark
@ 2022-03-06 23:53 Connor Patrick Jackson
       [not found] ` <c3c60679-e42e-4c01-a37b-7a940aad0370n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Connor Patrick Jackson @ 2022-03-06 23:53 UTC (permalink / raw)
  To: pandoc-discuss


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

I am attempting to use an align environment in a markdown file being 
compiled to both HTML and LaTeX. Doing so works fine with the markdown 
reader, but not with the commonmark_x reader, for either MathML or MathJax 
(the commonmark_x reader just passes it through as unaltered text). I 
*thought* that I had previously been able to use the commonmark_x reader to 
handle align environments for equation aligning, but I could be 
misremembering. 

Could someone confirm for me whether this is a feature that should be 
working, but isn't (in which case I'll go file a bug report), or if this is 
yet to be implemented in the commonmark_x reader? If the latter, is this an 
extension that is yet to be implemented (latex_macros?), or just a feature 
that needs to be ported over?

Thanks! 

Connor

-- 
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/c3c60679-e42e-4c01-a37b-7a940aad0370n%40googlegroups.com.

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

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

* Re: align environment with commonmark
       [not found] ` <c3c60679-e42e-4c01-a37b-7a940aad0370n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-03-06 23:56   ` Connor Patrick Jackson
       [not found]     ` <96046e7a-5618-4578-92c0-2de0fd02d416n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2022-03-07  4:49   ` John MacFarlane
  1 sibling, 1 reply; 9+ messages in thread
From: Connor Patrick Jackson @ 2022-03-06 23:56 UTC (permalink / raw)
  To: pandoc-discuss


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

If a reprex is desired: 

Contents of test.txt: 

# test

\begin{align*}
f(x) &= x \\
&= 2
\end{align*}


Call to pandoc: pandoc test.txt --mathml -f commonmark_x -t html5

yields:

<h1 id="test">test</h1>
<p>\begin{align*} f(x) &amp;= x \ &amp;= 2 \end{align*}</p>

Instead of the correct MathML that is rendered with -f markdown: 

<h1 id="test">test</h1>
<p><math display="block" 
xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable><mtr><mtd 
columnalign="right"><mi>f</mi><mrow><mo stretchy="true" 
form="prefix">(</mo><mi>x</mi><mo stretchy="true" 
form="postfix">)</mo></mrow></mtd><mtd 
columnalign="left"><mo>=</mo><mi>x</mi></mtd></mtr><mtr><mtd 
columnalign="right"></mtd><mtd 
columnalign="left"><mo>=</mo><mn>2</mn></mtd></mtr></mtable><annotation 
encoding="application/x-tex">\begin{align*}
f(x) &amp;= x \\
&amp;= 2
\end{align*}</annotation></semantics></math></p>
On Sunday, March 6, 2022 at 3:53:24 PM UTC-8 Connor Patrick Jackson wrote:

> I am attempting to use an align environment in a markdown file being 
> compiled to both HTML and LaTeX. Doing so works fine with the markdown 
> reader, but not with the commonmark_x reader, for either MathML or 
> MathJax (the commonmark_x reader just passes it through as unaltered 
> text). I *thought* that I had previously been able to use the commonmark_x 
> reader to handle align environments for equation aligning, but I could be 
> misremembering. 
>
> Could someone confirm for me whether this is a feature that should be 
> working, but isn't (in which case I'll go file a bug report), or if this is 
> yet to be implemented in the commonmark_x reader? If the latter, is this 
> an extension that is yet to be implemented (latex_macros?), or just a 
> feature that needs to be ported over?
>
> Thanks! 
>
> Connor
>

-- 
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/96046e7a-5618-4578-92c0-2de0fd02d416n%40googlegroups.com.

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

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

* Re: align environment with commonmark
       [not found]     ` <96046e7a-5618-4578-92c0-2de0fd02d416n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-03-06 23:58       ` Connor Patrick Jackson
  0 siblings, 0 replies; 9+ messages in thread
From: Connor Patrick Jackson @ 2022-03-06 23:58 UTC (permalink / raw)
  To: pandoc-discuss


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

(Run on version 2.17.1.1)

On Sunday, March 6, 2022 at 3:56:14 PM UTC-8 Connor Patrick Jackson wrote:

> If a reprex is desired: 
>
> Contents of test.txt: 
>
> # test
>
> \begin{align*}
> f(x) &= x \\
> &= 2
> \end{align*}
>
>
> Call to pandoc: pandoc test.txt --mathml -f commonmark_x -t html5
>
> yields:
>
> <h1 id="test">test</h1>
> <p>\begin{align*} f(x) &amp;= x \ &amp;= 2 \end{align*}</p>
>
> Instead of the correct MathML that is rendered with -f markdown: 
>
> <h1 id="test">test</h1>
> <p><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable><mtr><mtd 
> columnalign="right"><mi>f</mi><mrow><mo stretchy="true" 
> form="prefix">(</mo><mi>x</mi><mo stretchy="true" 
> form="postfix">)</mo></mrow></mtd><mtd 
> columnalign="left"><mo>=</mo><mi>x</mi></mtd></mtr><mtr><mtd 
> columnalign="right"></mtd><mtd 
> columnalign="left"><mo>=</mo><mn>2</mn></mtd></mtr></mtable><annotation 
> encoding="application/x-tex">\begin{align*}
> f(x) &amp;= x \\
> &amp;= 2
> \end{align*}</annotation></semantics></math></p>
> On Sunday, March 6, 2022 at 3:53:24 PM UTC-8 Connor Patrick Jackson wrote:
>
>> I am attempting to use an align environment in a markdown file being 
>> compiled to both HTML and LaTeX. Doing so works fine with the markdown 
>> reader, but not with the commonmark_x reader, for either MathML or 
>> MathJax (the commonmark_x reader just passes it through as unaltered 
>> text). I *thought* that I had previously been able to use the 
>> commonmark_x reader to handle align environments for equation aligning, 
>> but I could be misremembering. 
>>
>> Could someone confirm for me whether this is a feature that should be 
>> working, but isn't (in which case I'll go file a bug report), or if this is 
>> yet to be implemented in the commonmark_x reader? If the latter, is this 
>> an extension that is yet to be implemented (latex_macros?), or just a 
>> feature that needs to be ported over?
>>
>> Thanks! 
>>
>> Connor
>>
>

-- 
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/b27ac731-9e29-4b58-bda7-7e812b11cb46n%40googlegroups.com.

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

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

* Re: align environment with commonmark
       [not found] ` <c3c60679-e42e-4c01-a37b-7a940aad0370n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2022-03-06 23:56   ` Connor Patrick Jackson
@ 2022-03-07  4:49   ` John MacFarlane
       [not found]     ` <m2o82iv021.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>
  1 sibling, 1 reply; 9+ messages in thread
From: John MacFarlane @ 2022-03-07  4:49 UTC (permalink / raw)
  To: Connor Patrick Jackson, pandoc-discuss


I don't think this ever worked in commonmark_x, and I don't know
if it ever will.  But you should be able to do

$$
\begin{aligned}
x &= y \\
a &= b
\end{aligned}
$$

and get similar results in going to MathML.

Connor Patrick Jackson <cpjackson-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes:

> I am attempting to use an align environment in a markdown file being 
> compiled to both HTML and LaTeX. Doing so works fine with the markdown 
> reader, but not with the commonmark_x reader, for either MathML or MathJax 
> (the commonmark_x reader just passes it through as unaltered text). I 
> *thought* that I had previously been able to use the commonmark_x reader to 
> handle align environments for equation aligning, but I could be 
> misremembering. 
>
> Could someone confirm for me whether this is a feature that should be 
> working, but isn't (in which case I'll go file a bug report), or if this is 
> yet to be implemented in the commonmark_x reader? If the latter, is this an 
> extension that is yet to be implemented (latex_macros?), or just a feature 
> that needs to be ported over?
>
> Thanks! 
>
> Connor
>
> -- 
> 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/c3c60679-e42e-4c01-a37b-7a940aad0370n%40googlegroups.com.


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

* Re: align environment with commonmark
       [not found]     ` <m2o82iv021.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>
@ 2022-03-07  6:56       ` Connor Patrick Jackson
       [not found]         ` <58f03732-4779-4d40-8012-f383dd427755n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Connor Patrick Jackson @ 2022-03-07  6:56 UTC (permalink / raw)
  To: pandoc-discuss


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

Yeah, I think I was just misremembering. Is this something that was built 
into the markdown reader, or in a filter/extension? (I'm asking not just 
for the align environment in particular, but some other common mathy 
environments more generally). 

My concern with using aligned within $$…$$ is it breaks equation numbers 
and references. I know that isn't supported in pandoc by default for 
non-TeX output, but since there are other tools that hook onto pandoc 
(crossref, several Rmarkdown-flavored approaches, etc) and do use equation 
numbers and references, I'd like to try to write as clean of markup as 
possible. But if it happens in a filter regardless, then it's not that much 
extra work to handle the environment in the first place, I suppose.

Thanks! 

C

On Sunday, March 6, 2022 at 8:50:05 PM UTC-8 John MacFarlane wrote:

>
> I don't think this ever worked in commonmark_x, and I don't know
> if it ever will. But you should be able to do
>
> $$
> \begin{aligned}
> x &= y \\
> a &= b
> \end{aligned}
> $$
>
> and get similar results in going to MathML.
>
> Connor Patrick Jackson <cpja...-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes:
>
> > I am attempting to use an align environment in a markdown file being 
> > compiled to both HTML and LaTeX. Doing so works fine with the markdown 
> > reader, but not with the commonmark_x reader, for either MathML or 
> MathJax 
> > (the commonmark_x reader just passes it through as unaltered text). I 
> > *thought* that I had previously been able to use the commonmark_x reader 
> to 
> > handle align environments for equation aligning, but I could be 
> > misremembering. 
> >
> > Could someone confirm for me whether this is a feature that should be 
> > working, but isn't (in which case I'll go file a bug report), or if this 
> is 
> > yet to be implemented in the commonmark_x reader? If the latter, is this 
> an 
> > extension that is yet to be implemented (latex_macros?), or just a 
> feature 
> > that needs to be ported over?
> >
> > Thanks! 
> >
> > Connor
> >
> > -- 
> > 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/c3c60679-e42e-4c01-a37b-7a940aad0370n%40googlegroups.com
> .
>

-- 
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/58f03732-4779-4d40-8012-f383dd427755n%40googlegroups.com.

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

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

* Re: align environment with commonmark
       [not found]         ` <58f03732-4779-4d40-8012-f383dd427755n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-03-07  7:30           ` Connor Patrick Jackson
       [not found]             ` <35a67fa0-cdac-4bbc-b766-e89ca6f7f790n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2022-03-07 17:59           ` John MacFarlane
  1 sibling, 1 reply; 9+ messages in thread
From: Connor Patrick Jackson @ 2022-03-07  7:30 UTC (permalink / raw)
  To: pandoc-discuss


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

On deeper inspection, I think this is potentially an issue with the raw_tex 
extension of commonmark_x, or at least a change of behavior that I wasn't 
expecting. For the reprex in the above message, the native output for the 
markdown reader indicates the align environment is captured as a RawInline 
(probably should be a block, but that's beside the point) with format 
"tex". However, the native output from the commonmark_x reader is a 
paragraph: 

[ Header 1 ( "test" , [] , [] ) [ Str "test" ]
, Para
    [ Str "\\begin{align*}"
    , SoftBreak
    , Str "f(x)"
    , Space
    , Str "&="
    , Space
    , Str "x"
    , Space
    , Str "\\"
    , SoftBreak
    , Str "&="
    , Space
    , Str "3"
    , SoftBreak
    , Str "\\end{align*}"
    ]
]

Not only is this yielding inappropriate HTML, it actually generates the 
wrong LaTeX! 

\textbackslash begin\{align*\} f(x) \&= x \textbackslash{} \&= 3
\textbackslash end\{align*\}

Regardless of whether the align environment specifically is going to be 
handled as math by the commonmark_x reader, I think we have a problem here, 
unless I'm wildly misinterpreting. 

Lmk if I should move this to a bug report on GitHub.

C

On Sunday, March 6, 2022 at 10:56:13 PM UTC-8 Connor Patrick Jackson wrote:

> Yeah, I think I was just misremembering. Is this something that was built 
> into the markdown reader, or in a filter/extension? (I'm asking not just 
> for the align environment in particular, but some other common mathy 
> environments more generally). 
>
> My concern with using aligned within $$…$$ is it breaks equation numbers 
> and references. I know that isn't supported in pandoc by default for 
> non-TeX output, but since there are other tools that hook onto pandoc 
> (crossref, several Rmarkdown-flavored approaches, etc) and do use equation 
> numbers and references, I'd like to try to write as clean of markup as 
> possible. But if it happens in a filter regardless, then it's not that much 
> extra work to handle the environment in the first place, I suppose.
>
> Thanks! 
>
> C
>
> On Sunday, March 6, 2022 at 8:50:05 PM UTC-8 John MacFarlane wrote:
>
>>
>> I don't think this ever worked in commonmark_x, and I don't know 
>> if it ever will. But you should be able to do 
>>
>> $$ 
>> \begin{aligned} 
>> x &= y \\ 
>> a &= b 
>> \end{aligned} 
>> $$ 
>>
>> and get similar results in going to MathML. 
>>
>> Connor Patrick Jackson <cpja...-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes: 
>>
>> > I am attempting to use an align environment in a markdown file being 
>> > compiled to both HTML and LaTeX. Doing so works fine with the markdown 
>> > reader, but not with the commonmark_x reader, for either MathML or 
>> MathJax 
>> > (the commonmark_x reader just passes it through as unaltered text). I 
>> > *thought* that I had previously been able to use the commonmark_x 
>> reader to 
>> > handle align environments for equation aligning, but I could be 
>> > misremembering. 
>> > 
>> > Could someone confirm for me whether this is a feature that should be 
>> > working, but isn't (in which case I'll go file a bug report), or if 
>> this is 
>> > yet to be implemented in the commonmark_x reader? If the latter, is 
>> this an 
>> > extension that is yet to be implemented (latex_macros?), or just a 
>> feature 
>> > that needs to be ported over? 
>> > 
>> > Thanks! 
>> > 
>> > Connor 
>> > 
>> > -- 
>> > 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>> > To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/c3c60679-e42e-4c01-a37b-7a940aad0370n%40googlegroups.com. 
>>
>>
>

-- 
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/35a67fa0-cdac-4bbc-b766-e89ca6f7f790n%40googlegroups.com.

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

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

* Re: align environment with commonmark
       [not found]         ` <58f03732-4779-4d40-8012-f383dd427755n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2022-03-07  7:30           ` Connor Patrick Jackson
@ 2022-03-07 17:59           ` John MacFarlane
  1 sibling, 0 replies; 9+ messages in thread
From: John MacFarlane @ 2022-03-07 17:59 UTC (permalink / raw)
  To: Connor Patrick Jackson, pandoc-discuss

Connor Patrick Jackson <cpjackson-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes:

> Yeah, I think I was just misremembering. Is this something that was built 
> into the markdown reader, or in a filter/extension? (I'm asking not just 
> for the align environment in particular, but some other common mathy 
> environments more generally). 

As you know, the markdown reader allows you to include raw LaTeX
environments. (commonmark_x does not, unless you enclose them
in backticks with the "raw attribute.")

The markdown reader also knows which raw environments are math,
and it automatically parses these as math rather than as raw LaTeX.

> My concern with using aligned within $$…$$ is it breaks equation numbers 
> and references. I know that isn't supported in pandoc by default for 
> non-TeX output, but since there are other tools that hook onto pandoc 
> (crossref, several Rmarkdown-flavored approaches, etc) and do use equation 
> numbers and references, I'd like to try to write as clean of markup as 
> possible. But if it happens in a filter regardless, then it's not that much 
> extra work to handle the environment in the first place, I suppose.

You can try putting the \begin{align}..\end{align} inside $$ --
it's invalid TeX but it might pass through okay to mathjax if
you're targeting HTML.

If you're using --mathml, though, equation numbers aren't
supported.

-- 
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/m2fsntprt7.fsf%40MacBook-Pro-2.hsd1.ca.comcast.net.


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

* Re: align environment with commonmark
       [not found]             ` <35a67fa0-cdac-4bbc-b766-e89ca6f7f790n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-03-07 18:05               ` John MacFarlane
       [not found]                 ` <m2czixprj5.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: John MacFarlane @ 2022-03-07 18:05 UTC (permalink / raw)
  To: Connor Patrick Jackson, pandoc-discuss


I think it is just a mistake that `raw_tex` is enabled for
commonmark.  The commonmark reader doesn't parse raw TeX.
Currently the raw_tex extension does affect the writer, but only
if you do `commonmark+raw_tex` (since `commonmark_x` includes
`raw_attribute` which will take precedence).  I'll remove it.

If you want to include raw tex, you can do so using the raw
attribute:

```{=latex}
\begin{align*}
...
\end{align*}
```

But this will NOT be parsed as math in commonmark_x, as it
would be in markdown.

Connor Patrick Jackson <cpjackson-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes:

> On deeper inspection, I think this is potentially an issue with the raw_tex 
> extension of commonmark_x, or at least a change of behavior that I wasn't 
> expecting. For the reprex in the above message, the native output for the 
> markdown reader indicates the align environment is captured as a RawInline 
> (probably should be a block, but that's beside the point) with format 
> "tex". However, the native output from the commonmark_x reader is a 
> paragraph: 
>
> [ Header 1 ( "test" , [] , [] ) [ Str "test" ]
> , Para
>     [ Str "\\begin{align*}"
>     , SoftBreak
>     , Str "f(x)"
>     , Space
>     , Str "&="
>     , Space
>     , Str "x"
>     , Space
>     , Str "\\"
>     , SoftBreak
>     , Str "&="
>     , Space
>     , Str "3"
>     , SoftBreak
>     , Str "\\end{align*}"
>     ]
> ]
>
> Not only is this yielding inappropriate HTML, it actually generates the 
> wrong LaTeX! 
>
> \textbackslash begin\{align*\} f(x) \&= x \textbackslash{} \&= 3
> \textbackslash end\{align*\}
>
> Regardless of whether the align environment specifically is going to be 
> handled as math by the commonmark_x reader, I think we have a problem here, 
> unless I'm wildly misinterpreting. 
>
> Lmk if I should move this to a bug report on GitHub.
>
> C
>
> On Sunday, March 6, 2022 at 10:56:13 PM UTC-8 Connor Patrick Jackson wrote:
>
>> Yeah, I think I was just misremembering. Is this something that was built 
>> into the markdown reader, or in a filter/extension? (I'm asking not just 
>> for the align environment in particular, but some other common mathy 
>> environments more generally). 
>>
>> My concern with using aligned within $$…$$ is it breaks equation numbers 
>> and references. I know that isn't supported in pandoc by default for 
>> non-TeX output, but since there are other tools that hook onto pandoc 
>> (crossref, several Rmarkdown-flavored approaches, etc) and do use equation 
>> numbers and references, I'd like to try to write as clean of markup as 
>> possible. But if it happens in a filter regardless, then it's not that much 
>> extra work to handle the environment in the first place, I suppose.
>>
>> Thanks! 
>>
>> C
>>
>> On Sunday, March 6, 2022 at 8:50:05 PM UTC-8 John MacFarlane wrote:
>>
>>>
>>> I don't think this ever worked in commonmark_x, and I don't know 
>>> if it ever will. But you should be able to do 
>>>
>>> $$ 
>>> \begin{aligned} 
>>> x &= y \\ 
>>> a &= b 
>>> \end{aligned} 
>>> $$ 
>>>
>>> and get similar results in going to MathML. 
>>>
>>> Connor Patrick Jackson <cpja...-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes: 
>>>
>>> > I am attempting to use an align environment in a markdown file being 
>>> > compiled to both HTML and LaTeX. Doing so works fine with the markdown 
>>> > reader, but not with the commonmark_x reader, for either MathML or 
>>> MathJax 
>>> > (the commonmark_x reader just passes it through as unaltered text). I 
>>> > *thought* that I had previously been able to use the commonmark_x 
>>> reader to 
>>> > handle align environments for equation aligning, but I could be 
>>> > misremembering. 
>>> > 
>>> > Could someone confirm for me whether this is a feature that should be 
>>> > working, but isn't (in which case I'll go file a bug report), or if 
>>> this is 
>>> > yet to be implemented in the commonmark_x reader? If the latter, is 
>>> this an 
>>> > extension that is yet to be implemented (latex_macros?), or just a 
>>> feature 
>>> > that needs to be ported over? 
>>> > 
>>> > Thanks! 
>>> > 
>>> > Connor 
>>> > 
>>> > -- 
>>> > 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>>> > To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/pandoc-discuss/c3c60679-e42e-4c01-a37b-7a940aad0370n%40googlegroups.com. 
>>>
>>>
>>
>
> -- 
> 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/35a67fa0-cdac-4bbc-b766-e89ca6f7f790n%40googlegroups.com.

-- 
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/m2czixprj5.fsf%40MacBook-Pro-2.hsd1.ca.comcast.net.


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

* Re: align environment with commonmark
       [not found]                 ` <m2czixprj5.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>
@ 2022-03-07 23:46                   ` Connor Patrick Jackson
  0 siblings, 0 replies; 9+ messages in thread
From: Connor Patrick Jackson @ 2022-03-07 23:46 UTC (permalink / raw)
  To: pandoc-discuss


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

Okay, this is helpful context, thanks. So raw_tex is not available for the 
commonmark reader. Is the same true for raw_html, or is that a different 
kettle of fish? And if this is the way the commonmark reader is going, 
could we add a line to the manual under raw_tex to note that it is not 
valid for commonmark inputs?

One thing I'm not following: 

>But [math inside a raw attribute block] will NOT be parsed as math in 
commonmark_x, as it would be in markdown. 

My extremely simple testing (wrapping the align environment in my above 
reprex in a fenced block raw attribute), when run as pandoc test.txt -f 
commonmark_x -t html5 --mathml DOES render the align environment properly 
in mathML. Is this unexpected behavior? If all that's required for the 
commonmark reader is to wrap latex math environments (that pandoc knows 
about) in a raw attribute, then I am happy! 

But if this is wrong, I am a little thrown why that is not the vision for 
this feature. I don't know what exactly the right approach is, but what I 
(and presumably others) would like to do is write clean markdown 
(eventually commonmark) that converts cleanly to multiple different output 
formats when at all possible. Thus, the current behavior of the markdown 
reader to catch that the align environment is LaTeX math without (wrongly, 
from LaTeX's perspective) wrapping it in $$…$$ is extremely appealing, 
because it works correctly out of the box for both LaTeX and non-LaTeX 
outputs. Obviously you don't get equation numbering with every non-LaTeX 
output (like when using mathML), but it's still valid syntax that renders 
correctly, without having to write language-specific code. Wrapping those 
environments in raw attribute blocks for the commonmark reader would have 
the same benefit. Pass it as raw TeX if TeX is the output format, parse it 
as math if it's a known math environment that pandoc knows what to do with, 
and otherwise drop it. What part am I missing?

Thanks!

C
On Monday, March 7, 2022 at 10:05:24 AM UTC-8 John MacFarlane wrote:

>
> I think it is just a mistake that `raw_tex` is enabled for
> commonmark. The commonmark reader doesn't parse raw TeX.
> Currently the raw_tex extension does affect the writer, but only
> if you do `commonmark+raw_tex` (since `commonmark_x` includes
> `raw_attribute` which will take precedence). I'll remove it.
>
> If you want to include raw tex, you can do so using the raw
> attribute:
>
> ```{=latex}
> \begin{align*}
> ...
> \end{align*}
> ```
>
> But this will NOT be parsed as math in commonmark_x, as it
> would be in markdown.
>
> Connor Patrick Jackson <cpja...-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes:
>
> > On deeper inspection, I think this is potentially an issue with the 
> raw_tex 
> > extension of commonmark_x, or at least a change of behavior that I 
> wasn't 
> > expecting. For the reprex in the above message, the native output for 
> the 
> > markdown reader indicates the align environment is captured as a 
> RawInline 
> > (probably should be a block, but that's beside the point) with format 
> > "tex". However, the native output from the commonmark_x reader is a 
> > paragraph: 
> >
> > [ Header 1 ( "test" , [] , [] ) [ Str "test" ]
> > , Para
> > [ Str "\\begin{align*}"
> > , SoftBreak
> > , Str "f(x)"
> > , Space
> > , Str "&="
> > , Space
> > , Str "x"
> > , Space
> > , Str "\\"
> > , SoftBreak
> > , Str "&="
> > , Space
> > , Str "3"
> > , SoftBreak
> > , Str "\\end{align*}"
> > ]
> > ]
> >
> > Not only is this yielding inappropriate HTML, it actually generates the 
> > wrong LaTeX! 
> >
> > \textbackslash begin\{align*\} f(x) \&= x \textbackslash{} \&= 3
> > \textbackslash end\{align*\}
> >
> > Regardless of whether the align environment specifically is going to be 
> > handled as math by the commonmark_x reader, I think we have a problem 
> here, 
> > unless I'm wildly misinterpreting. 
> >
> > Lmk if I should move this to a bug report on GitHub.
> >
> > C
> >
> > On Sunday, March 6, 2022 at 10:56:13 PM UTC-8 Connor Patrick Jackson 
> wrote:
> >
> >> Yeah, I think I was just misremembering. Is this something that was 
> built 
> >> into the markdown reader, or in a filter/extension? (I'm asking not 
> just 
> >> for the align environment in particular, but some other common mathy 
> >> environments more generally). 
> >>
> >> My concern with using aligned within $$…$$ is it breaks equation 
> numbers 
> >> and references. I know that isn't supported in pandoc by default for 
> >> non-TeX output, but since there are other tools that hook onto pandoc 
> >> (crossref, several Rmarkdown-flavored approaches, etc) and do use 
> equation 
> >> numbers and references, I'd like to try to write as clean of markup as 
> >> possible. But if it happens in a filter regardless, then it's not that 
> much 
> >> extra work to handle the environment in the first place, I suppose.
> >>
> >> Thanks! 
> >>
> >> C
> >>
> >> On Sunday, March 6, 2022 at 8:50:05 PM UTC-8 John MacFarlane wrote:
> >>
> >>>
> >>> I don't think this ever worked in commonmark_x, and I don't know 
> >>> if it ever will. But you should be able to do 
> >>>
> >>> $$ 
> >>> \begin{aligned} 
> >>> x &= y \\ 
> >>> a &= b 
> >>> \end{aligned} 
> >>> $$ 
> >>>
> >>> and get similar results in going to MathML. 
> >>>
> >>> Connor Patrick Jackson <cpja...-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes: 
> >>>
> >>> > I am attempting to use an align environment in a markdown file being 
> >>> > compiled to both HTML and LaTeX. Doing so works fine with the 
> markdown 
> >>> > reader, but not with the commonmark_x reader, for either MathML or 
> >>> MathJax 
> >>> > (the commonmark_x reader just passes it through as unaltered text). 
> I 
> >>> > *thought* that I had previously been able to use the commonmark_x 
> >>> reader to 
> >>> > handle align environments for equation aligning, but I could be 
> >>> > misremembering. 
> >>> > 
> >>> > Could someone confirm for me whether this is a feature that should 
> be 
> >>> > working, but isn't (in which case I'll go file a bug report), or if 
> >>> this is 
> >>> > yet to be implemented in the commonmark_x reader? If the latter, is 
> >>> this an 
> >>> > extension that is yet to be implemented (latex_macros?), or just a 
> >>> feature 
> >>> > that needs to be ported over? 
> >>> > 
> >>> > Thanks! 
> >>> > 
> >>> > Connor 
> >>> > 
> >>> > -- 
> >>> > 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
> >>> > To view this discussion on the web visit 
> >>> 
> https://groups.google.com/d/msgid/pandoc-discuss/c3c60679-e42e-4c01-a37b-7a940aad0370n%40googlegroups.com. 
>
> >>>
> >>>
> >>
> >
> > -- 
> > 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/35a67fa0-cdac-4bbc-b766-e89ca6f7f790n%40googlegroups.com
> .
>

-- 
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/a5ae93c2-5a07-4351-a39e-7f11cffca25bn%40googlegroups.com.

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

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

end of thread, other threads:[~2022-03-07 23:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-06 23:53 align environment with commonmark Connor Patrick Jackson
     [not found] ` <c3c60679-e42e-4c01-a37b-7a940aad0370n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-03-06 23:56   ` Connor Patrick Jackson
     [not found]     ` <96046e7a-5618-4578-92c0-2de0fd02d416n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-03-06 23:58       ` Connor Patrick Jackson
2022-03-07  4:49   ` John MacFarlane
     [not found]     ` <m2o82iv021.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>
2022-03-07  6:56       ` Connor Patrick Jackson
     [not found]         ` <58f03732-4779-4d40-8012-f383dd427755n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-03-07  7:30           ` Connor Patrick Jackson
     [not found]             ` <35a67fa0-cdac-4bbc-b766-e89ca6f7f790n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-03-07 18:05               ` John MacFarlane
     [not found]                 ` <m2czixprj5.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>
2022-03-07 23:46                   ` Connor Patrick Jackson
2022-03-07 17:59           ` John MacFarlane

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).