Skip to content

Commit

Permalink
fix: Remove HTML tags before counting words for a note (#739)
Browse files Browse the repository at this point in the history
  • Loading branch information
amanharwara authored Nov 16, 2021
1 parent 80e89ec commit e16e817
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/assets/javascripts/components/NotesOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e16e817

Please sign in to comment.