[pmwiki-users] Re: Re: AllGroupHeader causes extra vertical space

chr at home.se chr at home.se
Mon Jul 25 09:49:29 CDT 2005


On Mon, 25 Jul 2005, Patrick R. Michaud wrote:

> > >     (:include Group.SomePage)(:nl:)This is some text
> > > 
> > > will add a newline only if Group.SomePage doesn't end with a newline.

> > 	http://www.pmwiki.org/wiki/Test/Newline

Ok, I understood the explanation of the first two examples. However, it 
doesn't seem so intuitive that 

	Bla bla bla.(:include NonExistingPage:)(:nl:)
	This becomes a new paragraph.

does not generate a new paragraph because the line ends after (:nl:). By 
placing a space after (:nl:) you do however get a new paragraph...

Anyway, I added a brief description of (:nl:)

	http://www.pmwiki.org/wiki/PmWiki/Directives#nl

	[[#nl]][@(:nl:)@] - Insert a newline into the ''markup'' if one is
	not already present before or after the directive. This is
	primarily for use together with directives  such as
	[[([==]:include ...:) -> #include]] and is  rarely used.

does this look ok?

/Christian

> Okay, so now you're probably wondering what (:nl:) is good for.  Here's
> the long answer:  it's primarily designed to add newlines around 
> (:include:)s that may or may not have them already.  Consider a 
> Site.SiteGroupHeader that contains
> 
>     %define=Pm color=purple font-style=italic%
> 
> but doesn't have a newline at the end.  The result of
> 
>     (:include Site.SiteGroupHeader:)Some text
> 
> is "%define=Pm color=purple font-style=italic%Some text"  which means
> that the text will be rendered in purple.  To avoid this, an author
> would have to write
> 
>     (:include Site.SiteGroupHeader:)
>     Some text
> 
> which is equivalent to
> 
>     %define=Pm color=purple font-style=italic%
>     Some text
> 
> and it looks fine.  But now, suppose someone edits Site.SiteGroupHeader
> and puts a newline at the end of the %define=% line.  Then the markup 
> above becomes equivalent to
> 
>     %define=Pm color=purple font-style=italic%
> 
>     Some text
> 
> and the inadvertent blank line generates a vertical space, which means
> the author would have to go back to doing
> 
>     (:include Site.SiteGroupHeader:)Some text
> 
> to eliminate it.
> 
> So, the purpose of (:nl:) is to add in an extra newline only when 
> it's needed:
> 
>     (:include Site.SiteGroupHeader:)(:nl:)Some text
> 
> which will always come out to
> 
>     %define=Pm color=purple font-style=italic%
>     Some text
> 
> regardless of Site.SiteGroupHeader having a newline at the end of its
> %define=... % statement..  A similar case exists for includes at the
> end (e.g., footers).  Something like
> 
>     (:nl:)(:include {$Group}.GroupFooter:)(:nl:)(:include Site.SiteGroupFooter:)
> 
> can be used to make sure that each of the includes start at the
> beginning of a line without inadvertently creating a blank one.
> 
> Originally I had thought that getting the newlines correct around
> (:include:) markups would require some options, but then the problem
> became needing diferent options to add a newline at the beginning
> versus at the end, as well as being able to explain when to use it.
> The (:nl:) markup ends up being a lot more flexible, because it provides
> an easy way to insert newlines only where they're needed without
> generating extra ones.
> 
> And, of course, this isn't a markup I expect authors to use very often;
> they're really more of an "internal" markup.
> 
> Hope this helps,
> 
> Pm
> 

-- 
Christian Ridderström, +46-8-768 39 44               http://www.md.kth.se/~chr






More information about the pmwiki-users mailing list