1.8.1 • Published 4 years ago

html-substring v1.8.1

Weekly downloads
526
License
MIT
Repository
github
Last release
4 years ago

html-substring

Travis CI Build Status App Veyor Build Status npm version

Module making safe substring of HTML source

Doc

interface Options {
  breakWords: boolean // defaults to true
  suffix: (() => string) | string | null // defaults to null
}

/**
 * @param source Source HTML
 * @param length Visible characters (everything but HTML tags) limit
 * @param options Options object or suffix
 *
 * @returns stripped source by length characters
 */
function html_substring(
  source: string,
  length: number,
  options?: string | Partial<Options>,
): string

Examples

// JavaScript/TypeScript

import html_substring from 'html-substring'

console.log(html_substring('<span><div>Hello</div> <p>World</p></span>', 6))
// <span><div>Hello</div> </span>

You can look tests for more examples

1.8.1

4 years ago

1.8.0

5 years ago

1.7.1

5 years ago

1.7.0

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.1

5 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago