Peter Jipsen's original implementation of asciimath has a rather large table of built-in symbols, but he also provided a couple of API hooks for adding to it, e.g.:
<script type="text/javascript">newcommand("mysymbol","\u210F")</script>
The more common problem I've encountered is that there are symbols that I don't want and that conflict with what I'm trying to do, e.g., he has a unary function "bar" for putting a bar over a symbol, which causes problems when I want to use the symbol hbar for the reduced Planck constant. Although he doesn't seem to have anticipated this, there are ways of getting around it. What I've been doing so far is to maintain my own private version of ASCIIMathML.js, with some symbols commented out. Now that I've gotten around to reading his code more carefully, it looks like there would also have been a cleaner way, which is that at run-time you simply delete entries from his global hash table AMsymbols.
However, I would like my application (
http://www.lightandmatter.com/spotter/spotter.html ) to support other browsers besides firefox, so I'd like to switch to mathjax's implementation of asciimath. This seems to raise some problems, which were discussed here in 2011:
https://groups.google.com/d/msg/mathjax-users/14yPzgrYjYw/Xncjr4uXeW0JBased on a casual glance at the code on github, it looks like the situation is still probably the same as it was then. Two methods were discussed and attempted for incorporating the asciimath code into mathjax without polluting the global namespace: putting all the code inside a closure, or making it into an object. Everyone seemed to agree that the object method was preferable, but difficulties were encountered with making it work, so the closure method was used. If I'm understanding correctly, then this makes it impossible to use asciimath's two API hooks for adding symbols, and it also makes it impossible to delete entries from AMsymbols at run-time.
From previous discussion, it looks to me like there are other users who may also see this as a problem, e.g., College of the Redwoods, who are using asciimath in their OptiMath project.
First off, could anyone tell me whether the above analysis seems incorrect or out of date?
Assuming I've got it right, I'm thinking that the way to go would be to augment mathjax's existing configuration system for the asciimath parser, so that one could do something like this:
MathJax.Hub.Config({
AsciiMath: {
deleteSymbols: ["bar"],
addSymbols: [{input:"acos", tag:"mo", output:"acos", tex:null, ttype:UNARY, func:true}]
}
});
If this sounds like a good idea, then I'd be interested in coding this up and submitting it as a patch.