mirror of
https://github.com/mwilliamson/mammoth.js.git
synced 2024-12-08 15:14:29 +00:00
67 lines
1.3 KiB
JavaScript
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;
|