-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Feature: Raw pass-through of math for MathJax / KaTeX etc. #799
Conversation
Perhaps it would be nice to allow more fine-grained control by changing the option |
The commit has been updated to use the above discussed more flexible variant. Since the option
Expected HTML:
|
If we get this merged, it would be nice to add marked to this list http://docs.mathjax.org/en/latest/misc/mathjax-in-use.html. |
looks like a cool addition! any objections for merging it? UPD: ah, I see: f0fd264 |
It looks good anyway. Any updates, BTW? |
@wookayin I found that markdown-here forked this project and it support LaTeX. Then I copied his marked.js, then
Usage: ;) |
If you want to keep it offline, you should use this PR. |
@ViktorQvarfordt Great work! Since you are already parsing the input, do you think you could return the delimeters and the contained TeX separately? This would allow for easy renderers like: renderer.math = function (begin, tex, end) {
if ( begin === "$" || begin === "\\(" )
return katex.renderToString(tex, {displayMode: false});
else if ( begin === "$$" || begin === "\\[" )
return katex.renderToString(tex, {displayMode: true});
else
return katex.renderToString(begin + tex + end, {displayMode: true});
}
} without further parsing. |
That's a cool idea! I've updated the PR to reflect this. But I'm lazy and ignored extracting the Note: I also rebased this PR on top of the latest chjj/marked. |
Closing due to merge conflicts - flagging with #936 for future reference. |
Only a partial solution to the use case described in this PR, but if you're doing server-side rendering of Math (for instance using KaTeX), why don't you:
|
Katex has been something people have been asking for for a while so I just created an extension and published it to npm. |
@Demi1024 Underscores around text are supposed to turn into If that is not what you are referring to, could you be more specific, or create a new issue describing your problem? |
I don't want to break the syntax of Markdown, but is it possible to skip the parsing of underscores when inserting mathematical formulas in Markdown? Parsing underscores as emphasis will cause the conversion of mathematical formulas to fail, as shown in the image below. Is it possible to output mathematical formulas as they are without any conversion, for example, when encountering segments that start and end with |
Yes, if you use https://www.npmjs.com/package/marked-katex-extension. |
Or if you don't want to use katex you can also use code blocks or html blocks, both of which won't convert the contents with markdown. <span>
_test_
</span> produces: _test_ |
Add an option
math
which, when enabled, disables all processing of math wrapped in$..$
,\(..\)
,\[..\]
,$$..$$
or\begin{}..\end{}
. For use with MathJax / KaTeX etc.Similar to #722 and #723, but better (in my opinion).