Closed vanabel closed 11 years ago
Hi @vanabel Yes, that's done by markdown, you can't avoid that. Are you still disabling MathJax extension before exporting to html? If so, that's not a good practice.
I don't want to use your method as:
If in any case, I have some misunderstanding, then please tell me, I really fell inconvenient to disable and resume mathjax angain and agian.
Please have a look into this. If you export the HTML output, then you will have the MathJax_Display
div block AND the MathJax-Element
script block. So you have two options:
MathJax_Display
as it is and eventually apply some css on it, but that's not what you want.MathJax_Display
from the MathJax-Element
script block by running MathJax again on your blog.With the second option, you can modify from your editor the script block which contains the raw latex code. MathJax will recreate MathJax_Display
according to it. You can also modify the latex code in StackEdit and click the "publish button" in the navigation bar to update your blog in one click.
You mean you will work this(the second option is attractive!)? thks a lot!!
That's already implemented. The HTML output contains both MathJax_Display
div block and MathJax-Element
script block.
Those are 2 options for your blog.
I don't get it, did you mean that I can keep only the Mathjax-Element
block in the final export? How to do this?
No, that's not what I meant. But you can do that as a 3rd option. To do that, you need to use the template output.
In Settings->Publish->Template, you can customize the template output. For instance you can modify the documentHTML variable to remove the MathJax
, MathJax_Display
, MathJax_Preview
elements like that:
<%
var output = $("<div>").html(documentHTML);
output.find(".MathJax, .MathJax_Display, .MathJax_Preview").remove();
print(output.html());
%>
You can even revert the MathJax-Element
script blocks into Tex with delimiters like that:
<%
var output = $("<div>").html(documentHTML);
output.find(".MathJax, .MathJax_Display, .MathJax_Preview").remove();
output.find('script[type="math/tex"]').each(function() { $(this).replaceWith('\\(' + this.innerHTML + '\\)'); });
output.find('script[type="math/tex; mode=display"]').each(function() { $(this).replaceWith('\\[' + this.innerHTML + '\\]'); });
print(output.html());
%>
Then you need to use Template
as output when publishing.
It's awesome, fantastic, that's so great!!
I only need to add two more classes in your 2nd script, i.e., .MathJax_SVG
and .MathJax_SVG_Display
, then the export by template will be what I exact like. Thanks a lot!!!
I recommend to make the preview HTML code only preserve the LaTeX code, just as I can configure in template, is there somewhere I can configure it for HTML code?
No, but I can add a configuration in the HTML code extension...
Added template configuration in the extension settings.
@benweet May I point out that your default configuration of display math have some typo? The \[
and \]
in display math should be \\[
and \\]
respectively.
Yes, you're right! I just changed the default settings... Thank you for your point.
I find that Html code view is not only preview the latex code, even when I setting it in template!
Can you give more detail?
I want to set the template output as
<%
var output = $("<div>").html(documentHTML);
output.find(".MathJax, .MathJax_Display, .MathJax_Preview").remove();
output.find('script[type="math/tex"]').each(function() { $(this).replaceWith('\\(' + this.innerHTML + '\\)'); });
output.find('script[type="math/tex; mode=display"]').each(function() { $(this).replaceWith('\\[' + this.innerHTML + '\\]'); });
print(output.html());
%>
such that the exported html file is not include the rendered latex code, but the original input form of latex.
When I use mathjax to render math formula, in which
\\
means new line, but when I export the markdown doc to html, the\\
has been transformed into\
, I think this is done by markdown automatically?How to fix it?