@mlightcad/mtext-parser 1.0.5 → 1.0.7
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/README.md +1 -1
- package/dist/node/example.cjs.js +9 -10
- package/dist/node/example.cjs.js.map +1 -1
- package/dist/parser.cjs.js +2 -3
- package/dist/parser.cjs.js.map +1 -1
- package/dist/parser.es.js +169 -135
- package/dist/parser.es.js.map +1 -1
- package/dist/parser.umd.js +2 -3
- package/dist/parser.umd.js.map +1 -1
- package/dist/types/parser.d.ts +28 -40
- package/package.json +1 -1
package/dist/parser.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var k = /* @__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))(k || {}), b = /* @__PURE__ */ ((s) => (s[s.BOTTOM = 0] = "BOTTOM", s[s.MIDDLE = 1] = "MIDDLE", s[s.TOP = 2] = "TOP", s))(b || {}),
|
|
1
|
+
var k = /* @__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))(k || {}), b = /* @__PURE__ */ ((s) => (s[s.BOTTOM = 0] = "BOTTOM", s[s.MIDDLE = 1] = "MIDDLE", s[s.TOP = 2] = "TOP", s))(b || {}), E = /* @__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))(E || {}), F = /* @__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))(F || {});
|
|
2
2
|
const m = {
|
|
3
3
|
c: "Ø",
|
|
4
4
|
d: "°",
|
|
5
5
|
p: "±"
|
|
6
|
-
},
|
|
6
|
+
}, _ = {
|
|
7
7
|
l: 1,
|
|
8
8
|
r: 2,
|
|
9
9
|
c: 3,
|
|
@@ -11,28 +11,21 @@ const m = {
|
|
|
11
11
|
d: 5
|
|
12
12
|
/* DISTRIBUTED */
|
|
13
13
|
};
|
|
14
|
-
function
|
|
14
|
+
function R(s) {
|
|
15
15
|
const [e, t, r] = s;
|
|
16
16
|
return r << 16 | t << 8 | e;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function S(s) {
|
|
19
19
|
const e = s & 255, t = s >> 8 & 255, r = s >> 16 & 255;
|
|
20
20
|
return [e, t, r];
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
return s.replace(/\^(.)/g, (e, t) => {
|
|
24
|
-
const r = t.charCodeAt(0);
|
|
25
|
-
return r === 32 ? "^" : r === 73 ? " " : r === 74 ? `
|
|
26
|
-
` : r === 77 ? "" : "▯";
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
function N(s) {
|
|
22
|
+
function v(s) {
|
|
30
23
|
return s.replace(/\r\n|\r|\n/g, "\\P");
|
|
31
24
|
}
|
|
32
|
-
function
|
|
25
|
+
function I(s) {
|
|
33
26
|
return s.replace(/\\P/g, "").replace(/\\~/g, "").includes("\\");
|
|
34
27
|
}
|
|
35
|
-
class
|
|
28
|
+
class N {
|
|
36
29
|
/**
|
|
37
30
|
* Creates a new MTextParser instance
|
|
38
31
|
* @param content - The MText content to parse
|
|
@@ -40,7 +33,7 @@ class v {
|
|
|
40
33
|
* @param yieldPropertyCommands - Whether to yield property change commands
|
|
41
34
|
*/
|
|
42
35
|
constructor(e, t, r = !1) {
|
|
43
|
-
this.ctxStack = [], this.continueStroke = !1, this.scanner = new
|
|
36
|
+
this.ctxStack = [], this.continueStroke = !1, this.inStackContext = !1, this.scanner = new f(e), this.ctx = t ?? new g(), this.lastCtx = this.ctx.copy(), this.yieldPropertyCommands = r, this.decoder = new TextDecoder("gbk");
|
|
44
37
|
}
|
|
45
38
|
/**
|
|
46
39
|
* Decode multi-byte character from hex code
|
|
@@ -52,8 +45,11 @@ class v {
|
|
|
52
45
|
const t = new Uint8Array([
|
|
53
46
|
parseInt(e.substr(0, 2), 16),
|
|
54
47
|
parseInt(e.substr(2, 2), 16)
|
|
55
|
-
]);
|
|
56
|
-
|
|
48
|
+
]), a = new TextDecoder("gbk").decode(t);
|
|
49
|
+
if (a !== "▯")
|
|
50
|
+
return a;
|
|
51
|
+
const h = new TextDecoder("big5").decode(t);
|
|
52
|
+
return h !== "▯" ? h : "▯";
|
|
57
53
|
} catch {
|
|
58
54
|
return "▯";
|
|
59
55
|
}
|
|
@@ -75,29 +71,33 @@ class v {
|
|
|
75
71
|
* @returns Tuple of [TokenType.STACK, [numerator, denominator, type]]
|
|
76
72
|
*/
|
|
77
73
|
parseStacking() {
|
|
78
|
-
const e = new
|
|
79
|
-
let t = "", r = "",
|
|
74
|
+
const e = new f(this.extractExpression(!0));
|
|
75
|
+
let t = "", r = "", a = "";
|
|
80
76
|
const i = () => {
|
|
81
|
-
let
|
|
82
|
-
return
|
|
83
|
-
},
|
|
84
|
-
let
|
|
77
|
+
let n = e.peek(), l = !1;
|
|
78
|
+
return n.charCodeAt(0) < 32 && (n = " "), n === "\\" && (l = !0, e.consume(1), n = e.peek()), e.consume(1), [n, l];
|
|
79
|
+
}, h = () => {
|
|
80
|
+
let n = "";
|
|
85
81
|
for (; e.hasData; ) {
|
|
86
|
-
const [
|
|
87
|
-
if (!
|
|
88
|
-
return [
|
|
89
|
-
|
|
82
|
+
const [l, o] = i();
|
|
83
|
+
if (!o && (l === "/" || l === "#" || l === "^"))
|
|
84
|
+
return [n, l];
|
|
85
|
+
n += l;
|
|
90
86
|
}
|
|
91
|
-
return [
|
|
92
|
-
}, u = () => {
|
|
93
|
-
let
|
|
87
|
+
return [n, ""];
|
|
88
|
+
}, u = (n) => {
|
|
89
|
+
let l = "", o = n;
|
|
94
90
|
for (; e.hasData; ) {
|
|
95
|
-
const [
|
|
96
|
-
|
|
91
|
+
const [c, p] = i();
|
|
92
|
+
if (!(o && c === " ")) {
|
|
93
|
+
if (o = !1, !p && c === ";")
|
|
94
|
+
break;
|
|
95
|
+
l += c;
|
|
96
|
+
}
|
|
97
97
|
}
|
|
98
|
-
return
|
|
98
|
+
return l;
|
|
99
99
|
};
|
|
100
|
-
return [t,
|
|
100
|
+
return [t, a] = h(), a && (r = u(a === "^")), t === "" && r.includes("I/") ? [2, [" ", " ", "/"]] : a === "^" ? [2, [t, r, "^"]] : [2, [t, r, a]];
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
103
|
* Parse MText properties
|
|
@@ -156,7 +156,7 @@ class v {
|
|
|
156
156
|
default:
|
|
157
157
|
throw new Error(`Unknown command: ${e}`);
|
|
158
158
|
}
|
|
159
|
-
if (t.continueStroke = this.continueStroke, this.ctx = t, this.yieldPropertyCommands) {
|
|
159
|
+
if (this.continueStroke = t.hasAnyStroke, t.continueStroke = this.continueStroke, this.ctx = t, this.yieldPropertyCommands) {
|
|
160
160
|
const r = this.getPropertyChanges(this.lastCtx, t);
|
|
161
161
|
if (Object.keys(r).length > 0)
|
|
162
162
|
return this.lastCtx = this.ctx.copy(), {
|
|
@@ -173,9 +173,9 @@ class v {
|
|
|
173
173
|
*/
|
|
174
174
|
getPropertyChanges(e, t) {
|
|
175
175
|
const r = {};
|
|
176
|
-
if (e.underline !== t.underline && (r.underline = t.underline), e.overline !== t.overline && (r.overline = t.overline), e.strikeThrough !== t.strikeThrough && (r.strikeThrough = t.strikeThrough), e.aci !== t.aci && (r.aci = t.aci, r.rgb = t.rgb), e.rgb !== t.rgb && (r.rgb = t.rgb), e.align !== t.align && (r.align = t.align), JSON.stringify(e.fontFace) !== JSON.stringify(t.fontFace) && (r.fontFace = t.fontFace), (e.capHeight !== t.capHeight || e.
|
|
177
|
-
const
|
|
178
|
-
e.paragraph.indent !== t.paragraph.indent && (
|
|
176
|
+
if (e.underline !== t.underline && (r.underline = t.underline), e.overline !== t.overline && (r.overline = t.overline), e.strikeThrough !== t.strikeThrough && (r.strikeThrough = t.strikeThrough), e.aci !== t.aci && (r.aci = t.aci, r.rgb = t.rgb), e.rgb !== t.rgb && (r.rgb = t.rgb), e.align !== t.align && (r.align = t.align), JSON.stringify(e.fontFace) !== JSON.stringify(t.fontFace) && (r.fontFace = t.fontFace), (e.capHeight.value !== t.capHeight.value || e.capHeight.isRelative !== t.capHeight.isRelative) && (r.capHeight = t.capHeight), (e.widthFactor.value !== t.widthFactor.value || e.widthFactor.isRelative !== t.widthFactor.isRelative) && (r.widthFactor = t.widthFactor), (e.charTrackingFactor.value !== t.charTrackingFactor.value || e.charTrackingFactor.isRelative !== t.charTrackingFactor.isRelative) && (r.charTrackingFactor = t.charTrackingFactor), e.oblique !== t.oblique && (r.oblique = t.oblique), JSON.stringify(e.paragraph) !== JSON.stringify(t.paragraph)) {
|
|
177
|
+
const a = {};
|
|
178
|
+
e.paragraph.indent !== t.paragraph.indent && (a.indent = t.paragraph.indent), e.paragraph.align !== t.paragraph.align && (a.align = t.paragraph.align), e.paragraph.left !== t.paragraph.left && (a.left = t.paragraph.left), e.paragraph.right !== t.paragraph.right && (a.right = t.paragraph.right), JSON.stringify(e.paragraph.tab_stops) !== JSON.stringify(t.paragraph.tab_stops) && (a.tab_stops = t.paragraph.tab_stops), Object.keys(a).length > 0 && (r.paragraph = a);
|
|
179
179
|
}
|
|
180
180
|
return r;
|
|
181
181
|
}
|
|
@@ -237,7 +237,13 @@ class v {
|
|
|
237
237
|
const t = this.extractFloatExpression(!0);
|
|
238
238
|
if (t)
|
|
239
239
|
try {
|
|
240
|
-
t.endsWith("x") ? e.charTrackingFactor =
|
|
240
|
+
t.endsWith("x") ? e.charTrackingFactor = {
|
|
241
|
+
value: Math.abs(parseFloat(t.slice(0, -1))),
|
|
242
|
+
isRelative: !0
|
|
243
|
+
} : e.charTrackingFactor = {
|
|
244
|
+
value: Math.abs(parseFloat(t)),
|
|
245
|
+
isRelative: !1
|
|
246
|
+
};
|
|
241
247
|
} catch {
|
|
242
248
|
this.scanner.consume(-t.length);
|
|
243
249
|
return;
|
|
@@ -254,9 +260,9 @@ class v {
|
|
|
254
260
|
if (t)
|
|
255
261
|
if (t.endsWith("x")) {
|
|
256
262
|
const r = parseFloat(t.slice(0, -1));
|
|
257
|
-
e *=
|
|
263
|
+
e *= r;
|
|
258
264
|
} else
|
|
259
|
-
e =
|
|
265
|
+
e = parseFloat(t);
|
|
260
266
|
return e;
|
|
261
267
|
}
|
|
262
268
|
/**
|
|
@@ -286,8 +292,8 @@ class v {
|
|
|
286
292
|
parseRgbColor(e) {
|
|
287
293
|
const t = this.extractIntExpression();
|
|
288
294
|
if (t) {
|
|
289
|
-
const r = parseInt(t) & 16777215, [
|
|
290
|
-
e.rgb = [
|
|
295
|
+
const r = parseInt(t) & 16777215, [a, i, h] = S(r);
|
|
296
|
+
e.rgb = [h, i, a];
|
|
291
297
|
}
|
|
292
298
|
this.consumeOptionalTerminator();
|
|
293
299
|
}
|
|
@@ -299,8 +305,8 @@ class v {
|
|
|
299
305
|
extractFloatExpression(e = !1) {
|
|
300
306
|
const t = e ? /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?x?/ : /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/, r = this.scanner.tail.match(t);
|
|
301
307
|
if (r) {
|
|
302
|
-
const
|
|
303
|
-
return this.scanner.consume(
|
|
308
|
+
const a = r[0];
|
|
309
|
+
return this.scanner.consume(a.length), a;
|
|
304
310
|
}
|
|
305
311
|
return "";
|
|
306
312
|
}
|
|
@@ -324,10 +330,10 @@ class v {
|
|
|
324
330
|
extractExpression(e = !1) {
|
|
325
331
|
const t = this.scanner.find(";", e);
|
|
326
332
|
if (t < 0) {
|
|
327
|
-
const
|
|
328
|
-
return this.scanner.consume(
|
|
333
|
+
const h = this.scanner.tail;
|
|
334
|
+
return this.scanner.consume(h.length), h;
|
|
329
335
|
}
|
|
330
|
-
const
|
|
336
|
+
const a = this.scanner.peek(t - this.scanner.currentIndex - 1) === "\\", i = this.scanner.tail.slice(0, t - this.scanner.currentIndex + (a ? 1 : 0));
|
|
331
337
|
return this.scanner.consume(i.length + 1), i;
|
|
332
338
|
}
|
|
333
339
|
/**
|
|
@@ -338,12 +344,12 @@ class v {
|
|
|
338
344
|
const t = this.extractExpression().split("|");
|
|
339
345
|
if (t.length > 0 && t[0]) {
|
|
340
346
|
const r = t[0];
|
|
341
|
-
let
|
|
342
|
-
for (const
|
|
343
|
-
|
|
347
|
+
let a = "Regular", i = 400;
|
|
348
|
+
for (const h of t.slice(1))
|
|
349
|
+
h.startsWith("b1") ? i = 700 : h.startsWith("i1") && (a = "Italic");
|
|
344
350
|
e.fontFace = {
|
|
345
351
|
family: r,
|
|
346
|
-
style:
|
|
352
|
+
style: a,
|
|
347
353
|
weight: i
|
|
348
354
|
};
|
|
349
355
|
}
|
|
@@ -354,56 +360,56 @@ class v {
|
|
|
354
360
|
* @param ctx - The context to update
|
|
355
361
|
*/
|
|
356
362
|
parseParagraphProperties(e) {
|
|
357
|
-
const t = new
|
|
358
|
-
let r = e.paragraph.indent,
|
|
359
|
-
const
|
|
360
|
-
const
|
|
361
|
-
if (
|
|
362
|
-
const
|
|
363
|
-
for (t.consume(
|
|
363
|
+
const t = new f(this.extractExpression());
|
|
364
|
+
let r = e.paragraph.indent, a = e.paragraph.left, i = e.paragraph.right, h = e.paragraph.align, u = [];
|
|
365
|
+
const n = () => {
|
|
366
|
+
const l = t.tail.match(/^[+-]?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/);
|
|
367
|
+
if (l) {
|
|
368
|
+
const o = parseFloat(l[0]);
|
|
369
|
+
for (t.consume(l[0].length); t.peek() === ","; )
|
|
364
370
|
t.consume(1);
|
|
365
|
-
return
|
|
371
|
+
return o;
|
|
366
372
|
}
|
|
367
373
|
return 0;
|
|
368
374
|
};
|
|
369
375
|
for (; t.hasData; )
|
|
370
376
|
switch (t.get()) {
|
|
371
377
|
case "i":
|
|
372
|
-
r =
|
|
378
|
+
r = n();
|
|
373
379
|
break;
|
|
374
380
|
case "l":
|
|
375
|
-
|
|
381
|
+
a = n();
|
|
376
382
|
break;
|
|
377
383
|
case "r":
|
|
378
|
-
i =
|
|
384
|
+
i = n();
|
|
379
385
|
break;
|
|
380
386
|
case "x":
|
|
381
387
|
break;
|
|
382
388
|
case "q": {
|
|
383
|
-
const
|
|
384
|
-
for (
|
|
389
|
+
const o = t.get();
|
|
390
|
+
for (h = _[o] || 0; t.peek() === ","; )
|
|
385
391
|
t.consume(1);
|
|
386
392
|
break;
|
|
387
393
|
}
|
|
388
394
|
case "t":
|
|
389
395
|
for (u = []; t.hasData; ) {
|
|
390
|
-
const
|
|
391
|
-
if (
|
|
396
|
+
const o = t.peek();
|
|
397
|
+
if (o === "r" || o === "c") {
|
|
392
398
|
t.consume(1);
|
|
393
|
-
const
|
|
394
|
-
u.push(
|
|
399
|
+
const c = n();
|
|
400
|
+
u.push(o + c.toString());
|
|
395
401
|
} else {
|
|
396
|
-
const
|
|
397
|
-
isNaN(
|
|
402
|
+
const c = n();
|
|
403
|
+
isNaN(c) ? t.consume(1) : u.push(c);
|
|
398
404
|
}
|
|
399
405
|
}
|
|
400
406
|
break;
|
|
401
407
|
}
|
|
402
408
|
e.paragraph = {
|
|
403
409
|
indent: r,
|
|
404
|
-
left:
|
|
410
|
+
left: a,
|
|
405
411
|
right: i,
|
|
406
|
-
align:
|
|
412
|
+
align: h,
|
|
407
413
|
tab_stops: u
|
|
408
414
|
};
|
|
409
415
|
}
|
|
@@ -419,29 +425,29 @@ class v {
|
|
|
419
425
|
*/
|
|
420
426
|
*parse() {
|
|
421
427
|
let r = null;
|
|
422
|
-
const
|
|
423
|
-
var
|
|
428
|
+
const a = () => {
|
|
429
|
+
var h;
|
|
424
430
|
let i = "";
|
|
425
431
|
for (; this.scanner.hasData; ) {
|
|
426
|
-
let u = !1,
|
|
427
|
-
const
|
|
428
|
-
if (
|
|
429
|
-
if (this.scanner.consume(1),
|
|
432
|
+
let u = !1, n = this.scanner.peek();
|
|
433
|
+
const l = this.scanner.currentIndex;
|
|
434
|
+
if (n.charCodeAt(0) < 32) {
|
|
435
|
+
if (this.scanner.consume(1), n === " ")
|
|
430
436
|
return [5, null];
|
|
431
|
-
if (
|
|
437
|
+
if (n === `
|
|
432
438
|
`)
|
|
433
439
|
return [6, null];
|
|
434
|
-
|
|
440
|
+
n = " ";
|
|
435
441
|
}
|
|
436
|
-
if (
|
|
442
|
+
if (n === "\\")
|
|
437
443
|
if ("\\{}".includes(this.scanner.peek(1)))
|
|
438
|
-
u = !0, this.scanner.consume(1),
|
|
444
|
+
u = !0, this.scanner.consume(1), n = this.scanner.peek();
|
|
439
445
|
else {
|
|
440
446
|
if (i)
|
|
441
447
|
return [1, i];
|
|
442
448
|
this.scanner.consume(1);
|
|
443
|
-
const
|
|
444
|
-
switch (
|
|
449
|
+
const o = this.scanner.get();
|
|
450
|
+
switch (o) {
|
|
445
451
|
case "~":
|
|
446
452
|
return [4, null];
|
|
447
453
|
case "P":
|
|
@@ -450,78 +456,99 @@ class v {
|
|
|
450
456
|
return [7, null];
|
|
451
457
|
case "X":
|
|
452
458
|
return [8, null];
|
|
453
|
-
case "S":
|
|
454
|
-
|
|
459
|
+
case "S": {
|
|
460
|
+
this.inStackContext = !0;
|
|
461
|
+
const c = this.parseStacking();
|
|
462
|
+
return this.inStackContext = !1, c;
|
|
463
|
+
}
|
|
455
464
|
case "m":
|
|
456
465
|
case "M":
|
|
457
466
|
if (this.scanner.peek() === "+") {
|
|
458
467
|
this.scanner.consume(1);
|
|
459
|
-
const
|
|
460
|
-
if (
|
|
468
|
+
const c = (h = this.scanner.tail.match(/^[0-9A-Fa-f]{4}/)) == null ? void 0 : h[0];
|
|
469
|
+
if (c) {
|
|
461
470
|
this.scanner.consume(4);
|
|
462
|
-
const
|
|
463
|
-
return i ? [1, i] : [1,
|
|
471
|
+
const p = this.decodeMultiByteChar(c);
|
|
472
|
+
return i ? [1, i] : [1, p];
|
|
464
473
|
}
|
|
465
474
|
this.scanner.consume(-1);
|
|
466
475
|
}
|
|
467
476
|
i += "\\M";
|
|
468
477
|
continue;
|
|
469
478
|
default:
|
|
470
|
-
if (
|
|
479
|
+
if (o)
|
|
471
480
|
try {
|
|
472
|
-
const
|
|
473
|
-
if (this.yieldPropertyCommands &&
|
|
474
|
-
return this.lastCtx = this.ctx.copy(), [9,
|
|
481
|
+
const c = this.parseProperties(o);
|
|
482
|
+
if (this.yieldPropertyCommands && c)
|
|
483
|
+
return this.lastCtx = this.ctx.copy(), [9, c];
|
|
475
484
|
continue;
|
|
476
485
|
} catch {
|
|
477
|
-
const
|
|
478
|
-
|
|
486
|
+
const c = this.scanner.tail.slice(
|
|
487
|
+
l,
|
|
479
488
|
this.scanner.currentIndex
|
|
480
489
|
);
|
|
481
|
-
i +=
|
|
490
|
+
i += c;
|
|
482
491
|
}
|
|
483
492
|
}
|
|
484
493
|
continue;
|
|
485
494
|
}
|
|
486
|
-
if (
|
|
487
|
-
const
|
|
488
|
-
if (
|
|
489
|
-
this.scanner.consume(3), i +=
|
|
495
|
+
if (n === "%" && this.scanner.peek(1) === "%") {
|
|
496
|
+
const o = this.scanner.peek(2).toLowerCase(), c = m[o];
|
|
497
|
+
if (c) {
|
|
498
|
+
this.scanner.consume(3), i += c;
|
|
490
499
|
continue;
|
|
491
500
|
} else {
|
|
492
501
|
this.scanner.consume(3);
|
|
493
502
|
continue;
|
|
494
503
|
}
|
|
495
504
|
}
|
|
496
|
-
if (
|
|
505
|
+
if (n === " ")
|
|
497
506
|
return i ? (this.scanner.consume(1), r = 3, [1, i]) : (this.scanner.consume(1), [3, null]);
|
|
498
507
|
if (!u) {
|
|
499
|
-
if (
|
|
508
|
+
if (n === "{") {
|
|
500
509
|
if (i)
|
|
501
510
|
return [1, i];
|
|
502
511
|
this.scanner.consume(1), this.pushCtx();
|
|
503
512
|
continue;
|
|
504
|
-
} else if (
|
|
513
|
+
} else if (n === "}") {
|
|
505
514
|
if (i)
|
|
506
515
|
return [1, i];
|
|
507
516
|
this.scanner.consume(1), this.popCtx();
|
|
508
517
|
continue;
|
|
509
518
|
}
|
|
510
519
|
}
|
|
511
|
-
this.
|
|
520
|
+
if (!this.inStackContext && n === "^") {
|
|
521
|
+
const o = this.scanner.peek(1);
|
|
522
|
+
if (o) {
|
|
523
|
+
const c = o.charCodeAt(0);
|
|
524
|
+
if (this.scanner.consume(2), c === 32)
|
|
525
|
+
i += "^";
|
|
526
|
+
else {
|
|
527
|
+
if (c === 73)
|
|
528
|
+
return i ? [1, i] : [5, null];
|
|
529
|
+
if (c === 74)
|
|
530
|
+
return i ? [1, i] : [6, null];
|
|
531
|
+
if (c === 77)
|
|
532
|
+
continue;
|
|
533
|
+
i += "▯";
|
|
534
|
+
}
|
|
535
|
+
continue;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
this.scanner.consume(1), n.charCodeAt(0) >= 32 && (i += n);
|
|
512
539
|
}
|
|
513
540
|
return i ? [1, i] : [0, null];
|
|
514
541
|
};
|
|
515
542
|
for (; ; ) {
|
|
516
|
-
const [i,
|
|
543
|
+
const [i, h] = a();
|
|
517
544
|
if (i)
|
|
518
|
-
yield new
|
|
545
|
+
yield new d(i, this.ctx, h), r && (yield new d(r, this.ctx, null), r = null);
|
|
519
546
|
else
|
|
520
547
|
break;
|
|
521
548
|
}
|
|
522
549
|
}
|
|
523
550
|
}
|
|
524
|
-
class
|
|
551
|
+
class f {
|
|
525
552
|
/**
|
|
526
553
|
* Create a new text scanner
|
|
527
554
|
* @param text - The text to scan
|
|
@@ -623,7 +650,7 @@ class p {
|
|
|
623
650
|
}
|
|
624
651
|
class g {
|
|
625
652
|
constructor() {
|
|
626
|
-
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,
|
|
653
|
+
this._stroke = 0, this.continueStroke = !1, this._aci = 7, this.rgb = null, 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 = {
|
|
627
654
|
indent: 0,
|
|
628
655
|
left: 0,
|
|
629
656
|
right: 0,
|
|
@@ -640,16 +667,12 @@ class g {
|
|
|
640
667
|
/**
|
|
641
668
|
* Set the capital letter height
|
|
642
669
|
* @param value - Height value
|
|
643
|
-
* @param isRelative - Whether the value is relative
|
|
644
670
|
*/
|
|
645
671
|
set capHeight(e) {
|
|
646
|
-
this._capHeight =
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
*/
|
|
651
|
-
get isHeightRelative() {
|
|
652
|
-
return this._isHeightRelative;
|
|
672
|
+
this._capHeight = {
|
|
673
|
+
value: Math.abs(e.value),
|
|
674
|
+
isRelative: e.isRelative
|
|
675
|
+
};
|
|
653
676
|
}
|
|
654
677
|
/**
|
|
655
678
|
* Get the character width factor
|
|
@@ -660,16 +683,28 @@ class g {
|
|
|
660
683
|
/**
|
|
661
684
|
* Set the character width factor
|
|
662
685
|
* @param value - Width factor value
|
|
663
|
-
* @param isRelative - Whether the value is relative
|
|
664
686
|
*/
|
|
665
687
|
set widthFactor(e) {
|
|
666
|
-
this._widthFactor =
|
|
688
|
+
this._widthFactor = {
|
|
689
|
+
value: Math.abs(e.value),
|
|
690
|
+
isRelative: e.isRelative
|
|
691
|
+
};
|
|
667
692
|
}
|
|
668
693
|
/**
|
|
669
|
-
* Get
|
|
694
|
+
* Get the character tracking factor
|
|
670
695
|
*/
|
|
671
|
-
get
|
|
672
|
-
return this.
|
|
696
|
+
get charTrackingFactor() {
|
|
697
|
+
return this._charTrackingFactor;
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Set the character tracking factor
|
|
701
|
+
* @param value - Tracking factor value
|
|
702
|
+
*/
|
|
703
|
+
set charTrackingFactor(e) {
|
|
704
|
+
this._charTrackingFactor = {
|
|
705
|
+
value: Math.abs(e.value),
|
|
706
|
+
isRelative: e.isRelative
|
|
707
|
+
};
|
|
673
708
|
}
|
|
674
709
|
/**
|
|
675
710
|
* Get the ACI color value
|
|
@@ -747,10 +782,10 @@ class g {
|
|
|
747
782
|
*/
|
|
748
783
|
copy() {
|
|
749
784
|
const e = new g();
|
|
750
|
-
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
|
|
785
|
+
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;
|
|
751
786
|
}
|
|
752
787
|
}
|
|
753
|
-
class
|
|
788
|
+
class d {
|
|
754
789
|
/**
|
|
755
790
|
* Create a new MText token
|
|
756
791
|
* @param type - The token type
|
|
@@ -764,16 +799,15 @@ class f {
|
|
|
764
799
|
export {
|
|
765
800
|
g as MTextContext,
|
|
766
801
|
b as MTextLineAlignment,
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
802
|
+
E as MTextParagraphAlignment,
|
|
803
|
+
N as MTextParser,
|
|
804
|
+
F as MTextStroke,
|
|
805
|
+
d as MTextToken,
|
|
806
|
+
f as TextScanner,
|
|
772
807
|
k as TokenType,
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
R as
|
|
777
|
-
I as rgb2int
|
|
808
|
+
v as escapeDxfLineEndings,
|
|
809
|
+
I as hasInlineFormattingCodes,
|
|
810
|
+
S as int2rgb,
|
|
811
|
+
R as rgb2int
|
|
778
812
|
};
|
|
779
813
|
//# sourceMappingURL=parser.es.js.map
|