[pmwiki-users] Need to fix the spacing on an Include...

Ben Wilson dausha at gmail.com
Sun Oct 14 16:23:47 CDT 2007


On 10/13/07, sti at pooq.com <sti at pooq.com> wrote:
> Ben Wilson wrote:
> > I am supporting a friend's wedding planner web site. In her blog,[2]
> > she wants the (read more...) tag to be at the end of the last
> > paragraph. The following is the page template code. Would somebody
> > mind suggesting how I can satisfy her request?
> >
> > [[#teasers]]
> > !!! {=$Titlespaced}
> >
> > (:include {=$FullName} para=2:)([[{=$FullName}|read more]]...)
> >
> > (:if equal {>$Group}:)
> > (:if:)
> > [[#teasersend]]
> >
> >
> > [1]: http://www.weddingsinvieques.com/SandysBlog/SandysBlog
>
> As far as I can tell from a quick reading of IncludeText(), the problem is
> that the included text ends with the blank line that delimits the paragraph.
> The only way I can see to fix it would involve a recipe that redefines the
> (:include...:) directive to call an extended IncludeText function that has a
> couple more options.
>
> It would be nice if there were some way to use a markup expression like:
>
>   {(chomp (:include {=$FullName} para=2:) )}
>
> But the order of evaluation of expressions precludes it. (you'd need to define
> chomp as well, but its trivial to write.)
>
> The simplest extension (in my mind) would be one that allows you to do an
> include into a variable. Thus you'd say something like:
>
>   (:includevar $foo {=$FullName} para=2:){(chomp {$foo})}([[{=$FullName}|read
> more]]...)
>
> You could probably replace chomp with substr, but the current PmWiki docs
> don't mention if it handles negative indexes and lengths in a way that would
> let you drop the last blank line, and I'm late to get out the door, so I can't
> take the time to work it out now.

Thanks for the push. I created another markup that gets rid of the last vspace.

Markup('included', '>if',
  '/\\(:included\\s+(\\S.*?):\\)/ei',
  "PRR(IncludedText(\$pagename, PSS('$1')))");

function IncludedText($pagename, $arg) {
    return preg_replace("/<:vspace>$/",'', IncludeText($pagename, PSS($arg)));
}



-- 
Ben Wilson
"Words are the only thing which will last forever" Churchill



More information about the pmwiki-users mailing list