evolving the spec (was: forking Markdown.pl?)

Allan Odgaard 29mtuz102 at sneakemail.com
Wed Mar 5 14:48:58 EST 2008


On 5 Mar 2008, at 05:02, Michel Fortin wrote:


>> [big explanation]

> So you're basically using a line by line approach.


Yes, seeing how the block-level nesting stuff affects things “line by
line”, this seems like the best approach :)


> I was thinking about that as a possibility for parsing blocks, but I

> don't think I'll do that because I need backtracking to be able to

> rewind beyond the current line. Or can you do it?


Backtracking? I am not sure when you want to do it and why you think
looking at things line-by-line will prevent you from doing it.


> I'm particularly curious about how you can handle headers of this

> form:

>

> Header

> ======


One approach is (for the regexp which starts a context) to allow an
array instead of just a single regexp¹. The index of the regexp in
this array is the relative line offset (to current line) that the
regexp should be matched against.

So for the setext style header the rule would be:

H1[1][0] = /\g.+/ # anything can go into a heading
H1[1][1] = /\g={3,}/ # but line below must have at least three
equal signs

Of course when testing the regexps on lines, these must be
preprocessed as if in the current context, i.e. all the regexps on the
stack are applied to that line.

¹ In practice one could allow a composite regexp that uses \n and
simply call split on that, then insert the regexps from the stack
before all but the first regexp resulting from this split. This would
have the advantage of making the implementation hidden from the actual
rules and simpler for the person tweaking the rules.


>> [...] placing a horizontal ruler just below a block quoted

>> paragraph does not give the expected “lazy mode” and places the

>> <hr> inside the block quote, instead it leaves the block quote.

>

> I'm not sure what's the problem with horizontal rules in blockquotes

> [...]


This is what I was referring to:

> Test
bla bla

> Test
- - -

The result becomes:

<blockquote>
<p>Test
bla bla</p>

<p>Test</p>
</blockquote>

<hr>



More information about the Markdown-Discuss mailing list