closing paragraphs </p> (Was Re: [Pmwiki-users] Another idea bef..)

Patrick R. Michaud pmichaud
Wed Jan 14 13:56:11 CST 2004


On Wed, Jan 14, 2004 at 07:20:12PM +0100, Christian Ridderstr?m wrote:
> 
> Just replacing <p>'s with <br/></br> is ugly IMO, because we remove the 
> information that a new paragraph is started. So we should only do that if 
> we want a blank line, and not something else.

Because of the way that HTML is defined, PmWiki already removes the 
information that a new paragraph is started.  Technically <br> is inline
markup, but <p> is block markup, and a paragraph always "contains"
something, thus it's to be terminated with a </p>.

> One solution would be using a stack where you push things like '</p>' 
> onto, and before leaving the list item you pop it.
> But I guess this assumes a general structure where tokens are parsed etc, 
> rather than *only* substituting regexps....

PmWiki already has a stack where it keeps track of the block markup
elements such as lists and tables.  Unfortunately, HTML defines <p> as 
block markup that cannot contain any other block markup.  Thus, a 
paragraph cannot contain a list, a table, a blockquote, or even another
paragraph.  Thus this is valid in HTML

    <li><p>Paragraph 1</p><p>Paragraph 2</p></li>

but this is not

    <p>Paragraph 1<ol><li>List item 1</li><li>List item 2</li></ol></p>

So, although the PmWiki element nesting code does understand HTML paragraphs
to some extent, it also understands that nothing can be nested inside of
a paragraph and it honors that.

> Oh, and at the moment, is it possible to a create new paragraph while 
> inside for instance a list item?

Not presently, although I'd love to have a markup that allows that.
But this brings up other points about the <p> tags in general; given
the following PmWiki markup (assuming that '\\\' represents "new
paragraph")

  * list 1\\\
    paragraph
  * list 2

which of the following should be produced?

  <ul>                               <ul>
  <li><p>list 1</p>                  <li>list 1
    <p>paragraph</p></li>              <p>paragraph</p></li>
  <li><p>list 2</p></li>             <li>list 2</li>
  </ul>                              </ul>

I.e., should the text of every list item or definition item automatically
be enclosed in <p>...</p>?  Or, put another way, should all text only
occur inside of paragraph tags?  If yes, then we can get some really 
annoying browser side effects in tables and other block constructs which
don't expect paragraphs.  If no, then there's not much point in having 
properly containerized <p>'s or CSS entries for the <p> tag, because some 
text elements would be affected and others would not.  (You start to see why
I dislike the <p> tag so much.  :-)

> Speaking of which, how is '\' at the end of a line handled? Is the '\' 
> stripped and the next line simply appended to the current variable 
> representing the current line?

The newline is replaced with a space and the next line appended to the
current one.

Pm



More information about the pmwiki-users mailing list