View Single Post
Old 08-14-2013, 02:52 PM   #10
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,708
Karma: 205039118
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
On the subject of using a true "parser" vs regex to modify x?(ht)?ml:
(I know you've said your request isn't JUST about avoiding Html/Regex madness and its inability to "parse" the code but I still need to comment briefly [Ha!] on just that)

I've taken part (in the past) in the parser vs regex debate that rages continually all around the internet, but I honestly think that the "regex can't 'parse' html" argument, while true, isn't really saying a whole big bunch, when it's all said and done. It's almost--but not quite--apples and oranges. At best, it's a bit disingenuous... at worst, it's programmer snobbery ("Go away kid. You need to use a parser.").

While it's perfectly true that regex can't "parse" markup (because it doesn't understand the syntax), that fact isn't really very relevant to a neophyte asking; "what regex can I use to do X?" For the experts to tell those DIYers; "Parser! You must use a parser!" is, for all practical purposes, the same thing as telling that person; "you can't do what you want to do. Not today, anyway. Give it up."

Why? Because they can't just download a "parser" and tell it to fix their code. They have to create some sort of interface using a programming language they don't know how to use. And chances are, even if they figure that part out, they're not going to be able to integrate it into the application they actually want to do the editing in. So they're either going to have to give up or beg the application's devs to do it for them. Which even if you have the nicest, most accommodating devs in the world, ain't going to happen overnight (and you'll still be at their mercy for any updates, tweaks and new requests to be added to the miracle parser's bag o' tricks).

So for the DIYer whose coding skills are somewhat limited, I still say regex has the most bang for their buck. It's already included in a crap-ton of editing applications, and as long as you understand that it's bone-dead stupid about syntax, you can start to figure out how to think FOR it. Sure you may not be able to do everything you want to do with the click of a button, but with a good plan and a multi-pass approach if necessary (which Sigil makes painless), I still say there's very little you can't do with it that a parser can. And if you struggle mightily to get a handle on regex, I hear there's people on the internet that like the challenge of finding regex solutions. So even the uninitiated can get pretty quick results.

Anyway, back to the thread! Sorry for the diatribe. I promise this time I'm done.

Last edited by DiapDealer; 08-14-2013 at 03:01 PM.
DiapDealer is offline   Reply With Quote