This repository has been archived by the owner on Sep 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocx.js
77 lines (76 loc) · 1.72 KB
/
docx.js
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
const factory = require('./element')
// http://officeopenxml.com/anatomyofOOXML.php
module.exports = {
p: factory({
tagName: 'w:p',
validChildren: ['w:r', 'w:pPr'],
}),
pPr: factory({
tagName: 'w:pPr',
validChildren: ['w:keepLines', 'w:keepNext', 'w:tabs', 'w:spacing', 'w:ind', 'w:rPr'],
}),
r: factory({
tagName: 'w:r',
validChildren: ['w:t', 'w:rPr', 'w:tab', 'w:fldChar', 'w:instrText'],
}),
t: factory({
tagName: 'w:t',
validAttributes: ['xml:space'],
}),
rPr: factory({
tagName: 'w:rPr',
validChildren: ['w:b', 'w:i', 'w:u', 'w:sz', 'w:color', 'w:rFonts'],
}),
keepLines: factory({
tagName: 'w:keepLines',
}),
keepNext: factory({
tagName: 'w:keepNext',
}),
tabs: factory({
tagName: 'w:tabs',
validChildren: ['w:tab'],
}),
spacing: factory({
tagName: 'w:spacing',
validAttributes: ['w:before', 'w:after'],
}),
ind: factory({
tagName: 'w:ind',
validAttributes: ['w:start', 'w:end', 'w:hanging', 'w:firstLine'],
}),
tab: factory({
tagName: 'w:tab',
validAttributes: ['w:val', 'w:pos', 'w:leader'],
}),
sz: factory({
tagName: 'w:sz',
validAttributes: ['w:val'],
}),
b: factory({
tagName: 'w:b',
}),
i: factory({
tagName: 'w:i',
}),
u: factory({
tagName: 'w:u',
validAttributes: ['w:val', 'w:color'],
}),
fldChar: factory({
tagName: 'w:fldChar',
validAttributes: ['w:fldCharType'],
}),
instrText: factory({
tagName: 'w:instrText',
validAttributes: ['xml:space'],
}),
rFonts: factory({
tagName: 'w:rFonts',
validAttributes: ['w:ascii', 'w:cs', 'w:hAnsi', 'w:eastAsia'],
}),
color: factory({
tagName: 'w:color',
validAttributes: ['w:val'],
}),
}