Skip to main content

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

Metadata

Release files for htmlcutstr 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for htmlcutstr 1.2.1
File Size Uploaded
htmlcutstr-1.2.1.tar.gz 2.0 kB Details

Release files / htmlcutstr-1.2.1.tar.gz

Download URL htmlcutstr-1.2.1.tar.gz
Size 2.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a07ad4b5605ca2565669250016d04f88b8e1fa167eff8fe20544e9260a96dd35
BLAKE2b-256 checksum
How to use checksums
02a53a4386c5d4952010f59748d97d502e5264ffd03e641da58d994fe6eda96e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.2.1 This release

1 release file

1.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page