Re: Formal Grammar — some thoughts

Allan Odgaard 29mtuz102 at
Tue Aug 1 11:16:36 EDT 2006

On 31/7/2006, at 4:56, A. Pagaltzis wrote:

>> [...] it can’t be done without revising some parts of the syntax,

>> OTOH the problematic parts (e.g. nested block elements)

> You keep asserting that, and it keeps failing to make any sense.

Asserting what? That nested block elements are problematic?

> [...] grammars can express nested constructs. I wonder what you are

> talking about.

Nested expressions in context free grammars [1] are not directly
comparable with nested block elements in Markdown.

> [...] That only means the current implementations need to be fixed.

Fixed how? From the syntax I get that I can do `> block quote` and `*
list item` and from the cheat sheet that I can nest things like:

* > list item with quoted text

Ignoring here that the HTML produced for that is:

<li>> list item with quoting</li>

Let’s continue with the syntax which further says that I can be lazy
and leave out the indent for list items and `>` for block quotes. So
what should this convert to:

* > list item with quoting
more text here

Does the additional line belong to the block quote or the list item?
I’m inclined to say block quote, since a block quote is not
terminated before there is a blank line, at least from how I read the
syntax. But then what about this:

* > list item with quoting
more text here
* another list item

There is no blank line after the block quote, so does `* another list
item` also belong to the block quote? This particular example does
not parse as a block quote, but if we make one that does, we will see
that Markdown does indeed make the list item part of the block quote,
for example this example:

* leading text as block quote can’t be first
> some block quoted text
* another list item

Turns into this (wrongly nested, but at least it got the block quote)

<li>leading text as block quote can’t be first</p>

<p>some block quoted text</li>
<li>another list item</li>

This however raises two questions:

1. Should it actually be a list item in the block quote? for example
take this example:

> block quote
* more block quote

Which turns into this markup (i.e. there is no list item):

<p>block quote
* more block quote</p>

2. If `* another list item` gets nested into the block quote, we need
a blank line in front of that item to make it part of the root list.
But then, will we get the “spaced out” version of the list where each
item is wrapped in `<p>…</p>` (which is normal for such “spaced out”

These are the problems I want to have addressed/fixed! And this is
where I think the syntax needs revising. I have shown above the
problems with the ambiguity of nesting, but lazy mode for block
quoting I think should not be a feature at all, take this example:

> > I wrote something
> you replied
and now here is my reply to your reply.

This turns into the following markup:

<p>I wrote something
you replied
and now here is my combat.</p>

Would people actually expect that?

Anyway, this thread was just to learn the interest in a more strict
(but potentially revised) syntax and Johns future direction and
thoughts on this.

It’s clear that this thread did not turn out to be productive, so I
will retreat from this discussion.


More information about the Markdown-Discuss mailing list