Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Python module which helps to cut HTML strings by keeping HTML tags as they are

Project Description

This is repository is an improved version of htmlcutstring ( I’m not the original author.

Differences between original

  1. htmlcutstr has availability to count words instead of characters
  2. It works fine on both Python 2.x and 3.x


Run ‘ install’ to install this package.


cutHtmlString(string, limit, countType=’c’)

string is obviously the string you want to cut
limit maximum number of characters/words (depending on countType value) output string can have
countType can be equal to ‘c’ or ‘w’
‘c’ means ‘count by characters’
‘w’ means ‘count by words’.


from htmlcutstr import cutHtmlString

htmlstring = '<div>insert your <a>text</a> here</div>'

print(cutHtmlString(htmlstring, 10)) # '<div>insert you</div>'
print(cutHtmlString(htmlstring, 3, 'w')) # '<div>insert your <a>text</a></div>'

Release History

This version
History Node


History Node


Download Files

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

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(2.0 kB) Copy SHA256 Hash SHA256
Source None Dec 31, 2014

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Kabu Creative Kabu Creative UX & Design Google Google Cloud Servers Fastly Fastly CDN StatusPage StatusPage Statuspage DigiCert DigiCert EV Certificate