exceljs
Version:
Excel Workbook Manager - Read and Write xlsx and csv Files.
52 lines (42 loc) • 1.12 kB
JavaScript
/**
* Copyright (c) 2016 Guyon Roche
* LICENCE: MIT - please refer to LICENCE file included with this module
* or https://github.com/guyonroche/exceljs/blob/master/LICENSE
*/
;
var utils = require('../../../utils/utils');
var BaseXform = require('../base-xform');
// <t xml:space="preserve"> is </t>
var TextXform = module.exports = function () {};
utils.inherits(TextXform, BaseXform, {
get tag() {
return 't';
},
render: function render(xmlStream, model) {
xmlStream.openNode('t');
if (model[0] === ' ' || model[model.length - 1] === ' ') {
xmlStream.addAttribute('xml:space', 'preserve');
}
xmlStream.writeText(model);
xmlStream.closeNode();
},
get model() {
return this._text.join('');
},
parseOpen: function parseOpen(node) {
switch (node.name) {
case 't':
this._text = [];
return true;
default:
return false;
}
},
parseText: function parseText(text) {
this._text.push(text);
},
parseClose: function parseClose() {
return false;
}
});
//# sourceMappingURL=text-xform.js.map