Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

truncatise

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

truncatise

Truncate HTML based on characters, words or paragraphs. Has the ability to strip tags.

  • 0.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15K
decreased by-60.02%
Maintainers
1
Weekly downloads
 
Created
Source

Truncatise

JavaScript module to truncate HTML strings.

Description

Provides the ability to truncate HTML strings down to excerpts based on character length, word length or paragraph length.

Features:

  • Truncate based on number of Characters, Words or Paragraphs.
  • Strip HTML from returned string.
  • Provides a strict flag to specify whether to cut-off mid word or not.
  • Configurable suffix appended to the end of the returned excerpt.

Install

npm install truncatise

Options (with default values)

{
  TruncateBy:     'words',  // Options are 'words', 'characters' or 'paragraphs'
  TruncateLength: 50,    	  // The count to be used with TruncatedBy
  StripHTML:      false,    // Whether or not the truncated text should contain HTML tags
  Strict:         true,     // If set to false the truncated text finish at the end of the word
  Suffix:         '...'     // Text to be appended to the end of the truncated text
}

Example Usage

var options = {
  TruncateLength: 4,
  TruncateBy : "words",
  Strict : false,
  StripHTML : true,
  Suffix : ' (Read More)'
};
var excerpt = truncatise("<p>This is a test of Truncatise</p>", options);
console.log(excerpt); // This is a test (Read More)

Keywords

FAQs

Package last updated on 12 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc