Page 1 of 1

nl2p

Posted: Thu Mar 19, 2009 9:10 pm
by onli
Nl2p is made as replacement for nl2br, preserving the possibility to distinct between small paragraphs/breaks and real paragraphs. One newline after a textblock will insert <p class="break"> at it's beginning, which inserts no whiteline after the block. If there are more newlines it inserts <p class="whiteline">. Used in combination with a css like:

Code: Select all

p.whiteline {
    margin-bottom: 1em;
}

p.break {
    margin-bottom: 0em;
}
it simulates the abilitys of a real editor without using (ugly) br-tags.

You can use textile and have almost the same effect, besides that textile uses br-tags for one newline. But opposing to textile nl2p totally ignores HTML-blockelements, so it's possible to construct a table in HTML without the need to deactivate the markup-plugin. Blockquotes are an exception, newlines in them will get converted. Nl2p makes sure that no blockelements are within <p>-tags, isolating them.

One issue: It won't work well in combination with markdown or textile. But for basic markup-functionality one can use s9ymarkup, or liquid (working title), which basically provides the necessary things: italic (*), bold (**) and links ().

Eine deutsche Erklärung gibt es [url=http://www.onli-blogging.de/index.php?/archives/629-nl2p-fuer-Serendipity.html]hier
(die dort verlinkte ist Version allerdings veraltet).

Re: nl2p

Posted: Fri Mar 20, 2009 9:57 am
by garvinhicking
Hi!

That sounds very interesting. How would you like to combine this functionality into the nl2br plugin, and then offer a configuration item to select if <br> or <p> tags should be used? Then the code could work either into the old behaviour or into your new one?

Regards,
Garvin

Re: nl2p

Posted: Fri Mar 20, 2009 12:44 pm
by onli
That really should be very easy, especially because nl2p actually is a fork of nl2br, everything besides the parser (and the isolate-option, which I removed) is equal. I'll combine them this weekend.
sincerely

PS: If this really becomes a part of nl2br and this way part of standard-serendipity, we would need the used p-tags in the serendipity-css. Without seem this is just a simple p-insert made in a very complex way.

Re: nl2p

Posted: Fri Mar 20, 2009 1:13 pm
by garvinhicking
Hi!

We could add that to the CSS also using the event hook "css"?

Regards,
Garvin

Re: nl2p

Posted: Fri Mar 20, 2009 1:28 pm
by onli
Ah, I didn't know about this hook. Will have a look at it.

Re: nl2p

Posted: Tue Mar 24, 2009 12:29 am
by onli
Using the CSS-hook seems to work well. Have a look at the attached version. I didn't enable the p-mode by default, maybe you want to change that if you don't experience issues. Also I didn't change the nl2p-code to check the isolate-configuration, ignoring all blockelements except blockquotes is hardcoded - having to configure anything for this to work properly didn't seem right for me. Do you agree ot shall I modify that (e.g. reading the option, but providing proper default?)?
sincerely

Re: nl2p

Posted: Tue Mar 24, 2009 11:42 am
by garvinhicking
Hi!

Thanks a lot. The replacements performed seem awfully complex, I wonder if that performs at all? :-)

Anyhow, I've committed your patch, but I slightly changed the $p_tags variable assignment to use a static variable.

Many thanks for your help,
Garvin

Re: nl2p

Posted: Tue Mar 24, 2009 12:53 pm
by onli
Well, I wrote a blogentry about the performance-issues I ran into. The attached version was the optimized one and should perform well. You're correct, the replacements are a bit complex and perform very bad if not implemented in a proper way.

Glad to help and thanks for the commit :)
sincerely