Skip to content

Python module for truncating text that contains markup

Notifications You must be signed in to change notification settings

chadpaulson/htmltruncate

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%