Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

CountGlyphs

Summary: A replacement for some of PmWiki's typographical wiki markup
Version: 20111015
Prerequisites: 2.1.0
Status: Stable
Maintainer: Pm
Categories: Markup

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 1731 glyphs and 269 words, where

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

Notes and Comments

  • This recipe was last tested on PmWiki version: 2.2.34
  • 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. The {$Glyphs} markup may report an incorrect number of international characters.

See Also

Contributors

  • Pm, 2005-Mar-25
  • BenWilson, 2006-May-19 Corrected for v2.1.5
  • Petko October 15, 2011, at 09:37 AM fixed PHP warning in recent versions.

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.

Edit - History - Print - Recent Changes - Search
Page last modified on October 15, 2011, at 09:40 AM