Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra paragraphs when convert LaTeX to HTML+MathML #1821

Closed
rgaiacs opened this issue Dec 16, 2014 · 2 comments
Closed

Extra paragraphs when convert LaTeX to HTML+MathML #1821

rgaiacs opened this issue Dec 16, 2014 · 2 comments

Comments

@rgaiacs
Copy link
Contributor

rgaiacs commented Dec 16, 2014

Summary

In LaTeX, a empty line marks the end of one paragraph and the begin of another. This rule also apply for math environments like equation, align, ...

Steps to Reproduce

$ cat sample.tex
begin of paragraph
\begin{equation}
a^2 + b^2 = c^2
\end{equation}
end of paragraph.
$ pandoc --version | head -n 1
pandoc 1.13.2
$ pandoc -f latex -t html --mathml sample.tex

Actual Results

Three paragraphs were created:

<p>begin of paragraph</p>
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup><mo>=</mo><msup><mi>c</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">a^2 + b^2 = c^2</annotation></semantics></math></p>
<p>end of paragraph.</p>

Expected Results

Only one paragraph was created:

<p>begin of paragraph <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup><mo>=</mo><msup><mi>c</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">a^2 + b^2 = c^2</annotation></semantics></math> end of paragraph.</p>

Aditional information

When I use $$ I get the correct behavior.

$ cat sample.tex
begin of paragraph
$$a^2 + b^2 = c^2$$
end of paragraph.
$ pandoc --version | head -n 1
pandoc 1.13.2
$ pandoc -f latex -t html --mathml sample.tex
<p>begin of paragraph <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup><mo>=</mo><msup><mi>c</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">a^2 + b^2 = c^2</annotation></semantics></math> end of paragraph.</p>
@mpickering mpickering added bug and removed bug labels Dec 16, 2014
@mpickering
Copy link
Collaborator

In pandoc all environments which start with \begin{...} are parsed as block level elements. Math is an inline element so has to be lifted to the block level and this is done using the extra Para element.

@jgm jgm closed this as completed in 7e41d0b Dec 16, 2014
@jgm
Copy link
Owner

jgm commented Dec 16, 2014

I think I came up with a fairly simple fix, which will cause
\begin{equation}...\end{equation} and the like to be
included in a display math inline inside a paragraph when
possible, rather than creating a new paragraph.

+++ Matthew Pickering [Dec 16 14 11:18 ]:

In pandoc all environments which start with \begin{...} are parsed as
block level elements. Math is an inline element so has to be lifted to
the block level and this is done using the extra Para element.


Reply to this email directly or [1]view it on GitHub.

References

  1. Extra paragraphs when convert LaTeX to HTML+MathML #1821 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants