Introduction¶
smartypants is a Python fork of SmartyPants.
smartypants can perform the following transformations:
Straight quotes (
"
and'
) into “curly” quote HTML entitiesBackticks-style quotes (
``like this''
) into “curly” quote HTML entitiesDashes (
--
and---
) into en- and em-dash entitiesThree consecutive dots (
...
or. . .
) 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 does not modify contents in some HTML element, see Skipped HTML Elements. Typically, these tags are used to display text where smart quotes and other “smart punctuation” would not be appropriate, such as source code or example markup.
Quick usage¶
To use it as a module:
import smartypants
text = '"SmartyPants" is smart, so is <code>smartypants</code> -- a Python port'
print(smartypants.smartypants(text))
To use the command-line script smartypants
:
echo '"SmartyPants" is smart, so is <code>smartypants</code> -- a Python port' | smartypants
Both produce:
“SmartyPants” is smart, so is <code>smartypants</code> — a Python port