Sha256: a92bf181cd76a3daa37c4504196b74d3d7f3968985db9847d7c106429caf8995
Contents?: true
Size: 668 Bytes
Versions: 52
Compression:
Stored size: 668 Bytes
Contents
var ElementType = require("domelementtype"), getOuterHTML = require("dom-serializer"), isTag = ElementType.isTag; module.exports = { getInnerHTML: getInnerHTML, getOuterHTML: getOuterHTML, getText: getText }; function getInnerHTML(elem, opts){ return elem.children ? elem.children.map(function(elem){ return getOuterHTML(elem, opts); }).join("") : ""; } function getText(elem){ if(Array.isArray(elem)) return elem.map(getText).join(""); if(isTag(elem)) return elem.name === "br" ? "\n" : getText(elem.children); if(elem.type === ElementType.CDATA) return getText(elem.children); if(elem.type === ElementType.Text) return elem.data; return ""; }
Version data entries
52 entries across 51 versions & 10 rubygems