public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Math in epub3
@ 2020-03-10 20:54 Juan
       [not found] ` <3f13f968-35b1-41fc-91bb-bc576fdd2450-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Juan @ 2020-03-10 20:54 UTC (permalink / raw)
  To: pandoc-discuss


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

Hi there,

This is my first time in here and I got a two-questions question. This 
happens using latest Pandoc version, Windows 8.1.

My 0001.md file:

Math test:

$Fe = \begin{cases} x, & \text{si } x < 1 \\ 1, & \text{si } x \geq 1 
\end{cases}$

The end.

Processing it this way:

pandoc -f markdown_strict 0001.md -t epub3 -o 0001.epub

I expect an unaltered string between $ and $ in the resulting epub's .xhtml 
(because I'm planning to process math later), but what I got is this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" 
xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="es">
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="pandoc" />
  <title>ch001.xhtml</title>
  <link rel="stylesheet" type="text/css" href="../styles/stylesheet1.css" />
</head>
<body epub:type="bodymatter">
<section id="section" class="level1 unnumbered" data-number="">
<h1 class="unnumbered" data-number=""></h1>
<p>Math test:</p>
<p>$Fe = \begin{cases} x, &amp; \text{si } x &lt; 1 \ 1, &amp; \text{si } x 
\geq 1 \end{cases}$</p>
<p>The end.</p>
</section>
</body>
</html>

Which is *almost* okay for me, except that, & and < are replaced by their 
entities and \\ is replaced by \. Adding raw_tex extension changes 
anything. Maybe using raw_attribute could do the trick, but I don't want to 
alter the whole .md because I want to build other documents processing the 
math strings with Pandoc. Is there any way to keep math strings totally 
unaltered in the output .epub?

---

But that's no all... I don't really want to use markdown_strict, I want to 
use most Pandoc's markdown features,so I tried this:

pandoc -f 
markdown-tex_math_dollars-tex_math_single_backslash-tex_math_double_backslash 
0001.md -t epub3 -o 0001.epub

And result is:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" 
xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="es">
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="pandoc" />
  <title>ch001.xhtml</title>
  <link rel="stylesheet" type="text/css" href="../styles/stylesheet1.css" />
</head>
<body epub:type="bodymatter">
<section id="section" class="level1 unnumbered" data-number="">
<h1 class="unnumbered" data-number=""></h1>
<p>Math test:</p>
$Fe =
<math display="block" 
xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo 
stretchy="true" form="prefix">{</mo><mtable><mtr><mtd 
columnalign="left"><mi>x</mi><mo>,</mo></mtd><mtd 
columnalign="left"><mrow><mtext mathvariant="normal">si </mtext><mspace 
width="0.333em"></mspace></mrow><mi>x</mi><mo>&lt;</mo><mn>1</mn></mtd></mtr><mtr><mtd 
columnalign="left"><mn>1</mn><mo>,</mo></mtd><mtd 
columnalign="left"><mrow><mtext mathvariant="normal">si </mtext><mspace 
width="0.333em"></mspace></mrow><mi>x</mi><mo>≥</mo><mn>1</mn></mtd></mtr></mtable></mrow><annotation 
encoding="application/x-tex">\begin{cases} x, &amp; \text{si } x &lt; 1 \\ 
1, &amp; \text{si } x \geq 1 \end{cases}</annotation></semantics></math>
<p>$</p>
<p>The end.</p>
</section>
</body>
</html>

Which is far from what I expected, didn't found anything else to avoid math 
processing using Pandoc's markdown, what i'am missing here?

Thanks and thanks,

Juan

-- 
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/3f13f968-35b1-41fc-91bb-bc576fdd2450%40googlegroups.com.

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

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

* Re: Math in epub3
       [not found] ` <3f13f968-35b1-41fc-91bb-bc576fdd2450-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-03-11  0:43   ` John MacFarlane
       [not found]     ` <yh480kzhcnsoul.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: John MacFarlane @ 2020-03-11  0:43 UTC (permalink / raw)
  To: Juan, pandoc-discuss


Well, MathML is part of the EPUB3 spec.  So, that's the right way
to encode math in an EPUB3 document.

You could try targeting EPUB2 and using --mathjax or another
HTML math method (see the manual).

PS. there are some oddities in the output you report (extra $s
which I can't explain) - when I try, I get 

<p><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>F</mi><mi>e</mi><mo>=</mo><mrow><mo stretchy="true" form="prefix">{</mo><mtable><mtr><mtd columnalign="left"><mi>x</mi><mo>,</mo></mtd><mtd columnalign="left"><mrow><mtext mathvariant="normal">si </mtext><mspace width="0.333em"></mspace></mrow><mi>x</mi><mo>&lt;</mo><mn>1</mn></mtd></mtr><mtr><mtd columnalign="left"><mn>1</mn><mo>,</mo></mtd><mtd columnalign="left"><mrow><mtext mathvariant="normal">si </mtext><mspace width="0.333em"></mspace></mrow><mi>x</mi><mo>≥</mo><mn>1</mn><mo>&gt;</mo></mtd></mtr></mtable></mrow></mrow><annotation encoding="application/x-tex">Fe = \begin{cases} x, &amp; \text{si } x &lt; 1 \\ 1, &amp; \text{si } x \geq 1 &gt; \end{cases}</annotation></semantics></math></p>

Juan <barriteau-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Hi there,
>
> This is my first time in here and I got a two-questions question. This 
> happens using latest Pandoc version, Windows 8.1.
>
> My 0001.md file:
>
> Math test:
>
> $Fe = \begin{cases} x, & \text{si } x < 1 \\ 1, & \text{si } x \geq 1 
> \end{cases}$
>
> The end.
>
> Processing it this way:
>
> pandoc -f markdown_strict 0001.md -t epub3 -o 0001.epub
>
> I expect an unaltered string between $ and $ in the resulting epub's .xhtml 
> (because I'm planning to process math later), but what I got is this:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE html>
> <html xmlns="http://www.w3.org/1999/xhtml" 
> xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="es">
> <head>
>   <meta charset="utf-8" />
>   <meta name="generator" content="pandoc" />
>   <title>ch001.xhtml</title>
>   <link rel="stylesheet" type="text/css" href="../styles/stylesheet1.css" />
> </head>
> <body epub:type="bodymatter">
> <section id="section" class="level1 unnumbered" data-number="">
> <h1 class="unnumbered" data-number=""></h1>
> <p>Math test:</p>
> <p>$Fe = \begin{cases} x, &amp; \text{si } x &lt; 1 \ 1, &amp; \text{si } x 
> \geq 1 \end{cases}$</p>
> <p>The end.</p>
> </section>
> </body>
> </html>
>
> Which is *almost* okay for me, except that, & and < are replaced by their 
> entities and \\ is replaced by \. Adding raw_tex extension changes 
> anything. Maybe using raw_attribute could do the trick, but I don't want to 
> alter the whole .md because I want to build other documents processing the 
> math strings with Pandoc. Is there any way to keep math strings totally 
> unaltered in the output .epub?
>
> ---
>
> But that's no all... I don't really want to use markdown_strict, I want to 
> use most Pandoc's markdown features,so I tried this:
>
> pandoc -f 
> markdown-tex_math_dollars-tex_math_single_backslash-tex_math_double_backslash 
> 0001.md -t epub3 -o 0001.epub
>
> And result is:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE html>
> <html xmlns="http://www.w3.org/1999/xhtml" 
> xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="es">
> <head>
>   <meta charset="utf-8" />
>   <meta name="generator" content="pandoc" />
>   <title>ch001.xhtml</title>
>   <link rel="stylesheet" type="text/css" href="../styles/stylesheet1.css" />
> </head>
> <body epub:type="bodymatter">
> <section id="section" class="level1 unnumbered" data-number="">
> <h1 class="unnumbered" data-number=""></h1>
> <p>Math test:</p>
> $Fe =
> <math display="block" 
> xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo 
> stretchy="true" form="prefix">{</mo><mtable><mtr><mtd 
> columnalign="left"><mi>x</mi><mo>,</mo></mtd><mtd 
> columnalign="left"><mrow><mtext mathvariant="normal">si </mtext><mspace 
> width="0.333em"></mspace></mrow><mi>x</mi><mo>&lt;</mo><mn>1</mn></mtd></mtr><mtr><mtd 
> columnalign="left"><mn>1</mn><mo>,</mo></mtd><mtd 
> columnalign="left"><mrow><mtext mathvariant="normal">si </mtext><mspace 
> width="0.333em"></mspace></mrow><mi>x</mi><mo>≥</mo><mn>1</mn></mtd></mtr></mtable></mrow><annotation 
> encoding="application/x-tex">\begin{cases} x, &amp; \text{si } x &lt; 1 \\ 
> 1, &amp; \text{si } x \geq 1 \end{cases}</annotation></semantics></math>
> <p>$</p>
> <p>The end.</p>
> </section>
> </body>
> </html>
>
> Which is far from what I expected, didn't found anything else to avoid math 
> processing using Pandoc's markdown, what i'am missing here?
>
> Thanks and thanks,
>
> Juan
>
> -- 
> 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/3f13f968-35b1-41fc-91bb-bc576fdd2450%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/yh480kzhcnsoul.fsf%40johnmacfarlane.net.


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

* Re: Math in epub3
       [not found]     ` <yh480kzhcnsoul.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2020-03-11  1:46       ` Juan
  0 siblings, 0 replies; 3+ messages in thread
From: Juan @ 2020-03-11  1:46 UTC (permalink / raw)
  To: pandoc-discuss


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

Thanks a lot for your kind response John :)

On Tuesday, March 10, 2020 at 8:43:48 PM UTC-4, John MacFarlane wrote:
>
>
> Well, MathML is part of the EPUB3 spec.  So, that's the right way 
> to encode math in an EPUB3 document. 
>
> You could try targeting EPUB2 and using --mathjax or another 
> HTML math method (see the manual). 
>
> PS. there are some oddities in the output you report (extra $s 
> which I can't explain) - when I try, I get 
>
> <p><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>F</mi><mi>e</mi><mo>=</mo><mrow><mo 
> stretchy="true" form="prefix">{</mo><mtable><mtr><mtd 
> columnalign="left"><mi>x</mi><mo>,</mo></mtd><mtd 
> columnalign="left"><mrow><mtext mathvariant="normal">si </mtext><mspace 
> width="0.333em"></mspace></mrow><mi>x</mi><mo>&lt;</mo><mn>1</mn></mtd></mtr><mtr><mtd 
> columnalign="left"><mn>1</mn><mo>,</mo></mtd><mtd 
> columnalign="left"><mrow><mtext mathvariant="normal">si </mtext><mspace 
> width="0.333em"></mspace></mrow><mi>x</mi><mo>≥</mo><mn>1</mn><mo>&gt;</mo></mtd></mtr></mtable></mrow></mrow><annotation 
> encoding="application/x-tex">Fe = \begin{cases} x, &amp; \text{si } x &lt; 
> 1 \\ 1, &amp; \text{si } x \geq 1 &gt; 
> \end{cases}</annotation></semantics></math></p> 
>
> Juan <barr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> writes: 
>
> > Hi there, 
> > 
> > This is my first time in here and I got a two-questions question. This 
> > happens using latest Pandoc version, Windows 8.1. 
> > 
> > My 0001.md file: 
> > 
> > Math test: 
> > 
> > $Fe = \begin{cases} x, & \text{si } x < 1 \\ 1, & \text{si } x \geq 1 
> > \end{cases}$ 
> > 
> > The end. 
> > 
> > Processing it this way: 
> > 
> > pandoc -f markdown_strict 0001.md -t epub3 -o 0001.epub 
> > 
> > I expect an unaltered string between $ and $ in the resulting epub's 
> .xhtml 
> > (because I'm planning to process math later), but what I got is this: 
> > 
> > <?xml version="1.0" encoding="UTF-8"?> 
> > <!DOCTYPE html> 
> > <html xmlns="http://www.w3.org/1999/xhtml" 
> > xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="es"> 
> > <head> 
> >   <meta charset="utf-8" /> 
> >   <meta name="generator" content="pandoc" /> 
> >   <title>ch001.xhtml</title> 
> >   <link rel="stylesheet" type="text/css" 
> href="../styles/stylesheet1.css" /> 
> > </head> 
> > <body epub:type="bodymatter"> 
> > <section id="section" class="level1 unnumbered" data-number=""> 
> > <h1 class="unnumbered" data-number=""></h1> 
> > <p>Math test:</p> 
> > <p>$Fe = \begin{cases} x, &amp; \text{si } x &lt; 1 \ 1, &amp; \text{si 
> } x 
> > \geq 1 \end{cases}$</p> 
> > <p>The end.</p> 
> > </section> 
> > </body> 
> > </html> 
> > 
> > Which is *almost* okay for me, except that, & and < are replaced by 
> their 
> > entities and \\ is replaced by \. Adding raw_tex extension changes 
> > anything. Maybe using raw_attribute could do the trick, but I don't want 
> to 
> > alter the whole .md because I want to build other documents processing 
> the 
> > math strings with Pandoc. Is there any way to keep math strings totally 
> > unaltered in the output .epub? 
> > 
> > --- 
> > 
> > But that's no all... I don't really want to use markdown_strict, I want 
> to 
> > use most Pandoc's markdown features,so I tried this: 
> > 
> > pandoc -f 
> > 
> markdown-tex_math_dollars-tex_math_single_backslash-tex_math_double_backslash 
>
> > 0001.md -t epub3 -o 0001.epub 
> > 
> > And result is: 
> > 
> > <?xml version="1.0" encoding="UTF-8"?> 
> > <!DOCTYPE html> 
> > <html xmlns="http://www.w3.org/1999/xhtml" 
> > xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="es"> 
> > <head> 
> >   <meta charset="utf-8" /> 
> >   <meta name="generator" content="pandoc" /> 
> >   <title>ch001.xhtml</title> 
> >   <link rel="stylesheet" type="text/css" 
> href="../styles/stylesheet1.css" /> 
> > </head> 
> > <body epub:type="bodymatter"> 
> > <section id="section" class="level1 unnumbered" data-number=""> 
> > <h1 class="unnumbered" data-number=""></h1> 
> > <p>Math test:</p> 
> > $Fe = 
> > <math display="block" 
> > xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo 
> > stretchy="true" form="prefix">{</mo><mtable><mtr><mtd 
> > columnalign="left"><mi>x</mi><mo>,</mo></mtd><mtd 
> > columnalign="left"><mrow><mtext mathvariant="normal">si </mtext><mspace 
> > 
> width="0.333em"></mspace></mrow><mi>x</mi><mo>&lt;</mo><mn>1</mn></mtd></mtr><mtr><mtd 
>
> > columnalign="left"><mn>1</mn><mo>,</mo></mtd><mtd 
> > columnalign="left"><mrow><mtext mathvariant="normal">si </mtext><mspace 
> > 
> width="0.333em"></mspace></mrow><mi>x</mi><mo>≥</mo><mn>1</mn></mtd></mtr></mtable></mrow><annotation 
>
> > encoding="application/x-tex">\begin{cases} x, &amp; \text{si } x &lt; 1 
> \\ 
> > 1, &amp; \text{si } x \geq 1 \end{cases}</annotation></semantics></math> 
> > <p>$</p> 
> > <p>The end.</p> 
> > </section> 
> > </body> 
> > </html> 
> > 
> > Which is far from what I expected, didn't found anything else to avoid 
> math 
> > processing using Pandoc's markdown, what i'am missing here? 
> > 
> > Thanks and thanks, 
> > 
> > Juan 
> > 
> > -- 
> > 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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/3f13f968-35b1-41fc-91bb-bc576fdd2450%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/71eacbe2-eb50-4d7b-a8bb-9e4e49d5384a%40googlegroups.com.

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

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

end of thread, other threads:[~2020-03-11  1:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-10 20:54 Math in epub3 Juan
     [not found] ` <3f13f968-35b1-41fc-91bb-bc576fdd2450-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-03-11  0:43   ` John MacFarlane
     [not found]     ` <yh480kzhcnsoul.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2020-03-11  1:46       ` Juan

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