How can I preprocess the posts? #1888

Closed
opened this Issue Dec 28, 2013 · 8 comments

None yet

5 participants

 I would like to use LaTeX in my posts. LaTeX gets rendered by MathJax and it works fine. But Markdown parsers (kramdown, redkarpet) parse this \begin{align} m &= |r|\\ n &= |h|\\ \end{align}  and replace & by & and add e.g. CDATA. (I already filed an kramdown issue for that) When I write 
\begin{align} m &= |r|\\ n &= |h|\\ \end{align}
 it works fine. So that could be a quick fix. But I don't want to encapsulate my LaTeX in divs manually. I would rather like to preprocess every file in _posts. (How) can I do that? Is it possible to write a plugin for that? (I don't want to change anything else. Markdown should still get parsed by kramdown / redcarpet)
Owner
commented Dec 28, 2013
 Presently? You can't. I know there are folks who have gotten LaTeX to work in Jekyll, so this shouldn't block you.
closed this Dec 28, 2013
 Could you please give me an article how to get it work or names of "folks who have gotten LaTeX to work in Jekyll"? I only find variations of LaTeX Math Magic (from C. Woebker) which does not work for me.
Owner
commented Dec 28, 2013
 Maruku has it built-in.
 I've just tried it and encountered an issue of Maruku: bhollis/maruku#121
 kramdown doesn't seem to be the problem since plain kramdown without jekyll process the input correctly.
 @parkr: gettalong just showed to me that kramdown can't be the cause of the CDATA-issue (see link). Do you have any idea what could add the unnecessary CDATA? Here is the relevant part of my _posts/2013-11-15-word-error-rate-calculation.md: I've understood it after I saw this on the German Wikipedia: \begin{align} m &= |r|\\ n &= |h|\\ \end{align} \begin{align} D_{0, 0} &= 0\\ D_{i, 0} &= i, 1 \leq i \leq m\\ D_{0, j} &= j, 1 \leq j \leq n \end{align} $$\text{For } 1 \leq i\leq m, 1\leq j \leq n\\ D_{i, j} = \min \begin{cases} D_{i - 1, j - 1}&+ 0 \ {\rm if}\ u_i = v_j\\ D_{i - 1, j - 1}&+ 1 \ {\rm(Replacement)} \\ D_{i, j - 1}&+ 1 \ {\rm(Insertion)} \\ D_{i - 1, j}&+ 1 \ {\rm(Deletion)} \end{cases}$$  This is the part of _site/word-error-rate-calculation/index.html: I’ve understood it after I saw this on the German Wikipedia:   This is what cat 2013-11-15-word-error-rate-calculation.md| kramdown > output.html generates: I’ve understood it after I saw this on the German Wikipedia:   As you can see, something inserts . Do you have any idea what could be the cause of this bug?
 I've just fixed the problem for me by adding some Python preprocessing (done with Makefile and _preprocess.py, see my blog sources). This is by no means an ideal solution, but it almost solves the problem for me.
 @MartinThoma Kramdown + MathJax currently seems to work fine on your initial example: http://cirosantilli.github.io/jekyll-cheat/#math The usual slow MathJax rendering of course...
locked and limited conversation to collaborators Feb 27, 2017