A Python library for hyphenating HTML in your Django project
Project description
<pre><code> ___ _ _ _
___ ___| _| |_ ___| |_ _ _ ___| |_ ___ ___
|_ -| . | _| _|___| | | | . | | -_| |
|___|___|_| |_| |_|_|_ | _|_|_|___|_|_|
|___|_| </code></pre>
A Python library for hyphenating HTML in your Django project.
Repurposed from Filipe Fortes' "excellent AppEngine app":https://github.com/fortes/softhyphen.
h2. Features
* Use the <code>­</code> "HTML entity":http://www.w3.org/TR/html4/struct/text.html#h-9.3.3 to hyphenate text. Works well with "text-align:justify;":http://www.w3schools.com/cssref/pr_text_text-align.asp
* Can be called as a function from inside Python code or as a filter in the Django template
* Supports more than 25 languages
* Supports Python 2.5, 2.6 and 2.7 and Django 1.0-1.4
h2. Getting started
Install it.
<pre><code>$ pip install django-softhyphen</code></pre>
Add it to the INSTALLED_APPS in your settings.py
<pre><code>INSTALLED_APPS = (
...
'softhyphen',
...
)</code></pre>
Use it in as a function.
<pre><code>>> from softhyphen.html import hyphenate
>>> hyphenate("<h1>I love hyphenation</h1>")
"<h1>I love hy­phen­a­tion</h1>"
>>> # It is English by default, but you can provide another language.
>>> hyphenate("<h1>Me encanta guiones</h1>", language="es-es")
<h1>Me en­can­ta gu­io­nes</h1></code></pre>
Or use it as a template filter.
<pre><code>{% load softhyphen_tags %}
{{ text|softhyphen }}
{# You can specify another language as an argument. English is the default #}
{{ text|softhyphen:"es-es" }}</code></pre>
(Warning! Because of its overhead, the filter is not recommended in production if it needs to run each time the page loads.)
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 Distribution
django-softhyphen-0.15.tar.gz
(1.0 MB
view hashes)