Skip to content

Latest commit

 

History

History
20 lines (15 loc) · 627 Bytes

README.md

File metadata and controls

20 lines (15 loc) · 627 Bytes

Html-parser

npm i @288-toolkit/html-parser

A collection of functions to work with html strings.

html()

Provides a simple way to manipulate HTML strings. It returns itself after each method call, so you can chain them. You end the chain by calling the toString() method.

const textWithOnlyBoldAndItalic = html(text)
	.newLinesToBr() // Converts line break characters to <br /> tags
	.removeEmptyTags() // Removes empty tags from the HTML string
	.stripTags(['strong', 'em']) // Removes all HTML tags from the string, except `strong` and `em`.
	.toString(); // Returns the processed HTML string