SmartyPants -- Smart quotes plug-in for Movable Type

Download

SmartyPants 1.5.1 (20 KB) — Fri 12 Mar 2004

What’s new?

Description

SmartyPants is a free web publishing plug-in for Movable Type, Blosxom, and BBEdit that easily translates plain ASCII punctuation characters into “smart” typographic punctuation HTML entities.

SmartyPants can perform the following transformations:

  • Straight quotes ( " and ' ) into “curly” quote HTML entities
  • Backticks-style quotes (``like this'') into “curly” quote HTML entities
  • Dashes (“--” and “---”) into en- and em-dash entities
  • Three consecutive dots (“...”) into an ellipsis entity

This means you can write, edit, and save your posts using plain old ASCII straight quotes, plain dashes, and plain dots, but your published posts (and final HTML output) will appear with smart quotes, em-dashes, and proper ellipses.

SmartyPants is a combination plug-in — a single plug-in file that works with Movable Type, Blosxom, and BBEdit. It can also be used from a Unix-style command-line.

SmartyPants does not modify characters within

, , , or  



If the bug involves quotes being curled the wrong way, please send example text to illustrate.

See Also

This plug-in effectively obsoletes the technique documented here.

However, the above instructions may still be of interest if for some reason you are still running an older version of Movable Type.

Version History

1.5.1: Fri 12 Mar 2004

  • Fixed a goof where if you had SmartyPants 1.5.0 installed, but didn’t have Markdown installed, when SmartyPants checked for Markdown’s presence, it created a blank entry in MT’s global hash of installed text filters. This showed up in MT’s Text Formatting pop-up menu as a blank entry.

1.5: Tue 9 Mar 2004

  • SmartyPants now features automatic integration with Markdown, my new text formatting plug-in. If Markdown and SmartyPants are both installed as Movable Type plug-ins, SmartyPants will add a new global text filter, “Markdown With Smartypants”.

  • Preliminary command-line options parsing. See the POD documentation for details, if you're into this sort of thing.

  • dot-space-dot-space-dot now counts as an ellipsis. This is the style used by Project Gutenberg: http://www.gutenberg.net/faq/index.shtml#V.110
    (Thanks to Fred Condo for the patch.)

  • Added to the list of tags to skip (pre, code, etc.).

1.4.1: Sat 8 Nov 2003

  • The bug fix from 1.4 for dashes followed by quotes with no intervening spaces now actually works.

  • “ ” now counts as whitespace where necessary. (Thanks to Greg Knauss for the patch.)

1.4: Mon 30 Jun 2003

  • Improved the HTML tokenizer so that it will parse nested <> pairs up to five levels deep. Previously, it only parsed up to two levels. What we *should* do is allow for any arbitrary level of nesting, but to do so, we would need to use Perl’s ?? construct (see Fried’s “Mastering Regular Expressions”, 2nd Ed., pp. 328-331), and sadly, this would only work in Perl 5.6 or later. SmartyPants still supports Perl 5.00503. I suppose we could test for the version and build a regex accordingly, but I don’t think I want to maintain two separate patterns.

  • Thanks to Stepan Riha, the tokenizer now handles HTML comments:

    
    

    and PHP-style processor instructions:

    
    
  • The quote educator now handles situations where dashes are used without whitespace, e.g.:

    "dashes"--without spaces--"are tricky"
    
  • Special case for decade abbreviations like this: the ’80s. This only works for the sequence apostrophe-digit-digit-s.

1.3: Wed 14 May 2003

  • Plugged the biggest hole in SmartyPants’s smart quotes algorithm. Previous versions were hopelessly confused by single-character quote tokens, such as:

    
    

    "Tricky!"

    The problem was that the EducateQuotes() function works on each token separately, with no means of getting surrounding context from the previous or next tokens. The solution is to curl these single-character quote tokens as a special case, before calling EducateQuotes().

  • New single-quotes backtick mode for smarty_pants attribute. The only way to turn it on is to include “B” in the configuration string, e.g. to translate backtick quotes, dashes, and ellipses:

    
    smarty_pants="Bde"
    
  • Fixed a bug where an opening quote would get curled the wrong way if the quote started with three dots, e.g.:

    
    

    "...meanwhile"

  • Fixed a bug where opening quotes would get curled the wrong way if there were double sets of quotes within each other, e.g.:

    
    

    "'Some' people."

  • Due to popular demand, four consecutive dots (....) will now be turned into an ellipsis followed by a period. Previous versions would turn this into a period followed by an ellipsis. If you really want a period-then-ellipsis sequence, escape the first period with a backslash: \....

  • Removed “&” from our home-grown punctuation class, since it denotes an entity, not a literal ampersand punctuation character. This fixes a bug where SmartyPants would mis-curl the opening quote in something like this:

    
    "…whatever"
    
  • SmartyPants has always had a special case where it looks for “'s” in situations like this:

    
    Custer's Last Stand
    
    

    This special case is now case-insensitive.

1.2.2: Thu Mar 13, 2003

  • 1.2.1 contained a boneheaded addition which prevented SmartyPants from compiling under Perl 5.005. This has been remedied, and is the only change from 1.2.1.

1.2.1: Tue Mar 11, 2003

  • New “stupefy mode” for smarty_pants attribute. If you set

    smarty_pants="-1"

    SmartyPants will perform reverse transformations, turning HTML entities into plain ASCII equivalents. E.g. curly quotes are turned into a simple double-quote ("), “—” is turned into two dashes, etc. This is useful if you are using SmartyPants from Brad Choate’s MT-Textile text filter, but wish to suppress smart punctuation in specific MT templates, such as RSS feeds. Text filters do their work before templates are processed; but you can use smarty_pants="-1" to reverse the transformations in specific templates.

  • Replaced the POSIX-style regex character class [:punct:] with an ugly hard-coded normal character class of all punctuation; POSIX classes require Perl 5.6 or later, but SmartyPants still supports back to 5.005.

  • Several small changes to allow SmartyPants to work when Blosxom is running in static mode.

1.2: Thu Feb 27, 2003

  • SmartyPants is now a combination plug-in, supporting both Movable Type (2.5 or later) and Blosxom (2.0 or later). It also works as a BBEdit text filter and standalone command-line Perl program. Thanks to Rael Dornfest for the initial Blosxom port (and for the excellent Blosxom plug-in API).

  • SmartyPants now accepts the following backslash escapes, to force non-smart punctuation. It does so by transforming the escape sequence into a decimal-encoded HTML entity:

    Escape  Value  Character
    ------  -----  ---------
      \\    \    \
      \"    "    "
      \'    '    '
      \.    .    .
      \-    -    -
      \`    `    `
    

    Note that this could produce different results than previous versions of SmartyPants, if for some reason you have an entry containing one or more of these sequences. (Thanks to Charles Wiltgen for the suggestion.)

  • Added a new option to support inverted en- and em-dash notation: “--” for em-dashes, “---” for en-dashes. This is compatible with SmartyPants’ original “--” syntax for em-dashes, but also allows you to specify en-dashes. It can be invoked by using smart_dashes="3", smarty_pants="3", or smarty_pants="i". (Suggested by Aaron Swartz.)

  • Added a new option to automatically convert " entities into regular double-quotes before educating quotes. This is mainly for the benefit of people who write posts using Dreamweaver, which substitutes this entity for any literal quote char. The one and only way to invoke this option is to use the letter shortcuts for the smarty_pants attribute; the shortcut for this option is “w” (for Dream_w_eaver). (Suggested by Jonathon Delacour.)

  • Added