@mlightcad/mtext-parser 1.0.1 → 1.0.4
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/dist/parser.cjs.js +3 -3
- package/dist/parser.cjs.js.map +1 -1
- package/dist/parser.es.js +162 -142
- package/dist/parser.es.js.map +1 -1
- package/dist/parser.umd.js +3 -3
- package/dist/parser.umd.js.map +1 -1
- package/dist/types/parser.d.ts +34 -1
- package/package.json +1 -1
package/dist/parser.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
const
|
|
1
|
+
var k = /* @__PURE__ */ ((r) => (r[r.NONE = 0] = "NONE", r[r.WORD = 1] = "WORD", r[r.STACK = 2] = "STACK", r[r.SPACE = 3] = "SPACE", r[r.NBSP = 4] = "NBSP", r[r.TABULATOR = 5] = "TABULATOR", r[r.NEW_PARAGRAPH = 6] = "NEW_PARAGRAPH", r[r.NEW_COLUMN = 7] = "NEW_COLUMN", r[r.WRAP_AT_DIMLINE = 8] = "WRAP_AT_DIMLINE", r[r.PROPERTIES_CHANGED = 9] = "PROPERTIES_CHANGED", r))(k || {}), b = /* @__PURE__ */ ((r) => (r[r.BOTTOM = 0] = "BOTTOM", r[r.MIDDLE = 1] = "MIDDLE", r[r.TOP = 2] = "TOP", r))(b || {}), E = /* @__PURE__ */ ((r) => (r[r.DEFAULT = 0] = "DEFAULT", r[r.LEFT = 1] = "LEFT", r[r.RIGHT = 2] = "RIGHT", r[r.CENTER = 3] = "CENTER", r[r.JUSTIFIED = 4] = "JUSTIFIED", r[r.DISTRIBUTED = 5] = "DISTRIBUTED", r))(E || {}), m = /* @__PURE__ */ ((r) => (r[r.NONE = 0] = "NONE", r[r.UNDERLINE = 1] = "UNDERLINE", r[r.OVERLINE = 2] = "OVERLINE", r[r.STRIKE_THROUGH = 4] = "STRIKE_THROUGH", r))(m || {});
|
|
2
|
+
const F = {
|
|
3
3
|
c: "Ø",
|
|
4
4
|
d: "°",
|
|
5
5
|
p: "±"
|
|
6
|
-
},
|
|
6
|
+
}, S = {
|
|
7
7
|
l: 1,
|
|
8
8
|
r: 2,
|
|
9
9
|
c: 3,
|
|
@@ -11,36 +11,36 @@ const b = {
|
|
|
11
11
|
d: 5
|
|
12
12
|
/* DISTRIBUTED */
|
|
13
13
|
};
|
|
14
|
-
function
|
|
15
|
-
const [e, t,
|
|
16
|
-
return
|
|
14
|
+
function N(r) {
|
|
15
|
+
const [e, t, s] = r;
|
|
16
|
+
return s << 16 | t << 8 | e;
|
|
17
17
|
}
|
|
18
|
-
function _(
|
|
19
|
-
const e =
|
|
20
|
-
return [e, t,
|
|
18
|
+
function _(r) {
|
|
19
|
+
const e = r & 255, t = r >> 8 & 255, s = r >> 16 & 255;
|
|
20
|
+
return [e, t, s];
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
return
|
|
24
|
-
const
|
|
25
|
-
return
|
|
26
|
-
` :
|
|
22
|
+
function I(r) {
|
|
23
|
+
return r.replace(/\^(.)/g, (e, t) => {
|
|
24
|
+
const s = t.charCodeAt(0);
|
|
25
|
+
return s === 32 ? "^" : s === 73 ? " " : s === 74 ? `
|
|
26
|
+
` : s === 77 ? "" : "▯";
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
return
|
|
29
|
+
function O(r) {
|
|
30
|
+
return r.replace(/\r\n|\r|\n/g, "\\P");
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
return
|
|
32
|
+
function R(r) {
|
|
33
|
+
return r.replace(/\\P/g, "").replace(/\\~/g, "").includes("\\");
|
|
34
34
|
}
|
|
35
|
-
class
|
|
35
|
+
class D {
|
|
36
36
|
/**
|
|
37
37
|
* Creates a new MTextParser instance
|
|
38
38
|
* @param content - The MText content to parse
|
|
39
39
|
* @param ctx - Optional initial MText context
|
|
40
40
|
* @param yieldPropertyCommands - Whether to yield property change commands
|
|
41
41
|
*/
|
|
42
|
-
constructor(e, t,
|
|
43
|
-
this.ctxStack = [], this.continueStroke = !1, this.scanner = new p(
|
|
42
|
+
constructor(e, t, s = !1) {
|
|
43
|
+
this.ctxStack = [], this.continueStroke = !1, this.scanner = new p(I(e)), this.ctx = t ?? new f(), this.lastCtx = this.ctx.copy(), this.yieldPropertyCommands = s, this.decoder = new TextDecoder("gbk");
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Decode multi-byte character from hex code
|
|
@@ -76,32 +76,33 @@ class N {
|
|
|
76
76
|
*/
|
|
77
77
|
parseStacking() {
|
|
78
78
|
const e = new p(this.extractExpression(!0));
|
|
79
|
-
let t = "",
|
|
80
|
-
const
|
|
81
|
-
let
|
|
82
|
-
return
|
|
79
|
+
let t = "", s = "", n = "";
|
|
80
|
+
const i = () => {
|
|
81
|
+
let a = e.peek(), h = !1;
|
|
82
|
+
return a.charCodeAt(0) < 32 && (a = " "), a === "\\" && (h = !0, e.consume(1), a = e.peek()), e.consume(1), [a, h];
|
|
83
83
|
}, c = () => {
|
|
84
|
-
let
|
|
84
|
+
let a = "";
|
|
85
85
|
for (; e.hasData; ) {
|
|
86
|
-
const [
|
|
87
|
-
if (!
|
|
88
|
-
return [
|
|
89
|
-
|
|
86
|
+
const [h, o] = i();
|
|
87
|
+
if (!o && "^/#".includes(h))
|
|
88
|
+
return [a, h];
|
|
89
|
+
a += h;
|
|
90
90
|
}
|
|
91
|
-
return [
|
|
91
|
+
return [a, ""];
|
|
92
92
|
}, l = () => {
|
|
93
|
-
let
|
|
93
|
+
let a = "";
|
|
94
94
|
for (; e.hasData; ) {
|
|
95
|
-
const [
|
|
96
|
-
|
|
95
|
+
const [h, o] = i();
|
|
96
|
+
o && h === ";" ? a += ";" : a += h;
|
|
97
97
|
}
|
|
98
|
-
return
|
|
98
|
+
return a;
|
|
99
99
|
};
|
|
100
|
-
return [t,
|
|
100
|
+
return [t, n] = c(), n && (s = l()), [2, [t, s, n]];
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
103
|
* Parse MText properties
|
|
104
104
|
* @param cmd - The property command to parse
|
|
105
|
+
* @returns Property changes if yieldPropertyCommands is true and changes occurred
|
|
105
106
|
*/
|
|
106
107
|
parseProperties(e) {
|
|
107
108
|
const t = this.ctx.copy();
|
|
@@ -155,7 +156,28 @@ class N {
|
|
|
155
156
|
default:
|
|
156
157
|
throw new Error(`Unknown command: ${e}`);
|
|
157
158
|
}
|
|
158
|
-
t.continueStroke = this.continueStroke, this.ctx = t
|
|
159
|
+
if (t.continueStroke = this.continueStroke, this.ctx = t, this.yieldPropertyCommands) {
|
|
160
|
+
const s = this.getPropertyChanges(this.lastCtx, t);
|
|
161
|
+
if (Object.keys(s).length > 0)
|
|
162
|
+
return this.lastCtx = this.ctx.copy(), {
|
|
163
|
+
command: e,
|
|
164
|
+
changes: s
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Get property changes between two contexts
|
|
170
|
+
* @param oldCtx - The old context
|
|
171
|
+
* @param newCtx - The new context
|
|
172
|
+
* @returns Object containing changed properties
|
|
173
|
+
*/
|
|
174
|
+
getPropertyChanges(e, t) {
|
|
175
|
+
const s = {};
|
|
176
|
+
if (e.underline !== t.underline && (s.underline = t.underline), e.overline !== t.overline && (s.overline = t.overline), e.strikeThrough !== t.strikeThrough && (s.strikeThrough = t.strikeThrough), e.aci !== t.aci && (s.aci = t.aci, s.rgb = t.rgb), e.rgb !== t.rgb && (s.rgb = t.rgb), e.align !== t.align && (s.align = t.align), JSON.stringify(e.fontFace) !== JSON.stringify(t.fontFace) && (s.fontFace = t.fontFace), e.capHeight !== t.capHeight && (s.capHeight = t.capHeight), e.widthFactor !== t.widthFactor && (s.widthFactor = t.widthFactor), e.charTrackingFactor !== t.charTrackingFactor && (s.charTrackingFactor = t.charTrackingFactor), e.oblique !== t.oblique && (s.oblique = t.oblique), JSON.stringify(e.paragraph) !== JSON.stringify(t.paragraph)) {
|
|
177
|
+
const n = {};
|
|
178
|
+
e.paragraph.indent !== t.paragraph.indent && (n.indent = t.paragraph.indent), e.paragraph.align !== t.paragraph.align && (n.align = t.paragraph.align), e.paragraph.left !== t.paragraph.left && (n.left = t.paragraph.left), e.paragraph.right !== t.paragraph.right && (n.right = t.paragraph.right), JSON.stringify(e.paragraph.tab_stops) !== JSON.stringify(t.paragraph.tab_stops) && (n.tab_stops = t.paragraph.tab_stops), Object.keys(n).length > 0 && (s.paragraph = n);
|
|
179
|
+
}
|
|
180
|
+
return s;
|
|
159
181
|
}
|
|
160
182
|
/**
|
|
161
183
|
* Parse alignment property
|
|
@@ -219,8 +241,8 @@ class N {
|
|
|
219
241
|
const t = this.extractFloatExpression(!0);
|
|
220
242
|
if (t)
|
|
221
243
|
if (t.endsWith("x")) {
|
|
222
|
-
const
|
|
223
|
-
e *= Math.abs(
|
|
244
|
+
const s = parseFloat(t.slice(0, -1));
|
|
245
|
+
e *= Math.abs(s);
|
|
224
246
|
} else
|
|
225
247
|
e = Math.abs(parseFloat(t));
|
|
226
248
|
return e;
|
|
@@ -240,8 +262,8 @@ class N {
|
|
|
240
262
|
parseAciColor(e) {
|
|
241
263
|
const t = this.extractIntExpression();
|
|
242
264
|
if (t) {
|
|
243
|
-
const
|
|
244
|
-
|
|
265
|
+
const s = parseInt(t);
|
|
266
|
+
s < 257 && (e.aci = s, e.rgb = null);
|
|
245
267
|
}
|
|
246
268
|
this.consumeOptionalTerminator();
|
|
247
269
|
}
|
|
@@ -252,8 +274,8 @@ class N {
|
|
|
252
274
|
parseRgbColor(e) {
|
|
253
275
|
const t = this.extractIntExpression();
|
|
254
276
|
if (t) {
|
|
255
|
-
const
|
|
256
|
-
e.rgb = [c,
|
|
277
|
+
const s = parseInt(t) & 16777215, [n, i, c] = _(s);
|
|
278
|
+
e.rgb = [c, i, n];
|
|
257
279
|
}
|
|
258
280
|
this.consumeOptionalTerminator();
|
|
259
281
|
}
|
|
@@ -263,10 +285,10 @@ class N {
|
|
|
263
285
|
* @returns Extracted expression
|
|
264
286
|
*/
|
|
265
287
|
extractFloatExpression(e = !1) {
|
|
266
|
-
const t = e ? /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?x?/ : /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/,
|
|
267
|
-
if (
|
|
268
|
-
const
|
|
269
|
-
return this.scanner.consume(
|
|
288
|
+
const t = e ? /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?x?/ : /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/, s = this.scanner.tail.match(t);
|
|
289
|
+
if (s) {
|
|
290
|
+
const n = s[0];
|
|
291
|
+
return this.scanner.consume(n.length), n;
|
|
270
292
|
}
|
|
271
293
|
return "";
|
|
272
294
|
}
|
|
@@ -293,8 +315,8 @@ class N {
|
|
|
293
315
|
const c = this.scanner.tail;
|
|
294
316
|
return this.scanner.consume(c.length), c;
|
|
295
317
|
}
|
|
296
|
-
const
|
|
297
|
-
return this.scanner.consume(
|
|
318
|
+
const n = this.scanner.peek(t - this.scanner.currentIndex - 1) === "\\", i = this.scanner.tail.slice(0, t - this.scanner.currentIndex + (n ? 1 : 0));
|
|
319
|
+
return this.scanner.consume(i.length + 1), i;
|
|
298
320
|
}
|
|
299
321
|
/**
|
|
300
322
|
* Parse font properties
|
|
@@ -303,14 +325,14 @@ class N {
|
|
|
303
325
|
parseFontProperties(e) {
|
|
304
326
|
const t = this.extractExpression().split("|");
|
|
305
327
|
if (t.length > 0 && t[0]) {
|
|
306
|
-
const
|
|
307
|
-
let
|
|
328
|
+
const s = t[0];
|
|
329
|
+
let n = "Regular", i = 400;
|
|
308
330
|
for (const c of t.slice(1))
|
|
309
|
-
c.startsWith("b1") ?
|
|
331
|
+
c.startsWith("b1") ? i = 700 : c.startsWith("i1") && (n = "Italic");
|
|
310
332
|
e.fontFace = {
|
|
311
|
-
family:
|
|
312
|
-
style:
|
|
313
|
-
weight:
|
|
333
|
+
family: s,
|
|
334
|
+
style: n,
|
|
335
|
+
weight: i
|
|
314
336
|
};
|
|
315
337
|
}
|
|
316
338
|
}
|
|
@@ -321,54 +343,54 @@ class N {
|
|
|
321
343
|
*/
|
|
322
344
|
parseParagraphProperties(e) {
|
|
323
345
|
const t = new p(this.extractExpression());
|
|
324
|
-
let
|
|
325
|
-
const
|
|
326
|
-
const
|
|
327
|
-
if (
|
|
328
|
-
const
|
|
329
|
-
for (t.consume(
|
|
346
|
+
let s = e.paragraph.indent, n = e.paragraph.left, i = e.paragraph.right, c = e.paragraph.align, l = [];
|
|
347
|
+
const a = () => {
|
|
348
|
+
const h = t.tail.match(/^[+-]?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/);
|
|
349
|
+
if (h) {
|
|
350
|
+
const o = parseFloat(h[0]);
|
|
351
|
+
for (t.consume(h[0].length); t.peek() === ","; )
|
|
330
352
|
t.consume(1);
|
|
331
|
-
return
|
|
353
|
+
return o;
|
|
332
354
|
}
|
|
333
355
|
return 0;
|
|
334
356
|
};
|
|
335
357
|
for (; t.hasData; )
|
|
336
358
|
switch (t.get()) {
|
|
337
359
|
case "i":
|
|
338
|
-
|
|
360
|
+
s = a();
|
|
339
361
|
break;
|
|
340
362
|
case "l":
|
|
341
|
-
|
|
363
|
+
n = a();
|
|
342
364
|
break;
|
|
343
365
|
case "r":
|
|
344
|
-
|
|
366
|
+
i = a();
|
|
345
367
|
break;
|
|
346
368
|
case "x":
|
|
347
369
|
break;
|
|
348
370
|
case "q": {
|
|
349
|
-
const
|
|
350
|
-
for (c =
|
|
371
|
+
const o = t.get();
|
|
372
|
+
for (c = S[o] || 0; t.peek() === ","; )
|
|
351
373
|
t.consume(1);
|
|
352
374
|
break;
|
|
353
375
|
}
|
|
354
376
|
case "t":
|
|
355
377
|
for (l = []; t.hasData; ) {
|
|
356
|
-
const
|
|
357
|
-
if (
|
|
378
|
+
const o = t.peek();
|
|
379
|
+
if (o === "r" || o === "c") {
|
|
358
380
|
t.consume(1);
|
|
359
|
-
const u =
|
|
360
|
-
l.push(
|
|
381
|
+
const u = a();
|
|
382
|
+
l.push(o + u.toString());
|
|
361
383
|
} else {
|
|
362
|
-
const u =
|
|
384
|
+
const u = a();
|
|
363
385
|
isNaN(u) ? t.consume(1) : l.push(u);
|
|
364
386
|
}
|
|
365
387
|
}
|
|
366
388
|
break;
|
|
367
389
|
}
|
|
368
390
|
e.paragraph = {
|
|
369
|
-
indent:
|
|
370
|
-
left:
|
|
371
|
-
right:
|
|
391
|
+
indent: s,
|
|
392
|
+
left: n,
|
|
393
|
+
right: i,
|
|
372
394
|
align: c,
|
|
373
395
|
tab_stops: l
|
|
374
396
|
};
|
|
@@ -384,30 +406,30 @@ class N {
|
|
|
384
406
|
* @yields MTextToken objects
|
|
385
407
|
*/
|
|
386
408
|
*parse() {
|
|
387
|
-
let
|
|
388
|
-
const
|
|
409
|
+
let s = null;
|
|
410
|
+
const n = () => {
|
|
389
411
|
var c;
|
|
390
|
-
let
|
|
412
|
+
let i = "";
|
|
391
413
|
for (; this.scanner.hasData; ) {
|
|
392
|
-
let l = !1,
|
|
393
|
-
const
|
|
394
|
-
if (
|
|
395
|
-
if (this.scanner.consume(1),
|
|
414
|
+
let l = !1, a = this.scanner.peek();
|
|
415
|
+
const h = this.scanner.currentIndex;
|
|
416
|
+
if (a.charCodeAt(0) < 32) {
|
|
417
|
+
if (this.scanner.consume(1), a === " ")
|
|
396
418
|
return [5, null];
|
|
397
|
-
if (
|
|
419
|
+
if (a === `
|
|
398
420
|
`)
|
|
399
421
|
return [6, null];
|
|
400
|
-
|
|
422
|
+
a = " ";
|
|
401
423
|
}
|
|
402
|
-
if (
|
|
424
|
+
if (a === "\\")
|
|
403
425
|
if ("\\{}".includes(this.scanner.peek(1)))
|
|
404
|
-
l = !0, this.scanner.consume(1),
|
|
426
|
+
l = !0, this.scanner.consume(1), a = this.scanner.peek();
|
|
405
427
|
else {
|
|
406
|
-
if (
|
|
407
|
-
return [1,
|
|
428
|
+
if (i)
|
|
429
|
+
return [1, i];
|
|
408
430
|
this.scanner.consume(1);
|
|
409
|
-
const
|
|
410
|
-
switch (
|
|
431
|
+
const o = this.scanner.get();
|
|
432
|
+
switch (o) {
|
|
411
433
|
case "~":
|
|
412
434
|
return [4, null];
|
|
413
435
|
case "P":
|
|
@@ -425,65 +447,63 @@ class N {
|
|
|
425
447
|
const u = (c = this.scanner.tail.match(/^[0-9A-Fa-f]{4}/)) == null ? void 0 : c[0];
|
|
426
448
|
if (u) {
|
|
427
449
|
this.scanner.consume(4);
|
|
428
|
-
const
|
|
429
|
-
return
|
|
450
|
+
const d = this.decodeMultiByteChar(u);
|
|
451
|
+
return i ? [1, i] : [1, d];
|
|
430
452
|
}
|
|
431
453
|
this.scanner.consume(-1);
|
|
432
454
|
}
|
|
433
|
-
|
|
455
|
+
i += "\\M";
|
|
434
456
|
continue;
|
|
435
457
|
default:
|
|
436
|
-
if (
|
|
458
|
+
if (o)
|
|
437
459
|
try {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
this.scanner.tail.slice(o, this.scanner.currentIndex)
|
|
442
|
-
];
|
|
460
|
+
const u = this.parseProperties(o);
|
|
461
|
+
if (this.yieldPropertyCommands && u)
|
|
462
|
+
return this.lastCtx = this.ctx.copy(), [9, u];
|
|
443
463
|
continue;
|
|
444
464
|
} catch {
|
|
445
465
|
const u = this.scanner.tail.slice(
|
|
446
|
-
|
|
466
|
+
h,
|
|
447
467
|
this.scanner.currentIndex
|
|
448
468
|
);
|
|
449
|
-
|
|
469
|
+
i += u;
|
|
450
470
|
}
|
|
451
471
|
}
|
|
452
472
|
continue;
|
|
453
473
|
}
|
|
454
|
-
if (
|
|
455
|
-
const
|
|
474
|
+
if (a === "%" && this.scanner.peek(1) === "%") {
|
|
475
|
+
const o = this.scanner.peek(2).toLowerCase(), u = F[o];
|
|
456
476
|
if (u) {
|
|
457
|
-
this.scanner.consume(3),
|
|
477
|
+
this.scanner.consume(3), i += u;
|
|
458
478
|
continue;
|
|
459
479
|
} else {
|
|
460
480
|
this.scanner.consume(3);
|
|
461
481
|
continue;
|
|
462
482
|
}
|
|
463
483
|
}
|
|
464
|
-
if (
|
|
465
|
-
return
|
|
484
|
+
if (a === " ")
|
|
485
|
+
return i ? (this.scanner.consume(1), s = 3, [1, i]) : (this.scanner.consume(1), [3, null]);
|
|
466
486
|
if (!l) {
|
|
467
|
-
if (
|
|
468
|
-
if (
|
|
469
|
-
return [1,
|
|
487
|
+
if (a === "{") {
|
|
488
|
+
if (i)
|
|
489
|
+
return [1, i];
|
|
470
490
|
this.scanner.consume(1), this.pushCtx();
|
|
471
491
|
continue;
|
|
472
|
-
} else if (
|
|
473
|
-
if (
|
|
474
|
-
return [1,
|
|
492
|
+
} else if (a === "}") {
|
|
493
|
+
if (i)
|
|
494
|
+
return [1, i];
|
|
475
495
|
this.scanner.consume(1), this.popCtx();
|
|
476
496
|
continue;
|
|
477
497
|
}
|
|
478
498
|
}
|
|
479
|
-
this.scanner.consume(1),
|
|
499
|
+
this.scanner.consume(1), a.charCodeAt(0) >= 32 && (i += a);
|
|
480
500
|
}
|
|
481
|
-
return
|
|
501
|
+
return i ? [1, i] : [0, null];
|
|
482
502
|
};
|
|
483
503
|
for (; ; ) {
|
|
484
|
-
const [
|
|
485
|
-
if (
|
|
486
|
-
yield new
|
|
504
|
+
const [i, c] = n();
|
|
505
|
+
if (i)
|
|
506
|
+
yield new g(i, this.ctx, c), s && (yield new g(s, this.ctx, null), s = null);
|
|
487
507
|
else
|
|
488
508
|
break;
|
|
489
509
|
}
|
|
@@ -548,21 +568,21 @@ class p {
|
|
|
548
568
|
* @returns Index of the character, or -1 if not found
|
|
549
569
|
*/
|
|
550
570
|
find(e, t = !1) {
|
|
551
|
-
let
|
|
552
|
-
for (;
|
|
553
|
-
if (t && this.text[
|
|
554
|
-
if (
|
|
555
|
-
if (this.text[
|
|
556
|
-
return
|
|
557
|
-
|
|
571
|
+
let s = this._index;
|
|
572
|
+
for (; s < this.textLen; ) {
|
|
573
|
+
if (t && this.text[s] === "\\") {
|
|
574
|
+
if (s + 1 < this.textLen) {
|
|
575
|
+
if (this.text[s + 1] === e)
|
|
576
|
+
return s + 1;
|
|
577
|
+
s += 2;
|
|
558
578
|
continue;
|
|
559
579
|
}
|
|
560
|
-
|
|
580
|
+
s++;
|
|
561
581
|
continue;
|
|
562
582
|
}
|
|
563
|
-
if (this.text[
|
|
564
|
-
return
|
|
565
|
-
|
|
583
|
+
if (this.text[s] === e)
|
|
584
|
+
return s;
|
|
585
|
+
s++;
|
|
566
586
|
}
|
|
567
587
|
return -1;
|
|
568
588
|
}
|
|
@@ -589,7 +609,7 @@ class p {
|
|
|
589
609
|
return e;
|
|
590
610
|
}
|
|
591
611
|
}
|
|
592
|
-
class
|
|
612
|
+
class f {
|
|
593
613
|
constructor() {
|
|
594
614
|
this._stroke = 0, this.continueStroke = !1, this._aci = 7, this.rgb = null, this.align = 0, this.fontFace = { family: "", style: "Regular", weight: 400 }, this.capHeight = 1, this.widthFactor = 1, this.charTrackingFactor = 1, this.oblique = 0, this.paragraph = {
|
|
595
615
|
indent: 0,
|
|
@@ -674,34 +694,34 @@ class d {
|
|
|
674
694
|
* @returns A new context with the same properties
|
|
675
695
|
*/
|
|
676
696
|
copy() {
|
|
677
|
-
const e = new
|
|
697
|
+
const e = new f();
|
|
678
698
|
return e._stroke = this._stroke, e.continueStroke = this.continueStroke, e._aci = this._aci, e.rgb = this.rgb, e.align = this.align, e.fontFace = { ...this.fontFace }, e.capHeight = this.capHeight, e.widthFactor = this.widthFactor, e.charTrackingFactor = this.charTrackingFactor, e.oblique = this.oblique, e.paragraph = { ...this.paragraph }, e;
|
|
679
699
|
}
|
|
680
700
|
}
|
|
681
|
-
class
|
|
701
|
+
class g {
|
|
682
702
|
/**
|
|
683
703
|
* Create a new MText token
|
|
684
704
|
* @param type - The token type
|
|
685
705
|
* @param ctx - The text context at this token
|
|
686
706
|
* @param data - Optional token data
|
|
687
707
|
*/
|
|
688
|
-
constructor(e, t,
|
|
689
|
-
this.type = e, this.ctx = t, this.data =
|
|
708
|
+
constructor(e, t, s) {
|
|
709
|
+
this.type = e, this.ctx = t, this.data = s;
|
|
690
710
|
}
|
|
691
711
|
}
|
|
692
712
|
export {
|
|
693
|
-
|
|
694
|
-
|
|
713
|
+
f as MTextContext,
|
|
714
|
+
b as MTextLineAlignment,
|
|
695
715
|
E as MTextParagraphAlignment,
|
|
696
|
-
|
|
716
|
+
D as MTextParser,
|
|
697
717
|
m as MTextStroke,
|
|
698
|
-
|
|
718
|
+
g as MTextToken,
|
|
699
719
|
p as TextScanner,
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
720
|
+
k as TokenType,
|
|
721
|
+
I as caretDecode,
|
|
722
|
+
O as escapeDxfLineEndings,
|
|
723
|
+
R as hasInlineFormattingCodes,
|
|
704
724
|
_ as int2rgb,
|
|
705
|
-
|
|
725
|
+
N as rgb2int
|
|
706
726
|
};
|
|
707
727
|
//# sourceMappingURL=parser.es.js.map
|