Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

CountGlyphs

Summary: A replacement for some of PmWiki's typographical wiki markup
Version: 2006-05-19
Prerequisites: 2.1.0
Status: Stable
Maintainer: Pm
Categories: Markup UpdateMe

Question

Is there a markup that will tell me the number of characters or words on a page?

Answer

The countglyphs.phpΔ script adds {$Glyphs} and {$Words} markups, which are replaced with the number of glyphs (non-whitespace characters) and words respectively. The algorithm excludes any HTML output from the count, as well as anything produced by the page's headers and footers (i.e., it counts only the wiki markup output).

Example

This page contains 1267 glyphs and 209 words, where

{$Glyphs} - Reports the number of glyphs on this page: 1267
{$Words} - Reports the number of words on this page: 209

Notes and Comments

  • This recipe was last tested on PmWiki version: 2.1.5
  • This recipe requires at least PmWiki version: 2.1.5

The algorithm considers a "word" to be any sequence of non-whitespace characters, thus Hello.World and !#@#$ are both counted as a single word.

Note also that the number of glyphs reported may be slightly different from a direct count, because of the existence of the {$Glyphs} and {$Words} markups themselves in the page being counted.

See Also

Contributors

  • Pm, 2005-Mar-25
  • BenWilson, 2006-May-19 Corrected for v2.1.5
Edit - History - Print - Recent Changes - Search
Page last modified on June 04, 2007, at 05:35 PM