News for hackers. Stuff that matters.
Re:A Working Mathematician’s Guide to Parsing by OskarS on Friday May 03, 2019 @06:51AM (#19817194)
> Our hero, a mathematician, is writing notes in LaTeX and needs to convert it to a format that her blog platform accepts. She’s used to using dollar sign delimiters for math mode, but her blog requires \( \) and \[ \].

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.

Re:A Working Mathematician’s Guide to Parsing by acprog42 on Friday May 03, 2019 @09:42AM (#19818333)
But killing an ant with a nuclear bomb is moar funnier! Don't stop the fun!
Re:A Working Mathematician’s Guide to Parsing by ngcc_hk on Friday May 03, 2019 @07:12PM (#19823080)
I think he use vim. Last paragraph. This is click bait. Hooked myself.
Re:A Working Mathematician’s Guide to Parsing by delinka on Friday May 03, 2019 @02:17PM (#19820858)
`sed` is your friend
Re:A Working Mathematician’s Guide to Parsing by RiversHaveWings on Friday May 03, 2019 @05:47AM (#19816895)
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.
Re:A Working Mathematician’s Guide to Parsing by vorg on Friday May 03, 2019 @12:28PM (#19819791)
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.

Re:A Working Mathematician’s Guide to Parsing by satyenr on Friday May 03, 2019 @02:30PM (#19820987)
Just use pandoc[1] — assuming the blog platform accepts a well known markup language.

[1] https://pandoc.org

Re:A Working Mathematician’s Guide to Parsing by kevinventullo on Friday May 03, 2019 @08:33AM (#19817801)
For converting LaTex to WordPress, I'm a fan of https://lucatrevisan.wordpress.com/latex-to-wordpress/
[dead]
Re:A Working Mathematician’s Guide to Parsing by mlevental on Friday May 03, 2019 @08:56AM (#19817956)
people are downvoting you because that's one the saltiest opinions I've ever seen on hn. the guy is a narcissist because he writes a blog and other people post it? how does make that sense in your head? or do you think that the people that post links to his blog are shills? not to mention his pedagogy is excellent - these blog posts (which are not his primers) are meant to be introductory and cursory.
Re:A Working Mathematician’s Guide to Parsing by pmyteh on Friday May 03, 2019 @06:17AM (#19817036)
I can't see that him being "just" a postdoc has very much to do with anything, especially when covering stuff like this which is foundational rather than cutting-edge.
Re:A Working Mathematician’s Guide to Parsing by theoh on Friday May 03, 2019 @06:25AM (#19817065)
The "just" was supposed to apply to the whole self-aggrandizing trip.

My point is that there are a lot of people with math PhDs, but Kun is in a small unenviable minority that is driven to engage in self-promotion via all these blog post "primers", which of very dubious pedagogical quality.

Re:A Working Mathematician’s Guide to Parsing by joppy on Friday May 03, 2019 @07:30AM (#19817400)
“Oh no, someone is attempting to teach, how dare they!” is what this reads like. Writing articles like this is good for the author, in terms of finding new ways to explain things, and clarify knowledge they already had. The writing style of this author in particular is quite engaging for myself and (I would assume) many others.
Re:A Working Mathematician’s Guide to Parsing by algorithmsRcool on Friday May 03, 2019 @12:30PM (#19819816)
I enjoy his content and I have found some of his explanations novel and enlightening.

I don't know why him spending untold hours producing detailed content is a bad thing. Even if it is for self-promotion.

Re:A Working Mathematician’s Guide to Parsing by sigstoat on Friday May 03, 2019 @11:18AM (#19819169)
yes, you are.
Re:A Working Mathematician’s Guide to Parsing by foldr on Friday May 03, 2019 @06:57AM (#19817223)
He's not a postdoc, though?
Re:A Working Mathematician’s Guide to Parsing by theoh on Friday May 03, 2019 @07:30AM (#19817401)
Presumably you understand what I'm saying ("he's 'just a vain postdoc on an ego trip'"). Of course I know what his professional status is, it's the most prominent information on his website.

It's a shame that rather than actually considering the very evident pathology here (i.e. the production of mediocre vanity blog content that serves primarily to improve the author's profile) everyone is either downvoting or nitpicking.

Re:A Working Mathematician’s Guide to Parsing by imgabe on Friday May 03, 2019 @07:39AM (#19817459)
You might have better luck if you were to expound upon the ways in which you found the content to be mediocre and how it might be improved rather than personally attacking the author for what you perceive his motives to be.
Re:A Working Mathematician’s Guide to Parsing by pfortuny on Friday May 03, 2019 @07:55AM (#19817546)
OTOH he might just be writing for the pleasure of it and getting self-feedback from it (the more you explain something the better you understand it).
Re:A Working Mathematician’s Guide to Parsing by foldr on Friday May 03, 2019 @11:37AM (#19819341)
I mean, if you know what his professional status is, why say that he's a postdoc when he isn't?
Re:A Working Mathematician’s Guide to Parsing by pgtan on Friday May 03, 2019 @07:21AM (#19817351)
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.
Re:A Working Mathematician’s Guide to Parsing by joppy on Friday May 03, 2019 @07:26AM (#19817379)
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.