Skip to content

Convert MathSpan to MathML using e.g. camoy/amath or gjtorikian/mtex2MML #15

@aslakr

Description

@aslakr

For html (and odf and epub) it would be nice to be able to produce MathML as mentioned in fletcher/peg-multimarkdown#39

I.e. as an option, instead of wrapping TeX math for MathJax in

MultiMarkdown-5/src/html.c

Lines 334 to 352 in f2a0b9c

case MATHSPAN:
temp = strdup(n->str);
if (temp[0] == '$') {
temp[strlen(temp)-1] = '\0';
if (temp[1] == '$') {
temp[strlen(temp)-1] = '\0';
g_string_append_printf(out, "<span class=\"math\">\\[%s\\]</span>",&temp[2]);
} else {
g_string_append_printf(out, "<span class=\"math\">\\(%s\\)</span>",&temp[1]);
}
} else if (temp[strlen(temp) - 1] == ']') {
temp[strlen(temp) - 3] = '\0';
g_string_append_printf(out, "<span class=\"math\">%s\\]</span>",temp);
} else {
temp[strlen(temp) - 3] = '\0';
g_string_append_printf(out, "<span class=\"math\">%s\\)</span>",temp);
}
free(temp);
break;
convert this to MathML.

In the original issue blahtex is mentioned, but doesn’t seem very active.

One very simple alternative might be to use amath, a peg-based AsciiMath to MathML converter. It’s only AsciiMath, so it might not be a good alternative for text that are based on TeX-like syntax, but the amath c/peg-code seem rather readable.

mtex2MML, which is a active fork of itex2MML, might be another alternative. It tries to be compatible with MathJax.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions