Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/honza/punctuation

Add real HTML punctuation
https://github.com/honza/punctuation

Last synced: about 5 hours ago
JSON representation

Add real HTML punctuation

Awesome Lists containing this project

README

        

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)][1] article.

License
-------

BSD, short and sweet.

[1]: http://www.alistapart.com/articles/emen/