Skip to main content

Tipi is for typographic replacements in HTML.

Status: ACTIVE

Under active development and maintenance.

https://travis-ci.org/honzajavorek/tipi.png?branch=master https://coveralls.io/repos/honzajavorek/tipi/badge.png?branch=master https://pypip.in/v/tipi/badge.png https://pypip.in/d/tipi/badge.png

Ideas behind this project

  • Input is HTML code, output is the same HTML code with changes in typography (entities, spaces, quotes, etc.).

  • You can’t parse HTML with regex.

  • The best existing HTML parser and tokenizer for Python is lxml.

  • There are more languages than English in the world. Each of them has different typographic rules.

Installation

Easy:

$ pip install tipi

Quickstart

Usage of tipi is very straightforward:

>>> from tipi import tipi
>>> html = '<p>"Zavolej mi na číslo <strong class="tel">765-876-888</strong>," řekla, a zmizela...</p>'
>>> html = tipi(html, lang='cs')
>>> html
'<p>\u201eZavolej mi na \u010d\xed\xadslo <strong class="tel">765\u2013876\u2013888</strong>,\u201c \u0159ekla, a\xa0zmizela\u2026</p>'
>>> print html
<p>Zavolej mi na čí­slo <strong class="tel">765876888</strong>, řekla, a zmizela</p>

Remember that tipi is designed to work with HTML. In case you need to perform replacements on plaintext, escape it first:

>>> fron tipi import tipi
>>> tipi('b -> c')  # this works only by coincidence!
u'b → c'
>>> tipi('a <- b -> c')
u'a  c'
>>> import cgi
>>> html = cgi.escape(u'a <- b -> c')
>>> html
u'a &lt;- b -&gt; c'
>>> tipi(html)
u'a ← b → c'

Features

  • Support for multiple languages.

  • Language-sensitive replacements for single quotes and double quotes.

  • Ellipsis, dashes, nonbreakable spaces, …

  • Arrows (–> turned into → ), dimensions (12 × 30).

  • Symbols (trademark, registered, copyright, EUR, …)

Alternatives

Plans

License: MIT

© 2013-2014 Jan Javorek <mail@honzajavorek.cz>

This work is licensed under MIT license.

Download files

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

Source Distribution

tipi-0.0.4.tar.gz (12.5 kB view details)

Uploaded Source

File details

Details for the file tipi-0.0.4.tar.gz.

File metadata

  • Download URL: tipi-0.0.4.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for tipi-0.0.4.tar.gz
Algorithm Hash digest
SHA256 a80a38ad7f8e18321e0456b40a24a82db64d338f7ed2100d10637892ba63cb03
MD5 618c6a534c83ace98a5c07d50b5a23af
BLAKE2b-256 53f22e53b18ef06d890f8fdab4bce4ca29c921022e37cd34a45e80fe07b8b14b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.4 This release

1 file

0.0.3

1 file

0.0.2

1 file

0.0.1

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page