Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

Abbreviation Plurals

Summary: Automatically format text like CCDs as a plural abbreviation, instead of as a wikiword.
Version:
Prerequisites:
Status:
Maintainer:
Categories: Markup

Questions answered by this recipe

How do I automatically format text like CCDs as a plural abbreviation, instead of as a wikiword?

Description

Enter your recipe's description here.

Notes

The following markup entry will do it:

 Markup("abbr",'>[[',"/\\b([[:upper:]][[:upper:]]+)(s?)/e",
    "'<big><span style=\'font-variant: small-caps\'>'.
      strtolower('$1').'</span></big>'.'$2'");

This formats abbreviations (strings of uppercase characters), including abbreviation plurals, as small caps, slightly larger than normal text. The output you see depends on the browser you use. Not all browsers support the small caps variant.

So while using small caps for abbreviations is good typographical practice, administrators may want to use the simpler alternative, given below.

Alternative

This just stops abbreviation plurals from wikifying:

 Markup("abbr",'>[[',"/`?\\b([[:upper:]][[:upper:]]+s)\\b/e","Keep('$1')");

The opening backtick catches dewikified references and the trailing \\b forces whole words.

Comments

I find this very useful, but I think the first markup (- haven't tried the second) can interfere with the MarkupExtensions script when it comes to the rendering of anchors.

With MarkupExtensions included after the AbbreviationPlurals markup, any anchors containing strings of uppar case chars are altered by the AbbreviationPlurals script first, which then completely messes up the rendering of the anchors by MarkupExtensions.

However, everything appears to work fine if MarkupExtensions is included before this markup. Probably best, then, to include this markup last.

- Val

MarkupExtensions also includes an alternative which requires a WikiWord to include at least 2 lower case characters. So this avoids the whole problem by ignoring strings that are just abbreviation plurals. jr

See Also

Contributors

jr

Edit - History - Print - Recent Changes - Search
Page last modified on March 20, 2007, at 05:45 PM