[pmwiki-devel] WordCount Recipe.
Patrick R. Michaud
pmichaud at pobox.com
Tue Oct 31 14:06:23 CST 2006
On Tue, Oct 31, 2006 at 02:35:27PM -0500, Stirling Westrup wrote:
> Patrick R. Michaud wrote:
> > On Tue, Oct 31, 2006 at 04:53:24AM -0500, Stirling Westrup wrote:
> >> I've just finished a word count recipe for NaNoWriMo.
> >
> > Having looked at it only briefly, I'd say it's done "right",
> > at least as far as 2.1 is concerned.
>
> Good! I was unsure of a number of things, including naming all my new
> page attributes 'foocount' and using =pagecounts as my flag to tell me
> that I've calculated them. I'm worried about core namespace issues. We
> may want some Recipe guidelines for naming things like this in the future.
It's likely to change. In particular, it's likely that we'll have
the capability to store page variables directly as page attributes.
For example, a recipe could put a value directly into $page['$Glyphs']
and have it saved as $Glyphs=... in the pagefile. Then the attribute
is automatically available as a {$Glyphs} page variable without
having to define a $FmtPV[] entry for it (although defining
$FmtPV['$Glyphs'] will still work).
> Yes, it might. I decided not to worry about it until I got my beta
> version working. Now that it is working, I suppose its the right time to
> worry. I can think of several solutions, but I don't know which is better:
> [...]
> 2) Try to more closely duplicate what countglyphs did. Run the markup
> text through MarkupToHTML, remove anything enclosed in <...> tags and
> count that.
This will be the way to go, especially since SaveAttributes
already runs the markup text through MarkupToHTML (and will be
making the result available to later edit functions).
In fact, there's the possibility that the rendered text
(sans HTML tags) will be saved as an attribute to make it easier
to count words and to display page excerpts (e.g. in pagelists
and searchresults).
There's also the bonus that when SaveAttributes runs MarkupToHTML,
it turns off (:include:), groupheaders, groupfooters, etc.
Pm
More information about the pmwiki-devel
mailing list