fix: Remove HTML tags before counting words for a note (#739)

This commit is contained in:
Aman Harwara
2021-11-16 19:19:28 +05:30
committed by GitHub
parent 80e89ec895
commit e16e817747

View File

@@ -44,8 +44,11 @@ const countNoteAttributes = (text: string) => {
paragraphs: 'N/A',
};
} catch {
const removeTags = text.replace(/<[^>]*>/g," ").replace(/\s+/g, ' ').trim();
text = removeTags;
const characters = text.length;
const words = text.match(/[\w'-]+\b/g)?.length;
const words = text.split(" ")?.length;
const paragraphs = text.replace(/\n$/gm, '').split(/\n/).length;
return {