asciimath / asciimathml

A new home for asciimathml
http://asciimath.org/
MIT License
958 stars 184 forks source link

Separate DOM & init from text processing in asciimath-based/ASCIIMathTeXImg.js #48

Open rileylark opened 8 years ago

rileylark commented 8 years ago

Ahoy! We are going to try to use your text processing functions in https://github.com/asciimath/asciimathml/blob/master/asciimath-based/ASCIIMathTeXImg.js in a few different environments, including in a DOMless node.js app. To that end, we're going to separate out the DOM-related components (which we don't need) and the auto-loading code.

Would you like a PR back with these changes, or does this break your API too much? We could try to preserve the API by making the default behavior the same, but I imagine we will at least have to force the user to manually call initialization code (maybe that's the user's responsibility anyway?).

Thanks again for an amazing library! We are looking forward to using it.

drlippman commented 8 years ago

Interesting.  I think I used DOM in the current just because it was what was used in the original asciimathml script and I was trying to keep it as consistent as possible. For a DOM-less approach, it might me helpful to look at the php version of the script. I'd welcome a  PR, but maybe as a separate file rather than as a modification of the existing script, at least for now. On Mar 22, 2016 11:05 AM, Riley Eynon-Lynch notifications@github.com wrote:Ahoy! We are going to try to use your text processing functions in https://github.com/asciimath/asciimathml/blob/master/asciimath-based/ASCIIMathTeXImg.js in a few different environments, including in a DOMless node.js app. To that end, we're going to separate out the DOM-related components (which we don't need) and the auto-loading code.

Would you like a PR back with these changes, or does this break your API too much? We could try to preserve the API by making the default behavior the same, but I imagine we will at least have to force the user to manually call initialization code (maybe that's the user's responsibility anyway?).

Thanks again for an amazing library! We are looking forward to using it.

—You are receiving this because you are subscribed to this thread.Reply to this email directly or view it on GitHub

rileylark commented 8 years ago

This is the kind of factoring I have in mind: https://github.com/peardeck/asciimathml/commit/44b5d8f80004a844216234760439f83cce8c4d80

I didn't make a PR because the api changed so much - in this version, you call e.g.:

const AMT = AMTinit(config);
string latex = AMT.parseAMtoTeX('b^2-4ac');

and there are no global variables exposed except AMTinit. For us that'll be more convenient, but we'll probably go a step further and get it ready to be consumed by a module system. I'd be happy to polish this more if you like, or reimplement the original API using this script, but for that I'd need to add a build system of some sort, which maybe you don't want to complicate things with yet.

Either way, thanks a bunch for the amazing interface - this will make a much nicer experience for our teachers than making them type latex.

drlippman commented 8 years ago

This seems to be consistent with the more common and modern approach to things nowadays, and I'm sure there are plenty of people who would like something like this. It'd be a nice addition to the collection if you want to put it together and share it.

On Wednesday, March 23, 2016 8:14 PM, Riley Eynon-Lynch <notifications@github.com> wrote:

This is the kind of factoring I have in mind: peardeck@44b5d8fI didn't make a PR because the api changed so much - in this version, you call e.g.:const AMT = AMTinit(config); string latex = AMT.parseAMtoTeX('b^2-4ac'); and there are no global variables exposed except AMTinit. For us that'll be more convenient, but we'll probably go a step further and get it ready to be consumed by a module system. I'd be happy to polish this more if you like, or reimplement the original API using this script, but for that I'd need to add a build system of some sort, which maybe you don't want to complicate things with yet.Either way, thanks a bunch for the amazing interface - this will make a much nicer experience for our teachers than making them type latex.— You are receiving this because you commented. Reply to this email directly or view it on GitHub

HughGrovesArup commented 5 years ago

I'd like to just use the text processing parts of ASCIIMathML.js in a similar situation i.e. I would like to pass in an AsciiMath string and be returned a MathML string. However, I'm really struggling on what parts of the code I need to modify to allow this - has anyone done this before?

drlippman commented 5 years ago

Since AMparseMath generates a MathML node, perhaps you could use node.outerHTML on the result to get it as a string? I know that's slightly hackish, but would probably be the easiest solution.