Open utsekaj42 opened 6 years ago
Regular expressions are only able to recognise regular languages. This is a big limitation when working with any language which may contain recursive structures.
We will implement proper parsing in the next major version, so I'm hesitant to spend time fixing this now.
It's probably best for you to continue with just including the newcommands for now.
newcommands parsing is broken as any newcommand replacement that is applied to text containing brackets with stop at the first closing bracket, e.g.
will result in
I believe is due to the limitations of the regex, but I'm not very competent with regex. I believe what is required is to some how match the brackets, further for nested newcommands it is unclear how many levels should be evaluated. In html, latex, and ipynb (as of hplgit/doconce/pull/136 it is fine to leave newcommands, thus it is question of how to handle this for other formats.
I had started on a quick fix for non-nested newcommands with only 1 argument, which is
and an example mirror
substitute
inexpand_newcommands.py
I can continue with this line of work, but I think just including the newcommands in ipython, latex, and html is fine for my uses of doconce. Further I'm not sure if this is the right path to go down, but perhaps it could help with issues others have.