My mathematics notes present an interesting challenge. For MathML the AsciiDoc user guide recommends using double-dollar passthroughs around equations, but this implies at least three characters are required to delimit every equation, since ASCIIMathML or equivalent itself needs at least one character.

I'd like to have something like:

= Introduction =to just work, so I settled on the following solution. I use itex2MML because

Let $E: Y^2 = X^3 + a X + b$ be an elliptic curve.

- My old-fashioned, superstitious, purist side prefers bare-bones JavaScript-free static documents.
- Familiarity.
- It has a handy syntax for equations in display mode, i.e. equations in their own center-justified paragraphs as seen in mathematics texts. An invaluable feature, as I can't figure out how to center a paragraph with AsciiDoc.

Write these rules to a file named "macros":

[miscellaneous]The first is optional. I just abhor the CR LF abomination.

newline=\n

[blockdef-passthrough]

delimiter=^@{4,}$

subs=none

Then feed the source through these commands to produce the final product, which should be a file with an .xhtml extension:

sed 's/\$\([^$]*\)\$/+++$\1$+++/g' \The above gobbledygook [careful with some of those newlines; Blogger may have put extra cuts in my lines] performs the following:

| sed '/\\\[/i@@@@' \

| sed '/\\\]/a@@@@' \

| asciidoc -b xhtml11 -f macros - \

| itex2MML | sed '/<!DOCTYPE/c \

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"\

"http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd" [\

<!ENTITY mathml "http://www.w3.org/1998/Math/MathML"> ]>

/xhtml11.dtd/d'

- Put the "+++" AsciiDoc inline passthrough around equations delimited by "$".
- Surround display-mode equations, delimited by "\[" and "\]", with our newly defined "@@@@" block passthrough macro.
- Put the resulting mess through AsciiDoc, which converts everything but our equations to an HTML 1.1 document.
- Run itex2MML to convert the equations to MathML.
- Fix the DOCTYPE declaration.

- Inline equations must be closed on the line they are opened.
- Expressions such as "$i$th" must be written as "$i$#th#", since AsciiDoc "+++" quotes are constrained.