Skip to main content

Typographic replacements in HTML

Project description


Tipi is for typographic replacements in HTML.

Status: ACTIVE

Under active development and maintenance.

.. image::
.. image::
.. image::
.. image::

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.



$ pip install tipi


Usage of tipi is very straightforward:

.. code-block:: python

>>> 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">765–876–888</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:

.. code-block:: python

>>> 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'


- 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, ...)


- `Typogrify <>`_ - English only, adds markup for styling, on top of `smartypants <>`_
- `cstypo <>`_ - Czech only, not working well with HTML


- Inspiration from `Typogrify <>`_?
- Get some inspiration from `Dero's <>`_ and `Typomil's <>`_ typography guides.
- Get some inspiration from ` <>`_) (`source <;zpet=%2Fauth%2Fvyhledavani%2F%3Fsearch%3Djakub%20fiala%26start%3D1>`_).
- Maybe also some inspiration `from here <>`_.

License: MIT

© 2013-2014 Jan Javorek <>

This work is licensed under `MIT license <>`_.

Project details

Download files

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

Files for tipi, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size tipi-0.0.4.tar.gz (12.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page