Markdown and Mathematics
Michel Fortin
michel.fortin at michelf.com
Wed Apr 7 20:38:52 EDT 2004
John Gruber wrote:
> The math stuff doesn't belong in Markdown itself. Maybe, possibly,
> perhaps, Markdown could support superscripts using something like
> `x^2`, but not something as complex as full-blown math markup.
> (Michel, I'm guessing you agree with this.)
That's exactly the way I see it: an external processor. What I've done
currently is a modified Markdown program to expriment with math
inclusion, but be assured I will not be releasing it integrated with
Markdown. This is better suited for an external program.
> The issue here is not Markdown and Mathematics. It's Markdown and
> expansion. What's needed, and I've thought about this for a while,
> is a generic escape sequence for expansion.
>
> [...]
>
> What I'm suggesting is that Markdown, by itself, simply define one
> set of delimiters, and that anything appearing between those
> delimiters would be ignored.
Writing about math is just like writing about code: you insert math
snippets everywhere in what you say. As an example:
Suppose {ax^2+bx+c=0} and {a!=0}. We first divide by {a} to
get {x^2+b/ax+c/a=0}.
(grabbed from
<http://www1.chapman.edu/~jipsen/mathml/asciimathdemo.html>)
What you just read is very readable because it's using simple
delimiters. Making the text readable is exactly what makes Markdown
great and I think that's important. However, as we said, if it's
implemented as another program that parse the text after markdown made
it HTML, then this syntax could be acceptable since only people that
care will have it installed.
That said, I think it's also very important to have some more
sophisticated expansion rules too.
[more on expansion below]
> That would mean that custom expansions could be built on top of
> Markdown, with the custom bits going inside those delimiters. You
> might write "Markdown Plus Math". Someone else might write "Markdown
> Plus Foo." The point is, you wouldn't have to rewrite the core
> Markdown parts; just the Foo, which users would include between the
> `{$` and `$}` delimiters.
I agree about the Markdown + Math name, it's great because it puts a
separation between the two tools even if they are used together.
Jelks Cabaniss wrote:
> Whatever they end up being, you'll probably want to include the
> "notation"
> along with the delimiters, something like
>
> {$mathml: ... Math expression ... $}
> {$latex: ... line noise ... $}
I like that idea. It is also my opinion that it's important to include
extension's name in the syntax, or otherwise there will be conflict the
minute someone want to use more than one extension.
But there is another potential problem: what if someone write this in a
code block? In order to respect the code block, we could ask that every
extensions parse the HTML and ignore what is inside `code`, `pre` and
some other tags. That's a lot of parsing if you have many extensions.
Or maybe Markdown could accept *plugins*. That means you put the
plugins in a special directory. When parsing, if Markdown encounter a
`{$latex: ...$}` block, it looks for a file named "latex" in that
directory and process the output using that program. If the plugin is
not found, Markdown removes the delimiters and leave only the content.
That way a casual user that does not write about math often can still
include some math when it want it using this rule.
Let's say I want to write an equation, I just have to write {$math:
a^2+b^2=c^2 $}.
To write about chemistry, I write: {$chemistry: 2H + CO + 2O2 -> H2CO3
$}.
And to write about music: {$music: ... how could I write music in
text? ... $}.
becomes this if appropriate plugins cannot be found:
Let's say I want to write an equation, I just have to write
a^2+b^2=c^2.
To write about chemistry, I write: 2H + CO + 2O2 -> H2CO3.
And to write about music: ... how could I write music in text? ....
Michel Fortin
michel.fortin at michelf.com
http://www.michelf.com/
More information about the Markdown-discuss
mailing list