A Working Mathematician’s Guide to Parsing(jeremykun.com)
jeremykun.com
A Working Mathematician’s Guide to Parsing
https://jeremykun.com/2019/04/20/a-working-mathematicians-guide-to-parsing/
6 comments
My go-to library for parsing in Python is https://github.com/pyparsing/pyparsing, a https://en.wikipedia.org/wiki/Parsing_expression_grammar -based https://en.wikipedia.org/wiki/Parser_combinator library. I generally find it much easier to get my head around parser combinators than parser generators.
As the author says:
> because the parser generator knows about all patterns you want to match in advance, it will match longer terminals before shorter—more ambiguous—terminals
If you don't mind manually ordering your choices in your alt operators, then PEG and parser combinators are OK.
Oh, and you often need to restructure your grammar to avoid left recursion.
> because the parser generator knows about all patterns you want to match in advance, it will match longer terminals before shorter—more ambiguous—terminals
If you don't mind manually ordering your choices in your alt operators, then PEG and parser combinators are OK.
Oh, and you often need to restructure your grammar to avoid left recursion.
Just use pandoc[1] — assuming the blog platform accepts a well known markup language.
[1] https://pandoc.org
[1] https://pandoc.org
For converting LaTex to WordPress, I'm a fan of https://lucatrevisan.wordpress.com/latex-to-wordpress/
theoh(4)
Sadly, he don't understand what LaTeX is and what TeX is. And $$ is a TeX macro, should not be used in LaTeX, the are much better math display environments.
Regardless, this is a very common way of writing mathematics in LaTeX, and so will need to be addressed in any solution to this problem.
Unless our hero mathematician is writing, like, several blog posts a day, using tools like parser generators and writing your grammar in BNF and the like is WAY overkill. Just use search/replace and manually fix it up. Or, like, maybe some kind of editor macro/multiple cursor nonsense in your fully-featured text editor. If she really wants to go nuts, she should write a four-line python script to do the search/replace a tiny bit smarter. Fixing it up with some manual oversight takes like three minutes per blog post at most, it's not worth trying to automate fully.
This is one of them "killing an ant with a nuclear bomb" situations.