Blog 1

Random Talk on Random Thoughts

A Quick Markdown Syntax Error Detection for Writing MathJax Equations in Octopress Posts (2)

| Comments |


In the previous post in this series, I’ve listed a number of steps and included a group of Vim editor commands for screening out kramdown syntax errors. This is useful for Octopress posts with ordinary contents. However, if one wants to write some math equations using MathJax, then one will encounter great difficulties.1

Even though the kramdown command line utility enables users to instantly convert code across different formats, and a web browser enables them to notice any syntax error, these tools just help them to find the mistakes, but not the solution. In the cited post in the first footnote, I spent hours to realise that exactly eight ‘\’s were needed to break the current line in MathJax. After that, I feel that using eight ‘\’s and adding a ‘\’ before a ‘_’ in MathJax equations interrupt my thinking.


Reading an old post on removing Linux kernels on Ubuntu, I remembered that the markdown attribute in <div markdown="1"> enabled kramdown to interpret the Markdown code within the <div> block. Therefore, I tried to surround the HTML code for an inline math expression with a <span> tag. Unluckily, unlike <div> blocks, the surrounded code was still interpreted by kramdown.

After that, I read the syntax documentation. It claimed that setting markdown="0" disabled parsing of contents inside the tag except for <span> tags.2 Though the manual says that it’s impossible, I still inserted it into the <span> tag which surrounded the code for the MathJax math expression, because it didn’t take much time to see the result: the inline MathJax expression could be successfully displayed.3

  1. For example, it’s troublesome to start a new line

  2. See the first bullet point of the section “HTML Spans” in kramdown’s syntax documentation

  3. See A Group of 689 Elements and its source code in Blog 1 at commit af4f216 for a working example.