MarkDownPad 中不能即時顯示數學公式,MathJax方案+F6
Pencil and Engine
Make to-do lists, write code, power to the people
MathJax with Markdownpad 2
with 5 comments
As I said before, Markdownpad 2 Rules. One thing that was missing was math markup of any kind. I take a lot of school notes and find myself wishing I could type out math notation instead of needing to resort to pen and paper. A post on the MarkdownPad 2 forums said using MathJax was a possibility so I looked into and decided to write up a little guide.
Step 1 of 1
Add MathJax CDN to the Head section of the generated HTML, per the MathJax documentation. The HTML Head section is under Tools > Options > Advanced > HTML Head Editor in MarkdownPad 2.
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" ></script>
And that’s it! I can now add TeX or MathML to my markdown docs and get MathJax-formatted output in the resulting HTML documents.
The only “gotcha” that I found was that the default delimiters for inline TeX or LaTex are ( and ), which MarkdownPad 2 will eat as an escape sequence, so we need to escape the slashes as so: \( and\).
Example
When I type the following into MarkdownPad 2:
When \\( a \ne 0 \\), there are two solutions to \\(ax^2 + bx + c = 0\\) and they are:
$$ x = {-b \pm \sqrt{b^2-4ac} \over 2a} $$
It should appear as below once rendered in a browser (F6 to preview):
When
WordPress
WordPress.com doesn’t support a hot-linked JavaScript library, or any JavaScript, so we’ll need to manually convert our delimiters to the WordPress.com latex syntax. Wordpress.org users can install a MathJax plugin instead and hopefully avoid these manual updates.
Conclusion
The only thing I’m missing is a live preview from within MarkdownPad 2, but I’m willing to live without that as long as I can turn in math homework without picking up a pencil. Now I’ve got a whole boatload of TeX/LaTex syntax to learn!