sec-edgar-api 0.3.4 → 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/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/XMLParser.d.ts +9 -38
- package/build/services/DocumentParser/XMLParser.js +87 -280
- 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-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 +2 -2
- 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/ReportRawBuilder/FactGrouper.js +6 -6
- package/build/services/SecEdgarApi/SecEdgarApi.d.ts +60 -1
- package/build/services/SecEdgarApi/SecEdgarApi.js +147 -2
- 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 +1 -1
|
@@ -1,304 +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;
|
|
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;
|
|
159
42
|
}
|
|
160
|
-
else if (
|
|
161
|
-
|
|
162
|
-
|
|
43
|
+
else if (Array.isArray(obj[tagName])) {
|
|
44
|
+
;
|
|
45
|
+
obj[tagName].push(newObj);
|
|
163
46
|
}
|
|
164
|
-
else if (
|
|
165
|
-
|
|
47
|
+
else if (typeof obj[tagName] === 'object') {
|
|
48
|
+
obj[tagName] = [obj[tagName], newObj];
|
|
166
49
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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));
|
|
50
|
+
_this.mapAttributes(attributes).forEach(function (value, att) {
|
|
51
|
+
newObj["@_".concat(att)] = value;
|
|
52
|
+
});
|
|
53
|
+
if (!isSelfEnclosing) {
|
|
54
|
+
objPath.push(newObj);
|
|
55
|
+
currentObj = newObj;
|
|
176
56
|
}
|
|
177
|
-
onCharacter === null || onCharacter === void 0 ? void 0 : onCharacter(__assign(__assign({}, data), { textMap: textByColKey }));
|
|
178
57
|
},
|
|
179
|
-
|
|
180
|
-
var
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
else if (!textCur.endsWith(' ')) {
|
|
187
|
-
textByColKey.set(colKey, "".concat(textCur, " "));
|
|
188
|
-
}
|
|
189
|
-
onCloseTag === null || onCloseTag === void 0 ? void 0 : onCloseTag(__assign(__assign({}, data), { textMap: textByColKey }));
|
|
58
|
+
onInnerText: function (text) {
|
|
59
|
+
var textTrimmed = text.trim();
|
|
60
|
+
if (!textTrimmed)
|
|
61
|
+
return;
|
|
62
|
+
var obj = currentObj;
|
|
63
|
+
obj['#text'] = textTrimmed;
|
|
190
64
|
},
|
|
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
65
|
onCloseTag: function () {
|
|
216
|
-
|
|
217
|
-
if ((curNode === null || curNode === void 0 ? void 0 : curNode.getPath()) === boldPath) {
|
|
218
|
-
curNode === null || curNode === void 0 ? void 0 : curNode.setText("".concat((_a = curNode === null || curNode === void 0 ? void 0 : curNode.getText()) !== null && _a !== void 0 ? _a : '', "}}"));
|
|
219
|
-
boldPath = null;
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
onCharacter: function (_a) {
|
|
223
|
-
var _b;
|
|
224
|
-
var char = _a.char;
|
|
225
|
-
curNode === null || curNode === void 0 ? void 0 : curNode.setText(((_b = curNode === null || curNode === void 0 ? void 0 : curNode.getText()) !== null && _b !== void 0 ? _b : '') + char);
|
|
226
|
-
},
|
|
227
|
-
onOpenTag: function (_a) {
|
|
228
|
-
var _b;
|
|
229
|
-
var path = _a.path, attributesStr = _a.attributesStr;
|
|
230
|
-
// skip nested tables
|
|
231
|
-
if (path.split('.').reduce(function (acc, cur) { return (cur === 'table' ? acc + 1 : acc); }, 0) > 1)
|
|
66
|
+
if (objPath.length === 1)
|
|
232
67
|
return;
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
var topLevelNodes = documentNode.getChildren();
|
|
236
|
-
var prevTopLevelNode = topLevelNodes[topLevelNodes.length - 1];
|
|
237
|
-
var wasHorizontalLine = prevTopLevelNode instanceof HRNode_1.HRNode;
|
|
238
|
-
var wasNonTableNode = prevTopLevelNode instanceof NonTableNode_1.NonTableNode;
|
|
239
|
-
var wasBold = isBold;
|
|
240
|
-
var attributesLower = attributesStr.toLowerCase().replace(/\s/g, '');
|
|
241
|
-
isBold =
|
|
242
|
-
tag === 'b' ||
|
|
243
|
-
tag === 'strong' ||
|
|
244
|
-
attributesLower.includes('font-weight:bold') ||
|
|
245
|
-
attributesLower.includes('font-weight:700') ||
|
|
246
|
-
attributesLower.includes('font-weight:800') ||
|
|
247
|
-
attributesLower.includes('font-weight:900');
|
|
248
|
-
if (!isInTable) {
|
|
249
|
-
prevRowCols = [];
|
|
250
|
-
curRowCols = [];
|
|
251
|
-
}
|
|
252
|
-
if (tag === 'hr' && !isInTable) {
|
|
253
|
-
var hr = new HRNode_1.HRNode({ attributesStr: attributesStr, path: path });
|
|
254
|
-
hr.setPreviousSibling(prevTopLevelNode !== null && prevTopLevelNode !== void 0 ? prevTopLevelNode : null);
|
|
255
|
-
topLevelNodes.push(hr);
|
|
256
|
-
curNode = hr;
|
|
257
|
-
}
|
|
258
|
-
else if (tag === 'table') {
|
|
259
|
-
var table = new TableNode_1.TableNode({ attributesStr: attributesStr, path: path });
|
|
260
|
-
table.setPreviousSibling(prevTopLevelNode !== null && prevTopLevelNode !== void 0 ? prevTopLevelNode : null);
|
|
261
|
-
topLevelNodes.push(table);
|
|
262
|
-
curNode = table;
|
|
263
|
-
}
|
|
264
|
-
else if (tag === 'tr') {
|
|
265
|
-
var row = new RowNode_1.RowNode({ attributesStr: attributesStr, path: path });
|
|
266
|
-
var prevRow = rowsArr[rowsArr.length - 1];
|
|
267
|
-
row.setParent(prevTopLevelNode);
|
|
268
|
-
row.setPreviousSibling((prevRow === null || prevRow === void 0 ? void 0 : prevRow.getParent()) === row.getParent() ? prevRow : null);
|
|
269
|
-
rowsArr.push(row);
|
|
270
|
-
prevRowCols = curRowCols;
|
|
271
|
-
curRowCols = [];
|
|
272
|
-
curNode = row;
|
|
273
|
-
}
|
|
274
|
-
else if (tag === 'td' || tag === 'th') {
|
|
275
|
-
var col = new ColNode_1.ColNode({ attributesStr: attributesStr, path: path });
|
|
276
|
-
var prevCol = colsArr[colsArr.length - 1];
|
|
277
|
-
col.setParent(rowsArr[rowsArr.length - 1]);
|
|
278
|
-
col.setPreviousSibling((prevCol === null || prevCol === void 0 ? void 0 : prevCol.getParent()) === col.getParent() ? prevCol : null);
|
|
279
|
-
colsArr.push(col);
|
|
280
|
-
pushColToRow(col);
|
|
281
|
-
curNode = col;
|
|
282
|
-
}
|
|
283
|
-
else if ((!isInTable && !wasNonTableNode) || (wasHorizontalLine && tag !== 'hr')) {
|
|
284
|
-
var node = new NonTableNode_1.NonTableNode({ attributesStr: attributesStr, path: path });
|
|
285
|
-
node.setPreviousSibling(prevTopLevelNode !== null && prevTopLevelNode !== void 0 ? prevTopLevelNode : null);
|
|
286
|
-
topLevelNodes.push(node);
|
|
287
|
-
curNode = node;
|
|
288
|
-
}
|
|
289
|
-
else if (curNode && !curNode.getText().endsWith('\n')) {
|
|
290
|
-
curNode.setText("".concat(curNode.getText().trim(), "\n"));
|
|
291
|
-
}
|
|
292
|
-
if (isBold && !wasBold && !(curNode === null || curNode === void 0 ? void 0 : curNode.getText().endsWith('{{'))) {
|
|
293
|
-
curNode === null || curNode === void 0 ? void 0 : curNode.setText("".concat(curNode === null || curNode === void 0 ? void 0 : curNode.getText().trim(), "{{"));
|
|
294
|
-
}
|
|
295
|
-
if (isBold) {
|
|
296
|
-
boldPath = (_b = curNode === null || curNode === void 0 ? void 0 : curNode.getPath()) !== null && _b !== void 0 ? _b : null;
|
|
297
|
-
}
|
|
68
|
+
objPath.pop();
|
|
69
|
+
currentObj = objPath[objPath.length - 1];
|
|
298
70
|
},
|
|
299
71
|
});
|
|
300
|
-
|
|
301
|
-
|
|
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
|
+
}
|
|
302
109
|
};
|
|
303
110
|
return XMLParser;
|
|
304
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 {};
|