commonform-docx 10.0.0 → 10.1.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/README.md +2 -0
- package/bin.js +5 -0
- package/index.js +22 -0
- package/package.json +10 -1
- package/NOTES.md +0 -11
- package/test.log +0 -102
package/README.md
CHANGED
|
@@ -24,4 +24,6 @@ It may contain:
|
|
|
24
24
|
|
|
25
25
|
4. a `markFilled` property whose value is `true` or `false`
|
|
26
26
|
|
|
27
|
+
5. other properties you can find in function exported from `index.js`
|
|
28
|
+
|
|
27
29
|
The function returns a [JSZip](https://npmjs.com/packages/jszip) Object primed with `.docx` document data.
|
package/bin.js
CHANGED
|
@@ -20,6 +20,8 @@ const usage = [
|
|
|
20
20
|
' --component-style STYLE Change component style [default: both]',
|
|
21
21
|
' -d JSON --directions JSON Use directions to fill in blanks',
|
|
22
22
|
' -e VERSION, --form-version VERSION Form version to be rendered',
|
|
23
|
+
' --font NAME Default font family name',
|
|
24
|
+
' --font-size POINTS Default font size in points',
|
|
23
25
|
' -i, --indent-margins Indent margins, commonwealth style',
|
|
24
26
|
' --incorporate-component-text TEXT Verb for component references [default: Incorporate]',
|
|
25
27
|
' --quote-component-text TEXT Text for introducing quoted components',
|
|
@@ -105,6 +107,9 @@ if (parsed['--blank-text']) options.blanks = parsed['--blank-text']
|
|
|
105
107
|
|
|
106
108
|
if (parsed['--mark-filled']) options.markFilled = true
|
|
107
109
|
|
|
110
|
+
if (parsed['--font']) options.font = parsed['--font']
|
|
111
|
+
if (parsed['--font-size']) options.fontSize = parsed['--font-size']
|
|
112
|
+
|
|
108
113
|
options.loadedComponentStyle = parsed['--component-style']
|
|
109
114
|
if (parsed['--quote-component-text']) options.quoteComponentText = parsed['--quote-component-text']
|
|
110
115
|
options.incorporateComponentText = parsed['--incorporate-component-text']
|
package/index.js
CHANGED
|
@@ -37,6 +37,8 @@ module.exports = (form, values = [], options = {}) => {
|
|
|
37
37
|
leftAlignTitle = false,
|
|
38
38
|
loadedComponentStyle = 'inline',
|
|
39
39
|
markFilled = false,
|
|
40
|
+
fontSize = 12,
|
|
41
|
+
font = 'Times New Roman',
|
|
40
42
|
complete = false,
|
|
41
43
|
numberStyle = decimalNumbering,
|
|
42
44
|
quoteComponentText = 'Quoting for convenience, with any conflicts resolved in favor of the standard:',
|
|
@@ -82,6 +84,26 @@ module.exports = (form, values = [], options = {}) => {
|
|
|
82
84
|
const clone = Object.assign({}, scaffold)
|
|
83
85
|
clone.word['document.xml'] = result.xml
|
|
84
86
|
clone.word._rels['document.xml.rels'] = docRels(result.hrefs)
|
|
87
|
+
// Set default font size. We need to replace <w:sz> and <w:szCs>
|
|
88
|
+
// elements both in <w:docDefaults> and in the default style.
|
|
89
|
+
const fontSizeInHalfPoints = Math.floor(fontSize * 2)
|
|
90
|
+
clone.word['styles.xml'] = clone.word['styles.xml']
|
|
91
|
+
.replaceAll(
|
|
92
|
+
/<w:sz w:val="[0-9]+"\/>/g,
|
|
93
|
+
`<w:sz w:val="${fontSizeInHalfPoints}"/>`
|
|
94
|
+
)
|
|
95
|
+
.replaceAll(
|
|
96
|
+
/<w:szCs w:val="[0-9]+"\/>/g,
|
|
97
|
+
`<w:szCs w:val="${fontSizeInHalfPoints}"/>`
|
|
98
|
+
)
|
|
99
|
+
// Set font family the same way.
|
|
100
|
+
if (font !== 'Times New Roman') {
|
|
101
|
+
clone.word['styles.xml'] = clone.word['styles.xml']
|
|
102
|
+
.replaceAll(
|
|
103
|
+
'<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>',
|
|
104
|
+
`<w:rFonts w:ascii="${font}" w:hAnsi="${font}"/>`
|
|
105
|
+
)
|
|
106
|
+
}
|
|
85
107
|
const zip = new JSZip()
|
|
86
108
|
zipObject(zip, clone)
|
|
87
109
|
return zip
|
package/package.json
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commonform-docx",
|
|
3
3
|
"description": "render Common Forms in Office Open XML (Microsoft Word .docx format)",
|
|
4
|
-
"version": "10.
|
|
4
|
+
"version": "10.1.0",
|
|
5
5
|
"author": "Kyle E. Mitchell <kyle@kemitchell.com> (http://kemitchell.com)",
|
|
6
6
|
"bin": "bin.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"bin.js",
|
|
9
|
+
"data/scaffold.json",
|
|
10
|
+
"escape.js",
|
|
11
|
+
"index.js",
|
|
12
|
+
"LICENSE.md",
|
|
13
|
+
"README.md",
|
|
14
|
+
"templates"
|
|
15
|
+
],
|
|
7
16
|
"dependencies": {
|
|
8
17
|
"@kemitchell/docopt": "^1.0.0",
|
|
9
18
|
"agreement-schedules-exhibits-numbering": "^3.0.0",
|
package/NOTES.md
DELETED
package/test.log
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> commonform-docx@9.3.0 pretest
|
|
3
|
-
> npm run prepublishOnly
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
> commonform-docx@9.3.0 prepublishOnly
|
|
7
|
-
> node build/scaffold.js data/scaffold.docx > data/scaffold.json
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
> commonform-docx@9.3.0 test
|
|
11
|
-
> tape test.js
|
|
12
|
-
|
|
13
|
-
TAP version 13
|
|
14
|
-
# renders text
|
|
15
|
-
ok 1 no render error
|
|
16
|
-
ok 2 no textract error
|
|
17
|
-
ok 3 text appears in output
|
|
18
|
-
# renders definitions
|
|
19
|
-
ok 4 no render error
|
|
20
|
-
ok 5 no textract error
|
|
21
|
-
ok 6 defined term appears in output
|
|
22
|
-
# renders uses
|
|
23
|
-
ok 7 no render error
|
|
24
|
-
ok 8 no textract error
|
|
25
|
-
ok 9 term appears in output
|
|
26
|
-
# renders references
|
|
27
|
-
ok 10 no render error
|
|
28
|
-
ok 11 no textract error
|
|
29
|
-
ok 12 reference appears in output
|
|
30
|
-
# handles components without headings
|
|
31
|
-
ok 13 no render error
|
|
32
|
-
# handles components with substitutions
|
|
33
|
-
ok 14 no render error
|
|
34
|
-
# omits period after heading ending w/ period
|
|
35
|
-
ok 15 no render error
|
|
36
|
-
ok 16 no textract error
|
|
37
|
-
ok 17 double period does not appear in output
|
|
38
|
-
# adds space between heading and defined term
|
|
39
|
-
ok 18 no render error
|
|
40
|
-
ok 19 no textract error
|
|
41
|
-
ok 20 space between heading and term
|
|
42
|
-
# adds space between heading and text
|
|
43
|
-
ok 21 no render error
|
|
44
|
-
ok 22 no textract error
|
|
45
|
-
ok 23 space between heading and text
|
|
46
|
-
# renders broken references
|
|
47
|
-
ok 24 no render error
|
|
48
|
-
ok 25 no textract error
|
|
49
|
-
ok 26 reference appears in output
|
|
50
|
-
# fills blanks
|
|
51
|
-
ok 27 no render error
|
|
52
|
-
ok 28 no textract error
|
|
53
|
-
ok 29 value appears in output
|
|
54
|
-
# custom blank text
|
|
55
|
-
ok 30 no render error
|
|
56
|
-
ok 31 no textract error
|
|
57
|
-
ok 32 value appears in output
|
|
58
|
-
# renders empty blank placeholders
|
|
59
|
-
ok 33 no render error
|
|
60
|
-
ok 34 no textract error
|
|
61
|
-
ok 35 placeholder appears in output
|
|
62
|
-
# renders custom empty blank placeholders
|
|
63
|
-
ok 36 no render error
|
|
64
|
-
ok 37 no textract error
|
|
65
|
-
ok 38 placeholder appears in output
|
|
66
|
-
# renders custom empty blank placeholders
|
|
67
|
-
ok 39 no render error
|
|
68
|
-
ok 40 no textract error
|
|
69
|
-
ok 41 placeholder appears in output
|
|
70
|
-
# renders conspicuous text
|
|
71
|
-
ok 42 no render error
|
|
72
|
-
ok 43 no textract error
|
|
73
|
-
ok 44 conspicuous text appears in output
|
|
74
|
-
# renders titles
|
|
75
|
-
ok 45 no render error
|
|
76
|
-
ok 46 no textract error
|
|
77
|
-
ok 47 title appears in output
|
|
78
|
-
# renders centered titles by default
|
|
79
|
-
ok 48 no render error
|
|
80
|
-
ok 49 no textract error
|
|
81
|
-
ok 50 title appears in output
|
|
82
|
-
# accepts option for left-align title
|
|
83
|
-
ok 51 no render error
|
|
84
|
-
ok 52 no textract error
|
|
85
|
-
ok 53 title appears in output
|
|
86
|
-
# renders versions
|
|
87
|
-
ok 54 no render error
|
|
88
|
-
ok 55 no textract error
|
|
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
|
|
94
|
-
# throws for invalid content
|
|
95
|
-
ok 60 throw an error
|
|
96
|
-
|
|
97
|
-
1..60
|
|
98
|
-
# tests 60
|
|
99
|
-
# pass 60
|
|
100
|
-
|
|
101
|
-
# ok
|
|
102
|
-
|