Socket
Socket
Sign inDemoInstall

excerpt-html

Package Overview
Dependencies
31
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    excerpt-html

Get the Excerpt from a markdown file (like in jekyll or *smith)


Version published
Weekly downloads
156
decreased by-24.64%
Maintainers
1
Install size
1.18 MB
Created
Weekly downloads
 

Readme

Source

Build Status js-standard-style Maintainability Test Coverage

excerpt-html

parses a given html text for a good excerpt.

Install

$ npm i excerpt-html --save

API usage

var htmlCode = '<p>Hello world</p>';
var excerptHtml = require('excerpt-html');
var excerpt = excerptHtml(htmlCode);

It will either use the first found paragraph or everything up to a

<!-- more -->

Options

You can specify a few options that modify the way the excerpt is parsed:

excerptHtml(htmlCode, {
    moreRegExp:  /\s*<!--\s*more\s*-->/i,  // Search for the slug
    stripTags:   true, // Set to false to get html code
    pruneLength: 140, // Amount of characters that the excerpt should contain
    pruneString: '…', // Character that will be added to the pruned string
    pruneSeparator: ' ', // Separator to be used to separate words
})

Note: pruneLength and prunestring only work when stripTags is set to true (default).

History

To make this project we detached the code of metalsmith-better-excerpts from metalsmith.

Keywords

FAQs

Last updated on 16 Apr 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc