mammoth.js/lib/documents.js
2013-04-08 20:38:35 +01:00

67 lines
1.3 KiB
JavaScript

function Document(children) {
return {
type: "document",
children: children
};
}
function Paragraph(children, properties) {
properties = properties || {};
return {
type: "paragraph",
children: children,
styleName: properties.styleName || null
};
}
function Run(children, properties) {
properties = properties || {};
return {
type: "run",
children: children,
styleName: properties.styleName || null,
isBold: properties.isBold,
isItalic: properties.isItalic
};
}
function Text(value) {
return {
type: "text",
value: value
};
}
function Hyperlink(children, options) {
return {
type: "hyperlink",
children: children,
href: options.href
};
}
function ElementWithChildren(type) {
return function(children, properties) {
return {
type: type,
children: children,
properties: properties || {}
};
};
}
function Image(read, altText) {
return {
type: "image",
read: read,
altText: altText
};
}
exports.Document = Document;
exports.Paragraph = Paragraph;
exports.Run = Run;
exports.Text = Text;
exports.Hyperlink = Hyperlink;
exports.Image = Image;