On 13/11/2007, Lars Aronsson lars@aronsson.se wrote:
Thomas Dalton wrote:
Why is the parser outputting something other than what the user wants ever desirable?
You're talking about some very different things when you use the word "user" here. The current parser (PHP regexp) is used both when an editor saves an article and when a reader browses an article (unless it was still in the cache). Producing an error message for a reader isn't meaningful. Some editors only fix a single spelling error and are not interested in learning about syntax errors in other parts of the article. Any kind of error message must be opt-in, that is what "lint" was to old C programmers, or what "-Wall -pedantic" (activate all warning messages) is to the GCC compiler. This could be useful, though, which suggests the parser should be able to run in different modes: Just-show-it mode and lint mode.
How about always allowing saves (I think most people are agreed that refusing to save invalid syntax is a bad idea), but showing error messages when the page is displayed immediately after saving (I've thinking ?action=debug, this would allow people to get the error messages manually at other times as well, and shouldn't be too hard to implement). Normal readers of the page would just see the parser's best guess, but when someone clicks "save" they would see it with inline error messages (appending them just makes it impossible to tell where the error is - articles don't have line numbers), probably with a big red warning at the top to make sure people don't just move on without looking at the article they've just saved.