@mlightcad/mtext-parser 1.1.9 → 1.3.1
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 +2 -2
- package/dist/parser.cjs.js.map +1 -1
- package/dist/parser.es.js +174 -126
- package/dist/parser.es.js.map +1 -1
- package/dist/parser.umd.js +2 -2
- package/dist/parser.umd.js.map +1 -1
- package/dist/types/parser.d.ts +26 -1
- package/package.json +3 -2
package/dist/parser.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
const
|
|
1
|
+
var _ = /* @__PURE__ */ ((s) => (s[s.NONE = 0] = "NONE", s[s.WORD = 1] = "WORD", s[s.STACK = 2] = "STACK", s[s.SPACE = 3] = "SPACE", s[s.NBSP = 4] = "NBSP", s[s.TABULATOR = 5] = "TABULATOR", s[s.NEW_PARAGRAPH = 6] = "NEW_PARAGRAPH", s[s.NEW_COLUMN = 7] = "NEW_COLUMN", s[s.WRAP_AT_DIMLINE = 8] = "WRAP_AT_DIMLINE", s[s.PROPERTIES_CHANGED = 9] = "PROPERTIES_CHANGED", s))(_ || {}), F = /* @__PURE__ */ ((s) => (s[s.BOTTOM = 0] = "BOTTOM", s[s.MIDDLE = 1] = "MIDDLE", s[s.TOP = 2] = "TOP", s))(F || {}), S = /* @__PURE__ */ ((s) => (s[s.DEFAULT = 0] = "DEFAULT", s[s.LEFT = 1] = "LEFT", s[s.RIGHT = 2] = "RIGHT", s[s.CENTER = 3] = "CENTER", s[s.JUSTIFIED = 4] = "JUSTIFIED", s[s.DISTRIBUTED = 5] = "DISTRIBUTED", s))(S || {}), E = /* @__PURE__ */ ((s) => (s[s.NONE = 0] = "NONE", s[s.UNDERLINE = 1] = "UNDERLINE", s[s.OVERLINE = 2] = "OVERLINE", s[s.STRIKE_THROUGH = 4] = "STRIKE_THROUGH", s))(E || {});
|
|
2
|
+
const R = {
|
|
3
3
|
c: "Ø",
|
|
4
4
|
d: "°",
|
|
5
5
|
p: "±"
|
|
6
|
-
},
|
|
6
|
+
}, v = {
|
|
7
7
|
l: 1,
|
|
8
8
|
r: 2,
|
|
9
9
|
c: 3,
|
|
@@ -11,28 +11,28 @@ const E = {
|
|
|
11
11
|
d: 5
|
|
12
12
|
/* DISTRIBUTED */
|
|
13
13
|
};
|
|
14
|
-
function
|
|
14
|
+
function O(s) {
|
|
15
15
|
const [t, e, r] = s;
|
|
16
16
|
return r << 16 | e << 8 | t;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function I(s) {
|
|
19
19
|
const t = s & 255, e = s >> 8 & 255, r = s >> 16 & 255;
|
|
20
20
|
return [t, e, r];
|
|
21
21
|
}
|
|
22
22
|
function N(s) {
|
|
23
23
|
return s.replace(/\r\n|\r|\n/g, "\\P");
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function w(s) {
|
|
26
26
|
return s.replace(/\\P/g, "").replace(/\\~/g, "").includes("\\");
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function D(s, t = !1) {
|
|
29
29
|
const e = /* @__PURE__ */ new Set(), r = /\\[fF](.*?)[;|]/g;
|
|
30
30
|
return [...s.matchAll(r)].forEach((a) => {
|
|
31
|
-
let
|
|
32
|
-
t && (
|
|
31
|
+
let o = a[1].toLowerCase();
|
|
32
|
+
t && (o = o.replace(/\.(ttf|otf|woff|shx)$/, "")), e.add(o);
|
|
33
33
|
}), e;
|
|
34
34
|
}
|
|
35
|
-
class
|
|
35
|
+
class y {
|
|
36
36
|
/**
|
|
37
37
|
* Creates a new ContextStack with an initial context.
|
|
38
38
|
* @param initial The initial MTextContext to use as the base of the stack.
|
|
@@ -92,29 +92,58 @@ class x {
|
|
|
92
92
|
* @param options - Parser options
|
|
93
93
|
*/
|
|
94
94
|
constructor(t, e, r = {}) {
|
|
95
|
-
this.continueStroke = !1, this.inStackContext = !1, this.scanner = new
|
|
96
|
-
const a = e ?? new
|
|
97
|
-
this.ctxStack = new
|
|
95
|
+
this.continueStroke = !1, this.inStackContext = !1, this.scanner = new f(t);
|
|
96
|
+
const a = e ?? new b();
|
|
97
|
+
this.ctxStack = new y(a), this.yieldPropertyCommands = r.yieldPropertyCommands ?? !1, this.resetParagraphParameters = r.resetParagraphParameters ?? !1, this.mifDecoder = r.mifDecoder ?? this.decodeMultiByteChar.bind(this), this.mifCodeLength = r.mifCodeLength ?? "auto";
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
100
|
* Decode multi-byte character from hex code
|
|
101
|
-
* @param hex - Hex code string (e.g. "C4E3")
|
|
101
|
+
* @param hex - Hex code string (e.g. "C4E3" or "1A2B3")
|
|
102
102
|
* @returns Decoded character or empty square if invalid
|
|
103
103
|
*/
|
|
104
104
|
decodeMultiByteChar(t) {
|
|
105
105
|
try {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
if (t.length === 5) {
|
|
107
|
+
const e = t[0];
|
|
108
|
+
let r = "gbk";
|
|
109
|
+
e === "1" ? r = "shift-jis" : e === "2" && (r = "big5");
|
|
110
|
+
const a = new Uint8Array([
|
|
111
|
+
parseInt(t.substr(1, 2), 16),
|
|
112
|
+
parseInt(t.substr(3, 2), 16)
|
|
113
|
+
]);
|
|
114
|
+
return new TextDecoder(r).decode(a);
|
|
115
|
+
} else if (t.length === 4) {
|
|
116
|
+
const e = new Uint8Array([
|
|
117
|
+
parseInt(t.substr(0, 2), 16),
|
|
118
|
+
parseInt(t.substr(2, 2), 16)
|
|
119
|
+
]), a = new TextDecoder("gbk").decode(e);
|
|
120
|
+
if (a !== "▯")
|
|
121
|
+
return a;
|
|
122
|
+
const i = new TextDecoder("big5").decode(e);
|
|
123
|
+
if (i !== "▯")
|
|
124
|
+
return i;
|
|
125
|
+
}
|
|
126
|
+
return "▯";
|
|
114
127
|
} catch {
|
|
115
128
|
return "▯";
|
|
116
129
|
}
|
|
117
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Extract MIF hex code from scanner
|
|
133
|
+
* @param length - The length of the hex code to extract (4 or 5), or 'auto' to detect
|
|
134
|
+
* @returns The extracted hex code, or null if not found
|
|
135
|
+
*/
|
|
136
|
+
extractMifCode(t) {
|
|
137
|
+
var e, r, a;
|
|
138
|
+
if (t === "auto") {
|
|
139
|
+
const o = (e = this.scanner.tail.match(/^[0-9A-Fa-f]{5}/)) == null ? void 0 : e[0];
|
|
140
|
+
if (o)
|
|
141
|
+
return o;
|
|
142
|
+
const i = (r = this.scanner.tail.match(/^[0-9A-Fa-f]{4}/)) == null ? void 0 : r[0];
|
|
143
|
+
return i || null;
|
|
144
|
+
} else
|
|
145
|
+
return ((a = this.scanner.tail.match(new RegExp(`^[0-9A-Fa-f]{${t}}`))) == null ? void 0 : a[0]) || null;
|
|
146
|
+
}
|
|
118
147
|
/**
|
|
119
148
|
* Push current context onto the stack
|
|
120
149
|
*/
|
|
@@ -132,31 +161,31 @@ class x {
|
|
|
132
161
|
* @returns Tuple of [TokenType.STACK, [numerator, denominator, type]]
|
|
133
162
|
*/
|
|
134
163
|
parseStacking() {
|
|
135
|
-
const t = new
|
|
164
|
+
const t = new f(this.extractExpression(!0));
|
|
136
165
|
let e = "", r = "", a = "";
|
|
137
|
-
const
|
|
138
|
-
let
|
|
139
|
-
return
|
|
166
|
+
const o = () => {
|
|
167
|
+
let n = t.peek(), l = !1;
|
|
168
|
+
return n.charCodeAt(0) < 32 && (n = " "), n === "\\" && (l = !0, t.consume(1), n = t.peek()), t.consume(1), [n, l];
|
|
140
169
|
}, i = () => {
|
|
141
|
-
let
|
|
170
|
+
let n = "";
|
|
142
171
|
for (; t.hasData; ) {
|
|
143
|
-
const [
|
|
144
|
-
if (!
|
|
145
|
-
return [
|
|
146
|
-
|
|
172
|
+
const [l, h] = o();
|
|
173
|
+
if (!h && (l === "/" || l === "#" || l === "^"))
|
|
174
|
+
return [n, l];
|
|
175
|
+
n += l;
|
|
147
176
|
}
|
|
148
|
-
return [
|
|
149
|
-
}, u = (
|
|
150
|
-
let
|
|
177
|
+
return [n, ""];
|
|
178
|
+
}, u = (n) => {
|
|
179
|
+
let l = "", h = n;
|
|
151
180
|
for (; t.hasData; ) {
|
|
152
|
-
const [
|
|
153
|
-
if (!(
|
|
154
|
-
if (
|
|
181
|
+
const [c, p] = o();
|
|
182
|
+
if (!(h && c === " ")) {
|
|
183
|
+
if (h = !1, !p && c === ";")
|
|
155
184
|
break;
|
|
156
|
-
|
|
185
|
+
l += c;
|
|
157
186
|
}
|
|
158
187
|
}
|
|
159
|
-
return
|
|
188
|
+
return l;
|
|
160
189
|
};
|
|
161
190
|
return [e, a] = i(), a && (r = u(a === "^")), e === "" && r.includes("I/") ? [2, [" ", " ", "/"]] : a === "^" ? [2, [e, r, "^"]] : [2, [e, r, a]];
|
|
162
191
|
}
|
|
@@ -395,8 +424,8 @@ class x {
|
|
|
395
424
|
const i = this.scanner.tail;
|
|
396
425
|
return this.scanner.consume(i.length), i;
|
|
397
426
|
}
|
|
398
|
-
const a = this.scanner.peek(e - this.scanner.currentIndex - 1) === "\\",
|
|
399
|
-
return this.scanner.consume(
|
|
427
|
+
const a = this.scanner.peek(e - this.scanner.currentIndex - 1) === "\\", o = this.scanner.tail.slice(0, e - this.scanner.currentIndex + (a ? 1 : 0));
|
|
428
|
+
return this.scanner.consume(o.length + 1), o;
|
|
400
429
|
}
|
|
401
430
|
/**
|
|
402
431
|
* Parse font properties
|
|
@@ -406,13 +435,13 @@ class x {
|
|
|
406
435
|
const e = this.extractExpression().split("|");
|
|
407
436
|
if (e.length > 0 && e[0]) {
|
|
408
437
|
const r = e[0];
|
|
409
|
-
let a = "Regular",
|
|
438
|
+
let a = "Regular", o = 400;
|
|
410
439
|
for (const i of e.slice(1))
|
|
411
|
-
i.startsWith("b1") ?
|
|
440
|
+
i.startsWith("b1") ? o = 700 : i === "i" || i.startsWith("i1") ? a = "Italic" : (i === "i0" || i.startsWith("i0")) && (a = "Regular");
|
|
412
441
|
t.fontFace = {
|
|
413
442
|
family: r,
|
|
414
443
|
style: a,
|
|
415
|
-
weight:
|
|
444
|
+
weight: o
|
|
416
445
|
};
|
|
417
446
|
}
|
|
418
447
|
}
|
|
@@ -422,47 +451,47 @@ class x {
|
|
|
422
451
|
* @param ctx - The context to update
|
|
423
452
|
*/
|
|
424
453
|
parseParagraphProperties(t) {
|
|
425
|
-
const e = new
|
|
426
|
-
let r = t.paragraph.indent, a = t.paragraph.left,
|
|
427
|
-
const
|
|
428
|
-
const
|
|
429
|
-
if (
|
|
430
|
-
const
|
|
431
|
-
for (e.consume(
|
|
454
|
+
const e = new f(this.extractExpression());
|
|
455
|
+
let r = t.paragraph.indent, a = t.paragraph.left, o = t.paragraph.right, i = t.paragraph.align, u = [];
|
|
456
|
+
const n = () => {
|
|
457
|
+
const l = e.tail.match(/^[+-]?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/);
|
|
458
|
+
if (l) {
|
|
459
|
+
const h = parseFloat(l[0]);
|
|
460
|
+
for (e.consume(l[0].length); e.peek() === ","; )
|
|
432
461
|
e.consume(1);
|
|
433
|
-
return
|
|
462
|
+
return h;
|
|
434
463
|
}
|
|
435
464
|
return 0;
|
|
436
465
|
};
|
|
437
466
|
for (; e.hasData; )
|
|
438
467
|
switch (e.get()) {
|
|
439
468
|
case "i":
|
|
440
|
-
r =
|
|
469
|
+
r = n();
|
|
441
470
|
break;
|
|
442
471
|
case "l":
|
|
443
|
-
a =
|
|
472
|
+
a = n();
|
|
444
473
|
break;
|
|
445
474
|
case "r":
|
|
446
|
-
|
|
475
|
+
o = n();
|
|
447
476
|
break;
|
|
448
477
|
case "x":
|
|
449
478
|
break;
|
|
450
479
|
case "q": {
|
|
451
|
-
const
|
|
452
|
-
for (i =
|
|
480
|
+
const h = e.get();
|
|
481
|
+
for (i = v[h] || 0; e.peek() === ","; )
|
|
453
482
|
e.consume(1);
|
|
454
483
|
break;
|
|
455
484
|
}
|
|
456
485
|
case "t":
|
|
457
486
|
for (u = []; e.hasData; ) {
|
|
458
|
-
const
|
|
459
|
-
if (
|
|
487
|
+
const h = e.peek();
|
|
488
|
+
if (h === "r" || h === "c") {
|
|
460
489
|
e.consume(1);
|
|
461
|
-
const
|
|
462
|
-
u.push(
|
|
490
|
+
const c = n();
|
|
491
|
+
u.push(h + c.toString());
|
|
463
492
|
} else {
|
|
464
|
-
const
|
|
465
|
-
isNaN(
|
|
493
|
+
const c = n();
|
|
494
|
+
isNaN(c) ? e.consume(1) : u.push(c);
|
|
466
495
|
}
|
|
467
496
|
}
|
|
468
497
|
break;
|
|
@@ -470,7 +499,7 @@ class x {
|
|
|
470
499
|
t.paragraph = {
|
|
471
500
|
indent: r,
|
|
472
501
|
left: a,
|
|
473
|
-
right:
|
|
502
|
+
right: o,
|
|
474
503
|
align: i,
|
|
475
504
|
tabs: u
|
|
476
505
|
};
|
|
@@ -496,15 +525,14 @@ class x {
|
|
|
496
525
|
align: 0,
|
|
497
526
|
tabs: []
|
|
498
527
|
};
|
|
499
|
-
const
|
|
500
|
-
return u.indent !== 0 && (
|
|
528
|
+
const n = {};
|
|
529
|
+
return u.indent !== 0 && (n.indent = 0), u.left !== 0 && (n.left = 0), u.right !== 0 && (n.right = 0), u.align !== 0 && (n.align = 0), JSON.stringify(u.tabs) !== JSON.stringify([]) && (n.tabs = []), n;
|
|
501
530
|
}
|
|
502
|
-
const
|
|
503
|
-
var u;
|
|
531
|
+
const o = () => {
|
|
504
532
|
let i = "";
|
|
505
533
|
for (; this.scanner.hasData; ) {
|
|
506
|
-
let
|
|
507
|
-
const
|
|
534
|
+
let u = !1, n = this.scanner.peek();
|
|
535
|
+
const l = this.scanner.currentIndex;
|
|
508
536
|
if (n.charCodeAt(0) < 32) {
|
|
509
537
|
if (this.scanner.consume(1), n === " ")
|
|
510
538
|
return [5, null];
|
|
@@ -515,13 +543,13 @@ class x {
|
|
|
515
543
|
}
|
|
516
544
|
if (n === "\\")
|
|
517
545
|
if ("\\{}".includes(this.scanner.peek(1)))
|
|
518
|
-
|
|
546
|
+
u = !0, this.scanner.consume(1), n = this.scanner.peek();
|
|
519
547
|
else {
|
|
520
548
|
if (i)
|
|
521
549
|
return [1, i];
|
|
522
550
|
this.scanner.consume(1);
|
|
523
|
-
const
|
|
524
|
-
switch (
|
|
551
|
+
const h = this.scanner.get();
|
|
552
|
+
switch (h) {
|
|
525
553
|
case "~":
|
|
526
554
|
return [4, null];
|
|
527
555
|
case "P":
|
|
@@ -532,44 +560,64 @@ class x {
|
|
|
532
560
|
return [8, null];
|
|
533
561
|
case "S": {
|
|
534
562
|
this.inStackContext = !0;
|
|
535
|
-
const
|
|
536
|
-
return this.inStackContext = !1,
|
|
563
|
+
const c = this.parseStacking();
|
|
564
|
+
return this.inStackContext = !1, c;
|
|
537
565
|
}
|
|
538
566
|
case "m":
|
|
539
567
|
case "M":
|
|
540
568
|
if (this.scanner.peek() === "+") {
|
|
541
569
|
this.scanner.consume(1);
|
|
542
|
-
const
|
|
543
|
-
if (
|
|
544
|
-
this.scanner.consume(
|
|
545
|
-
const
|
|
546
|
-
return i ? [1, i] : [1,
|
|
570
|
+
const c = this.extractMifCode(this.mifCodeLength);
|
|
571
|
+
if (c) {
|
|
572
|
+
this.scanner.consume(c.length);
|
|
573
|
+
const p = this.mifDecoder(c);
|
|
574
|
+
return i ? [1, i] : [1, p];
|
|
547
575
|
}
|
|
548
576
|
this.scanner.consume(-1);
|
|
549
577
|
}
|
|
550
578
|
i += "\\M";
|
|
551
579
|
continue;
|
|
580
|
+
case "U":
|
|
581
|
+
if (this.scanner.peek() === "+") {
|
|
582
|
+
this.scanner.consume(1);
|
|
583
|
+
const c = this.scanner.tail.match(/^[0-9A-Fa-f]{4,8}/);
|
|
584
|
+
if (c) {
|
|
585
|
+
const p = c[0];
|
|
586
|
+
this.scanner.consume(p.length);
|
|
587
|
+
const m = parseInt(p, 16);
|
|
588
|
+
let g = "";
|
|
589
|
+
try {
|
|
590
|
+
g = String.fromCodePoint(m);
|
|
591
|
+
} catch {
|
|
592
|
+
g = "▯";
|
|
593
|
+
}
|
|
594
|
+
return i ? [1, i] : [1, g];
|
|
595
|
+
}
|
|
596
|
+
this.scanner.consume(-1);
|
|
597
|
+
}
|
|
598
|
+
i += "\\U";
|
|
599
|
+
continue;
|
|
552
600
|
default:
|
|
553
|
-
if (
|
|
601
|
+
if (h)
|
|
554
602
|
try {
|
|
555
|
-
const
|
|
556
|
-
if (this.yieldPropertyCommands &&
|
|
557
|
-
return [9,
|
|
603
|
+
const c = this.parseProperties(h);
|
|
604
|
+
if (this.yieldPropertyCommands && c)
|
|
605
|
+
return [9, c];
|
|
558
606
|
continue;
|
|
559
607
|
} catch {
|
|
560
|
-
const
|
|
561
|
-
|
|
608
|
+
const c = this.scanner.tail.slice(
|
|
609
|
+
l,
|
|
562
610
|
this.scanner.currentIndex
|
|
563
611
|
);
|
|
564
|
-
i +=
|
|
612
|
+
i += c;
|
|
565
613
|
}
|
|
566
614
|
}
|
|
567
615
|
continue;
|
|
568
616
|
}
|
|
569
617
|
if (n === "%" && this.scanner.peek(1) === "%") {
|
|
570
|
-
const
|
|
571
|
-
if (
|
|
572
|
-
this.scanner.consume(3), i +=
|
|
618
|
+
const h = this.scanner.peek(2).toLowerCase(), c = R[h];
|
|
619
|
+
if (c) {
|
|
620
|
+
this.scanner.consume(3), i += c;
|
|
573
621
|
continue;
|
|
574
622
|
} else {
|
|
575
623
|
this.scanner.consume(3);
|
|
@@ -578,7 +626,7 @@ class x {
|
|
|
578
626
|
}
|
|
579
627
|
if (n === " ")
|
|
580
628
|
return i ? (this.scanner.consume(1), r = 3, [1, i]) : (this.scanner.consume(1), [3, null]);
|
|
581
|
-
if (!
|
|
629
|
+
if (!u) {
|
|
582
630
|
if (n === "{") {
|
|
583
631
|
if (i)
|
|
584
632
|
return [1, i];
|
|
@@ -588,13 +636,13 @@ class x {
|
|
|
588
636
|
if (i)
|
|
589
637
|
return [1, i];
|
|
590
638
|
if (this.scanner.consume(1), this.yieldPropertyCommands) {
|
|
591
|
-
const
|
|
639
|
+
const h = this.ctxStack.current;
|
|
592
640
|
this.popCtx();
|
|
593
|
-
const
|
|
594
|
-
if (Object.keys(
|
|
641
|
+
const c = this.getPropertyChanges(h, this.ctxStack.current);
|
|
642
|
+
if (Object.keys(c).length > 0)
|
|
595
643
|
return [
|
|
596
644
|
9,
|
|
597
|
-
{ command: void 0, changes:
|
|
645
|
+
{ command: void 0, changes: c, depth: this.ctxStack.depth }
|
|
598
646
|
];
|
|
599
647
|
} else
|
|
600
648
|
this.popCtx();
|
|
@@ -602,17 +650,17 @@ class x {
|
|
|
602
650
|
}
|
|
603
651
|
}
|
|
604
652
|
if (!this.inStackContext && n === "^") {
|
|
605
|
-
const
|
|
606
|
-
if (
|
|
607
|
-
const
|
|
608
|
-
if (this.scanner.consume(2),
|
|
653
|
+
const h = this.scanner.peek(1);
|
|
654
|
+
if (h) {
|
|
655
|
+
const c = h.charCodeAt(0);
|
|
656
|
+
if (this.scanner.consume(2), c === 32)
|
|
609
657
|
i += "^";
|
|
610
658
|
else {
|
|
611
|
-
if (
|
|
659
|
+
if (c === 73)
|
|
612
660
|
return i ? [1, i] : [5, null];
|
|
613
|
-
if (
|
|
661
|
+
if (c === 74)
|
|
614
662
|
return i ? [1, i] : [6, null];
|
|
615
|
-
if (
|
|
663
|
+
if (c === 77)
|
|
616
664
|
continue;
|
|
617
665
|
i += "▯";
|
|
618
666
|
}
|
|
@@ -624,23 +672,23 @@ class x {
|
|
|
624
672
|
return i ? [1, i] : [0, null];
|
|
625
673
|
};
|
|
626
674
|
for (; ; ) {
|
|
627
|
-
const [i, u] =
|
|
675
|
+
const [i, u] = o.call(this);
|
|
628
676
|
if (i) {
|
|
629
|
-
if (yield new
|
|
630
|
-
const
|
|
631
|
-
this.yieldPropertyCommands && Object.keys(
|
|
677
|
+
if (yield new d(i, this.ctxStack.current.copy(), u), i === 6 && this.resetParagraphParameters) {
|
|
678
|
+
const n = this.ctxStack.current, l = a(n);
|
|
679
|
+
this.yieldPropertyCommands && Object.keys(l).length > 0 && (yield new d(9, n.copy(), {
|
|
632
680
|
command: void 0,
|
|
633
|
-
changes: { paragraph:
|
|
681
|
+
changes: { paragraph: l },
|
|
634
682
|
depth: this.ctxStack.depth
|
|
635
683
|
}));
|
|
636
684
|
}
|
|
637
|
-
r && (yield new
|
|
685
|
+
r && (yield new d(r, this.ctxStack.current.copy(), null), r = null);
|
|
638
686
|
} else
|
|
639
687
|
break;
|
|
640
688
|
}
|
|
641
689
|
}
|
|
642
690
|
}
|
|
643
|
-
class
|
|
691
|
+
class f {
|
|
644
692
|
/**
|
|
645
693
|
* Create a new text scanner
|
|
646
694
|
* @param text - The text to scan
|
|
@@ -740,7 +788,7 @@ class g {
|
|
|
740
788
|
return t;
|
|
741
789
|
}
|
|
742
790
|
}
|
|
743
|
-
class
|
|
791
|
+
class k {
|
|
744
792
|
// Store as 0xRRGGBB or null
|
|
745
793
|
/**
|
|
746
794
|
* Create a new MTextColor instance.
|
|
@@ -816,7 +864,7 @@ class d {
|
|
|
816
864
|
* @returns A new MTextColor instance with the same color state.
|
|
817
865
|
*/
|
|
818
866
|
copy() {
|
|
819
|
-
const t = new
|
|
867
|
+
const t = new k();
|
|
820
868
|
return t._aci = this._aci, t._rgbValue = this._rgbValue, t;
|
|
821
869
|
}
|
|
822
870
|
/**
|
|
@@ -835,9 +883,9 @@ class d {
|
|
|
835
883
|
return this._aci === t._aci && this._rgbValue === t._rgbValue;
|
|
836
884
|
}
|
|
837
885
|
}
|
|
838
|
-
class
|
|
886
|
+
class b {
|
|
839
887
|
constructor() {
|
|
840
|
-
this._stroke = 0, this.continueStroke = !1, this.color = new
|
|
888
|
+
this._stroke = 0, this.continueStroke = !1, this.color = new k(), this.align = 0, this.fontFace = { family: "", style: "Regular", weight: 400 }, this._capHeight = { value: 1, isRelative: !1 }, this._widthFactor = { value: 1, isRelative: !1 }, this._charTrackingFactor = { value: 1, isRelative: !1 }, this.oblique = 0, this.paragraph = {
|
|
841
889
|
indent: 0,
|
|
842
890
|
left: 0,
|
|
843
891
|
right: 0,
|
|
@@ -1007,11 +1055,11 @@ class k {
|
|
|
1007
1055
|
* @returns A new context with the same properties
|
|
1008
1056
|
*/
|
|
1009
1057
|
copy() {
|
|
1010
|
-
const t = new
|
|
1058
|
+
const t = new b();
|
|
1011
1059
|
return t._stroke = this._stroke, t.continueStroke = this.continueStroke, t.color = this.color.copy(), t.align = this.align, t.fontFace = { ...this.fontFace }, t._capHeight = { ...this._capHeight }, t._widthFactor = { ...this._widthFactor }, t._charTrackingFactor = { ...this._charTrackingFactor }, t.oblique = this.oblique, t.paragraph = { ...this.paragraph }, t;
|
|
1012
1060
|
}
|
|
1013
1061
|
}
|
|
1014
|
-
class
|
|
1062
|
+
class d {
|
|
1015
1063
|
/**
|
|
1016
1064
|
* Create a new MText token
|
|
1017
1065
|
* @param type - The token type
|
|
@@ -1023,19 +1071,19 @@ class f {
|
|
|
1023
1071
|
}
|
|
1024
1072
|
}
|
|
1025
1073
|
export {
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1074
|
+
k as MTextColor,
|
|
1075
|
+
b as MTextContext,
|
|
1076
|
+
F as MTextLineAlignment,
|
|
1029
1077
|
S as MTextParagraphAlignment,
|
|
1030
1078
|
x as MTextParser,
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1079
|
+
E as MTextStroke,
|
|
1080
|
+
d as MTextToken,
|
|
1081
|
+
f as TextScanner,
|
|
1082
|
+
_ as TokenType,
|
|
1035
1083
|
N as escapeDxfLineEndings,
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1084
|
+
D as getFonts,
|
|
1085
|
+
w as hasInlineFormattingCodes,
|
|
1086
|
+
I as int2rgb,
|
|
1087
|
+
O as rgb2int
|
|
1040
1088
|
};
|
|
1041
1089
|
//# sourceMappingURL=parser.es.js.map
|