@mlightcad/mtext-parser 1.0.3 → 1.0.5
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/node/example.cjs.js +36 -0
- package/dist/node/example.cjs.js.map +1 -0
- package/dist/parser.cjs.js +3 -3
- package/dist/parser.cjs.js.map +1 -1
- package/dist/parser.es.js +171 -119
- 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 +69 -21
- package/package.json +1 -1
package/dist/parser.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var k = /* @__PURE__ */ ((
|
|
2
|
-
const
|
|
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 || {}), _ = /* @__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 = /* @__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 m = {
|
|
3
3
|
c: "Ø",
|
|
4
4
|
d: "°",
|
|
5
5
|
p: "±"
|
|
6
|
-
},
|
|
6
|
+
}, F = {
|
|
7
7
|
l: 1,
|
|
8
8
|
r: 2,
|
|
9
9
|
c: 3,
|
|
@@ -11,36 +11,36 @@ const F = {
|
|
|
11
11
|
d: 5
|
|
12
12
|
/* DISTRIBUTED */
|
|
13
13
|
};
|
|
14
|
-
function
|
|
15
|
-
const [e, t,
|
|
16
|
-
return
|
|
14
|
+
function I(s) {
|
|
15
|
+
const [e, t, r] = s;
|
|
16
|
+
return r << 16 | t << 8 | e;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
const e =
|
|
20
|
-
return [e, t,
|
|
18
|
+
function R(s) {
|
|
19
|
+
const e = s & 255, t = s >> 8 & 255, r = s >> 16 & 255;
|
|
20
|
+
return [e, t, r];
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
return
|
|
24
|
-
const
|
|
25
|
-
return
|
|
26
|
-
` :
|
|
22
|
+
function S(s) {
|
|
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
27
|
});
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
return
|
|
29
|
+
function N(s) {
|
|
30
|
+
return s.replace(/\r\n|\r|\n/g, "\\P");
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
return
|
|
32
|
+
function O(s) {
|
|
33
|
+
return s.replace(/\\P/g, "").replace(/\\~/g, "").includes("\\");
|
|
34
34
|
}
|
|
35
|
-
class
|
|
35
|
+
class v {
|
|
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, r = !1) {
|
|
43
|
+
this.ctxStack = [], this.continueStroke = !1, this.scanner = new p(S(e)), this.ctx = t ?? new g(), this.lastCtx = this.ctx.copy(), this.yieldPropertyCommands = r, this.decoder = new TextDecoder("gbk");
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Decode multi-byte character from hex code
|
|
@@ -76,28 +76,28 @@ class D {
|
|
|
76
76
|
*/
|
|
77
77
|
parseStacking() {
|
|
78
78
|
const e = new p(this.extractExpression(!0));
|
|
79
|
-
let t = "",
|
|
79
|
+
let t = "", r = "", n = "";
|
|
80
80
|
const i = () => {
|
|
81
|
-
let a = e.peek(),
|
|
82
|
-
return a.charCodeAt(0) < 32 && (a = " "), a === "\\" && (
|
|
81
|
+
let a = e.peek(), o = !1;
|
|
82
|
+
return a.charCodeAt(0) < 32 && (a = " "), a === "\\" && (o = !0, e.consume(1), a = e.peek()), e.consume(1), [a, o];
|
|
83
83
|
}, c = () => {
|
|
84
84
|
let a = "";
|
|
85
85
|
for (; e.hasData; ) {
|
|
86
|
-
const [
|
|
87
|
-
if (!
|
|
88
|
-
return [a,
|
|
89
|
-
a +=
|
|
86
|
+
const [o, h] = i();
|
|
87
|
+
if (!h && "^/#".includes(o))
|
|
88
|
+
return [a, o];
|
|
89
|
+
a += o;
|
|
90
90
|
}
|
|
91
91
|
return [a, ""];
|
|
92
|
-
},
|
|
92
|
+
}, u = () => {
|
|
93
93
|
let a = "";
|
|
94
94
|
for (; e.hasData; ) {
|
|
95
|
-
const [
|
|
96
|
-
|
|
95
|
+
const [o, h] = i();
|
|
96
|
+
h && o === ";" ? a += ";" : a += o;
|
|
97
97
|
}
|
|
98
98
|
return a;
|
|
99
99
|
};
|
|
100
|
-
return [t, n] = c(), n && (
|
|
100
|
+
return [t, n] = c(), n && (r = u()), [2, [t, r, n]];
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
103
|
* Parse MText properties
|
|
@@ -157,11 +157,11 @@ class D {
|
|
|
157
157
|
throw new Error(`Unknown command: ${e}`);
|
|
158
158
|
}
|
|
159
159
|
if (t.continueStroke = this.continueStroke, this.ctx = t, this.yieldPropertyCommands) {
|
|
160
|
-
const
|
|
161
|
-
if (Object.keys(
|
|
160
|
+
const r = this.getPropertyChanges(this.lastCtx, t);
|
|
161
|
+
if (Object.keys(r).length > 0)
|
|
162
162
|
return this.lastCtx = this.ctx.copy(), {
|
|
163
163
|
command: e,
|
|
164
|
-
changes:
|
|
164
|
+
changes: r
|
|
165
165
|
};
|
|
166
166
|
}
|
|
167
167
|
}
|
|
@@ -172,12 +172,12 @@ class D {
|
|
|
172
172
|
* @returns Object containing changed properties
|
|
173
173
|
*/
|
|
174
174
|
getPropertyChanges(e, t) {
|
|
175
|
-
const
|
|
176
|
-
if (e.underline !== t.underline && (
|
|
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.isHeightRelative !== t.isHeightRelative) && (r.capHeight = t.capHeight, r.isHeightRelative = t.isHeightRelative), (e.widthFactor !== t.widthFactor || e.isWidthRelative !== t.isWidthRelative) && (r.widthFactor = t.widthFactor, r.isWidthRelative = t.isWidthRelative), e.charTrackingFactor !== t.charTrackingFactor && (r.charTrackingFactor = t.charTrackingFactor), e.oblique !== t.oblique && (r.oblique = t.oblique), JSON.stringify(e.paragraph) !== JSON.stringify(t.paragraph)) {
|
|
177
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 && (
|
|
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 && (r.paragraph = n);
|
|
179
179
|
}
|
|
180
|
-
return
|
|
180
|
+
return r;
|
|
181
181
|
}
|
|
182
182
|
/**
|
|
183
183
|
* Parse alignment property
|
|
@@ -195,7 +195,13 @@ class D {
|
|
|
195
195
|
const t = this.extractFloatExpression(!0);
|
|
196
196
|
if (t)
|
|
197
197
|
try {
|
|
198
|
-
t.endsWith("x") ? e.capHeight =
|
|
198
|
+
t.endsWith("x") ? e.capHeight = {
|
|
199
|
+
value: parseFloat(t.slice(0, -1)),
|
|
200
|
+
isRelative: !0
|
|
201
|
+
} : e.capHeight = {
|
|
202
|
+
value: parseFloat(t),
|
|
203
|
+
isRelative: !1
|
|
204
|
+
};
|
|
199
205
|
} catch {
|
|
200
206
|
this.scanner.consume(-t.length);
|
|
201
207
|
return;
|
|
@@ -210,7 +216,13 @@ class D {
|
|
|
210
216
|
const t = this.extractFloatExpression(!0);
|
|
211
217
|
if (t)
|
|
212
218
|
try {
|
|
213
|
-
t.endsWith("x") ? e.widthFactor =
|
|
219
|
+
t.endsWith("x") ? e.widthFactor = {
|
|
220
|
+
value: parseFloat(t.slice(0, -1)),
|
|
221
|
+
isRelative: !0
|
|
222
|
+
} : e.widthFactor = {
|
|
223
|
+
value: parseFloat(t),
|
|
224
|
+
isRelative: !1
|
|
225
|
+
};
|
|
214
226
|
} catch {
|
|
215
227
|
this.scanner.consume(-t.length);
|
|
216
228
|
return;
|
|
@@ -241,8 +253,8 @@ class D {
|
|
|
241
253
|
const t = this.extractFloatExpression(!0);
|
|
242
254
|
if (t)
|
|
243
255
|
if (t.endsWith("x")) {
|
|
244
|
-
const
|
|
245
|
-
e *= Math.abs(
|
|
256
|
+
const r = parseFloat(t.slice(0, -1));
|
|
257
|
+
e *= Math.abs(r);
|
|
246
258
|
} else
|
|
247
259
|
e = Math.abs(parseFloat(t));
|
|
248
260
|
return e;
|
|
@@ -262,8 +274,8 @@ class D {
|
|
|
262
274
|
parseAciColor(e) {
|
|
263
275
|
const t = this.extractIntExpression();
|
|
264
276
|
if (t) {
|
|
265
|
-
const
|
|
266
|
-
|
|
277
|
+
const r = parseInt(t);
|
|
278
|
+
r < 257 && (e.aci = r, e.rgb = null);
|
|
267
279
|
}
|
|
268
280
|
this.consumeOptionalTerminator();
|
|
269
281
|
}
|
|
@@ -274,7 +286,7 @@ class D {
|
|
|
274
286
|
parseRgbColor(e) {
|
|
275
287
|
const t = this.extractIntExpression();
|
|
276
288
|
if (t) {
|
|
277
|
-
const
|
|
289
|
+
const r = parseInt(t) & 16777215, [n, i, c] = R(r);
|
|
278
290
|
e.rgb = [c, i, n];
|
|
279
291
|
}
|
|
280
292
|
this.consumeOptionalTerminator();
|
|
@@ -285,9 +297,9 @@ class D {
|
|
|
285
297
|
* @returns Extracted expression
|
|
286
298
|
*/
|
|
287
299
|
extractFloatExpression(e = !1) {
|
|
288
|
-
const t = e ? /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?x?/ : /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/,
|
|
289
|
-
if (
|
|
290
|
-
const n =
|
|
300
|
+
const t = e ? /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?x?/ : /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/, r = this.scanner.tail.match(t);
|
|
301
|
+
if (r) {
|
|
302
|
+
const n = r[0];
|
|
291
303
|
return this.scanner.consume(n.length), n;
|
|
292
304
|
}
|
|
293
305
|
return "";
|
|
@@ -325,12 +337,12 @@ class D {
|
|
|
325
337
|
parseFontProperties(e) {
|
|
326
338
|
const t = this.extractExpression().split("|");
|
|
327
339
|
if (t.length > 0 && t[0]) {
|
|
328
|
-
const
|
|
340
|
+
const r = t[0];
|
|
329
341
|
let n = "Regular", i = 400;
|
|
330
342
|
for (const c of t.slice(1))
|
|
331
343
|
c.startsWith("b1") ? i = 700 : c.startsWith("i1") && (n = "Italic");
|
|
332
344
|
e.fontFace = {
|
|
333
|
-
family:
|
|
345
|
+
family: r,
|
|
334
346
|
style: n,
|
|
335
347
|
weight: i
|
|
336
348
|
};
|
|
@@ -343,21 +355,21 @@ class D {
|
|
|
343
355
|
*/
|
|
344
356
|
parseParagraphProperties(e) {
|
|
345
357
|
const t = new p(this.extractExpression());
|
|
346
|
-
let
|
|
358
|
+
let r = e.paragraph.indent, n = e.paragraph.left, i = e.paragraph.right, c = e.paragraph.align, u = [];
|
|
347
359
|
const a = () => {
|
|
348
|
-
const
|
|
349
|
-
if (
|
|
350
|
-
const
|
|
351
|
-
for (t.consume(
|
|
360
|
+
const o = t.tail.match(/^[+-]?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/);
|
|
361
|
+
if (o) {
|
|
362
|
+
const h = parseFloat(o[0]);
|
|
363
|
+
for (t.consume(o[0].length); t.peek() === ","; )
|
|
352
364
|
t.consume(1);
|
|
353
|
-
return
|
|
365
|
+
return h;
|
|
354
366
|
}
|
|
355
367
|
return 0;
|
|
356
368
|
};
|
|
357
369
|
for (; t.hasData; )
|
|
358
370
|
switch (t.get()) {
|
|
359
371
|
case "i":
|
|
360
|
-
|
|
372
|
+
r = a();
|
|
361
373
|
break;
|
|
362
374
|
case "l":
|
|
363
375
|
n = a();
|
|
@@ -368,31 +380,31 @@ class D {
|
|
|
368
380
|
case "x":
|
|
369
381
|
break;
|
|
370
382
|
case "q": {
|
|
371
|
-
const
|
|
372
|
-
for (c =
|
|
383
|
+
const h = t.get();
|
|
384
|
+
for (c = F[h] || 0; t.peek() === ","; )
|
|
373
385
|
t.consume(1);
|
|
374
386
|
break;
|
|
375
387
|
}
|
|
376
388
|
case "t":
|
|
377
|
-
for (
|
|
378
|
-
const
|
|
379
|
-
if (
|
|
389
|
+
for (u = []; t.hasData; ) {
|
|
390
|
+
const h = t.peek();
|
|
391
|
+
if (h === "r" || h === "c") {
|
|
380
392
|
t.consume(1);
|
|
381
|
-
const
|
|
382
|
-
|
|
393
|
+
const l = a();
|
|
394
|
+
u.push(h + l.toString());
|
|
383
395
|
} else {
|
|
384
|
-
const
|
|
385
|
-
isNaN(
|
|
396
|
+
const l = a();
|
|
397
|
+
isNaN(l) ? t.consume(1) : u.push(l);
|
|
386
398
|
}
|
|
387
399
|
}
|
|
388
400
|
break;
|
|
389
401
|
}
|
|
390
402
|
e.paragraph = {
|
|
391
|
-
indent:
|
|
403
|
+
indent: r,
|
|
392
404
|
left: n,
|
|
393
405
|
right: i,
|
|
394
406
|
align: c,
|
|
395
|
-
tab_stops:
|
|
407
|
+
tab_stops: u
|
|
396
408
|
};
|
|
397
409
|
}
|
|
398
410
|
/**
|
|
@@ -406,13 +418,13 @@ class D {
|
|
|
406
418
|
* @yields MTextToken objects
|
|
407
419
|
*/
|
|
408
420
|
*parse() {
|
|
409
|
-
let
|
|
421
|
+
let r = null;
|
|
410
422
|
const n = () => {
|
|
411
423
|
var c;
|
|
412
424
|
let i = "";
|
|
413
425
|
for (; this.scanner.hasData; ) {
|
|
414
|
-
let
|
|
415
|
-
const
|
|
426
|
+
let u = !1, a = this.scanner.peek();
|
|
427
|
+
const o = this.scanner.currentIndex;
|
|
416
428
|
if (a.charCodeAt(0) < 32) {
|
|
417
429
|
if (this.scanner.consume(1), a === " ")
|
|
418
430
|
return [5, null];
|
|
@@ -423,13 +435,13 @@ class D {
|
|
|
423
435
|
}
|
|
424
436
|
if (a === "\\")
|
|
425
437
|
if ("\\{}".includes(this.scanner.peek(1)))
|
|
426
|
-
|
|
438
|
+
u = !0, this.scanner.consume(1), a = this.scanner.peek();
|
|
427
439
|
else {
|
|
428
440
|
if (i)
|
|
429
441
|
return [1, i];
|
|
430
442
|
this.scanner.consume(1);
|
|
431
|
-
const
|
|
432
|
-
switch (
|
|
443
|
+
const h = this.scanner.get();
|
|
444
|
+
switch (h) {
|
|
433
445
|
case "~":
|
|
434
446
|
return [4, null];
|
|
435
447
|
case "P":
|
|
@@ -444,10 +456,10 @@ class D {
|
|
|
444
456
|
case "M":
|
|
445
457
|
if (this.scanner.peek() === "+") {
|
|
446
458
|
this.scanner.consume(1);
|
|
447
|
-
const
|
|
448
|
-
if (
|
|
459
|
+
const l = (c = this.scanner.tail.match(/^[0-9A-Fa-f]{4}/)) == null ? void 0 : c[0];
|
|
460
|
+
if (l) {
|
|
449
461
|
this.scanner.consume(4);
|
|
450
|
-
const d = this.decodeMultiByteChar(
|
|
462
|
+
const d = this.decodeMultiByteChar(l);
|
|
451
463
|
return i ? [1, i] : [1, d];
|
|
452
464
|
}
|
|
453
465
|
this.scanner.consume(-1);
|
|
@@ -455,26 +467,26 @@ class D {
|
|
|
455
467
|
i += "\\M";
|
|
456
468
|
continue;
|
|
457
469
|
default:
|
|
458
|
-
if (
|
|
470
|
+
if (h)
|
|
459
471
|
try {
|
|
460
|
-
const
|
|
461
|
-
if (this.yieldPropertyCommands &&
|
|
462
|
-
return this.lastCtx = this.ctx.copy(), [9,
|
|
472
|
+
const l = this.parseProperties(h);
|
|
473
|
+
if (this.yieldPropertyCommands && l)
|
|
474
|
+
return this.lastCtx = this.ctx.copy(), [9, l];
|
|
463
475
|
continue;
|
|
464
476
|
} catch {
|
|
465
|
-
const
|
|
466
|
-
|
|
477
|
+
const l = this.scanner.tail.slice(
|
|
478
|
+
o,
|
|
467
479
|
this.scanner.currentIndex
|
|
468
480
|
);
|
|
469
|
-
i +=
|
|
481
|
+
i += l;
|
|
470
482
|
}
|
|
471
483
|
}
|
|
472
484
|
continue;
|
|
473
485
|
}
|
|
474
486
|
if (a === "%" && this.scanner.peek(1) === "%") {
|
|
475
|
-
const
|
|
476
|
-
if (
|
|
477
|
-
this.scanner.consume(3), i +=
|
|
487
|
+
const h = this.scanner.peek(2).toLowerCase(), l = m[h];
|
|
488
|
+
if (l) {
|
|
489
|
+
this.scanner.consume(3), i += l;
|
|
478
490
|
continue;
|
|
479
491
|
} else {
|
|
480
492
|
this.scanner.consume(3);
|
|
@@ -482,8 +494,8 @@ class D {
|
|
|
482
494
|
}
|
|
483
495
|
}
|
|
484
496
|
if (a === " ")
|
|
485
|
-
return i ? (this.scanner.consume(1),
|
|
486
|
-
if (!
|
|
497
|
+
return i ? (this.scanner.consume(1), r = 3, [1, i]) : (this.scanner.consume(1), [3, null]);
|
|
498
|
+
if (!u) {
|
|
487
499
|
if (a === "{") {
|
|
488
500
|
if (i)
|
|
489
501
|
return [1, i];
|
|
@@ -503,7 +515,7 @@ class D {
|
|
|
503
515
|
for (; ; ) {
|
|
504
516
|
const [i, c] = n();
|
|
505
517
|
if (i)
|
|
506
|
-
yield new
|
|
518
|
+
yield new f(i, this.ctx, c), r && (yield new f(r, this.ctx, null), r = null);
|
|
507
519
|
else
|
|
508
520
|
break;
|
|
509
521
|
}
|
|
@@ -568,21 +580,21 @@ class p {
|
|
|
568
580
|
* @returns Index of the character, or -1 if not found
|
|
569
581
|
*/
|
|
570
582
|
find(e, t = !1) {
|
|
571
|
-
let
|
|
572
|
-
for (;
|
|
573
|
-
if (t && this.text[
|
|
574
|
-
if (
|
|
575
|
-
if (this.text[
|
|
576
|
-
return
|
|
577
|
-
|
|
583
|
+
let r = this._index;
|
|
584
|
+
for (; r < this.textLen; ) {
|
|
585
|
+
if (t && this.text[r] === "\\") {
|
|
586
|
+
if (r + 1 < this.textLen) {
|
|
587
|
+
if (this.text[r + 1] === e)
|
|
588
|
+
return r + 1;
|
|
589
|
+
r += 2;
|
|
578
590
|
continue;
|
|
579
591
|
}
|
|
580
|
-
|
|
592
|
+
r++;
|
|
581
593
|
continue;
|
|
582
594
|
}
|
|
583
|
-
if (this.text[
|
|
584
|
-
return
|
|
585
|
-
|
|
595
|
+
if (this.text[r] === e)
|
|
596
|
+
return r;
|
|
597
|
+
r++;
|
|
586
598
|
}
|
|
587
599
|
return -1;
|
|
588
600
|
}
|
|
@@ -609,9 +621,9 @@ class p {
|
|
|
609
621
|
return e;
|
|
610
622
|
}
|
|
611
623
|
}
|
|
612
|
-
class
|
|
624
|
+
class g {
|
|
613
625
|
constructor() {
|
|
614
|
-
this._stroke = 0, this.continueStroke = !1, this._aci = 7, this.rgb = null, this.align = 0, this.fontFace = { family: "", style: "Regular", weight: 400 }, this.
|
|
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, this._isHeightRelative = !1, this._widthFactor = 1, this._isWidthRelative = !1, this.charTrackingFactor = 1, this.oblique = 0, this.paragraph = {
|
|
615
627
|
indent: 0,
|
|
616
628
|
left: 0,
|
|
617
629
|
right: 0,
|
|
@@ -619,6 +631,46 @@ class f {
|
|
|
619
631
|
tab_stops: []
|
|
620
632
|
};
|
|
621
633
|
}
|
|
634
|
+
/**
|
|
635
|
+
* Get the capital letter height
|
|
636
|
+
*/
|
|
637
|
+
get capHeight() {
|
|
638
|
+
return this._capHeight;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Set the capital letter height
|
|
642
|
+
* @param value - Height value
|
|
643
|
+
* @param isRelative - Whether the value is relative
|
|
644
|
+
*/
|
|
645
|
+
set capHeight(e) {
|
|
646
|
+
this._capHeight = Math.abs(e.value), this._isHeightRelative = e.isRelative;
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* Get whether height is relative
|
|
650
|
+
*/
|
|
651
|
+
get isHeightRelative() {
|
|
652
|
+
return this._isHeightRelative;
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Get the character width factor
|
|
656
|
+
*/
|
|
657
|
+
get widthFactor() {
|
|
658
|
+
return this._widthFactor;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Set the character width factor
|
|
662
|
+
* @param value - Width factor value
|
|
663
|
+
* @param isRelative - Whether the value is relative
|
|
664
|
+
*/
|
|
665
|
+
set widthFactor(e) {
|
|
666
|
+
this._widthFactor = Math.abs(e.value), this._isWidthRelative = e.isRelative;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Get whether width is relative
|
|
670
|
+
*/
|
|
671
|
+
get isWidthRelative() {
|
|
672
|
+
return this._isWidthRelative;
|
|
673
|
+
}
|
|
622
674
|
/**
|
|
623
675
|
* Get the ACI color value
|
|
624
676
|
*/
|
|
@@ -694,34 +746,34 @@ class f {
|
|
|
694
746
|
* @returns A new context with the same properties
|
|
695
747
|
*/
|
|
696
748
|
copy() {
|
|
697
|
-
const e = new
|
|
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.
|
|
749
|
+
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, e._isHeightRelative = this._isHeightRelative, e._widthFactor = this._widthFactor, e._isWidthRelative = this._isWidthRelative, e.charTrackingFactor = this.charTrackingFactor, e.oblique = this.oblique, e.paragraph = { ...this.paragraph }, e;
|
|
699
751
|
}
|
|
700
752
|
}
|
|
701
|
-
class
|
|
753
|
+
class f {
|
|
702
754
|
/**
|
|
703
755
|
* Create a new MText token
|
|
704
756
|
* @param type - The token type
|
|
705
757
|
* @param ctx - The text context at this token
|
|
706
758
|
* @param data - Optional token data
|
|
707
759
|
*/
|
|
708
|
-
constructor(e, t,
|
|
709
|
-
this.type = e, this.ctx = t, this.data =
|
|
760
|
+
constructor(e, t, r) {
|
|
761
|
+
this.type = e, this.ctx = t, this.data = r;
|
|
710
762
|
}
|
|
711
763
|
}
|
|
712
764
|
export {
|
|
713
|
-
|
|
765
|
+
g as MTextContext,
|
|
714
766
|
b as MTextLineAlignment,
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
767
|
+
_ as MTextParagraphAlignment,
|
|
768
|
+
v as MTextParser,
|
|
769
|
+
E as MTextStroke,
|
|
770
|
+
f as MTextToken,
|
|
719
771
|
p as TextScanner,
|
|
720
772
|
k as TokenType,
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
773
|
+
S as caretDecode,
|
|
774
|
+
N as escapeDxfLineEndings,
|
|
775
|
+
O as hasInlineFormattingCodes,
|
|
776
|
+
R as int2rgb,
|
|
777
|
+
I as rgb2int
|
|
726
778
|
};
|
|
727
779
|
//# sourceMappingURL=parser.es.js.map
|