var downsize = require('downsize'); function getExcerpt(html, truncateOptions) { truncateOptions = truncateOptions || {}; // Strip inline and bottom footnotes var excerpt = html.replace(/.*?<\/a>/gi, ''); excerpt = excerpt.replace(/
    .*?<\/ol><\/div>/, ''); // Strip other html excerpt = excerpt.replace(/<\/?[^>]+>/gi, ''); excerpt = excerpt.replace(/(\r\n|\n|\r)+/gm, ' '); /*jslint regexp:false */ if (!truncateOptions.words && !truncateOptions.characters) { truncateOptions.words = 50; } return downsize(excerpt, truncateOptions); } module.exports = getExcerpt;