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

Unexpected parsing _underline_ in $LaTeX$ #457

Closed
foreshadow opened this issue Jan 2, 2017 · 1 comment
Closed

Unexpected parsing _underline_ in $LaTeX$ #457

foreshadow opened this issue Jan 2, 2017 · 1 comment
Labels

Comments

@foreshadow
Copy link

I tried it in demo.
There is a LaTeX formula in my markdown

$\Pi_{\text{Sno},\text{Cno}}(\text{SC})\div \Pi_{\text{Cno}}(\text{Course})\bowtie \Pi_{\text{Sno},\text{Sname}}(\text{Student})$

And it is parsed to

$\Pi<em>{\text{Sno},\text{Cno}}(\text{SC})\div \Pi</em>{\text{Cno}}(\text{Course})\bowtie \Pi_{\text{Sno},\text{Sname}}(\text{Student})$

in which the underlines _ was parsed to <em></em> and I do not expect that.
What should I do to avoid this? Is it a bug or unsupported feature?
By the way, I am using mathjax to render this.

@erusev erusev added the priority label Jan 2, 2017
@aidantwoods
Copy link
Collaborator

aidantwoods commented Jan 3, 2017

Funnily enough I'd been having my own go at integrating MathJax LaTeX into Parsedown. So here's a hack to do it for now (Parsedown may want to forgo parsing the actual mathjax latex syntax by default though).

I opted to overload the ` inline marker for inline MathJax LaTeX (actual inline code can now be two (``) or more backticks), and have defined a specific language parser for fenced code to show up as block latex.

(Obviously, those are both my decisions based entirely on my own preferences – so don't take those as an implied standard or anything)

Branch here: https://github.com/aidantwoods/parsedown/tree/mathjaxlatex

Because the text containing the LaTeX now has its own handler, we can avoid Parsedown trying to apply markdown to it.

E.g.

include('Parsedown.php');
include('ParsedownExtensionMathJaxLaTeX.php');

$Parsedown = new ParsedownExtensionMathJaxLaTeX();

test source:

test text inline LaTeX: `x = \int_{0^1}^1(-b \pm \sqrt{b^2-4ac})/(2a)` more
inline text

```
x = \int_{0^1}^1(-b \pm \sqrt{b^2-4ac})/(2a)
```

```latex
x = \int_{0^1}^1(-b \pm \sqrt{b^2-4ac})/(2a)
```

`\Pi_{\text{Sno},\text{Cno}}(\text{SC})\div \Pi_{\text{Cno}}(\text{Course})
\bowtie \Pi_{\text{Sno},\text{Sname}}(\text{Student})`

```latex
\Pi_{\text{Sno},\text{Cno}}(\text{SC})\div \Pi_{\text{Cno}}(\text{Course})
\bowtie \Pi_{\text{Sno},\text{Sname}}(\text{Student})
```

```not-latex
\Pi_{\text{Sno},\text{Cno}}(\text{SC})\div \Pi_{\text{Cno}}(\text{Course})
\bowtie \Pi_{\text{Sno},\text{Sname}}(\text{Student})
```

* line item

``inlineCode``

output:

<p>test text inline LaTeX: <span>\(x = \int_{0^1}^1(-b \pm \sqrt{b^2-4ac})/(2a)\)</span> more
inline text</p>
<pre><code>x = \int_{0^1}^1(-b \pm \sqrt{b^2-4ac})/(2a)</code></pre>
<span>$$
x = \int_{0^1}^1(-b \pm \sqrt{b^2-4ac})/(2a)
$$</span>
<p><span>\(\Pi_{\text{Sno},\text{Cno}}(\text{SC})\div \Pi_{\text{Cno}}(\text{Course}) \bowtie \Pi_{\text{Sno},\text{Sname}}(\text{Student})\)</span></p>
<span>$$
\Pi_{\text{Sno},\text{Cno}}(\text{SC})\div \Pi_{\text{Cno}}(\text{Course})
\bowtie \Pi_{\text{Sno},\text{Sname}}(\text{Student})
$$</span>
<pre><code class="language-not-latex">\Pi_{\text{Sno},\text{Cno}}(\text{SC})\div \Pi_{\text{Cno}}(\text{Course})
\bowtie \Pi_{\text{Sno},\text{Sname}}(\text{Student})</code></pre>
<ul>
<li>line item</li>
</ul>
<p><code>inlineCode</code></p>

screen shot 2017-01-03 at 18 28 28

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

No branches or pull requests

3 participants