@wdprlib/ast 4.3.0 → 5.0.0

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/index.cjs CHANGED
@@ -47,11 +47,16 @@ __export(exports_src, {
47
47
  horizontalRule: () => horizontalRule,
48
48
  heading: () => heading,
49
49
  formatExprValue: () => formatExprValue,
50
+ extractReadableText: () => extractReadableText,
51
+ extractFirstParagraph: () => extractFirstParagraph,
52
+ excerptText: () => excerptText,
50
53
  evaluateExpression: () => evaluateExpression,
51
54
  createSettings: () => createSettings,
52
55
  createPosition: () => createPosition,
53
56
  createPoint: () => createPoint,
57
+ countCharacters: () => countCharacters,
54
58
  container: () => container,
59
+ compileTextExcerpt: () => compileTextExcerpt,
55
60
  buildInfo: () => buildInfo,
56
61
  bold: () => bold,
57
62
  STYLE_SLOT_PREFIX: () => STYLE_SLOT_PREFIX,
@@ -63,320 +68,43 @@ module.exports = __toCommonJS(exports_src);
63
68
 
64
69
  // packages/ast/src/build-info.generated.ts
65
70
  var buildInfo = Object.freeze({
66
- version: "4.3.0",
67
- sha: "5e221ddeccc585e64dd1a2eb49b14817c3c1be5d",
71
+ version: "5.0.0",
72
+ sha: "705ff97e22abd7bfb49d7f8f30087e6f09654c91",
68
73
  dirty: false
69
74
  });
70
- // packages/ast/src/position.ts
71
- function createPoint(line, column, offset) {
72
- return { line, column, offset };
73
- }
74
- function createPosition(start, end) {
75
- return { start, end };
76
- }
77
- // packages/ast/src/element.ts
78
- function isStringContainerType(type) {
79
- return typeof type === "string";
80
- }
81
- function isHeaderType(type) {
82
- return typeof type === "object" && type !== null && "header" in type;
83
- }
84
- function isAlignType(type) {
85
- return typeof type === "object" && type !== null && "align" in type;
86
- }
87
- function text(value) {
88
- return { element: "text", data: value };
89
- }
90
- function container(type, elements, attributes = {}) {
91
- return {
92
- element: "container",
93
- data: { type, attributes, elements }
94
- };
95
- }
96
- function paragraph(elements, attributes = {}) {
97
- return container("paragraph", elements, attributes);
98
- }
99
- function bold(elements, attributes = {}) {
100
- return container("bold", elements, attributes);
101
- }
102
- function italics(elements, attributes = {}) {
103
- return container("italics", elements, attributes);
104
- }
105
- function heading(level, elements, hasToc = true, attributes = {}) {
106
- return container({ header: { level, "has-toc": hasToc } }, elements, attributes);
75
+ // packages/ast/src/expr-eval.ts
76
+ var FALSE_VALUES = new Set(["false", "null", "", "0"]);
77
+ function isTruthy(value) {
78
+ return !FALSE_VALUES.has(value.toLowerCase().trim());
107
79
  }
108
- function lineBreak() {
109
- return { element: "line-break" };
80
+ var MAX_EXPRESSION_LENGTH = 256;
81
+ function isTruthyNum(n) {
82
+ return n !== 0 && !Number.isNaN(n);
110
83
  }
111
- function horizontalRule() {
112
- return { element: "horizontal-rule" };
84
+ function formatExprValue(n) {
85
+ return String(n);
113
86
  }
114
- function link(linkLocation, label, options = {}) {
115
- return {
116
- element: "link",
117
- data: {
118
- type: options.type ?? (typeof linkLocation === "string" ? "direct" : "page"),
119
- link: linkLocation,
120
- extra: options.extra ?? null,
121
- label,
122
- target: options.target ?? null
87
+ function evaluateExpression(expr) {
88
+ try {
89
+ if (expr.length > MAX_EXPRESSION_LENGTH) {
90
+ return { success: false, error: "expression too long" };
123
91
  }
124
- };
125
- }
126
- function list(type, items, attributes = {}) {
127
- return {
128
- element: "list",
129
- data: { type, attributes, items }
130
- };
131
- }
132
- function listItemElements(elements, attributes = {}) {
133
- return {
134
- "item-type": "elements",
135
- attributes,
136
- elements
137
- };
138
- }
139
- function listItemSubList(data) {
140
- return {
141
- "item-type": "sub-list",
142
- element: "list",
143
- data
144
- };
145
- }
146
- function isContainerTypeParagraphSafe(type) {
147
- if (isHeaderType(type))
148
- return false;
149
- if (isAlignType(type))
150
- return false;
151
- switch (type) {
152
- case "bold":
153
- case "italics":
154
- case "underline":
155
- case "superscript":
156
- case "subscript":
157
- case "strikethrough":
158
- case "monospace":
159
- case "span":
160
- case "size":
161
- return true;
162
- case "div":
163
- case "note":
164
- case "blockquote":
165
- case "paragraph":
166
- case "heading":
167
- case "collapsible":
168
- case "definition-list":
169
- case "definition-list-item":
170
- case "definition-list-key":
171
- case "definition-list-value":
172
- case "table-row":
173
- case "table-cell":
174
- return false;
175
- default:
176
- return false;
177
- }
178
- }
179
- function isParagraphSafe(element) {
180
- switch (element.element) {
181
- case "container": {
182
- const data = element.data;
183
- return isContainerTypeParagraphSafe(data.type);
92
+ if (expr.trim() === "") {
93
+ return { success: false, error: "empty expression" };
184
94
  }
185
- case "module":
186
- return false;
187
- case "text":
188
- case "raw":
189
- case "variable":
190
- case "email":
191
- return true;
192
- case "table":
193
- return false;
194
- case "tab-view":
195
- return false;
196
- case "anchor":
197
- case "anchor-name":
198
- case "link":
199
- return true;
200
- case "image":
201
- return true;
202
- case "list":
203
- return false;
204
- case "definition-list":
205
- return false;
206
- case "collapsible":
207
- return false;
208
- case "table-of-contents":
209
- return false;
210
- case "footnote":
211
- return true;
212
- case "footnote-ref":
213
- return true;
214
- case "footnote-block":
215
- return false;
216
- case "bibliography-cite":
217
- return true;
218
- case "bibliography-block":
219
- return false;
220
- case "user":
221
- return true;
222
- case "date":
223
- case "social":
224
- return true;
225
- case "button":
226
- return isPageButtonAction(element.data.action);
227
- case "color":
228
- return true;
229
- case "code":
230
- return false;
231
- case "math":
232
- return false;
233
- case "math-inline":
234
- return true;
235
- case "embed":
236
- return false;
237
- case "embed-block":
238
- return true;
239
- case "html":
240
- case "iframe":
241
- return false;
242
- case "include": {
243
- const data = element.data;
244
- return data["paragraph-safe"];
95
+ const tokens = tokenize(expr);
96
+ if (tokens.length <= 1) {
97
+ return { success: false, error: "empty expression" };
245
98
  }
246
- case "style":
247
- return false;
248
- case "line-break":
249
- case "line-breaks":
250
- return true;
251
- case "clear-float":
252
- return false;
253
- case "horizontal-rule":
254
- return false;
255
- case "content-separator":
256
- return false;
257
- case "if-tags":
258
- return false;
259
- case "expr":
260
- case "if":
261
- case "ifexpr":
262
- return true;
263
- default:
264
- return false;
265
- }
266
- }
267
- function isPageButtonAction(action) {
268
- switch (action) {
269
- case "edit":
270
- case "edit-append":
271
- case "edit-sections":
272
- case "history":
273
- case "print":
274
- case "files":
275
- case "tags":
276
- case "source":
277
- case "backlinks":
278
- case "talk":
279
- case "delete":
280
- case "rename":
281
- case "site-tools":
282
- case "edit-meta":
283
- case "watchers":
284
- case "parent":
285
- case "lock-page":
286
- return true;
287
- default:
288
- return false;
289
- }
290
- }
291
- // packages/ast/src/constants.ts
292
- var STYLE_SLOT_PREFIX = "\x00__IFTAGS_SLOT__";
293
- var STYLE_ANCHOR_PREFIX = "\x00__STYLE_ANCHOR__";
294
- // packages/ast/src/css.ts
295
- var CSS_LENGTH_UNITS = [
296
- "cqmax",
297
- "cqmin",
298
- "cqw",
299
- "cqh",
300
- "cqi",
301
- "cqb",
302
- "svmin",
303
- "svmax",
304
- "lvmin",
305
- "lvmax",
306
- "dvmin",
307
- "dvmax",
308
- "vmin",
309
- "vmax",
310
- "svw",
311
- "svh",
312
- "svi",
313
- "svb",
314
- "lvw",
315
- "lvh",
316
- "lvi",
317
- "lvb",
318
- "dvw",
319
- "dvh",
320
- "dvi",
321
- "dvb",
322
- "vw",
323
- "vh",
324
- "vi",
325
- "vb",
326
- "rcap",
327
- "rem",
328
- "rex",
329
- "rch",
330
- "ric",
331
- "rlh",
332
- "cap",
333
- "em",
334
- "ex",
335
- "ch",
336
- "ic",
337
- "lh",
338
- "cm",
339
- "mm",
340
- "in",
341
- "pc",
342
- "pt",
343
- "px",
344
- "q",
345
- "%"
346
- ];
347
- // packages/ast/src/expr-eval.ts
348
- var FALSE_VALUES = new Set(["false", "null", "", "0"]);
349
- function isTruthy(value) {
350
- return !FALSE_VALUES.has(value.toLowerCase().trim());
351
- }
352
- var MAX_EXPRESSION_LENGTH = 256;
353
- function isTruthyNum(n) {
354
- return n !== 0 && !Number.isNaN(n);
355
- }
356
- function formatExprValue(n) {
357
- return String(n);
358
- }
359
- function evaluateExpression(expr) {
360
- try {
361
- if (expr.length > MAX_EXPRESSION_LENGTH) {
362
- return { success: false, error: "expression too long" };
363
- }
364
- if (expr.trim() === "") {
365
- return { success: false, error: "empty expression" };
366
- }
367
- const tokens = tokenize(expr);
368
- if (tokens.length <= 1) {
369
- return { success: false, error: "empty expression" };
370
- }
371
- const parser = new ExprParser(tokens);
372
- const result = parser.parse();
373
- if (!Number.isFinite(result)) {
374
- return { success: false, error: "division by zero" };
375
- }
376
- return { success: true, value: result };
377
- } catch (e) {
378
- const msg = e instanceof Error ? e.message : "unknown error";
379
- return { success: false, error: msg };
99
+ const parser = new ExprParser(tokens);
100
+ const result = parser.parse();
101
+ if (!Number.isFinite(result)) {
102
+ return { success: false, error: "division by zero" };
103
+ }
104
+ return { success: true, value: result };
105
+ } catch (e) {
106
+ const msg = e instanceof Error ? e.message : "unknown error";
107
+ return { success: false, error: msg };
380
108
  }
381
109
  }
382
110
  function tokenize(expr) {
@@ -732,6 +460,574 @@ class ExprParser {
732
460
  }
733
461
  }
734
462
  }
463
+
464
+ // packages/ast/src/readable-text.ts
465
+ var segmenter = new Intl.Segmenter("und", { granularity: "grapheme" });
466
+ function countCharacters(text) {
467
+ let count = 0;
468
+ for (const _segment of segmenter.segment(text))
469
+ count++;
470
+ return count;
471
+ }
472
+ function extractReadableText(ast, options = {}) {
473
+ return extractText(ast, options, false);
474
+ }
475
+ function extractFirstParagraph(ast, options = {}) {
476
+ return extractText(ast, options, true);
477
+ }
478
+ function extractText(ast, options, firstParagraphOnly) {
479
+ const parts = [];
480
+ const notes = new Set;
481
+ let footnoteIndex = 0;
482
+ let firstParagraph;
483
+ const emit = (value, omit) => {
484
+ if (!omit)
485
+ parts.push(value);
486
+ };
487
+ const block = (elements, omit) => {
488
+ emit(`
489
+
490
+ `, omit);
491
+ visit(elements, omit);
492
+ emit(`
493
+
494
+ `, omit);
495
+ };
496
+ const visitBranch = (elements, omit) => {
497
+ const end = elements.findLastIndex((element) => element.element !== "text" || element.data.trim() !== "") + 1;
498
+ visit(elements.slice(0, end), omit);
499
+ };
500
+ const visit = (elements, inheritedOmit = false) => {
501
+ for (const element of elements) {
502
+ if (firstParagraphOnly && firstParagraph !== undefined)
503
+ return;
504
+ const omit = inheritedOmit || options.exclude?.(element) === true;
505
+ switch (element.element) {
506
+ case "text":
507
+ case "raw":
508
+ case "email":
509
+ emit(element.data, omit);
510
+ break;
511
+ case "container": {
512
+ const start = parts.length;
513
+ const type = element.data.type;
514
+ const kind = typeof type === "string" ? type : "block";
515
+ const hidden = omit || ["ruby-text", "hidden", "invisible"].includes(kind);
516
+ if ([
517
+ "paragraph",
518
+ "div",
519
+ "blockquote",
520
+ "note",
521
+ "heading",
522
+ "block",
523
+ "table-row",
524
+ "definition-list"
525
+ ].includes(kind))
526
+ block(element.data.elements, hidden);
527
+ else
528
+ visit(element.data.elements, hidden);
529
+ if (firstParagraphOnly && kind === "paragraph" && firstParagraph === undefined) {
530
+ const text = normalizeText(parts.slice(start).join(""));
531
+ if (text)
532
+ firstParagraph = text;
533
+ }
534
+ break;
535
+ }
536
+ case "color":
537
+ case "anchor":
538
+ case "include":
539
+ visit(element.data.elements, omit);
540
+ break;
541
+ case "collapsible":
542
+ block(element.data.elements, omit);
543
+ break;
544
+ case "tab-view":
545
+ for (const tab of element.data) {
546
+ emit(`
547
+
548
+ ${tab.label}
549
+ `, omit);
550
+ block(tab.elements, omit);
551
+ }
552
+ break;
553
+ case "table":
554
+ emit(`
555
+
556
+ `, omit);
557
+ for (const row of element.data.rows) {
558
+ for (const cell of row.cells) {
559
+ visit(cell.elements, omit);
560
+ emit(" ", omit);
561
+ }
562
+ emit(`
563
+ `, omit);
564
+ }
565
+ emit(`
566
+ `, omit);
567
+ break;
568
+ case "definition-list":
569
+ for (const entry of element.data) {
570
+ block(entry.key, omit);
571
+ visit(entry.value, omit);
572
+ }
573
+ break;
574
+ case "list":
575
+ for (const item of element.data.items) {
576
+ emit(`
577
+ `, omit);
578
+ if (item["item-type"] === "elements")
579
+ visit(item.elements, omit);
580
+ else
581
+ visit([{ element: "list", data: item.data }], omit);
582
+ }
583
+ emit(`
584
+ `, omit);
585
+ break;
586
+ case "link": {
587
+ const label = element.data.label;
588
+ const destination = typeof element.data.link === "string" ? element.data.link : element.data.link.page;
589
+ const fallback = label === "page" ? destination : ("text" in label) ? label.text : label.url ?? destination;
590
+ emit(options.resolveText?.(element) ?? fallback, omit);
591
+ break;
592
+ }
593
+ case "user":
594
+ emit(options.resolveText?.(element) ?? element.data.name, omit);
595
+ break;
596
+ case "date":
597
+ case "math":
598
+ case "math-inline":
599
+ emit(options.resolveText?.(element) ?? "", omit);
600
+ break;
601
+ case "image":
602
+ emit(element.data.attributes.alt ?? "", omit);
603
+ break;
604
+ case "gallery":
605
+ if (element.data.content.type === "items")
606
+ for (const item of element.data.content.items)
607
+ emit(`${item.alt ?? ""}
608
+ `, omit);
609
+ break;
610
+ case "code":
611
+ emit(`
612
+
613
+ ${element.data.contents}
614
+
615
+ `, omit);
616
+ break;
617
+ case "footnote":
618
+ case "footnote-ref": {
619
+ const index = element.element === "footnote" ? footnoteIndex++ : element.data - 1;
620
+ if (!omit)
621
+ notes.add(index);
622
+ break;
623
+ }
624
+ case "bibliography-block":
625
+ for (const entry of element.data.entries)
626
+ block(entry.value, omit);
627
+ break;
628
+ case "if":
629
+ visitBranch(isTruthy(element.data.condition) ? element.data.then : element.data.else, omit);
630
+ break;
631
+ case "ifexpr": {
632
+ const result = evaluateExpression(element.data.expression);
633
+ if (result.success)
634
+ visitBranch(result.value !== 0 ? element.data.then : element.data.else, omit);
635
+ break;
636
+ }
637
+ case "expr": {
638
+ const result = evaluateExpression(element.data.expression);
639
+ if (result.success)
640
+ emit(formatExprValue(result.value), omit);
641
+ break;
642
+ }
643
+ case "line-break":
644
+ case "line-breaks":
645
+ emit(`
646
+ `, omit);
647
+ break;
648
+ case "horizontal-rule":
649
+ case "content-separator":
650
+ emit(`
651
+
652
+ `, omit);
653
+ break;
654
+ default:
655
+ break;
656
+ }
657
+ }
658
+ };
659
+ visit(ast.elements);
660
+ if (firstParagraphOnly)
661
+ return firstParagraph ?? "";
662
+ for (const index of notes) {
663
+ const note = ast.footnotes?.[index];
664
+ if (note)
665
+ block(note, false);
666
+ }
667
+ return normalizeText(parts.join(""));
668
+ }
669
+ function normalizeText(text) {
670
+ return text.replace(/[^\S\n]+/g, " ").replace(/ ?\n ?/g, `
671
+ `).replace(/\n{3,}/g, `
672
+
673
+ `).trim();
674
+ }
675
+ // packages/ast/src/text-excerpt.ts
676
+ var import_re2js = require("re2js");
677
+ var segmenter2 = new Intl.Segmenter("und", { granularity: "grapheme" });
678
+ var emptyExcerpt = (_text) => "";
679
+ var MAX_PATTERN_LENGTH = 4096;
680
+ var MAX_INPUT_LENGTH = 1e6;
681
+ var MAX_PROGRAM_SIZE = 4096;
682
+ var MAX_MATCHES = 1e4;
683
+ var SEARCH_BUDGET = 16000000;
684
+ function compileTextExcerpt(options = {}) {
685
+ const limit = options.maxLength ?? 200;
686
+ if (!Number.isSafeInteger(limit) || limit <= 0)
687
+ return emptyExcerpt;
688
+ if (options.pattern === undefined) {
689
+ if (options.flags !== undefined || options.group !== undefined || options.match !== undefined) {
690
+ return emptyExcerpt;
691
+ }
692
+ return (text) => truncateText(text, limit);
693
+ }
694
+ const occurrence = options.match ?? 1;
695
+ const group = options.group ?? 0;
696
+ if (options.pattern.length > MAX_PATTERN_LENGTH || !Number.isSafeInteger(occurrence) || occurrence < 1 || occurrence > MAX_MATCHES || typeof group === "number" && (!Number.isSafeInteger(group) || group < 0))
697
+ return emptyExcerpt;
698
+ let flags = 0;
699
+ const seenFlags = new Set;
700
+ for (const flag of options.flags ?? "") {
701
+ if (seenFlags.has(flag))
702
+ return emptyExcerpt;
703
+ seenFlags.add(flag);
704
+ switch (flag) {
705
+ case "i":
706
+ flags |= import_re2js.RE2JS.CASE_INSENSITIVE;
707
+ break;
708
+ case "m":
709
+ flags |= import_re2js.RE2JS.MULTILINE;
710
+ break;
711
+ case "s":
712
+ flags |= import_re2js.RE2JS.DOTALL;
713
+ break;
714
+ default:
715
+ return emptyExcerpt;
716
+ }
717
+ }
718
+ let compiled;
719
+ try {
720
+ compiled = import_re2js.RE2JS.compile(options.pattern, flags);
721
+ } catch {
722
+ return emptyExcerpt;
723
+ }
724
+ const programSize = compiled.programSize();
725
+ const groupCount = compiled.groupCount();
726
+ if (programSize > MAX_PROGRAM_SIZE || (typeof group === "number" ? group > groupCount : !Object.hasOwn(compiled.namedGroups(), group)))
727
+ return emptyExcerpt;
728
+ return (text) => {
729
+ if (text.length > MAX_INPUT_LENGTH)
730
+ return "";
731
+ const matcher = compiled.matcher(text);
732
+ let budget = SEARCH_BUDGET;
733
+ let from = 0;
734
+ for (let index = 1;index <= occurrence; index++) {
735
+ budget -= programSize * (groupCount + 1) * (text.length - from + 1);
736
+ if (budget < 0 || !matcher.find())
737
+ return "";
738
+ from = matcher.end();
739
+ }
740
+ return truncateText(matcher.group(group) ?? "", limit);
741
+ };
742
+ }
743
+ function excerptText(text, options = {}) {
744
+ return compileTextExcerpt(options)(text);
745
+ }
746
+ function truncateText(text, limit) {
747
+ let count = 0;
748
+ for (const segment of segmenter2.segment(text)) {
749
+ if (count++ === limit)
750
+ return text.slice(0, segment.index);
751
+ }
752
+ return text;
753
+ }
754
+ // packages/ast/src/position.ts
755
+ function createPoint(line, column, offset) {
756
+ return { line, column, offset };
757
+ }
758
+ function createPosition(start, end) {
759
+ return { start, end };
760
+ }
761
+ // packages/ast/src/element.ts
762
+ function isStringContainerType(type) {
763
+ return typeof type === "string";
764
+ }
765
+ function isHeaderType(type) {
766
+ return typeof type === "object" && type !== null && "header" in type;
767
+ }
768
+ function isAlignType(type) {
769
+ return typeof type === "object" && type !== null && "align" in type;
770
+ }
771
+ function text(value) {
772
+ return { element: "text", data: value };
773
+ }
774
+ function container(type, elements, attributes = {}) {
775
+ return {
776
+ element: "container",
777
+ data: { type, attributes, elements }
778
+ };
779
+ }
780
+ function paragraph(elements, attributes = {}) {
781
+ return container("paragraph", elements, attributes);
782
+ }
783
+ function bold(elements, attributes = {}) {
784
+ return container("bold", elements, attributes);
785
+ }
786
+ function italics(elements, attributes = {}) {
787
+ return container("italics", elements, attributes);
788
+ }
789
+ function heading(level, elements, hasToc = true, attributes = {}) {
790
+ return container({ header: { level, "has-toc": hasToc } }, elements, attributes);
791
+ }
792
+ function lineBreak() {
793
+ return { element: "line-break" };
794
+ }
795
+ function horizontalRule() {
796
+ return { element: "horizontal-rule" };
797
+ }
798
+ function link(linkLocation, label, options = {}) {
799
+ return {
800
+ element: "link",
801
+ data: {
802
+ type: options.type ?? (typeof linkLocation === "string" ? "direct" : "page"),
803
+ link: linkLocation,
804
+ extra: options.extra ?? null,
805
+ label,
806
+ target: options.target ?? null
807
+ }
808
+ };
809
+ }
810
+ function list(type, items, attributes = {}) {
811
+ return {
812
+ element: "list",
813
+ data: { type, attributes, items }
814
+ };
815
+ }
816
+ function listItemElements(elements, attributes = {}) {
817
+ return {
818
+ "item-type": "elements",
819
+ attributes,
820
+ elements
821
+ };
822
+ }
823
+ function listItemSubList(data) {
824
+ return {
825
+ "item-type": "sub-list",
826
+ element: "list",
827
+ data
828
+ };
829
+ }
830
+ function isContainerTypeParagraphSafe(type) {
831
+ if (isHeaderType(type))
832
+ return false;
833
+ if (isAlignType(type))
834
+ return false;
835
+ switch (type) {
836
+ case "bold":
837
+ case "italics":
838
+ case "underline":
839
+ case "superscript":
840
+ case "subscript":
841
+ case "strikethrough":
842
+ case "monospace":
843
+ case "span":
844
+ case "size":
845
+ return true;
846
+ case "div":
847
+ case "note":
848
+ case "blockquote":
849
+ case "paragraph":
850
+ case "heading":
851
+ case "collapsible":
852
+ case "definition-list":
853
+ case "definition-list-item":
854
+ case "definition-list-key":
855
+ case "definition-list-value":
856
+ case "table-row":
857
+ case "table-cell":
858
+ return false;
859
+ default:
860
+ return false;
861
+ }
862
+ }
863
+ function isParagraphSafe(element) {
864
+ switch (element.element) {
865
+ case "container": {
866
+ const data = element.data;
867
+ return isContainerTypeParagraphSafe(data.type);
868
+ }
869
+ case "module":
870
+ return false;
871
+ case "text":
872
+ case "raw":
873
+ case "variable":
874
+ case "email":
875
+ return true;
876
+ case "table":
877
+ return false;
878
+ case "tab-view":
879
+ return false;
880
+ case "anchor":
881
+ case "anchor-name":
882
+ case "link":
883
+ return true;
884
+ case "image":
885
+ return true;
886
+ case "list":
887
+ return false;
888
+ case "definition-list":
889
+ return false;
890
+ case "collapsible":
891
+ return false;
892
+ case "table-of-contents":
893
+ return false;
894
+ case "footnote":
895
+ return true;
896
+ case "footnote-ref":
897
+ return true;
898
+ case "footnote-block":
899
+ return false;
900
+ case "bibliography-cite":
901
+ return true;
902
+ case "bibliography-block":
903
+ return false;
904
+ case "user":
905
+ return true;
906
+ case "date":
907
+ case "social":
908
+ return true;
909
+ case "button":
910
+ return isPageButtonAction(element.data.action);
911
+ case "color":
912
+ return true;
913
+ case "code":
914
+ return false;
915
+ case "math":
916
+ return false;
917
+ case "math-inline":
918
+ return true;
919
+ case "embed":
920
+ return false;
921
+ case "embed-block":
922
+ return true;
923
+ case "html":
924
+ case "iframe":
925
+ return false;
926
+ case "include": {
927
+ const data = element.data;
928
+ return data["paragraph-safe"];
929
+ }
930
+ case "style":
931
+ return false;
932
+ case "line-break":
933
+ case "line-breaks":
934
+ return true;
935
+ case "clear-float":
936
+ return false;
937
+ case "horizontal-rule":
938
+ return false;
939
+ case "content-separator":
940
+ return false;
941
+ case "if-tags":
942
+ return false;
943
+ case "expr":
944
+ case "if":
945
+ case "ifexpr":
946
+ return true;
947
+ default:
948
+ return false;
949
+ }
950
+ }
951
+ function isPageButtonAction(action) {
952
+ switch (action) {
953
+ case "edit":
954
+ case "edit-append":
955
+ case "edit-sections":
956
+ case "history":
957
+ case "print":
958
+ case "files":
959
+ case "tags":
960
+ case "source":
961
+ case "backlinks":
962
+ case "talk":
963
+ case "delete":
964
+ case "rename":
965
+ case "site-tools":
966
+ case "edit-meta":
967
+ case "watchers":
968
+ case "parent":
969
+ case "lock-page":
970
+ return true;
971
+ default:
972
+ return false;
973
+ }
974
+ }
975
+ // packages/ast/src/constants.ts
976
+ var STYLE_SLOT_PREFIX = "\x00__IFTAGS_SLOT__";
977
+ var STYLE_ANCHOR_PREFIX = "\x00__STYLE_ANCHOR__";
978
+ // packages/ast/src/css.ts
979
+ var CSS_LENGTH_UNITS = [
980
+ "cqmax",
981
+ "cqmin",
982
+ "cqw",
983
+ "cqh",
984
+ "cqi",
985
+ "cqb",
986
+ "svmin",
987
+ "svmax",
988
+ "lvmin",
989
+ "lvmax",
990
+ "dvmin",
991
+ "dvmax",
992
+ "vmin",
993
+ "vmax",
994
+ "svw",
995
+ "svh",
996
+ "svi",
997
+ "svb",
998
+ "lvw",
999
+ "lvh",
1000
+ "lvi",
1001
+ "lvb",
1002
+ "dvw",
1003
+ "dvh",
1004
+ "dvi",
1005
+ "dvb",
1006
+ "vw",
1007
+ "vh",
1008
+ "vi",
1009
+ "vb",
1010
+ "rcap",
1011
+ "rem",
1012
+ "rex",
1013
+ "rch",
1014
+ "ric",
1015
+ "rlh",
1016
+ "cap",
1017
+ "em",
1018
+ "ex",
1019
+ "ch",
1020
+ "ic",
1021
+ "lh",
1022
+ "cm",
1023
+ "mm",
1024
+ "in",
1025
+ "pc",
1026
+ "pt",
1027
+ "px",
1028
+ "q",
1029
+ "%"
1030
+ ];
735
1031
  // packages/ast/src/settings.ts
736
1032
  function createSettings(mode) {
737
1033
  switch (mode) {