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

Version Path
trusty-cms-6.3.1 node_modules/domutils/lib/stringify.js
optimacms-0.1.61 spec/dummy/node_modules/domutils/lib/stringify.js
disco_app-0.18.0 test/dummy/node_modules/domutils/lib/stringify.js
disco_app-0.18.2 test/dummy/node_modules/domutils/lib/stringify.js
trusty-cms-5.0.7 node_modules/domutils/lib/stringify.js
trusty-cms-5.0.6 node_modules/domutils/lib/stringify.js
trusty-cms-5.0.5 node_modules/domutils/lib/stringify.js
trusty-cms-5.0.4 node_modules/domutils/lib/stringify.js
disco_app-0.16.1 test/dummy/node_modules/domutils/lib/stringify.js
disco_app-0.15.2 test/dummy/node_modules/domutils/lib/stringify.js
trusty-cms-5.0.3 node_modules/domutils/lib/stringify.js
trusty-cms-5.0.2 node_modules/domutils/lib/stringify.js
disco_app-0.18.4 test/dummy/node_modules/domutils/lib/stringify.js
disco_app-0.18.1 test/dummy/node_modules/domutils/lib/stringify.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/domutils/lib/stringify.js
disco_app-0.14.0 test/dummy/node_modules/domutils/lib/stringify.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/domutils/lib/stringify.js
trusty-cms-5.0.1 node_modules/domutils/lib/stringify.js
trusty-cms-4.3.5 node_modules/domutils/lib/stringify.js
trusty-cms-5.0.0 node_modules/domutils/lib/stringify.js