Skip to content
프로젝트

소개

:triangular_ruler: truncate html by text length

웹 및 앱 개발

이 수치를 측정하는 방법

What you can do

  • fast, lean, extensible
  • truncate by text length, not html length
  • truncate by complete words, not just by characters

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

trunc-html

Build Status

truncate html by text length

install

using npm.

npm install -S trunc-html

features

  • fast, lean, extensible
  • truncate by text length, not html length
  • truncate by complete words, not just by characters

trunc(html, limit, options?)

Returns the result of truncating the provided html. A plain-text version is provided as well.

var html = 'the force is <strong>with this one</strong>. some more rubbish';
trunc(html, 30);
// <-
//    { html: 'the force is <strong>with this one</strong>. …',
//      text: 'the force is with this one. …' }

limit

Maximum amount of text characters allowed. When the limit is reached, the algorithm will trace back to the last word separator and trim the rest into a … glyph.

options.ignoreTags

If you'd like to supress certain HTML tags from being output you can provide an array of tags to be excluded, set ignoreTags to something like ['strong'].

options.imageAltText

If you'd like to use the alt attribute for the text portion of the result, instead of dropping images entirely in text flavor, set imageAltText to true.

options.sanitizer

Options passed to insane. Note that these options are overridden by the options provided by trunc-html, so you can't use transformText, which trunc-html reserves for itself.

related

license

MIT

관련 프로젝트 살펴보기

불러오는 중…