[IPython-dev] markdown tangential discussion
aron at ahmadia.net
Fri Aug 24 09:42:16 EDT 2012
> I hate to be a downer, but having implemented latex + wiki several times
> jsMath+TiddlyWiki, etc), I can tell you that this solution is a hack that
> fail eventually. For that matter, it appears that Pagedown itself is a
> too, that will have bad edge cases. (In other words it is a pile of
> successively applied regular expressions, in which one hopes there are not
> overlapping cases -- rather than a grammar which has no overlapping cases
The original MarkDown was implemented in Perl and was almost certainly a
pile of successively applied regular expressions. I agree that we get much
nicer stuff with a proper parser, but somebody has to support it. I don't
think I have anything against Markdown-js if the IPython developers decide
to switch to it (or somebody implements it in the notebook).
The correct solution to this problem is therefore to use a true grammar that
> involves an escape. Since latex uses the backslash its escape character,
> and so
> does markdown, this seems naively easy, but one must hook into to
> processing stream, and call MathJax from it, rather than invoking two
> independent processing sessions (markdown followed by MathJax or v/v).
This isn't that hard. The document's grammar is in Markdown or LaTeX
blocks. The grammar becomes LaTeX whenever we enter a math-delimited
region. Markdown is NOT allowed in a LaTeX region, and LaTeX is NOT
allowed in a Markdown region. The important thing is to properly decompose
the text into Markdown-formatted text and LaTeX-formated text, and hide the
LaTeX from the Markdown processor (MathJaX confines itself to its delimited
The way SE does it (which I shamelessly copied), is to pull out all blocks
that are either delimited with classic TeX delimiters or contain anything
between $ $ that is not in a code block. This effectively reserves all of
the major TeX environment delimiters within Markdown blocks ($$, \[,
\begin, etc., ...), which I think most people can live with.
> Markdown-js: https://github.com/evilstreak/markdown-js appears to be a
> better written parser than Pagedown, in which inserting an extra rule for
> and calling MathJax would be straightforward (disabling MathJax's document
I don't see anything wrong with this approach.
> Correct me if I'm wrong, but this penchant for writing functions that
> classes that everyone is using basically makes it impossible to use
> to extend a Markdown parser. (I don't understand why iPython,
> Markdown-js, and
> everyone in the known universe has decided this is The Way to write
> -- maybe someone can enlighten me)
You can modify a class or object's function after it has been instantiated
without inheriting. I think this is a separate discussion, though.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-dev