Skip to main content

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

  • Repackaged as a Python package, rather than independent modules.

  • Now successfully packaged for, and tests against, against Python 2.5, 2.6, 2.7, 3.2, and 3.3, as well as PyPy 1.7 (based on 2.7.2). Mutomated multi-version testing managed with pytest and tox.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

namedentities-1.3.zip (9.3 kB view details)

Uploaded Source

namedentities-1.3.tar.gz (4.1 kB view details)

Uploaded Source

File details

Details for the file namedentities-1.3.zip.

File metadata

  • Download URL: namedentities-1.3.zip
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for namedentities-1.3.zip
Algorithm Hash digest
SHA256 ec748150ebeb7d402244ee4cd8e49e2cce7a80ce64b635f23c95dbea1482a26d
MD5 157a009f3deb0c8b2dc2e629d23f7558
BLAKE2b-256 1c17e91b5cbb38cd3358055b35f34239b5e8284577a0b2e52d67080b7d5c432b

See more details on using hashes here.

File details

Details for the file namedentities-1.3.tar.gz.

File metadata

  • Download URL: namedentities-1.3.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for namedentities-1.3.tar.gz
Algorithm Hash digest
SHA256 23607529c4c7fd6d8afdd821b78ca5da5888fcaccb42f04b06b09ceaebd4b5f7
MD5 bcfc73ffd4f70e32c69566c9dc8b1b32
BLAKE2b-256 9421b6656c44e419adb723347e7506612bcd654785654b737c68beaa93684b60

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page