Converts numeric HTML entities and Unicode characters to nice, neat named HTML entities
Project description
Named HTML entities are much neater and much easier to comprehend than numeric entities. And because they fall within the ASCII range, they’re much safer to use in multiple contexts than Unicode and its various encodings (UTF-8 and such).
This module helps convert from numerical HTML entites and Unicode characters that fall outside the normal ASCII range into named entities.
Usage
Python 2:
from namedentities import named_entities u = u'both em\u2014and–dashes…' print named_entities(u)
yields:
both em—and–dashes…
Python 3:
from namedentities import named_entities u = 'both em\u2014and–dashes…' print(named_entities(u)) # same result
Or using the six cross-version compatibility library, either one:
from namedentities import named_entities import six u = six.u('both em\u2014and–dashes…') six.print_(named_entities(u)) # same result
Recent Changes
Notes
Doesn’t attempt to encode <, >, or & (or their numerical equivalents) to avoid interfering with HTML escaping.
This is basically a packaging of Ian Beck’s work. Thank you, Ian!
Installation
pip install namedentities
To easy_install under a specific Python version (3.3 in this example):
python3.3 -m easy_install namedentities
(You may need to prefix these with “sudo “ to authorize installation.)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
File details
Details for the file namedentities-1.2.zip
.
File metadata
- Download URL: namedentities-1.2.zip
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ec9ab70b1bc7eada9be7226252c238544b573eeb3629cd9b0dc0a272f30a504 |
|
MD5 | 22259dc316a3dd2861a34026f20397c7 |
|
BLAKE2b-256 | 3b1ea863334acf2b944825e4054a31f5d6b46647bdba80505948d912d708786a |
File details
Details for the file namedentities-1.2.tar.gz
.
File metadata
- Download URL: namedentities-1.2.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2191cc966e8204ac580a4bb11a044a04c440a81476f5ffcaeae2d1d3c9935f4 |
|
MD5 | 45be79ddd0419ed58a04e982a829de0c |
|
BLAKE2b-256 | 8a33606ac116013a0b90aea4d3491578aa1382651fca88e697487b7393d4c0a0 |