@lyuboslavlyubenov/node-summary
Version:
Summarizes text using a naive summarization algorithm
19 lines (16 loc) • 406 B
JavaScript
const cheerio = require('cheerio')
const htmlToText = require('html-to-text')
const convertHTMLToText = body => {
return htmlToText.fromString(body.toString(), {
ignoreHref: true,
ignoreImage: true,
})
}
const getTitle = htmlBody => {
let $ = cheerio.load(htmlBody)
return $('title').text() || $('h1').text() || ''
}
module.exports = {
convertHTMLToText,
getTitle
}