commonform-docx 9.2.0 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTES.md +11 -0
- package/index.js +8 -6
- package/package.json +1 -1
- package/templates/hyperlink.js +6 -0
- package/templates/paragraph.js +2 -3
- package/templates/run.js +2 -3
- package/test.log +16 -12
- package/lint.log +0 -4
package/NOTES.md
ADDED
package/index.js
CHANGED
|
@@ -25,10 +25,8 @@ function defaultStyles (smart) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
module.exports = (
|
|
29
|
-
|
|
30
|
-
values = [],
|
|
31
|
-
{
|
|
28
|
+
module.exports = (form, values = [], options = {}) => {
|
|
29
|
+
let {
|
|
32
30
|
a4 = false,
|
|
33
31
|
after = '',
|
|
34
32
|
blanks = { text: '[•]', highlight: 'yellow' },
|
|
@@ -45,9 +43,13 @@ module.exports = (
|
|
|
45
43
|
smart,
|
|
46
44
|
styles,
|
|
47
45
|
title,
|
|
48
|
-
version
|
|
46
|
+
version,
|
|
47
|
+
...rest
|
|
48
|
+
} = options
|
|
49
|
+
const extraKeys = Object.keys(rest)
|
|
50
|
+
if (extraKeys.length !== 0) {
|
|
51
|
+
throw new Error(`Unsupported Options: ${extraKeys.join(', ')}`)
|
|
49
52
|
}
|
|
50
|
-
) => {
|
|
51
53
|
styles = styles
|
|
52
54
|
? Object.assign({}, defaultStyles(smart), styles)
|
|
53
55
|
: defaultStyles(smart)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commonform-docx",
|
|
3
3
|
"description": "render Common Forms in Office Open XML (Microsoft Word .docx format)",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "10.0.0",
|
|
5
5
|
"author": "Kyle E. Mitchell <kyle@kemitchell.com> (http://kemitchell.com)",
|
|
6
6
|
"bin": "bin.js",
|
|
7
7
|
"dependencies": {
|
package/templates/paragraph.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const escape = require('../escape')
|
|
2
1
|
const has = require('has')
|
|
2
|
+
const hyperlink = require('./hyperlink')
|
|
3
3
|
const numberToWords = require('number-to-words-en')
|
|
4
4
|
const run = require('./run')
|
|
5
5
|
const tag = require('./tag')
|
|
@@ -113,8 +113,7 @@ module.exports = (element, options) => {
|
|
|
113
113
|
function componentReference (component, meta) {
|
|
114
114
|
const href = component.component + '/' + component.version
|
|
115
115
|
const returned = [makeRun(options.incorporateComponentText + ' ')]
|
|
116
|
-
const
|
|
117
|
-
const link = '<w:hyperlink r:id="' + rId + '" w:history="1"><w:r><w:rPr><w:color w:val="0000EE"/><w:u w:val="single"/></w:rPr><w:t>' + escape(href) + '</w:t></w:r></w:hyperlink>'
|
|
116
|
+
const link = hyperlink(options, href)
|
|
118
117
|
if (meta) {
|
|
119
118
|
returned.push(
|
|
120
119
|
makeRun(meta.publisher + ' ' + meta.name + ' Version ' + meta.version + ' ('),
|
package/templates/run.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const escape = require('../escape')
|
|
2
2
|
const has = require('has')
|
|
3
|
+
const hyperlink = require('./hyperlink')
|
|
3
4
|
const tag = require('./tag')
|
|
4
5
|
|
|
5
6
|
const defaults = {
|
|
@@ -84,9 +85,7 @@ module.exports = function run (element, conspicuous, options) {
|
|
|
84
85
|
)
|
|
85
86
|
}
|
|
86
87
|
} else if (has(element, 'link')) {
|
|
87
|
-
|
|
88
|
-
const rId = options.rIdForHREF(url)
|
|
89
|
-
return '<w:hyperlink r:id="' + rId + '"><w:r><w:rPr><w:rStyle w:val="Hyperlink"/></w:rPr><w:t>' + escape(url) + '</w:t></w:r></w:hyperlink>'
|
|
88
|
+
return hyperlink(options, element.link)
|
|
90
89
|
} else {
|
|
91
90
|
throw new Error('Invalid type: ' + JSON.stringify(element, null, 2))
|
|
92
91
|
}
|
package/test.log
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
|
|
2
|
-
> commonform-docx@9.
|
|
2
|
+
> commonform-docx@9.3.0 pretest
|
|
3
3
|
> npm run prepublishOnly
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> commonform-docx@9.
|
|
6
|
+
> commonform-docx@9.3.0 prepublishOnly
|
|
7
7
|
> node build/scaffold.js data/scaffold.docx > data/scaffold.json
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> commonform-docx@9.
|
|
10
|
+
> commonform-docx@9.3.0 test
|
|
11
11
|
> tape test.js
|
|
12
12
|
|
|
13
13
|
TAP version 13
|
|
@@ -75,24 +75,28 @@ ok 44 conspicuous text appears in output
|
|
|
75
75
|
ok 45 no render error
|
|
76
76
|
ok 46 no textract error
|
|
77
77
|
ok 47 title appears in output
|
|
78
|
-
# renders centered titles
|
|
78
|
+
# renders centered titles by default
|
|
79
79
|
ok 48 no render error
|
|
80
80
|
ok 49 no textract error
|
|
81
81
|
ok 50 title appears in output
|
|
82
|
-
#
|
|
82
|
+
# accepts option for left-align title
|
|
83
83
|
ok 51 no render error
|
|
84
84
|
ok 52 no textract error
|
|
85
|
-
ok 53
|
|
86
|
-
# renders
|
|
85
|
+
ok 53 title appears in output
|
|
86
|
+
# renders versions
|
|
87
87
|
ok 54 no render error
|
|
88
88
|
ok 55 no textract error
|
|
89
|
-
ok 56
|
|
89
|
+
ok 56 version appears in output
|
|
90
|
+
# renders hashes
|
|
91
|
+
ok 57 no render error
|
|
92
|
+
ok 58 no textract error
|
|
93
|
+
ok 59 hash symbol appears in output
|
|
90
94
|
# throws for invalid content
|
|
91
|
-
ok
|
|
95
|
+
ok 60 throw an error
|
|
92
96
|
|
|
93
|
-
1..
|
|
94
|
-
# tests
|
|
95
|
-
# pass
|
|
97
|
+
1..60
|
|
98
|
+
# tests 60
|
|
99
|
+
# pass 60
|
|
96
100
|
|
|
97
101
|
# ok
|
|
98
102
|
|
package/lint.log
DELETED