sec-edgar-api 0.3.3 → 0.4.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/build/services/Client/Client.d.ts +1 -0
- package/build/services/DocumentParser/DocumentParser.d.ts +18 -1
- package/build/services/DocumentParser/DocumentParser.js +17 -2
- package/build/services/DocumentParser/DocumentXmlSplitter.d.ts +17 -0
- package/build/services/DocumentParser/DocumentXmlSplitter.js +38 -0
- package/build/services/DocumentParser/ObjectUtil.d.ts +20 -0
- package/build/services/DocumentParser/ObjectUtil.js +60 -0
- package/build/services/DocumentParser/XBRLParser/HeaderParser.d.ts +38 -0
- package/build/services/DocumentParser/XBRLParser/HeaderParser.js +138 -0
- package/build/services/DocumentParser/XBRLParser/InstanceParser.d.ts +6 -0
- package/build/services/DocumentParser/XBRLParser/InstanceParser.js +107 -0
- package/build/services/DocumentParser/XBRLParser/LinkbaseParser.d.ts +13 -0
- package/build/services/DocumentParser/XBRLParser/LinkbaseParser.js +99 -0
- package/build/services/DocumentParser/XBRLParser/SchemaParser.d.ts +11 -0
- package/build/services/DocumentParser/XBRLParser/SchemaParser.js +144 -0
- package/build/services/DocumentParser/XBRLParser/XBRLParser.d.ts +34 -0
- package/build/services/DocumentParser/XBRLParser/XBRLParser.js +64 -0
- package/build/services/DocumentParser/XBRLParser/util-type.d.ts +15 -0
- package/build/services/DocumentParser/XBRLParser/util-type.js +34 -0
- package/build/services/DocumentParser/XMLNode/XMLNode.js +2 -2
- package/build/services/DocumentParser/XMLParser.d.ts +9 -38
- package/build/services/DocumentParser/XMLParser.js +88 -283
- package/build/services/DocumentParser/XMLParserLegacy.d.ts +43 -0
- package/build/services/DocumentParser/XMLParserLegacy.js +308 -0
- package/build/services/DocumentParser/parsers/index.d.ts +10 -0
- package/build/services/DocumentParser/parsers/index.js +10 -0
- package/build/services/DocumentParser/parsers/parse-companies.d.ts +5 -0
- package/build/services/DocumentParser/parsers/parse-companies.js +52 -0
- package/build/services/DocumentParser/parsers/parse-current-filings-daily.js +8 -8
- package/build/services/DocumentParser/parsers/parse-current-filings-xbrl.d.ts +2 -0
- package/build/services/DocumentParser/parsers/parse-current-filings-xbrl.js +104 -0
- package/build/services/DocumentParser/parsers/parse-current-filings.d.ts +2 -0
- package/build/services/DocumentParser/parsers/parse-current-filings.js +76 -0
- package/build/services/DocumentParser/parsers/parse-form-10k.d.ts +1 -1
- package/build/services/DocumentParser/parsers/parse-form-10k.js +2 -2
- package/build/services/DocumentParser/parsers/parse-form-13g.d.ts +1 -1
- package/build/services/DocumentParser/parsers/parse-form-13g.js +2 -2
- package/build/services/DocumentParser/parsers/parse-form-4.d.ts +1 -1
- package/build/services/DocumentParser/parsers/parse-form-4.js +6 -4
- package/build/services/DocumentParser/parsers/parse-form-def14a.d.ts +1 -1
- package/build/services/DocumentParser/parsers/parse-form-def14a.js +2 -2
- package/build/services/DocumentParser/parsers/parse-insider-transaction.d.ts +7 -0
- package/build/services/DocumentParser/parsers/parse-insider-transaction.js +199 -0
- package/build/services/DocumentParser/parsers/parse-xbrl.d.ts +8 -0
- package/build/services/DocumentParser/parsers/parse-xbrl.js +171 -0
- package/build/services/HtmlTableExtractor/HtmlTableExtractor.d.ts +45 -0
- package/build/services/HtmlTableExtractor/HtmlTableExtractor.js +430 -0
- package/build/services/HtmlTableExtractor/index.d.ts +2 -0
- package/build/services/HtmlTableExtractor/index.js +4 -0
- package/build/services/ReportParser/ReportParser.d.ts +1 -1
- package/build/services/ReportParser/ReportWrapper.js +1 -1
- package/build/services/ReportRawBuilder/FactFiscalCalculator.d.ts +0 -1
- package/build/services/ReportRawBuilder/FactFiscalCalculator.js +1 -1
- package/build/services/ReportRawBuilder/FactGrouper.d.ts +1 -0
- package/build/services/ReportRawBuilder/FactGrouper.js +21 -13
- package/build/services/ReportRawBuilder/FactSplitAdjuster.js +17 -7
- package/build/services/ReportRawBuilder/ReportRawBuilder.d.ts +1 -0
- package/build/services/ReportRawBuilder/ReportRawBuilder.js +20 -15
- package/build/services/SecEdgarApi/FilingMapper.d.ts +4 -0
- package/build/services/SecEdgarApi/FilingMapper.js +37 -0
- package/build/services/SecEdgarApi/RequestWrapper.d.ts +2 -0
- package/build/services/SecEdgarApi/RequestWrapper.js +6 -4
- package/build/services/SecEdgarApi/SecEdgarApi.d.ts +66 -2
- package/build/services/SecEdgarApi/SecEdgarApi.js +236 -71
- package/build/services/SecEdgarApi/Throttler.d.ts +9 -8
- package/build/types/common.type.d.ts +9 -9
- package/build/types/company-search.type.d.ts +5 -0
- package/build/types/company-search.type.js +2 -0
- package/build/types/current-filings.type.d.ts +57 -0
- package/build/types/current-filings.type.js +2 -0
- package/build/types/index.d.ts +3 -0
- package/build/types/index.js +3 -0
- package/build/types/insider-transaction.type.d.ts +32 -0
- package/build/types/insider-transaction.type.js +2 -0
- package/build/types/parsed-filings.type.d.ts +3 -3
- package/build/types/xbrl.type.d.ts +155 -0
- package/build/types/xbrl.type.js +2 -0
- package/package.json +8 -3
|
@@ -1,306 +1,111 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
var ColNode_1 = require("./XMLNode/ColNode");
|
|
15
|
-
var DocumentNode_1 = require("./XMLNode/DocumentNode");
|
|
16
|
-
var HRNode_1 = require("./XMLNode/HRNode");
|
|
17
|
-
var NonTableNode_1 = require("./XMLNode/NonTableNode");
|
|
18
|
-
var RowNode_1 = require("./XMLNode/RowNode");
|
|
19
|
-
var TableNode_1 = require("./XMLNode/TableNode");
|
|
20
3
|
var XMLParser = /** @class */ (function () {
|
|
21
4
|
function XMLParser() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
'filename',
|
|
28
|
-
'description',
|
|
5
|
+
this.selfEnclosingTags = new Set([
|
|
6
|
+
'!doctype',
|
|
7
|
+
'?xml',
|
|
8
|
+
'xml',
|
|
9
|
+
'hr',
|
|
29
10
|
'br',
|
|
30
|
-
'meta',
|
|
31
|
-
'link',
|
|
32
11
|
'img',
|
|
33
12
|
'input',
|
|
34
|
-
'
|
|
35
|
-
'
|
|
36
|
-
'
|
|
37
|
-
'col',
|
|
38
|
-
'command',
|
|
39
|
-
'embed',
|
|
40
|
-
'keygen',
|
|
41
|
-
'param',
|
|
42
|
-
'source',
|
|
43
|
-
'track',
|
|
44
|
-
'wbr',
|
|
13
|
+
'meta',
|
|
14
|
+
'filename',
|
|
15
|
+
'description',
|
|
45
16
|
]);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var isCloseTag = char === '<' && xml[i + 1] === '/';
|
|
57
|
-
var onCharacterData = {
|
|
58
|
-
char: char,
|
|
59
|
-
index: i,
|
|
60
|
-
path: curPath,
|
|
61
|
-
pathOccurrenceCount: (_a = pathOccurrenceCountMap.get(curPath)) !== null && _a !== void 0 ? _a : 0,
|
|
62
|
-
attributesStr: curAttributes,
|
|
63
|
-
};
|
|
64
|
-
if (isOpenTag) {
|
|
65
|
-
var didEndTagName = false;
|
|
66
|
-
var j = 0;
|
|
67
|
-
didStart = true;
|
|
68
|
-
i++;
|
|
69
|
-
while (xml[i] !== '>') {
|
|
70
|
-
didEndTagName = didEndTagName || spaceChars.has(xml[i]) || xml[i] === '/';
|
|
71
|
-
if (!didEndTagName) {
|
|
72
|
-
curTag += xml[i].toLowerCase();
|
|
73
|
-
}
|
|
74
|
-
else if (xml[i] !== '/') {
|
|
75
|
-
curAttributes += xml[i];
|
|
76
|
-
}
|
|
77
|
-
i++;
|
|
78
|
-
j++;
|
|
79
|
-
if (j > 1000000) {
|
|
80
|
-
throw new Error('too many iterations');
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
var pathNew = "".concat(curPath).concat(curPath.length > 0 ? '.' : '').concat(curTag).toLowerCase();
|
|
84
|
-
var countBefore = (_b = pathOccurrenceCountMap.get(pathNew)) !== null && _b !== void 0 ? _b : 0;
|
|
85
|
-
var pathOccurrenceCount = (_c = pathOccurrenceCountMap.set(pathNew, countBefore + 1).get(pathNew)) !== null && _c !== void 0 ? _c : 0;
|
|
86
|
-
onCharacterData.path = pathNew;
|
|
87
|
-
onCharacterData.pathOccurrenceCount = pathOccurrenceCount;
|
|
88
|
-
onCharacterData.attributesStr = curAttributes;
|
|
89
|
-
pathsArr.push(pathNew);
|
|
90
|
-
onOpenTag === null || onOpenTag === void 0 ? void 0 : onOpenTag(onCharacterData);
|
|
91
|
-
if (selfEnclosingTags.has(curTag)) {
|
|
92
|
-
onCloseTag === null || onCloseTag === void 0 ? void 0 : onCloseTag(onCharacterData);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
curPath = pathNew;
|
|
96
|
-
}
|
|
97
|
-
curTag = '';
|
|
98
|
-
}
|
|
99
|
-
else if (isCloseTag) {
|
|
100
|
-
while (xml[i] !== '>') {
|
|
101
|
-
i++;
|
|
102
|
-
}
|
|
103
|
-
onCloseTag === null || onCloseTag === void 0 ? void 0 : onCloseTag(onCharacterData);
|
|
104
|
-
curPath = curPath.slice(0, curPath.lastIndexOf('.'));
|
|
105
|
-
curAttributes = '';
|
|
106
|
-
}
|
|
107
|
-
else if (didStart) {
|
|
108
|
-
onCharacter === null || onCharacter === void 0 ? void 0 : onCharacter(onCharacterData);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return pathsArr;
|
|
17
|
+
}
|
|
18
|
+
XMLParser.prototype.mapAttributes = function (attributes) {
|
|
19
|
+
var attributesMap = new Map();
|
|
20
|
+
attributes.forEach(function (attr) {
|
|
21
|
+
var _a = attr.split('='), key = _a[0], value = _a[1];
|
|
22
|
+
if (!value)
|
|
23
|
+
return;
|
|
24
|
+
attributesMap.set(key, value.replace(/"/g, '').trim());
|
|
25
|
+
});
|
|
26
|
+
return attributesMap;
|
|
112
27
|
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
var xml = params.xml, parentPath = params.parentPath, onCharacter = params.onCharacter, onCloseTag = params.onCloseTag, onOpenTag = params.onOpenTag, _a = params.trimSpaces, trimSpaces = _a === void 0 ? true : _a;
|
|
118
|
-
var rowPaths = new Set([
|
|
119
|
-
"".concat(parentPath, ".table.tbody.tr"),
|
|
120
|
-
"".concat(parentPath, ".table.thead.tr"),
|
|
121
|
-
"".concat(parentPath, ".table.tfoot.tr"),
|
|
122
|
-
"".concat(parentPath, ".table.tr"),
|
|
123
|
-
]);
|
|
124
|
-
var colPaths = new Set([
|
|
125
|
-
"".concat(parentPath, ".table.tbody.tr.td"),
|
|
126
|
-
"".concat(parentPath, ".table.thead.tr.td"),
|
|
127
|
-
"".concat(parentPath, ".table.tfoot.tr.td"),
|
|
128
|
-
"".concat(parentPath, ".table.tr.td"),
|
|
129
|
-
"".concat(parentPath, ".table.tbody.tr.th"),
|
|
130
|
-
"".concat(parentPath, ".table.thead.tr.th"),
|
|
131
|
-
"".concat(parentPath, ".table.tfoot.tr.th"),
|
|
132
|
-
"".concat(parentPath, ".table.tr.th"),
|
|
133
|
-
]);
|
|
134
|
-
var table = 0;
|
|
135
|
-
var row = 0;
|
|
136
|
-
var col = 0;
|
|
137
|
-
var textByColKey = new Map();
|
|
138
|
-
var spaceChars = new Set(['\n', '\r', '\t']);
|
|
28
|
+
XMLParser.prototype.parse = function (xml) {
|
|
29
|
+
var _this = this;
|
|
30
|
+
var currentObj = {};
|
|
31
|
+
var objPath = [currentObj];
|
|
139
32
|
this.iterateXML({
|
|
140
33
|
xml: xml,
|
|
141
|
-
onOpenTag: function (
|
|
142
|
-
var
|
|
143
|
-
var
|
|
144
|
-
var
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
var isTable = parentPath ? pathLower === "".concat(parentPath, ".table") : pathLower.endsWith('table');
|
|
151
|
-
var isRow = parentPath ? rowPaths.has(pathLower) : pathLower.endsWith('tr');
|
|
152
|
-
var isCol = parentPath
|
|
153
|
-
? colPaths.has(pathLower)
|
|
154
|
-
: pathLower.endsWith('td') || pathLower.endsWith('th');
|
|
155
|
-
if (isTable) {
|
|
156
|
-
table++;
|
|
157
|
-
col = 0;
|
|
158
|
-
row = 0;
|
|
159
|
-
}
|
|
160
|
-
else if (isRow) {
|
|
161
|
-
row++;
|
|
162
|
-
col = 0;
|
|
163
|
-
}
|
|
164
|
-
else if (isCol) {
|
|
165
|
-
col++;
|
|
34
|
+
onOpenTag: function (tagName, attributes, isSelfEnclosing) {
|
|
35
|
+
var newObj = {};
|
|
36
|
+
var obj = currentObj;
|
|
37
|
+
var isComment = tagName.startsWith('!--');
|
|
38
|
+
if (isComment || tagName === '?xml')
|
|
39
|
+
return;
|
|
40
|
+
if (obj[tagName] === undefined) {
|
|
41
|
+
obj[tagName] = newObj;
|
|
166
42
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
var _a;
|
|
171
|
-
var char = spaceChars.has(data.char) ? ' ' : data.char;
|
|
172
|
-
var colKey = "".concat(table, ".").concat(row, ".").concat(col);
|
|
173
|
-
var textCur = (_a = textByColKey.get(colKey)) !== null && _a !== void 0 ? _a : '';
|
|
174
|
-
if (!(trimSpaces && char === ' ' && textCur.endsWith(' '))) {
|
|
175
|
-
textByColKey.set(colKey, "".concat(textCur).concat(char));
|
|
43
|
+
else if (Array.isArray(obj[tagName])) {
|
|
44
|
+
;
|
|
45
|
+
obj[tagName].push(newObj);
|
|
176
46
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
onCloseTag: function (data) {
|
|
180
|
-
var _a;
|
|
181
|
-
var colKey = "".concat(table, ".").concat(row, ".").concat(col);
|
|
182
|
-
var textCur = (_a = textByColKey.get(colKey)) !== null && _a !== void 0 ? _a : '';
|
|
183
|
-
if (textCur.trim().length === 0 && col === 0) {
|
|
184
|
-
textByColKey.delete(colKey);
|
|
47
|
+
else if (typeof obj[tagName] === 'object') {
|
|
48
|
+
obj[tagName] = [obj[tagName], newObj];
|
|
185
49
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
return textByColKey;
|
|
193
|
-
};
|
|
194
|
-
XMLParser.prototype.getDocumentNode = function (params) {
|
|
195
|
-
var xml = params.xml;
|
|
196
|
-
var rowsArr = [];
|
|
197
|
-
var colsArr = [];
|
|
198
|
-
var documentNode = new DocumentNode_1.DocumentNode();
|
|
199
|
-
var curNode = null;
|
|
200
|
-
var prevRowCols = [];
|
|
201
|
-
var curRowCols = [];
|
|
202
|
-
var isBold = false;
|
|
203
|
-
var boldPath = null;
|
|
204
|
-
var pushColToRow = function (col) {
|
|
205
|
-
var _a;
|
|
206
|
-
var colIndex = curRowCols.length;
|
|
207
|
-
col.setIndex(colIndex);
|
|
208
|
-
var colSpan = col.getColSpan();
|
|
209
|
-
Array.from({ length: colSpan }).forEach(function () { return curRowCols.push(col); });
|
|
210
|
-
var topSibling = (_a = prevRowCols[colIndex]) !== null && _a !== void 0 ? _a : null;
|
|
211
|
-
topSibling === null || topSibling === void 0 ? void 0 : topSibling.addBottomSibling(col);
|
|
212
|
-
};
|
|
213
|
-
this.iterateXML({
|
|
214
|
-
xml: xml,
|
|
215
|
-
onCloseTag: function (_a) {
|
|
216
|
-
var _b;
|
|
217
|
-
var path = _a.path;
|
|
218
|
-
var tag = path.split('.').pop();
|
|
219
|
-
if ((curNode === null || curNode === void 0 ? void 0 : curNode.getPath()) === boldPath) {
|
|
220
|
-
curNode === null || curNode === void 0 ? void 0 : curNode.setText("".concat((_b = curNode === null || curNode === void 0 ? void 0 : curNode.getText()) !== null && _b !== void 0 ? _b : '', "}}"));
|
|
221
|
-
boldPath = null;
|
|
50
|
+
_this.mapAttributes(attributes).forEach(function (value, att) {
|
|
51
|
+
newObj["@_".concat(att)] = value;
|
|
52
|
+
});
|
|
53
|
+
if (!isSelfEnclosing) {
|
|
54
|
+
objPath.push(newObj);
|
|
55
|
+
currentObj = newObj;
|
|
222
56
|
}
|
|
223
57
|
},
|
|
224
|
-
|
|
225
|
-
var
|
|
226
|
-
|
|
227
|
-
|
|
58
|
+
onInnerText: function (text) {
|
|
59
|
+
var textTrimmed = text.trim();
|
|
60
|
+
if (!textTrimmed)
|
|
61
|
+
return;
|
|
62
|
+
var obj = currentObj;
|
|
63
|
+
obj['#text'] = textTrimmed;
|
|
228
64
|
},
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
var path = _a.path, attributesStr = _a.attributesStr;
|
|
232
|
-
// skip nested tables
|
|
233
|
-
if (path.split('.').reduce(function (acc, cur) { return (cur === 'table' ? acc + 1 : acc); }, 0) > 1)
|
|
65
|
+
onCloseTag: function () {
|
|
66
|
+
if (objPath.length === 1)
|
|
234
67
|
return;
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
var topLevelNodes = documentNode.getChildren();
|
|
238
|
-
var prevTopLevelNode = topLevelNodes[topLevelNodes.length - 1];
|
|
239
|
-
var wasHorizontalLine = prevTopLevelNode instanceof HRNode_1.HRNode;
|
|
240
|
-
var wasNonTableNode = prevTopLevelNode instanceof NonTableNode_1.NonTableNode;
|
|
241
|
-
var wasBold = isBold;
|
|
242
|
-
var attributesLower = attributesStr.toLowerCase().replace(/\s/g, '');
|
|
243
|
-
isBold =
|
|
244
|
-
tag === 'b' ||
|
|
245
|
-
tag === 'strong' ||
|
|
246
|
-
attributesLower.includes('font-weight:bold') ||
|
|
247
|
-
attributesLower.includes('font-weight:700') ||
|
|
248
|
-
attributesLower.includes('font-weight:800') ||
|
|
249
|
-
attributesLower.includes('font-weight:900');
|
|
250
|
-
if (!isInTable) {
|
|
251
|
-
prevRowCols = [];
|
|
252
|
-
curRowCols = [];
|
|
253
|
-
}
|
|
254
|
-
if (tag === 'hr' && !isInTable) {
|
|
255
|
-
var hr = new HRNode_1.HRNode({ attributesStr: attributesStr, path: path });
|
|
256
|
-
hr.setPreviousSibling(prevTopLevelNode !== null && prevTopLevelNode !== void 0 ? prevTopLevelNode : null);
|
|
257
|
-
topLevelNodes.push(hr);
|
|
258
|
-
curNode = hr;
|
|
259
|
-
}
|
|
260
|
-
else if (tag === 'table') {
|
|
261
|
-
var table = new TableNode_1.TableNode({ attributesStr: attributesStr, path: path });
|
|
262
|
-
table.setPreviousSibling(prevTopLevelNode !== null && prevTopLevelNode !== void 0 ? prevTopLevelNode : null);
|
|
263
|
-
topLevelNodes.push(table);
|
|
264
|
-
curNode = table;
|
|
265
|
-
}
|
|
266
|
-
else if (tag === 'tr') {
|
|
267
|
-
var row = new RowNode_1.RowNode({ attributesStr: attributesStr, path: path });
|
|
268
|
-
var prevRow = rowsArr[rowsArr.length - 1];
|
|
269
|
-
row.setParent(prevTopLevelNode);
|
|
270
|
-
row.setPreviousSibling((prevRow === null || prevRow === void 0 ? void 0 : prevRow.getParent()) === row.getParent() ? prevRow : null);
|
|
271
|
-
rowsArr.push(row);
|
|
272
|
-
prevRowCols = curRowCols;
|
|
273
|
-
curRowCols = [];
|
|
274
|
-
curNode = row;
|
|
275
|
-
}
|
|
276
|
-
else if (tag === 'td' || tag === 'th') {
|
|
277
|
-
var col = new ColNode_1.ColNode({ attributesStr: attributesStr, path: path });
|
|
278
|
-
var prevCol = colsArr[colsArr.length - 1];
|
|
279
|
-
col.setParent(rowsArr[rowsArr.length - 1]);
|
|
280
|
-
col.setPreviousSibling((prevCol === null || prevCol === void 0 ? void 0 : prevCol.getParent()) === col.getParent() ? prevCol : null);
|
|
281
|
-
colsArr.push(col);
|
|
282
|
-
pushColToRow(col);
|
|
283
|
-
curNode = col;
|
|
284
|
-
}
|
|
285
|
-
else if ((!isInTable && !wasNonTableNode) || (wasHorizontalLine && tag !== 'hr')) {
|
|
286
|
-
var node = new NonTableNode_1.NonTableNode({ attributesStr: attributesStr, path: path });
|
|
287
|
-
node.setPreviousSibling(prevTopLevelNode !== null && prevTopLevelNode !== void 0 ? prevTopLevelNode : null);
|
|
288
|
-
topLevelNodes.push(node);
|
|
289
|
-
curNode = node;
|
|
290
|
-
}
|
|
291
|
-
else if (curNode && !curNode.getText().endsWith('\n')) {
|
|
292
|
-
curNode.setText("".concat(curNode.getText().trim(), "\n"));
|
|
293
|
-
}
|
|
294
|
-
if (isBold && !wasBold && !(curNode === null || curNode === void 0 ? void 0 : curNode.getText().endsWith('{{'))) {
|
|
295
|
-
curNode === null || curNode === void 0 ? void 0 : curNode.setText("".concat(curNode === null || curNode === void 0 ? void 0 : curNode.getText().trim(), "{{"));
|
|
296
|
-
}
|
|
297
|
-
if (isBold) {
|
|
298
|
-
boldPath = (_b = curNode === null || curNode === void 0 ? void 0 : curNode.getPath()) !== null && _b !== void 0 ? _b : null;
|
|
299
|
-
}
|
|
68
|
+
objPath.pop();
|
|
69
|
+
currentObj = objPath[objPath.length - 1];
|
|
300
70
|
},
|
|
301
71
|
});
|
|
302
|
-
|
|
303
|
-
|
|
72
|
+
return objPath[0];
|
|
73
|
+
};
|
|
74
|
+
XMLParser.prototype.iterateXML = function (params) {
|
|
75
|
+
var onCloseTag = params.onCloseTag, onInnerText = params.onInnerText, onOpenTag = params.onOpenTag, xml = params.xml;
|
|
76
|
+
for (var i = 0; i < xml.length; i++) {
|
|
77
|
+
if (xml[i] === '<' && xml[i + 1] !== '/') {
|
|
78
|
+
i++;
|
|
79
|
+
var tagEndIndex = xml.indexOf('>', i);
|
|
80
|
+
var currentTagStr = xml.substring(i, tagEndIndex);
|
|
81
|
+
var tagName = currentTagStr.split(' ', 1)[0].trim();
|
|
82
|
+
var attributes = currentTagStr.split(' ').slice(1);
|
|
83
|
+
var lastAttribute = attributes[attributes.length - 1];
|
|
84
|
+
if (lastAttribute === null || lastAttribute === void 0 ? void 0 : lastAttribute.endsWith('/')) {
|
|
85
|
+
attributes[attributes.length - 1] = lastAttribute.substring(0, lastAttribute.length - 1);
|
|
86
|
+
}
|
|
87
|
+
if (!lastAttribute || !lastAttribute.includes('=')) {
|
|
88
|
+
attributes.pop();
|
|
89
|
+
}
|
|
90
|
+
i = tagEndIndex;
|
|
91
|
+
var isSelfEnclosing = xml[tagEndIndex - 1] === '/' || this.selfEnclosingTags.has(tagName.toLowerCase());
|
|
92
|
+
onOpenTag === null || onOpenTag === void 0 ? void 0 : onOpenTag(tagName, attributes, isSelfEnclosing);
|
|
93
|
+
}
|
|
94
|
+
else if (xml[i] === '<' && xml[i + 1] === '/') {
|
|
95
|
+
i += 2;
|
|
96
|
+
var tagEndIndex = xml.indexOf('>', i);
|
|
97
|
+
var currentTagStr = xml.substring(i, tagEndIndex);
|
|
98
|
+
i = tagEndIndex;
|
|
99
|
+
onCloseTag === null || onCloseTag === void 0 ? void 0 : onCloseTag(currentTagStr);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
var nextOpenTagIndex = xml.indexOf('<', i);
|
|
103
|
+
var nextIndex = nextOpenTagIndex === -1 ? xml.length : nextOpenTagIndex;
|
|
104
|
+
var text = xml.substring(i, nextIndex);
|
|
105
|
+
onInnerText === null || onInnerText === void 0 ? void 0 : onInnerText(text);
|
|
106
|
+
i = nextIndex - 1;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
304
109
|
};
|
|
305
110
|
return XMLParser;
|
|
306
111
|
}());
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { DocumentNode } from './XMLNode/DocumentNode';
|
|
2
|
+
interface OnCharacterData {
|
|
3
|
+
char: string;
|
|
4
|
+
index: number;
|
|
5
|
+
path: string;
|
|
6
|
+
pathOccurrenceCount: number;
|
|
7
|
+
attributesStr: string;
|
|
8
|
+
}
|
|
9
|
+
interface ParseTableNodesParams {
|
|
10
|
+
xml: string;
|
|
11
|
+
}
|
|
12
|
+
interface Parse2Params {
|
|
13
|
+
xml: string;
|
|
14
|
+
onCharacter?: (data: OnCharacterData) => void;
|
|
15
|
+
onOpenTag?: (data: OnCharacterData) => void;
|
|
16
|
+
onCloseTag?: (data: OnCharacterData) => void;
|
|
17
|
+
}
|
|
18
|
+
interface IterateTablesParams {
|
|
19
|
+
xml: string;
|
|
20
|
+
parentPath?: string;
|
|
21
|
+
trimSpaces?: boolean;
|
|
22
|
+
onCharacter?: (data: OnCharacterData & {
|
|
23
|
+
textMap: Map<string, string>;
|
|
24
|
+
}) => void;
|
|
25
|
+
onOpenTag?: (data: OnCharacterData & {
|
|
26
|
+
textMap: Map<string, string>;
|
|
27
|
+
}) => void;
|
|
28
|
+
onCloseTag?: (data: OnCharacterData & {
|
|
29
|
+
textMap: Map<string, string>;
|
|
30
|
+
}) => void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated use XMLParser
|
|
34
|
+
*/
|
|
35
|
+
export default class XMLParserLegacy {
|
|
36
|
+
iterateXML(params: Parse2Params): string[];
|
|
37
|
+
/**
|
|
38
|
+
* Returns text in each table cell mapped by `${table}.${row}.${col}`
|
|
39
|
+
*/
|
|
40
|
+
getTableTextMap(params: IterateTablesParams): Map<string, string>;
|
|
41
|
+
getDocumentNode(params: ParseTableNodesParams): DocumentNode;
|
|
42
|
+
}
|
|
43
|
+
export {};
|