diff --git a/client/src/helpers/text.js b/client/src/helpers/text.js index 58c7780f..6802f773 100644 --- a/client/src/helpers/text.js +++ b/client/src/helpers/text.js @@ -1,6 +1,12 @@ +const sanitize = html => { + let doc = new DOMParser().parseFromString(html, 'text/html'); + return doc.body.textContent || ''; +}; + export const newLineToParagraph = (text) => { return text .split(/\n+/) + .map(sanitize)// sanitize after the split, because the sanitizer would probably remove the newlines .map(p => `
${p}
`) .join(''); };