mirror of
https://github.com/daniel-j/fimfic2epub.git
synced 2024-06-28 19:10:17 +12:00
17 lines
333 B
JavaScript
17 lines
333 B
JavaScript
import htmlToText from 'html-to-text'
|
|
import matchWords from 'match-words'
|
|
|
|
export default function htmlWordCount (html) {
|
|
let text = htmlToText.fromString(html, {
|
|
wordwrap: false,
|
|
ignoreImage: true,
|
|
ignoreHref: true
|
|
})
|
|
|
|
let count = 0
|
|
try {
|
|
count = matchWords(text).length
|
|
} catch (err) {}
|
|
return count
|
|
}
|