[pmwiki-users] CountGlyphs

Patrick R. Michaud pmichaud at pobox.com
Wed Aug 30 16:34:48 CDT 2006


On Wed, Aug 30, 2006 at 04:01:28PM -0400, Stirling Westrup wrote:
> I was recently hoping to use the CountGlyphs recipe to annotate the
> sizes of stories on my index page. It doesn't seem to work though and a
> quick look at countglyphs.php gives me little hope of knowing how to fix it.

CountGlyphs was originally written a long time ago, before
we had page variables and the like.

> It should be trivial to write something that counts words and glyphs and
> caches them in the page attributes during a save, but I'm not sure how
> to integrate that with the Page variable system. 

Yes, it seems like it should be trivial to do this, but it currently 
isn't.  :-(

I can probably fix that.  But even after fixing it, there will be
the caveat that the count won't be very precise, since we can't
really count things coming from (:include:), (:pagelist:), trails,
and other such markups.

> a) Work using the {Group.Page$Words} notation.
> b) Be accessible inside a pagelist format as {=$Words}?
> 
> I had been naively assuming that a) and b) would simply work for
> anything defined in FmtPV, but that doesn't seem to be the case.

Well, once you get a) working, b) works also.  But getting
a) to work does mean that the counts have to be saved as an attribute
somewhere, because we *really* don't want to be rendering the markup
and counting the words for every page we encounter in a pagelist.  :-)

The reason the CountGlyphs recipe can work now is because the
{$Words} markup only works on the current page (and, of course, we
have the text of the page already available and rendered in order to
be able to determine the count).

Pm




More information about the pmwiki-users mailing list