punctuation

Add real HTML punctuation


License
Other
Install
pip install punctuation

Documentation

Punctuation

punctuation is a Python utility that converts common punctuation markers in a string of text into proper HTML entities.

Source     HTML entity            Description
----------------------------------------------------------------------
---        —                 em dash
--         –                 en dash
"" ... ""  “ and ”     opening and closing double quotes
' ... '    ‘ and ’     opening and closing single quotes
'          ’                 apostrophe

Installation

Install with pip:

$ pip install punctuation

Or, the latest from Github:

$ pip install -e git+git://github.com/honza/punctuation.git#egg=punctuation

Usage

Command line utility:

$ punctuation path/to/file.html

Or, API:

from punctuation import HtmlPunctuationMaker

string = "This is a test---that's right"
html = HtmlPunctuationMaker(string).html
print html
>>>
"This is a test—that’s right"

Credits

The recommendations and entity characters come from the excellent The Trouble With EM & EN (and Other Shady Characters) article.

License

BSD, short and sweet.