Towards a Markdown reloaded plugin for WordPress

Opinion — The Markdown syntax is sweet, but it also suffers major usability flaws. I’m seriously considering to take the Markdown fix plugin (obsolete) a few steps in a direction where it actually enhances Markdown. My two main concerns come from the fact that Markdown uses a ‘dumb’ syntax. ‘Dumb’, as in too rigidly consistent.

The first is a bug/feature that you bump into whenever a user inserts code in a comment. Invariably, do_something_method() will format a dosomethingmethod() because the user did not insert backticks. To make things worse, users do not insert backticks even when explicitly invited to. And even if they did, it is a pathetic way to solve the problem. Markdown must change.

I’m thinking of fixing this by automatically translating do_something_method() to do\_something\_method() outside of code blocks. Obviously, it’s a bit more complex, because of things like __foo(), but it might very well work out by trying to match symmetric patterns based on word boundaries, which arguably looks more like a user inserting an emphasis. The same goes, to a lesser extent, with * (as in 2*3=6).

The second common bug/feature that you bump into is related to the way Markdown processes line breaks. Some users insert paragraphs in their comments… using a single line break to insert a paragraph. Whereby Markdown will transform a perfectly formatted text into a horrendous single text block.

I think there is room for auto-correction here too. For instance, by adding line feeds and double spaces where they are obviously missing, outside of code blocks.

I’d be curious to know your thoughts on the two topics, if any.

Update: Michel Fortin released a Markdown Extra plugin, that does the above.

Comments on Towards a Markdown reloaded plugin for WordPress

  1. I ran in to the opposite problem in a wiki I use – and never realized that the way they do it makes sense until I ran into the `this_has_underlines()` problem in markdown. In order to get the underlines to work as highlighting in that program I had to code it thus:

    `thi\s_has_\underlines()` it requires a space or and escaped character to preceed a starting formatting character and to follow an ending formatting character.

    I expected to have to escape the the `_` until I realized the ‘rule’ it was using to determine if it was a formatting mark or not.

  2. Checking for `some_thing_like_this` with a regex? Ignoring those in code span, code blocks, HTML blocks, and inline HTML tags? I’m not sure how hard this is… but it won’t be easy.

    Maybe it would be better to create a new fork from PHP Markdown.