aboutsummaryrefslogtreecommitdiff
path: root/lib/documents.js
blob: 8fc3df70cf9bd5e8ad99f5442f89e6a32814eacc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function Document(children) {
    return {
        type: "document",
        children: children
    };
}

Paragraph = ElementWithChildren("paragraph");
Run = ElementWithChildren("run");

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 || {}
        };
    };
}

exports.Document = Document;
exports.Paragraph = Paragraph;
exports.Run = Run;
exports.Text = Text;
exports.Hyperlink = Hyperlink;