MCPcopy Create free account
hub / github.com/Tjatse/node-readability / parse

Function parse

index.js:95–113  ·  view source on GitHub ↗

* Parse html to cheerio dom. * @param o options * @param e extra data * @return {String}

(o, e)

Source from the content-addressed store, hash-verified

93 * @return {String}
94 */
95function parse(o, e){
96 if (!o.html) {
97 return '';
98 }
99 if (o.options.killBreaks) {
100 // replace <br />(blanks goes here) to <br />.
101 o.html = o.html.replace(/<br[^\/>]*\/?>/ig, '<br />');
102 // remove tab symbols like \r\t\n
103 o.html = o.html.replace(/[\n\r\t]{2,}/gi, ' ');
104 }
105
106 var co = {decodeEntities: false};
107 ['normalizeWhitespace', 'xmlMode', 'lowerCaseTags'].forEach(function(n){
108 co[n] = !!o.options[n];
109 });
110
111 var $ = cheerio.load(o.html, co);
112 o.callback(null, new Article($, o.options), o.options, e);
113}

Callers 1

readFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…