ikiwiki/doc/plugins/contrib/wordcount.mdwn

23 lines
961 B
Plaintext
Raw Normal View History

2013-08-10 10:53:23 +02:00
[[!template id=plugin name=wordcount author="[[schmonz]]"]]
[[!template id=gitbranch branch=schmonz/wordcount author="[[schmonz]]"]]
2013-02-23 20:24:08 +01:00
[[!tag type/meta]]
2013-02-23 20:29:50 +01:00
[[!tag patch]]
2013-02-23 20:24:08 +01:00
This plugin counts words in a page. For a single page, write a
2013-08-10 10:53:23 +02:00
`\[[!wordcount]]` directive and the word count will be interpolated there.
2013-02-23 20:24:08 +01:00
For a site, add `<TMPL_VAR WORDCOUNT>` to your [[templates]].
If [[!cpan HTML::Strip]] is installed, the wordcount will be slightly
more accurate.
Possible enhancements:
* Optimize: count words iff the result will be displayed. `sanitize()`
seems like the right place to count. Since it's called well after
`preprocess()`, I can tell whether a directive needs the result,
but since it appears to be called before `pagetemplate()`, I can't
tell whether a template wants to know and possibly skip the
computation. (In other words, if I add `$needed_for_template`
like `$needed_for_directive`, it gets set too late for `sanitize()`
to see.)