UNPKG

sbd-ts

Version:

Split text into sentences with Sentence Boundary Detection (SBD).

16 lines (13 loc) 475 B
export function sanitizeHtml(text, opts) { // Strip HTML from Text using browser HTML parser if ((typeof text == 'string' || text instanceof String) && typeof document !== "undefined") { var $div : any = document.createElement("DIV"); $div.innerHTML = text; text = ($div.textContent || '').trim(); } //DOM Object else if (typeof text === 'object' && text.textContent) { text = (text.textContent || '').trim(); } return text; };