chadpaulson / htmltruncate

Python module for truncating text that contains markup

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

htmltruncate

Build Status

Returns a truncated string while preserving HTML markup (which does not count towards length). All tags left open by truncation are closed.

Example:

>>> import htmltruncate
>>> str = "<p>You're not gonna lose the house, <b>everybody</b> has three mortgages nowadays.</p>"
>>> htmltruncate.truncate(str, 33)
"<p>You're not gonna lose the house, </p>"

Options:

>>> htmltruncate.truncate(str, 33, full_word=True, ellipsis="...")
"<p>You're not gonna lose the house, <b>everybody</b></p>..."

About

Python module for truncating text that contains markup


Languages

Language:Python 100.0%