Minor regexp oversight for setext headings

Allan Odgaard 29mtuz102 at sneakemail.com
Sat Oct 7 19:16:58 EDT 2006


On 7. Oct 2006, at 06:27, Allan Odgaard wrote:

Replying to myself here, as I didn’t get any other replies than the
latest from A. Pagaitzis (so checked the archive).


> Noticed the patterns for setext style headings are:

> ^(.+)[ \t]*\n=+[ \t]*\n+


Here (.+) is greedy and thus will match as much as possible,
including trailing tabs or spaces, thus leaving the [ \t]* with
nothing (which will then do zero repeats).

Example:

% Markdown.pl <<< $'Test \n=\n'
<h1>Test </h1>

While it doesn’t matter, I would expect the intended output to be:

<h1>Test</h1>

And if not, well, then the above regexp could just as well be:

^(.+)\n=+[ \t]*\n+




More information about the Markdown-Discuss mailing list