treating doctype and php as block-level elements

Yuri T. qaramazov at gmail.com
Sun Nov 20 09:01:41 EST 2005


I would go for a simpler rule, even if it captures some cases that
shouldn't be, since you can always override it by inserting an extra
space. Here is what I would propose:

Leave as is any block that both (1) starts with "<!", "<@", "<?", or
"<%" or with "<" followed by a block-level HTML tag and (2) ends with
">" + optional whitespace

I.e., don't pay attention at the closing tags: if it starts with the
right tag and ends with a ">" treat it as a block-level HTML segment
and leave it unmodified. This means that all the examples you
suggested would be left as-is, unless the blocks start with a space.

Here is the python code I am currently using:

if ( block.startswith("<") and block.rstrip().endswith(">")
and (block[1] in ["!", "?", "@", "%"]
or is_block_level( block[1:].replace(">", " ")
.split()[0].lower()))) :

Another possibility would be simplify it yet further and say: that any
paragraph that starts with a "<" and ends with a ">" (plus maybe
whitespace at the end) is left in place as is. This would include
non-block-level HTML elements, but if people want to get them wrapped
they just need to indent the paragraph.

- yuri


On 11/20/05, Michel Fortin <michel.fortin at michelf.com> wrote:

> Le 2005-11-20 à 04:07, A. Pagaltzis a écrit :

>

> > I don't care what decision is taken about the vendor-invented

> > syntaxes, but the standard syntax elements should definitely be

> > supported.

>

> Sure, but my question was how far should we go? For example, this is

> a valid doctype declaration:

>

> <!DOCTYPE note [

> <!ELEMENT note (to,from,heading,body)>

> <!ELEMENT to (#PCDATA)>

> <!ELEMENT from (#PCDATA)>

> <!ELEMENT heading (#PCDATA)>

> <!ELEMENT body (#PCDATA)>

> ]>

>

> Should we support it? (Browsers support this correctly only for xml

> mime types.)

>

> What about comments inside it (delimited by `--`)?

>

> <!DOCTYPE note [

> <!ELEMENT note (to,from,heading,body)>

> <!ELEMENT to (#PCDATA)>

> <!ELEMENT from (#PCDATA)>

> <!ELEMENT heading (#PCDATA)>

> <!ELEMENT body (#PCDATA)>

> -- this is ]> a comment --

> ]>

>

> And what about quoted text inside it?

>

> So we have the choice of supporting this loosely like browsers do

> with a text/html mime type or we could support it fully according to

> the xml spec, which is not a trivial task. Or we could do something

> in the middle.

>

> That was the essence of my question.

>

> I think the answer (for `<!`) is obvious: there is not much value in

> supporting this currently. But it's still good to know that this

> limitation exists.

>

> - - -

>

> As for `<%` and `<@`, I've never used them so I don't even know what

> is the correct closing marker. Is it `<@ @>` or just `<@ >`? Is

> there any special consideration to take into account?

>

>

> Michel Fortin

> michel.fortin at michelf.com

> http://www.michelf.com/

>

>

> _______________________________________________

> Markdown-Discuss mailing list

> Markdown-Discuss at six.pairlist.net

> http://six.pairlist.net/mailman/listinfo/markdown-discuss

>



--
http://www.freewisdom.org/


More information about the Markdown-Discuss mailing list