Source misalignment makes code very difficult to read. this.text starts at ident level but finishes at position 0 and rest of module is misaligned. There is online JS beautifier http://jsbeautifier.org/ although I prefer Eclipse formatting
this.text = function(content) {
content = strval(content);
if (!tags && !comment && !pi && !cdata) return this;
if (attributes && attribute) {
++texts;
write(content.replace(/&/g, '&').replace(/"/g, '"'));
return this;
}
else if(attributes && !attribute) {
this.endAttributes();
}
++texts;
write(content.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'));
return this;
}