aboutsummaryrefslogtreecommitdiff
path: root/lib/documents.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-04-01 16:57:41 +0100
committerMichael Williamson <mike@zwobble.org>2013-04-01 16:57:41 +0100
commit25109ca7e318e188229cac92552ba0dcd7e897a1 (patch)
tree324cecb9ddc3cd5ad85c45143cbe1513aa3e2edc /lib/documents.js
parent376094a18d76eef4335e374455f0b2869e53120b (diff)
Add conversion of hyperlink elements to <a> tags
Diffstat (limited to 'lib/documents.js')
-rw-r--r--lib/documents.js39
1 files changed, 22 insertions, 17 deletions
diff --git a/lib/documents.js b/lib/documents.js
index 27190aa..8fc3df7 100644
--- a/lib/documents.js
+++ b/lib/documents.js
@@ -1,9 +1,3 @@
-exports.Document = Document;
-exports.Paragraph = Paragraph;
-exports.Run = Run;
-exports.Text = Text;
-
-
function Document(children) {
return {
type: "document",
@@ -11,25 +5,36 @@ function Document(children) {
};
}
-function Paragraph(children, properties) {
+Paragraph = ElementWithChildren("paragraph");
+Run = ElementWithChildren("run");
+
+function Text(value) {
return {
- type: "paragraph",
- children: children,
- properties: properties || {}
+ type: "text",
+ value: value
};
}
-function Run(children, properties) {
+function Hyperlink(children, options) {
return {
- type: "run",
+ type: "hyperlink",
children: children,
- properties: properties || {}
+ href: options.href
};
}
-function Text(value) {
- return {
- type: "text",
- value: value
+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;