@mlightcad/mtext-parser 1.2.0 → 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 +159 -131
- 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,7 +11,7 @@ const v = {
|
|
|
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
|
}
|
|
@@ -19,20 +19,20 @@ 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
|
-
function
|
|
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.
|
|
@@ -84,7 +84,7 @@ class O {
|
|
|
84
84
|
this.stack[this.stack.length - 1] = t;
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
class
|
|
87
|
+
class x {
|
|
88
88
|
/**
|
|
89
89
|
* Creates a new MTextParser instance
|
|
90
90
|
* @param content - The MText content to parse
|
|
@@ -92,29 +92,58 @@ class D {
|
|
|
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 D {
|
|
|
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 D {
|
|
|
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 D {
|
|
|
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 D {
|
|
|
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 D {
|
|
|
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 D {
|
|
|
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,7 +543,7 @@ class D {
|
|
|
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];
|
|
@@ -532,18 +560,18 @@ class D {
|
|
|
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
|
}
|
|
@@ -552,18 +580,18 @@ class D {
|
|
|
552
580
|
case "U":
|
|
553
581
|
if (this.scanner.peek() === "+") {
|
|
554
582
|
this.scanner.consume(1);
|
|
555
|
-
const
|
|
556
|
-
if (
|
|
557
|
-
const
|
|
558
|
-
this.scanner.consume(
|
|
559
|
-
const
|
|
560
|
-
let
|
|
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 = "";
|
|
561
589
|
try {
|
|
562
|
-
|
|
590
|
+
g = String.fromCodePoint(m);
|
|
563
591
|
} catch {
|
|
564
|
-
|
|
592
|
+
g = "▯";
|
|
565
593
|
}
|
|
566
|
-
return i ? [1, i] : [1,
|
|
594
|
+
return i ? [1, i] : [1, g];
|
|
567
595
|
}
|
|
568
596
|
this.scanner.consume(-1);
|
|
569
597
|
}
|
|
@@ -572,24 +600,24 @@ class D {
|
|
|
572
600
|
default:
|
|
573
601
|
if (h)
|
|
574
602
|
try {
|
|
575
|
-
const
|
|
576
|
-
if (this.yieldPropertyCommands &&
|
|
577
|
-
return [9,
|
|
603
|
+
const c = this.parseProperties(h);
|
|
604
|
+
if (this.yieldPropertyCommands && c)
|
|
605
|
+
return [9, c];
|
|
578
606
|
continue;
|
|
579
607
|
} catch {
|
|
580
|
-
const
|
|
581
|
-
|
|
608
|
+
const c = this.scanner.tail.slice(
|
|
609
|
+
l,
|
|
582
610
|
this.scanner.currentIndex
|
|
583
611
|
);
|
|
584
|
-
i +=
|
|
612
|
+
i += c;
|
|
585
613
|
}
|
|
586
614
|
}
|
|
587
615
|
continue;
|
|
588
616
|
}
|
|
589
617
|
if (n === "%" && this.scanner.peek(1) === "%") {
|
|
590
|
-
const h = this.scanner.peek(2).toLowerCase(),
|
|
591
|
-
if (
|
|
592
|
-
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;
|
|
593
621
|
continue;
|
|
594
622
|
} else {
|
|
595
623
|
this.scanner.consume(3);
|
|
@@ -598,7 +626,7 @@ class D {
|
|
|
598
626
|
}
|
|
599
627
|
if (n === " ")
|
|
600
628
|
return i ? (this.scanner.consume(1), r = 3, [1, i]) : (this.scanner.consume(1), [3, null]);
|
|
601
|
-
if (!
|
|
629
|
+
if (!u) {
|
|
602
630
|
if (n === "{") {
|
|
603
631
|
if (i)
|
|
604
632
|
return [1, i];
|
|
@@ -610,11 +638,11 @@ class D {
|
|
|
610
638
|
if (this.scanner.consume(1), this.yieldPropertyCommands) {
|
|
611
639
|
const h = this.ctxStack.current;
|
|
612
640
|
this.popCtx();
|
|
613
|
-
const
|
|
614
|
-
if (Object.keys(
|
|
641
|
+
const c = this.getPropertyChanges(h, this.ctxStack.current);
|
|
642
|
+
if (Object.keys(c).length > 0)
|
|
615
643
|
return [
|
|
616
644
|
9,
|
|
617
|
-
{ command: void 0, changes:
|
|
645
|
+
{ command: void 0, changes: c, depth: this.ctxStack.depth }
|
|
618
646
|
];
|
|
619
647
|
} else
|
|
620
648
|
this.popCtx();
|
|
@@ -624,15 +652,15 @@ class D {
|
|
|
624
652
|
if (!this.inStackContext && n === "^") {
|
|
625
653
|
const h = this.scanner.peek(1);
|
|
626
654
|
if (h) {
|
|
627
|
-
const
|
|
628
|
-
if (this.scanner.consume(2),
|
|
655
|
+
const c = h.charCodeAt(0);
|
|
656
|
+
if (this.scanner.consume(2), c === 32)
|
|
629
657
|
i += "^";
|
|
630
658
|
else {
|
|
631
|
-
if (
|
|
659
|
+
if (c === 73)
|
|
632
660
|
return i ? [1, i] : [5, null];
|
|
633
|
-
if (
|
|
661
|
+
if (c === 74)
|
|
634
662
|
return i ? [1, i] : [6, null];
|
|
635
|
-
if (
|
|
663
|
+
if (c === 77)
|
|
636
664
|
continue;
|
|
637
665
|
i += "▯";
|
|
638
666
|
}
|
|
@@ -644,23 +672,23 @@ class D {
|
|
|
644
672
|
return i ? [1, i] : [0, null];
|
|
645
673
|
};
|
|
646
674
|
for (; ; ) {
|
|
647
|
-
const [i, u] =
|
|
675
|
+
const [i, u] = o.call(this);
|
|
648
676
|
if (i) {
|
|
649
|
-
if (yield new
|
|
650
|
-
const
|
|
651
|
-
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(), {
|
|
652
680
|
command: void 0,
|
|
653
|
-
changes: { paragraph:
|
|
681
|
+
changes: { paragraph: l },
|
|
654
682
|
depth: this.ctxStack.depth
|
|
655
683
|
}));
|
|
656
684
|
}
|
|
657
|
-
r && (yield new
|
|
685
|
+
r && (yield new d(r, this.ctxStack.current.copy(), null), r = null);
|
|
658
686
|
} else
|
|
659
687
|
break;
|
|
660
688
|
}
|
|
661
689
|
}
|
|
662
690
|
}
|
|
663
|
-
class
|
|
691
|
+
class f {
|
|
664
692
|
/**
|
|
665
693
|
* Create a new text scanner
|
|
666
694
|
* @param text - The text to scan
|
|
@@ -760,7 +788,7 @@ class d {
|
|
|
760
788
|
return t;
|
|
761
789
|
}
|
|
762
790
|
}
|
|
763
|
-
class
|
|
791
|
+
class k {
|
|
764
792
|
// Store as 0xRRGGBB or null
|
|
765
793
|
/**
|
|
766
794
|
* Create a new MTextColor instance.
|
|
@@ -836,7 +864,7 @@ class b {
|
|
|
836
864
|
* @returns A new MTextColor instance with the same color state.
|
|
837
865
|
*/
|
|
838
866
|
copy() {
|
|
839
|
-
const t = new
|
|
867
|
+
const t = new k();
|
|
840
868
|
return t._aci = this._aci, t._rgbValue = this._rgbValue, t;
|
|
841
869
|
}
|
|
842
870
|
/**
|
|
@@ -855,9 +883,9 @@ class b {
|
|
|
855
883
|
return this._aci === t._aci && this._rgbValue === t._rgbValue;
|
|
856
884
|
}
|
|
857
885
|
}
|
|
858
|
-
class
|
|
886
|
+
class b {
|
|
859
887
|
constructor() {
|
|
860
|
-
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 = {
|
|
861
889
|
indent: 0,
|
|
862
890
|
left: 0,
|
|
863
891
|
right: 0,
|
|
@@ -1027,11 +1055,11 @@ class m {
|
|
|
1027
1055
|
* @returns A new context with the same properties
|
|
1028
1056
|
*/
|
|
1029
1057
|
copy() {
|
|
1030
|
-
const t = new
|
|
1058
|
+
const t = new b();
|
|
1031
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;
|
|
1032
1060
|
}
|
|
1033
1061
|
}
|
|
1034
|
-
class
|
|
1062
|
+
class d {
|
|
1035
1063
|
/**
|
|
1036
1064
|
* Create a new MText token
|
|
1037
1065
|
* @param type - The token type
|
|
@@ -1043,19 +1071,19 @@ class k {
|
|
|
1043
1071
|
}
|
|
1044
1072
|
}
|
|
1045
1073
|
export {
|
|
1046
|
-
|
|
1047
|
-
|
|
1074
|
+
k as MTextColor,
|
|
1075
|
+
b as MTextContext,
|
|
1048
1076
|
F as MTextLineAlignment,
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1077
|
+
S as MTextParagraphAlignment,
|
|
1078
|
+
x as MTextParser,
|
|
1079
|
+
E as MTextStroke,
|
|
1080
|
+
d as MTextToken,
|
|
1081
|
+
f as TextScanner,
|
|
1082
|
+
_ as TokenType,
|
|
1083
|
+
N as escapeDxfLineEndings,
|
|
1084
|
+
D as getFonts,
|
|
1085
|
+
w as hasInlineFormattingCodes,
|
|
1058
1086
|
I as int2rgb,
|
|
1059
|
-
|
|
1087
|
+
O as rgb2int
|
|
1060
1088
|
};
|
|
1061
1089
|
//# sourceMappingURL=parser.es.js.map
|