mirror of
https://github.com/mwilliamson/mammoth.js.git
synced 2024-12-08 15:14:29 +00:00
30 lines
687 B
JavaScript
30 lines
687 B
JavaScript
var _ = require("underscore");
|
|
|
|
exports.topLevelElement = topLevelElement;
|
|
exports.elements = elements;
|
|
exports.element = element;
|
|
|
|
function topLevelElement(tagName, attributes) {
|
|
return elements([element(tagName, attributes, {fresh: true})]);
|
|
}
|
|
|
|
function elements(elementStyles) {
|
|
return elementStyles.map(function(elementStyle) {
|
|
if (_.isString(elementStyle)) {
|
|
return element(elementStyle);
|
|
} else {
|
|
return elementStyle;
|
|
}
|
|
});
|
|
}
|
|
|
|
function element(tagName, attributes, options) {
|
|
options = options || {};
|
|
return {
|
|
tagName: tagName,
|
|
attributes: attributes || {},
|
|
fresh: options.fresh
|
|
};
|
|
}
|
|
|