You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is quite surprising—I imagined that this option would disable the feature entirely, letting me keep my $$s exactly as they were in the source. Is there any option to turn off this extension entirely?
This happens in the convert_math method in the HTML converter. The format_math call returns nil when this is disabled, so the if falls through to the second arm, which wraps the value in a <pre> block.
You are probably right. I have looked through the previous version of the conversion function and it didn't use <pre> or <span> there. So if the math_engine is turned off, it really should just output the input string.
@sampsyo So, looking at the code and the previous versions in more detail, it seems the best way to go forward when no math engine is selected, is to output LaTeX style inline/block delimiters, i.e. $ for inline and $$ for block, wrapped in <div> and <span>.
The <div> and <span> tags won't do anything to the styled output but allows us to preserve possibly set attributes and to assign class="kdmath" to allow for easy selection via CSS or Javascript.
So this input:
Some $$inline=math$$ is here
$$
And some
block math here
$$
would yield the following output:
<p>Some <spanclass="kdmath">$inline=math$</span> is here</p><divclass="kdmath">$$
And some
block math here
$$</div>
@gettalong, having the same syntax for inline and display math conflicts with usual math-writing use, where display math is usually inside paragraphs (text after starts in lowercase and all), and there is no way to do that with kramdown second guessing the writer's intentions. Please consider a math_engine that truly ignores everything between single and double dollars (dollars included), leaving all the config to a MathJax config block.
@9peppe Sorry, I don't understand your statement. Could you please be more specific to what kramdown should do? Best would be to include sample input, current output and preferred output.
You can already disable the math_engine by setting it to null. Then the output just consists of <div> plus $$ for block math elements and <span> plus $ for inline math elements.
@gettalong Well, if I do that, single dollars get rightly ignored. But double dollars do not.
Inputs like
This is a paragraph $$with a display equation inside\text{.}$$
and
This is a paragraph.
$$followed by display math in another paragraph\text{.}$$
Give outputs like:
<p>This is a paragraph <span class="kdmath">$with a display equation inside\text{.}$</span></p>
and
<p>This is a paragraph.</p>
<div class="kdmath">$$followed by display math in another paragraph\text{.}$$</div>
I have no problems with the second example, but in the first my equation becomes an inline equation, when I expected it to be a display math piece inside <p>, or at least a raw source piece with both dollars left alone. Like:
<p>This is a paragraph $$with a display equation inside\text{.}$$</p>
The main problem is that while I can use single and double dollars to let MathJax decide what to do, kramdown converts all double-dollar display math inside paragraphs to single-dollar inline math, even with math_engine set to null or nil.
kramdown distinguishes between inline and block elements. Block elements like math blocks cannot be used as inline elements. This means that inside a paragraph math elements are treated as inline math and otherwise as block elements.
So what you want is not directly possible with kramdown. However, you can tell kramdown to ignore dollar signs by escaping them. Then it will not treat the dollar signs as the start of a math element.
Escaping dollar signs kinda works, but I am worried the underscores in the equation contents might end up interpreted as emphasis, and other conflicts like that (and every authoring tool not expecting escaped dollars to mean anything). Isn't there a way to tell kramdown to treat dollars, double dollars, and everything in between like raw text?
Please remember that we are talking about kramdown, not MathJax here. In kramdown there is a difference between block and span elements. And therefore there are two different forms of math elements, one block math element and one span math element. And only the span math element may be used inside a paragraph. This has nothing to do with how MathJax sees things.
You can use the nomarkdown extension to tell kramdown to not parse part of the source as kramdown source but raw text.
Modifying the parsing behaviour of kramdown is not possible and will not be implemented. If you want to change how kramdown parses things, you can easily subclass the parser and modify it. See the GFM or Markdown parser implementations for that.
Activity
Turn off Kramdown's math engine
gettalong commentedon May 28, 2016
You are probably right. I have looked through the previous version of the conversion function and it didn't use
<pre>or<span>there. So if the math_engine is turned off, it really should just output the input string.Thanks for letting me know!
gettalong commentedon Aug 6, 2016
@sampsyo So, looking at the code and the previous versions in more detail, it seems the best way to go forward when no math engine is selected, is to output LaTeX style inline/block delimiters, i.e.
$for inline and$$for block, wrapped in<div>and<span>.The
<div>and<span>tags won't do anything to the styled output but allows us to preserve possibly set attributes and to assignclass="kdmath"to allow for easy selection via CSS or Javascript.So this input:
would yield the following output:
Would that satisfy your needs?
sampsyo commentedon Aug 6, 2016
Absolutely! Thanks for looking into it.
gettalong commentedon Aug 6, 2016
Okay, then I will do that.
gettalong commentedon Aug 7, 2016
Will be in the next version.
Fixed HTML output for math elements when no math engine is set
sampsyo commentedon Aug 7, 2016
Woohoo! Thank you!
AvverbioPronome commentedon Nov 9, 2017
@gettalong, having the same syntax for inline and display math conflicts with usual math-writing use, where display math is usually inside paragraphs (text after starts in lowercase and all), and there is no way to do that with kramdown second guessing the writer's intentions. Please consider a math_engine that truly ignores everything between single and double dollars (dollars included), leaving all the config to a MathJax config block.
gettalong commentedon Nov 9, 2017
@9peppe Sorry, I don't understand your statement. Could you please be more specific to what kramdown should do? Best would be to include sample input, current output and preferred output.
You can already disable the math_engine by setting it to null. Then the output just consists of
<div>plus$$for block math elements and<span>plus$for inline math elements.AvverbioPronome commentedon Nov 9, 2017
@gettalong Well, if I do that, single dollars get rightly ignored. But double dollars do not.
Inputs like
and
Give outputs like:
and
I have no problems with the second example, but in the first my equation becomes an inline equation, when I expected it to be a display math piece inside
<p>, or at least a raw source piece with both dollars left alone. Like:The main problem is that while I can use single and double dollars to let MathJax decide what to do, kramdown converts all double-dollar display math inside paragraphs to single-dollar inline math, even with math_engine set to null or nil.
gettalong commentedon Nov 9, 2017
kramdown distinguishes between inline and block elements. Block elements like math blocks cannot be used as inline elements. This means that inside a paragraph math elements are treated as inline math and otherwise as block elements.
So what you want is not directly possible with kramdown. However, you can tell kramdown to ignore dollar signs by escaping them. Then it will not treat the dollar signs as the start of a math element.
AvverbioPronome commentedon Nov 9, 2017
Uhm, display math isn't really a block element according to MathJax people, and is traditionally used inside paragraphs.
Escaping dollar signs kinda works, but I am worried the underscores in the equation contents might end up interpreted as emphasis, and other conflicts like that (and every authoring tool not expecting escaped dollars to mean anything). Isn't there a way to tell kramdown to treat dollars, double dollars, and everything in between like raw text?
gettalong commentedon Nov 9, 2017
Please remember that we are talking about kramdown, not MathJax here. In kramdown there is a difference between block and span elements. And therefore there are two different forms of math elements, one block math element and one span math element. And only the span math element may be used inside a paragraph. This has nothing to do with how MathJax sees things.
You can use the nomarkdown extension to tell kramdown to not parse part of the source as kramdown source but raw text.
Modifying the parsing behaviour of kramdown is not possible and will not be implemented. If you want to change how kramdown parses things, you can easily subclass the parser and modify it. See the GFM or Markdown parser implementations for that.
AvverbioPronome commentedon Nov 10, 2017
Ok. I found a solution that might work for me. I'll use the second group of delimiters: