export function htmlNormalizer(htmlInput) { let str = htmlInput; // We are normalizing the input from contenteditable of each browser, also removing unnecesary html tags // https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Editable_content#Differences_in_markup_generation // Old browsers uses `p` normalize to `div` instead. str = str .replace(/

/g, '

') // IE and old browsers outputs

instead of

s .replace(/<\/p>/g, '
'); // IE and old browsers outputs

instead of

s // Harmonize all to tag. str = str .replace(//g, '') // IE .replace(/<\/strong>/g, ''); // IE // Harmonize all to tag. str = str .replace(//g, '') // IE .replace(/<\/em>/g, ''); // IE // Remove first opening tag, otherwise // with the following transformation below // we might add an unintended first empty line. if (str.startsWith('
')) { str = str.replace('
', ''); } // Normalize
s to
. // return str.replace(/
/g, '
').replace(/<\/div>/g, ''); return str; }