Closed grgbnc closed 6 years ago
This is most likely due to MathJax being too aggressive and grouping the two patterns together, or something like that. The output from Markdown looks proper. It's possible using something like "processClass": "arithmatex"
in the MathJax config would fix your problem.
Maybe the class needs to be in an array in that config. You'll have to reference tex2jax docs. I'm not by my computer right now.
Okay, I need more details from you. What are you seeing, because I saw the same behavior for all three cases. I need to see what you expect vs what you are seeing.
You can ignore the processClass
statement for now.
In the "not ok:" line i expect the two above different mathjax expressions rendered the same, with the rendered output separated by whitespace
Instead i get this:
not ok: $(a)n(a)$
This is its html:
<p>
"not ok: $(a)"
<em n="n">
"n"
<span class="MathJax_Preview" style="display: none;"></span>
<span class="MathJax" id="MathJax-Element-72-Frame" tabindex="0" style="">
<nobr>
<span class="math" id="MathJax-Span-583" style="width: 0em; display: inline-block;">
<span style="display: inline-block; position: relative; width: 0em; height: 0px; font-size: 130%;">
<span style="position: absolute; clip: rect(3.849em, 1000em, 4.137em, -999.998em); top: -3.988em; left: 0em;">
<span class="mrow" id="MathJax-Span-584"></span>
<span style="display: inline-block; width: 0px; height: 3.993em;"></span>
</span>
</span>
<span style="display: inline-block; overflow: hidden; vertical-align: -0.059em; border-left: 0px solid; width: 0px; height: 0.128em;"></span>
</span>
</nobr>
</span>
<script type="math/tex" id="MathJax-Element-72"> </script>
"(a)"
</em>
"$"
</p>
The first underscore is interpreted as markdown start of italic instead of latex subscript operator
Are you previewing with the GitHub parser? I can only duplicate your issue if I export with GitHub which I would expect. Looking at the documentation, it reads (emphasis added):
When using Python Markdown (the markdown parser), it is recommended to use something like the extension pymdownx.arithmatex as it ensures that math notation is preserved in the Markdown conversion process. GitHub (the github parser) does not have such an extension, so you might have to escape accordingly.
In this example, we will try to show a generalized approach that should work when using Python Markdown with pymdownx.arithmatex or GitHub (though preservation of math in GitHub may or may not be problematic).
GitHub has nothing to preserve LaTeX style math syntax. You are basically throwing LaTeX in and hoping it makes it through the parser.
So for clarity, if you want to push this through GitHub's parser, you need to escape anything that is problematic. This is not a bug and is frankly expected.
ok: $(a)\_n$
ok: $(a)\_{n}$
not ok: $(a)\_n$ $(a)\_{n}$
I'm not previewing with the GitHub parser. The above is the (partial) content of the HTML file as built with SublimeText's build command (CTRL-B)
My user config is the following:
{
"js": [
"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js",
"res://MarkdownPreview/js/math_config.js",
],
/*
"markdown_extensions": {
"pymdownx.arithmatex": {
"generic": true,
}
},
*/
}
and in the system config i see:
"parser": "markdown",
which makes me think i'm using the correct python-markdown
parser
If do add the arithmatex extension, the following partially works:
# section heading {#with-arithmatex-i-dont-work}
[without arithmatex i link fine]: #with-arithmatex-i-dont-work
ok: $(a)_n$
ok: $(a)_{n}$
only with arithmatex added i do work: $(a)_n$ $(a)_{n}$
[without arithmatex i link fine]
in the sense that all latex is rendered correctly, but the php markdown extra id attribute block is not parsed, therefore the link is not generated (without arithmatex it is parsed correctly, and the link is generated correctly)
Maybe the latter should go in a new different issue, my apologies for being off-topic
I need to emphasize, I am testing with Markdown Preview, with Arithmatex, following the documentation for adding MathJax support.
Here is the source and results of my tests:
# Test MathJax
ok: $(a)_n$
ok: $(a)_{n}$
not ok: $(a)_n$ $(a)_{n}$
{
"js": [
"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js",
"res://MarkdownPreview/js/math_config.js"
],
"markdown_extensions": [
// Python Markdown Extra with SuperFences.
// You can't include "extra" and "superfences"
// as "fenced_code" can not be included with "superfences",
// so we include the pieces separately.
"markdown.extensions.smart_strong",
"markdown.extensions.footnotes",
"markdown.extensions.attr_list",
"markdown.extensions.def_list",
"markdown.extensions.tables",
"markdown.extensions.abbr",
"markdown.extensions.codehilite",
// Extra's Markdown parsing in raw HTML cannot be
// included by itself, but "pymdownx" exposes it so we can.
"pymdownx.extrarawhtml",
// Arithmatex generic mode.
{
"pymdownx.arithmatex": {
"generic": true
}
},
// More default Python Markdown extensions
{
"markdown.extensions.toc":
{
"permalink": "\ue157"
}
},
"markdown.extensions.meta",
"markdown.extensions.sane_lists",
"markdown.extensions.smarty",
"markdown.extensions.wikilinks",
"markdown.extensions.admonition",
// PyMdown extensions that help give a GitHub-ish feel
"pymdownx.superfences", // Nested fences and UML support
{
"pymdownx.magiclink": { // Auto linkify URLs and email addresses
"repo_url_shortener": true,
"repo_url_shorthand": true
}
},
"pymdownx.tasklist", // Task lists
{
"pymdownx.tilde": { // Provide ~~delete~~
"subscript": false
}
},
{
"pymdownx.emoji": { // Provide GitHub's emojis
"emoji_index": {"!!python/name": "pymdownx.emoji.gemoji"},
"emoji_generator": {"!!python/name": "pymdownx.emoji.to_png"},
"alt": "short",
"options": {
"attributes": {
"align": "absmiddle",
"height": "20px",
"width": "20px"
},
"image_path": "https://assets-cdn.github.com/images/icons/emoji/unicode/",
"non_standard_image_path": "https://assets-cdn.github.com/images/icons/emoji/"
}
}
}
]
}
As for your second issue, I see no problems there either:
# section heading {#with-arithmatex-i-dont-work}
ok: $(a)_n$
ok: $(a)_{n}$
only with arithmatex added i do work: $(a)_n$ $(a)_{n}$
[without arithmatex i link fine]
You are doing something different, I don't know what it is, but I see no issue with Arithmatex.
i suspect there's something with my configs somewhere, i'll have to sort it out. thank you.
Closing as this does not appear to be reproducible.
Using the same config as detailed in https://facelessuser.github.io/MarkdownPreview/extras/