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

Patrick R. Michaud pmichaud
Wed Jan 14 14:45:27 CST 2004


A long discussion on <p> and PmWiki markup (feel free to skip)...

I don't think PmWiki has (or should have) "paragraphs" in the traditional
sense.  What really exists are blank lines in the markup which the author
generally wants to become blank lines in the output.  The fact that something
could be represented by an HTML <p> tag is largely irrelevant as long as
the output formats correctly.  This is why I'm somewhat in favor of using
<br /><br /> instead of <p /> to mean "vertical space between elements".

Also, <p> has some often unwanted side effects on output--namely forced 
vertical white space above and below the paragraph.  To continue my
example from earlier:

    Here is some wiki text
    # item 1
    ## subitem 1
    ## subitem 2
    # item 2
    More text

In PmWiki's current model, this produces

    Here is some wiki text                        Here is some wiki text
    <ul>
      <li>item 1                                    1. item 1
        <ul><li>subitem 1</li>                           1. subitem 1
          <li>subitem 2</li>                             2. subitem 2
        </ul>                                       2. item 2
      </li>
      <li>item 2</li>                             More text
    </ul>
    More text

which is fairly close to what the author put down, except that the
top-level <ul> forces blank lines on either side (this behavior can
be adjusted with CSS).

If we say that '\\\' produces an empty paragraph tag <p />, then

    Here is some wiki text
    # item 1\\\
    More paragraph text
    ## subitem 1
    ## subitem 2
    # item 2
    More text

becomes

    Here is some wiki text                        Here is some wiki text
    <ul>
      <li>item 1                                    1. item 1
        <p />
        More paragraph text                            More paragraph text
        <ul><li>subitem 1</li>                           1. subitem 1
          <li>subitem 2</li>                             2. subitem 2
        </ul>                                       2. item 2
      </li>
      <li>item 2</li>                             More text
    </ul>
    More text

This isn't so bad, except that it makes use of empty paragraphs (<p />)
which is discouraged by HTML and several PmWiki users have commented that
empty paragraphs cause problems for them.  (See, for example,
http://pmichaud.com/pipermail/pmwiki-users_pmichaud.com/2003-December/001750.html.)

So, if we properly containerize the paragraph in item 1, we get:

    Here is some wiki text                        Here is some wiki text
    <ul>
      <li>item 1                                    1. item 1
        <p>
        More paragraph text                            More paragraph text
        </p>
        <ul><li>subitem 1</li>                           1. subitem 1
          <li>subitem 2</li>                             2. subitem 2
        </ul>                                       2. item 2
      </li>
      <li>item 2</li>                             More text
    </ul>
    More text

which looks still less like the original wiki markup because of the blank
space added between "More paragraph text" and subitem 1 (due to the
space required around <p>...</p> containers).  Also, "More paragraph text"
will appear with any P-styles applied, but the remainer of the text would
not, which will likely confuse people as well.  So, we might try putting
everything in paragraphs:

   <p>Here is some wiki text</p>                  Here is some wiki text
   <ul>
     <li><p>item 1</p>                              1. item 1
       <p>More paragraph text</p>
       <ul><li><p>subitem 1</p></li>                   More paragraph text
         <li><p>subitem 2</p></li>
       </ul>                                             1. subitem 1
     </li>
     <li><p>item 2</p></li>                              2. subitem 2
   </ul>
   <p>More text</p>                                 2. item 2

                                                  More text

And now everything has blank lines around it, only one of which was
likely intended by the original markup (via the '\\\' specifier in item 1).

Using the <br> tags to simulate blank lines in output instead of <p>
seems much more reliable and browser friendly.  For example:

    Here is some wiki text                        Here is some wiki text
    <ul>
      <li>item 1                                    1. item 1
        <br /><br />
        More paragraph text                            More paragraph text
        <ul><li>subitem 1</li>                           1. subitem 1
          <li>subitem 2</li>                             2. subitem 2
        </ul>                                       2. item 2
      </li>
      <li>item 2</li>                             More text
    </ul>
    More text

avoids the empty paragraph tags altogether.  In fact, if we say that
the number of backslashes at the end of a line determines the number of
<br>'s produced, then '\\' is a simple line break, '\\\' is a vertical
space, '\\\\' is a very large vertical space, etc.  Consecutive blank lines
in the markup would be translated into <br /><br />, or a single blank line.

   
    Here is 
    some 


    wiki text
    # item 1\\\
    More paragraph\\
    text
    ## subitem 1
    ## subitem 2
    # item 2
    More text
   
Results in

    Here is some<br />                            Here is some 
    <br />
    wiki text                                     wiki text
    <ul>
      <li>item 1<br />                              1. item 1
        <br />
        More paragraph<br />                           More paragraph
        text                                           text
        <ul>                                             1. subitem 1
          <li>subitem 1</li>                             2. subitem 2
          <li>subitem 2</li>                        2. item 2
        </ul>
      <li>item 2</li>                             More text
    </ul>
    More text


If there's enough interest, I'll implement this in the beta site and
we can see how it works...

Pm



More information about the pmwiki-users mailing list