Skip to main content

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 (https://code.google.com/p/cut-html-string/). 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

Installation

Run ‘setup.py install’ to install this package.

Usage

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’.

Examples

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

Project details


Download files

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

Source Distribution

htmlcutstr-1.2.1.tar.gz (2.0 kB view details)

Uploaded Source

File details

Details for the file htmlcutstr-1.2.1.tar.gz.

File metadata

  • Download URL: htmlcutstr-1.2.1.tar.gz
  • Upload date:
  • Size: 2.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for htmlcutstr-1.2.1.tar.gz
Algorithm Hash digest
SHA256 a07ad4b5605ca2565669250016d04f88b8e1fa167eff8fe20544e9260a96dd35
MD5 b7c79ef59b56bf918ce0a537d313566e
BLAKE2b-256 02a53a4386c5d4952010f59748d97d502e5264ffd03e641da58d994fe6eda96e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page