aboutsummaryrefslogtreecommitdiff
path: root/doc/plugins/contrib/wordcount.mdwn
blob: 6a90d0ec59c51ddc89e63f2460f44d9e749d11b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[[!template id=plugin name=wordcount author="[[schmonz]]"]]
[[!template id=gitbranch branch=schmonz/wordcount author="[[schmonz]]"]]
[[!tag type/meta]]
[[!tag patch]]

This plugin counts words in a page. For a single page, write a
`\[[!wordcount]]` directive and the word count will be interpolated there.
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.)