@gmb/bitmark-parser-generator 5.24.0 → 5.25.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/browser/bitmark-parser-generator.min.js +1 -1
- package/dist/browser/bundle-report.html +2 -2
- package/dist/browser/cjs/index.cjs +1035 -17
- package/dist/browser/cjs/index.cjs.map +1 -1
- package/dist/browser/cjs/index.d.cts +175 -1
- package/dist/browser/esm/index.d.ts +175 -1
- package/dist/browser/esm/index.js +1033 -17
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/cli/main.js +1150 -75
- package/dist/cli/main.js.map +1 -1
- package/dist/index.cjs +1035 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +175 -1
- package/dist/index.d.ts +175 -1
- package/dist/index.js +1033 -17
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
|
@@ -34,6 +34,8 @@ __export(index_exports, {
|
|
|
34
34
|
BoundingBoxIndex: () => BoundingBoxIndex,
|
|
35
35
|
Builder: () => Builder,
|
|
36
36
|
CardSetVersion: () => CardSetVersion,
|
|
37
|
+
HtmlTableGenerator: () => HtmlTableGenerator2,
|
|
38
|
+
HtmlTableParser: () => HtmlTableParser2,
|
|
37
39
|
InfoFormat: () => InfoFormat,
|
|
38
40
|
InfoType: () => InfoType,
|
|
39
41
|
Input: () => Input,
|
|
@@ -279,6 +281,7 @@ var BitType2 = {
|
|
|
279
281
|
dangerAlt: "danger-alt",
|
|
280
282
|
dangerCollapsible: "danger-collapsible",
|
|
281
283
|
definitionList: "definition-list",
|
|
284
|
+
definitionListCollapsible: "definition-list-collapsible",
|
|
282
285
|
definitionTerm: "definition-term",
|
|
283
286
|
deleted: "deleted",
|
|
284
287
|
details: "details",
|
|
@@ -559,6 +562,8 @@ var BitType2 = {
|
|
|
559
562
|
smartStandardArticleNonNormativeCollapsible: "smart-standard-article-non-normative-collapsible",
|
|
560
563
|
smartStandardArticleNormative: "smart-standard-article-normative",
|
|
561
564
|
smartStandardArticleNormativeCollapsible: "smart-standard-article-normative-collapsible",
|
|
565
|
+
smartStandardDefinitionListNonNormative: "smart-standard-definition-list-non-normative",
|
|
566
|
+
smartStandardDefinitionListNormative: "smart-standard-definition-list-normative",
|
|
562
567
|
smartStandardExampleNonNormative: "smart-standard-example-non-normative",
|
|
563
568
|
smartStandardExampleNonNormativeCollapsible: "smart-standard-example-non-normative-collapsible",
|
|
564
569
|
smartStandardExampleNormative: "smart-standard-example-normative",
|
|
@@ -609,6 +614,8 @@ var BitType2 = {
|
|
|
609
614
|
smartStandardTableNormativeCollapsible: "smart-standard-table-normative-collapsible",
|
|
610
615
|
standardArticleNonNormative: "standard-article-non-normative",
|
|
611
616
|
standardArticleNormative: "standard-article-normative",
|
|
617
|
+
standardDefinitionListNonNormative: "standard-definition-list-non-normative",
|
|
618
|
+
standardDefinitionListNormative: "standard-definition-list-normative",
|
|
612
619
|
standardExampleNonNormative: "standard-example-non-normative",
|
|
613
620
|
standardExampleNormative: "standard-example-normative",
|
|
614
621
|
standardImageFigureNonNormative: "standard-image-figure-non-normative",
|
|
@@ -780,6 +787,7 @@ var CardSetConfigKey = {
|
|
|
780
787
|
flashcard: "flashcard",
|
|
781
788
|
flashcard1: "flashcard1",
|
|
782
789
|
definitionList: "definitionList",
|
|
790
|
+
definitionListPlain: "definitionListPlain",
|
|
783
791
|
elements: "elements",
|
|
784
792
|
statements: "statements",
|
|
785
793
|
quiz: "quiz",
|
|
@@ -1393,6 +1401,7 @@ var propertyKeys = {
|
|
|
1393
1401
|
property_enforceUpdateOverUserInput: "@enforceUpdateOverUserInput",
|
|
1394
1402
|
property_extractorExtractionTimestamp: "@extractorExtractionTimestamp",
|
|
1395
1403
|
property_isCaseSensitive: "@isCaseSensitive",
|
|
1404
|
+
property_isCollapsible: "@isCollapsible",
|
|
1396
1405
|
property_isInfoOnly: "@isInfoOnly",
|
|
1397
1406
|
property_isPublic: "@isPublic",
|
|
1398
1407
|
property_isTemplate: "@isTemplate",
|
|
@@ -2597,6 +2606,126 @@ var CARDSETS = {
|
|
|
2597
2606
|
]
|
|
2598
2607
|
},
|
|
2599
2608
|
//
|
|
2609
|
+
// definition-list-plain
|
|
2610
|
+
//
|
|
2611
|
+
// Same shape as `definitionList`, but every variant body is rendered as
|
|
2612
|
+
// plain text (string), not bitmark+ AST. Used by
|
|
2613
|
+
// `meta-search-default-terms` / `meta-search-default-topics`, which need
|
|
2614
|
+
// term/definition text emitted verbatim instead of as a ProseMirror tree.
|
|
2615
|
+
//
|
|
2616
|
+
[CardSetConfigKey.definitionListPlain]: {
|
|
2617
|
+
jsonKey: "definitions",
|
|
2618
|
+
exportJsonKey: { definitions: "$" },
|
|
2619
|
+
sides: [
|
|
2620
|
+
{
|
|
2621
|
+
name: "term",
|
|
2622
|
+
variants: [
|
|
2623
|
+
{
|
|
2624
|
+
jsonKey: "term.text",
|
|
2625
|
+
exportJsonKey: [{ "@absent": { term: {} } }, { term: { text: "$" } }],
|
|
2626
|
+
format: TextFormat2.plainText,
|
|
2627
|
+
tags: [
|
|
2628
|
+
{
|
|
2629
|
+
key: ConfigKey.group_standardTags,
|
|
2630
|
+
description: "Standard tags for the definition."
|
|
2631
|
+
},
|
|
2632
|
+
{
|
|
2633
|
+
key: ConfigKey.tag_title,
|
|
2634
|
+
description: "Title of the definition.",
|
|
2635
|
+
format: TagFormat.plainText,
|
|
2636
|
+
jsonKey: "^heading.forKeys",
|
|
2637
|
+
exportJsonKey: { "@bit": { heading: { forKeys: "$" } } }
|
|
2638
|
+
},
|
|
2639
|
+
{
|
|
2640
|
+
key: ConfigKey.group_resourceIcon,
|
|
2641
|
+
description: "Icon resource for the definition.",
|
|
2642
|
+
format: TagFormat.plainText,
|
|
2643
|
+
jsonKey: "term.icon|resource(type=image, key=image)",
|
|
2644
|
+
exportJsonKey: { term: { icon: { type: "image", image: { src: "$" } } } }
|
|
2645
|
+
},
|
|
2646
|
+
{
|
|
2647
|
+
key: ConfigKey.property_example,
|
|
2648
|
+
exportJsonKey: [
|
|
2649
|
+
{ "@keyonly": { isExample: true, example: true, "@bit": { isExample: true } } },
|
|
2650
|
+
{ "@absent": { isExample: true, example: true, "@bit": { isExample: true } } },
|
|
2651
|
+
{ isExample: true, example: "$", "@bit": { isExample: true } }
|
|
2652
|
+
],
|
|
2653
|
+
description: "Example marker for the definition term.",
|
|
2654
|
+
format: TagFormat.bitmarkText,
|
|
2655
|
+
nullable: true
|
|
2656
|
+
}
|
|
2657
|
+
]
|
|
2658
|
+
}
|
|
2659
|
+
]
|
|
2660
|
+
},
|
|
2661
|
+
{
|
|
2662
|
+
name: "definition",
|
|
2663
|
+
variants: [
|
|
2664
|
+
{
|
|
2665
|
+
jsonKey: "definition.text",
|
|
2666
|
+
exportJsonKey: [{ "@absent": { definition: {} } }, { definition: { text: "$" } }],
|
|
2667
|
+
format: TextFormat2.plainText,
|
|
2668
|
+
tags: [
|
|
2669
|
+
{
|
|
2670
|
+
key: ConfigKey.group_standardTags,
|
|
2671
|
+
description: "Standard tags for the definition."
|
|
2672
|
+
},
|
|
2673
|
+
{
|
|
2674
|
+
key: ConfigKey.tag_title,
|
|
2675
|
+
description: "Title of the definition.",
|
|
2676
|
+
format: TagFormat.plainText,
|
|
2677
|
+
jsonKey: "^heading.forValues",
|
|
2678
|
+
exportJsonKey: { "@bit": { heading: { forValues: "$" } } }
|
|
2679
|
+
},
|
|
2680
|
+
{
|
|
2681
|
+
key: ConfigKey.group_resourceIcon,
|
|
2682
|
+
description: "Icon resource for the definition.",
|
|
2683
|
+
jsonKey: "definition.icon|resource(type=image, key=image)",
|
|
2684
|
+
exportJsonKey: { definition: { icon: { type: "image", image: { src: "$" } } } }
|
|
2685
|
+
},
|
|
2686
|
+
{
|
|
2687
|
+
key: ConfigKey.property_example,
|
|
2688
|
+
exportJsonKey: [
|
|
2689
|
+
{ "@keyonly": { isExample: true, example: true, "@bit": { isExample: true } } },
|
|
2690
|
+
{ "@absent": { isExample: true, example: true, "@bit": { isExample: true } } },
|
|
2691
|
+
{ isExample: true, example: "$", "@bit": { isExample: true } }
|
|
2692
|
+
],
|
|
2693
|
+
description: "Example marker for the definition.",
|
|
2694
|
+
format: TagFormat.bitmarkText,
|
|
2695
|
+
nullable: true
|
|
2696
|
+
}
|
|
2697
|
+
]
|
|
2698
|
+
},
|
|
2699
|
+
{
|
|
2700
|
+
jsonKey: "alternativeDefinitions[].text",
|
|
2701
|
+
exportJsonKey: { alternativeDefinitions: [{ text: "$" }] },
|
|
2702
|
+
format: TextFormat2.plainText,
|
|
2703
|
+
tags: [
|
|
2704
|
+
{
|
|
2705
|
+
key: ConfigKey.group_standardTags,
|
|
2706
|
+
description: "Standard tags for the definition."
|
|
2707
|
+
},
|
|
2708
|
+
{
|
|
2709
|
+
exportJsonKey: { title: "$" },
|
|
2710
|
+
key: ConfigKey.tag_title,
|
|
2711
|
+
description: "Title of the definition."
|
|
2712
|
+
},
|
|
2713
|
+
{
|
|
2714
|
+
key: ConfigKey.group_resourceIcon,
|
|
2715
|
+
description: "Icon resource for the definition.",
|
|
2716
|
+
jsonKey: "alternativeDefinitions[].icon|resource(type=image, key=image)",
|
|
2717
|
+
exportJsonKey: {
|
|
2718
|
+
alternativeDefinitions: [{ icon: { type: "image", image: { src: "$" } } }]
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
],
|
|
2722
|
+
repeatCount: Count.infinity
|
|
2723
|
+
}
|
|
2724
|
+
]
|
|
2725
|
+
}
|
|
2726
|
+
]
|
|
2727
|
+
},
|
|
2728
|
+
//
|
|
2600
2729
|
// match-pairs
|
|
2601
2730
|
//
|
|
2602
2731
|
[CardSetConfigKey.matchPairs]: {
|
|
@@ -3534,12 +3663,29 @@ var CARDSETS = {
|
|
|
3534
3663
|
// ALIGN-EXAMPLE-CASCADE §3.10: `questions` is NOT in BPG's
|
|
3535
3664
|
// `pushExampleDownTree` dispatch — bit-header `[@example]`
|
|
3536
3665
|
// does not propagate `example`/`isExample` onto question
|
|
3537
|
-
// entries. Only entry-local `[@example]` fires
|
|
3538
|
-
//
|
|
3539
|
-
//
|
|
3666
|
+
// entries. Only entry-local `[@example]` fires.
|
|
3667
|
+
//
|
|
3668
|
+
// BPG's `BaseBuilder.toExample` for interview questions
|
|
3669
|
+
// (Builder.ts:2575,2588) uses `data.__sampleSolutionAst`
|
|
3670
|
+
// as `defaultExample` — bare `[@example]` (which sets
|
|
3671
|
+
// `__isDefaultExample=true, example=undefined`) emits the
|
|
3672
|
+
// parsed sample-solution AST in the `example` slot. The
|
|
3673
|
+
// `@keyonly` rule mirrors that runtime behaviour via
|
|
3674
|
+
// `$parent.sampleSolution` — the chain-walker's post-walk
|
|
3675
|
+
// retry resolves this once the sibling `[@sampleSolution]`
|
|
3676
|
+
// chain has merged into the shared scope (interview's
|
|
3677
|
+
// `[@example]` typically precedes `[@sampleSolution]` in
|
|
3678
|
+
// source). Format coercion turns the resolved string
|
|
3679
|
+
// value into a PM tree.
|
|
3540
3680
|
key: ConfigKey.property_example,
|
|
3541
3681
|
exportJsonKey: [
|
|
3542
|
-
{
|
|
3682
|
+
{
|
|
3683
|
+
"@keyonly": {
|
|
3684
|
+
isExample: true,
|
|
3685
|
+
example: "$parent.sampleSolution",
|
|
3686
|
+
"@bit": { isExample: true }
|
|
3687
|
+
}
|
|
3688
|
+
},
|
|
3543
3689
|
{ isExample: true, example: "$", "@bit": { isExample: true } }
|
|
3544
3690
|
],
|
|
3545
3691
|
description: "Example marker for the question (entry-local only; no bit-header cascade).",
|
|
@@ -5362,7 +5508,11 @@ var GROUPS = {
|
|
|
5362
5508
|
{
|
|
5363
5509
|
key: ConfigKey.property_mark,
|
|
5364
5510
|
jsonKey: "marks.mark",
|
|
5365
|
-
|
|
5511
|
+
// `emphasis: 'underline'` is the per-entry default for mark
|
|
5512
|
+
// configs — mirrors the hardcoded default in BPG
|
|
5513
|
+
// `MarkConfigChainContentProcessor.ts:55-58`. Chained
|
|
5514
|
+
// `[@emphasis:…]` overrides via deep-merge into `marks[-1]`.
|
|
5515
|
+
exportJsonKey: { marks: [{ mark: "$", emphasis: "underline" }] },
|
|
5366
5516
|
description: "The mark configuration",
|
|
5367
5517
|
format: TagFormat.plainText,
|
|
5368
5518
|
maxCount: Count.infinity,
|
|
@@ -5404,13 +5554,22 @@ var GROUPS = {
|
|
|
5404
5554
|
{
|
|
5405
5555
|
key: ConfigKey.property_example,
|
|
5406
5556
|
jsonKey: "example",
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5557
|
+
// Per-mark `@example` is a boolean toggle. BPG's runtime
|
|
5558
|
+
// `ExampleTagContentProcessor.handleDefaultOnlyExample`
|
|
5559
|
+
// (lines 147-161) normalises ANY `[@example]` or
|
|
5560
|
+
// `[@example:V]` on a mark body-bit to
|
|
5561
|
+
// `__isDefaultExample=true, example=undefined`; the
|
|
5562
|
+
// downstream `toExample(_, _, defaultExample=true)` in
|
|
5563
|
+
// `BaseBuilder.ts:80-87` then emits `example: true`
|
|
5564
|
+
// regardless of source. Declare a single unconditional
|
|
5565
|
+
// boolean-shape rule so the exported schema matches that
|
|
5566
|
+
// runtime semantic instead of the misleading `example: $`
|
|
5567
|
+
// shape (which would only fire if `handleDefaultOnlyExample`
|
|
5568
|
+
// were removed). `@bit: {isExample: true}` cascades the
|
|
5569
|
+
// marker — but NOT the `example` value — to bit root.
|
|
5570
|
+
exportJsonKey: { isExample: true, example: true, "@bit": { isExample: true } },
|
|
5412
5571
|
description: "An example for the marked content",
|
|
5413
|
-
format: TagFormat.
|
|
5572
|
+
format: TagFormat.boolean,
|
|
5414
5573
|
nullable: true
|
|
5415
5574
|
}
|
|
5416
5575
|
]
|
|
@@ -8186,6 +8345,12 @@ var BITS = {
|
|
|
8186
8345
|
description: "The progress of the chapter, used for tracking reading progress",
|
|
8187
8346
|
format: TagFormat.boolean,
|
|
8188
8347
|
defaultValue: "true"
|
|
8348
|
+
},
|
|
8349
|
+
{
|
|
8350
|
+
key: ConfigKey.property_isCollapsible,
|
|
8351
|
+
description: "If true, the chapter is collapsible",
|
|
8352
|
+
format: TagFormat.boolean,
|
|
8353
|
+
defaultValue: "false"
|
|
8189
8354
|
}
|
|
8190
8355
|
]
|
|
8191
8356
|
},
|
|
@@ -8960,7 +9125,12 @@ var BITS = {
|
|
|
8960
9125
|
maxCount: Count.infinity
|
|
8961
9126
|
},
|
|
8962
9127
|
{
|
|
8963
|
-
// Override inherited @example from group_standardTags:
|
|
9128
|
+
// Override inherited @example from group_standardTags: emits both
|
|
9129
|
+
// `isExample` (bool) AND `example` (paragraph array). Declared as
|
|
9130
|
+
// bitmarkText because BPG `JsonGenerator.toExample` renders the
|
|
9131
|
+
// root-example value through the bit's textFormat (not this tag's
|
|
9132
|
+
// declared format) — `TagFormat.plainText` here would be ignored
|
|
9133
|
+
// at runtime and is misleading.
|
|
8964
9134
|
key: ConfigKey.property_example,
|
|
8965
9135
|
exportJsonKey: [
|
|
8966
9136
|
{ "@keyonly": { isExample: true, example: "true" } },
|
|
@@ -8968,7 +9138,7 @@ var BITS = {
|
|
|
8968
9138
|
{ isExample: true, example: "$" }
|
|
8969
9139
|
],
|
|
8970
9140
|
description: "The example text for the essay bit",
|
|
8971
|
-
format: TagFormat.
|
|
9141
|
+
format: TagFormat.bitmarkText,
|
|
8972
9142
|
nullable: true
|
|
8973
9143
|
}
|
|
8974
9144
|
],
|
|
@@ -10330,11 +10500,36 @@ var BITS = {
|
|
|
10330
10500
|
],
|
|
10331
10501
|
cardSet: CardSetConfigKey.definitionList
|
|
10332
10502
|
},
|
|
10503
|
+
[BitType2.definitionListCollapsible]: {
|
|
10504
|
+
since: "5.25.0",
|
|
10505
|
+
baseBitType: BitType2.definitionList,
|
|
10506
|
+
description: "Collapsible definition list bit, used to create collapsible lists of definitions in articles or books"
|
|
10507
|
+
},
|
|
10508
|
+
[BitType2.standardDefinitionListNormative]: {
|
|
10509
|
+
since: "5.24.0",
|
|
10510
|
+
baseBitType: BitType2.definitionList,
|
|
10511
|
+
description: "Standard normative definition list bit, used to create normative standard definition lists in articles or books"
|
|
10512
|
+
},
|
|
10513
|
+
[BitType2.standardDefinitionListNonNormative]: {
|
|
10514
|
+
since: "5.24.0",
|
|
10515
|
+
baseBitType: BitType2.definitionList,
|
|
10516
|
+
description: "Standard non-normative definition list bit, used to create non-normative standard definition lists in articles or books"
|
|
10517
|
+
},
|
|
10518
|
+
[BitType2.smartStandardDefinitionListNormative]: {
|
|
10519
|
+
since: "5.24.0",
|
|
10520
|
+
baseBitType: BitType2.standardDefinitionListNormative,
|
|
10521
|
+
description: "Smart standard normative definition list bit, used to create normative smart standard definition lists in articles or books"
|
|
10522
|
+
},
|
|
10523
|
+
[BitType2.smartStandardDefinitionListNonNormative]: {
|
|
10524
|
+
since: "5.24.0",
|
|
10525
|
+
baseBitType: BitType2.standardDefinitionListNonNormative,
|
|
10526
|
+
description: "Smart standard non-normative definition list bit, used to create non-normative smart standard definition lists in articles or books"
|
|
10527
|
+
},
|
|
10333
10528
|
[BitType2.metaSearchDefaultTerms]: {
|
|
10334
10529
|
since: "3.12.0",
|
|
10335
10530
|
baseBitType: BitType2._standard,
|
|
10336
10531
|
description: "Meta search default terms bit, used to define default search terms in articles",
|
|
10337
|
-
cardSet: CardSetConfigKey.
|
|
10532
|
+
cardSet: CardSetConfigKey.definitionListPlain
|
|
10338
10533
|
},
|
|
10339
10534
|
[BitType2.metaSearchDefaultTopics]: {
|
|
10340
10535
|
since: "3.12.0",
|
|
@@ -10378,7 +10573,11 @@ var BITS = {
|
|
|
10378
10573
|
[BitType2.qAndACard]: {
|
|
10379
10574
|
since: "3.25.0",
|
|
10380
10575
|
baseBitType: BitType2.flashcard1,
|
|
10381
|
-
description: "Q&A card bit, used to create question and answer cards in articles or books"
|
|
10576
|
+
description: "Q&A card bit, used to create question and answer cards in articles or books",
|
|
10577
|
+
// PLAN-085: q-and-a-card permits multiple cards (some fixtures carry
|
|
10578
|
+
// two). Override the inherited `flashcard1` (max=1) cardset back to
|
|
10579
|
+
// the unbounded `flashcard` cardset.
|
|
10580
|
+
cardSet: CardSetConfigKey.flashcard
|
|
10382
10581
|
},
|
|
10383
10582
|
[BitType2.focusImage]: {
|
|
10384
10583
|
since: "1.3.0",
|
|
@@ -13464,7 +13663,7 @@ var instance2 = new Config();
|
|
|
13464
13663
|
// src/generated/package_info.ts
|
|
13465
13664
|
var PACKAGE_INFO = {
|
|
13466
13665
|
"name": "@gmb/bitmark-parser-generator",
|
|
13467
|
-
"version": "5.
|
|
13666
|
+
"version": "5.25.0",
|
|
13468
13667
|
"author": "Get More Brain Ltd",
|
|
13469
13668
|
"license": "ISC",
|
|
13470
13669
|
"description": "A bitmark parser and generator using Peggy.js"
|
|
@@ -14110,6 +14309,8 @@ var NodeType = {
|
|
|
14110
14309
|
internalPrintPdf: "internalPrintPdf",
|
|
14111
14310
|
internalPrintPdfValue: "internalPrintPdfValue",
|
|
14112
14311
|
isCaseSensitive: "isCaseSensitive",
|
|
14312
|
+
isCollapsible: "isCollapsible",
|
|
14313
|
+
isCollapsibleValue: "isCollapsibleValue",
|
|
14113
14314
|
isCommented: "isCommented",
|
|
14114
14315
|
isCorrect: "isCorrect",
|
|
14115
14316
|
isEditable: "isEditable",
|
|
@@ -28348,6 +28549,12 @@ var Builder = class extends BaseBuilder {
|
|
|
28348
28549
|
level: instance6.asNumber(data.level),
|
|
28349
28550
|
toc: this.toAstProperty(bitType, ConfigKey.property_toc, data.toc, options),
|
|
28350
28551
|
progress: this.toAstProperty(bitType, ConfigKey.property_progress, data.progress, options),
|
|
28552
|
+
isCollapsible: this.toAstProperty(
|
|
28553
|
+
bitType,
|
|
28554
|
+
ConfigKey.property_isCollapsible,
|
|
28555
|
+
data.isCollapsible,
|
|
28556
|
+
options
|
|
28557
|
+
),
|
|
28351
28558
|
anchor: data.anchor,
|
|
28352
28559
|
reference: data.reference,
|
|
28353
28560
|
referenceEnd: data.referenceEnd,
|
|
@@ -33894,6 +34101,7 @@ var JsonGenerator = class extends AstWalkerGenerator {
|
|
|
33894
34101
|
if (instance2.isOfBitType(bitType, BitType2.chapter)) {
|
|
33895
34102
|
if (bitJson.toc == null) bitJson.toc = true;
|
|
33896
34103
|
if (bitJson.progress == null) bitJson.progress = true;
|
|
34104
|
+
if (bitJson.isCollapsible == null) bitJson.isCollapsible = false;
|
|
33897
34105
|
if (bitJson.level == null) bitJson.level = 1;
|
|
33898
34106
|
if (bitJson.body == null) bitJson.body = this.bodyDefault;
|
|
33899
34107
|
}
|
|
@@ -36091,6 +36299,7 @@ function buildCards(context, bitType, textFormat, parsedCardSet, statementV1, st
|
|
|
36091
36299
|
case CardSetConfigKey.flashcard:
|
|
36092
36300
|
case CardSetConfigKey.flashcard1:
|
|
36093
36301
|
case CardSetConfigKey.definitionList:
|
|
36302
|
+
case CardSetConfigKey.definitionListPlain:
|
|
36094
36303
|
result = parseFlashcardOrDefinitionList(context, bitType, processedCardSet);
|
|
36095
36304
|
break;
|
|
36096
36305
|
case CardSetConfigKey.elements:
|
|
@@ -42157,7 +42366,11 @@ var InputFormat = {
|
|
|
42157
42366
|
/**
|
|
42158
42367
|
* Input is plain text
|
|
42159
42368
|
*/
|
|
42160
|
-
plainText: "plainText"
|
|
42369
|
+
plainText: "plainText",
|
|
42370
|
+
/**
|
|
42371
|
+
* Input is HTML (used by convertHtmlTable)
|
|
42372
|
+
*/
|
|
42373
|
+
html: "html"
|
|
42161
42374
|
};
|
|
42162
42375
|
var BitmarkParserGenerator = class {
|
|
42163
42376
|
constructor() {
|
|
@@ -42692,6 +42905,87 @@ var BitmarkParserGenerator = class {
|
|
|
42692
42905
|
const res = generator.generate(data);
|
|
42693
42906
|
return res;
|
|
42694
42907
|
}
|
|
42908
|
+
/**
|
|
42909
|
+
* Convert between HTML tables and bitmark tables.
|
|
42910
|
+
*
|
|
42911
|
+
* Direction is auto-detected (override with `options.inputFormat`):
|
|
42912
|
+
* - HTML input: every `<table>` is extracted and emitted as a `[.table-extended]` (or `[.table]`)
|
|
42913
|
+
* bit; output as bitmark (default), JSON, AST, or HTML (re-emit).
|
|
42914
|
+
* - bitmark / JSON / AST input: each `table` / `table-extended` bit is rendered as an HTML
|
|
42915
|
+
* `<table>` fragment.
|
|
42916
|
+
*
|
|
42917
|
+
* Cell content is reproduced verbatim except inline conversion to bitmark marks (bold, italic,
|
|
42918
|
+
* superscript, etc.), with lists and images mapped to their bitmark equivalents.
|
|
42919
|
+
*
|
|
42920
|
+
* @param input - HTML, bitmark, JSON or AST string; or a parsed JSON/AST value; or a file path.
|
|
42921
|
+
* @param options - the conversion options
|
|
42922
|
+
* @returns the converted output as a string (or object for JSON/AST), or void when writing a file
|
|
42923
|
+
* @throws Error if any error occurs
|
|
42924
|
+
*/
|
|
42925
|
+
convertHtmlTable(input, options) {
|
|
42926
|
+
const opts = Object.assign({}, options);
|
|
42927
|
+
if (env.isBrowser && opts.outputFile) {
|
|
42928
|
+
throw new Error("Cannot write to file in browser environment");
|
|
42929
|
+
}
|
|
42930
|
+
let inStr = input;
|
|
42931
|
+
const inputIsString = typeof input === "string";
|
|
42932
|
+
if (env.isNode && inputIsString && fs.existsSync(inStr)) {
|
|
42933
|
+
inStr = fs.readFileSync(inStr, { encoding: "utf8" });
|
|
42934
|
+
}
|
|
42935
|
+
const isHtmlString = (s) => {
|
|
42936
|
+
const t = s.replace(/^\s+/, "");
|
|
42937
|
+
return t.startsWith("<") && /<table/i.test(t);
|
|
42938
|
+
};
|
|
42939
|
+
let htmlInput;
|
|
42940
|
+
if (opts.inputFormat === InputFormat.html) {
|
|
42941
|
+
htmlInput = true;
|
|
42942
|
+
} else if (opts.inputFormat != null) {
|
|
42943
|
+
htmlInput = false;
|
|
42944
|
+
} else {
|
|
42945
|
+
htmlInput = inputIsString && isHtmlString(inStr);
|
|
42946
|
+
}
|
|
42947
|
+
if (htmlInput) {
|
|
42948
|
+
const parser2 = new HtmlTableParser();
|
|
42949
|
+
const bits = parser2.parse(inStr, {
|
|
42950
|
+
tableFormat: opts.tableFormat ?? "table-extended",
|
|
42951
|
+
keepUnknownTags: opts.keepUnknownTags,
|
|
42952
|
+
onWarning: (m) => console.warn(m)
|
|
42953
|
+
});
|
|
42954
|
+
const outputFormat2 = opts.outputFormat ?? Output.bitmark;
|
|
42955
|
+
if (outputFormat2 === "html") {
|
|
42956
|
+
const json2 = this.convert(bits, { outputFormat: Output.json });
|
|
42957
|
+
return this.outputHtml(new HtmlTableGenerator().generate(json2), opts);
|
|
42958
|
+
}
|
|
42959
|
+
return this.convert(bits, {
|
|
42960
|
+
outputFormat: (0, import_superenum50.Enum)(Output).fromValue(outputFormat2),
|
|
42961
|
+
outputFile: opts.outputFile,
|
|
42962
|
+
fileOptions: opts.fileOptions,
|
|
42963
|
+
jsonOptions: opts.jsonOptions,
|
|
42964
|
+
bitmarkOptions: opts.bitmarkOptions
|
|
42965
|
+
});
|
|
42966
|
+
}
|
|
42967
|
+
const outputFormat = opts.outputFormat ?? "html";
|
|
42968
|
+
if (outputFormat !== "html") {
|
|
42969
|
+
throw new Error(
|
|
42970
|
+
"convertHtmlTable: non-HTML input can only be converted to HTML. Use convert() for bitmark/JSON/AST conversions."
|
|
42971
|
+
);
|
|
42972
|
+
}
|
|
42973
|
+
const json = this.convert(inputIsString ? inStr : input, { outputFormat: Output.json });
|
|
42974
|
+
return this.outputHtml(new HtmlTableGenerator().generate(json), opts);
|
|
42975
|
+
}
|
|
42976
|
+
/**
|
|
42977
|
+
* Write an HTML string to the configured output file, or return it.
|
|
42978
|
+
*/
|
|
42979
|
+
outputHtml(html, opts) {
|
|
42980
|
+
if (opts.outputFile) {
|
|
42981
|
+
const output = opts.outputFile.toString();
|
|
42982
|
+
const flag = opts.fileOptions?.append ? "a" : "w";
|
|
42983
|
+
fs.ensureDirSync(path.dirname(output));
|
|
42984
|
+
fs.writeFileSync(output, html, { flag });
|
|
42985
|
+
return;
|
|
42986
|
+
}
|
|
42987
|
+
return html;
|
|
42988
|
+
}
|
|
42695
42989
|
/**
|
|
42696
42990
|
* Breakscape bitmark text.
|
|
42697
42991
|
*
|
|
@@ -42970,6 +43264,728 @@ var BoundingBoxIndex = class _BoundingBoxIndex {
|
|
|
42970
43264
|
}
|
|
42971
43265
|
};
|
|
42972
43266
|
|
|
43267
|
+
// src/generator/html/HtmlTableGenerator.ts
|
|
43268
|
+
var MARK_TO_TAG = {
|
|
43269
|
+
bold: "b",
|
|
43270
|
+
italic: "i",
|
|
43271
|
+
superscript: "sup",
|
|
43272
|
+
subscript: "sub",
|
|
43273
|
+
strike: "s",
|
|
43274
|
+
del: "del",
|
|
43275
|
+
ins: "ins",
|
|
43276
|
+
underline: "u",
|
|
43277
|
+
highlight: "mark",
|
|
43278
|
+
code: "code"
|
|
43279
|
+
};
|
|
43280
|
+
var HtmlTableGenerator2 = class {
|
|
43281
|
+
constructor() {
|
|
43282
|
+
__publicField(this, "indentUnit", " ");
|
|
43283
|
+
}
|
|
43284
|
+
/**
|
|
43285
|
+
* Generate HTML table fragments from a string or JSON value.
|
|
43286
|
+
* @returns the concatenated `<table>` fragments, blank-line separated (empty string if none).
|
|
43287
|
+
*/
|
|
43288
|
+
generate(input) {
|
|
43289
|
+
let data = input;
|
|
43290
|
+
if (typeof data === "string") {
|
|
43291
|
+
try {
|
|
43292
|
+
data = JSON.parse(data);
|
|
43293
|
+
} catch {
|
|
43294
|
+
return "";
|
|
43295
|
+
}
|
|
43296
|
+
}
|
|
43297
|
+
const bits = this.collectBits(data);
|
|
43298
|
+
const fragments = [];
|
|
43299
|
+
for (const bit of bits) {
|
|
43300
|
+
const html = this.renderTableBit(bit);
|
|
43301
|
+
if (html) fragments.push(html);
|
|
43302
|
+
}
|
|
43303
|
+
return fragments.join("\n\n");
|
|
43304
|
+
}
|
|
43305
|
+
// --- bit collection -------------------------------------------------------
|
|
43306
|
+
collectBits(data) {
|
|
43307
|
+
const out = [];
|
|
43308
|
+
const visit = (value) => {
|
|
43309
|
+
if (value == null || typeof value !== "object") return;
|
|
43310
|
+
if (Array.isArray(value)) {
|
|
43311
|
+
value.forEach(visit);
|
|
43312
|
+
return;
|
|
43313
|
+
}
|
|
43314
|
+
const obj = value;
|
|
43315
|
+
if ("bit" in obj && obj.bit && typeof obj.bit === "object") {
|
|
43316
|
+
out.push(obj.bit);
|
|
43317
|
+
} else if ("type" in obj) {
|
|
43318
|
+
out.push(obj);
|
|
43319
|
+
}
|
|
43320
|
+
};
|
|
43321
|
+
visit(data);
|
|
43322
|
+
return out;
|
|
43323
|
+
}
|
|
43324
|
+
// --- table rendering ------------------------------------------------------
|
|
43325
|
+
renderTableBit(bit) {
|
|
43326
|
+
const table = bit.table;
|
|
43327
|
+
if (!table) return "";
|
|
43328
|
+
if (bit.type !== "table" && bit.type !== "table-extended") return "";
|
|
43329
|
+
const extended = this.toExtended(table);
|
|
43330
|
+
const lines = [];
|
|
43331
|
+
lines.push("<table>");
|
|
43332
|
+
if (bit.caption != null) {
|
|
43333
|
+
const caption = this.cellContentToHtml(this.asTextAst(bit.caption));
|
|
43334
|
+
if (caption) lines.push(`${this.indentUnit}<caption>${caption}</caption>`);
|
|
43335
|
+
}
|
|
43336
|
+
this.renderSection(lines, "thead", extended.header, "header");
|
|
43337
|
+
this.renderSection(lines, "tbody", extended.body, "body");
|
|
43338
|
+
this.renderSection(lines, "tfoot", extended.footer, "footer");
|
|
43339
|
+
lines.push("</table>");
|
|
43340
|
+
return lines.join("\n");
|
|
43341
|
+
}
|
|
43342
|
+
toExtended(table) {
|
|
43343
|
+
const t = table;
|
|
43344
|
+
if (t.header || t.body || t.footer) return table;
|
|
43345
|
+
return convertBasicToExtendedTableFormat(table);
|
|
43346
|
+
}
|
|
43347
|
+
renderSection(lines, tag, section, key) {
|
|
43348
|
+
if (!section || !section.rows || section.rows.length === 0) return;
|
|
43349
|
+
lines.push(`${this.indentUnit}<${tag}>`);
|
|
43350
|
+
for (const row of section.rows) {
|
|
43351
|
+
lines.push(`${this.indentUnit.repeat(2)}<tr>`);
|
|
43352
|
+
for (const cell of row.cells ?? []) {
|
|
43353
|
+
lines.push(`${this.indentUnit.repeat(3)}${this.renderCell(cell, key)}`);
|
|
43354
|
+
}
|
|
43355
|
+
lines.push(`${this.indentUnit.repeat(2)}</tr>`);
|
|
43356
|
+
}
|
|
43357
|
+
lines.push(`${this.indentUnit}</${tag}>`);
|
|
43358
|
+
}
|
|
43359
|
+
renderCell(cell, _key) {
|
|
43360
|
+
const tag = cell.title === true ? "th" : "td";
|
|
43361
|
+
const attrs = [];
|
|
43362
|
+
if (cell.rowspan && cell.rowspan > 1) attrs.push(`rowspan="${cell.rowspan}"`);
|
|
43363
|
+
if (cell.colspan && cell.colspan > 1) attrs.push(`colspan="${cell.colspan}"`);
|
|
43364
|
+
if (cell.scope) attrs.push(`scope="${cell.scope}"`);
|
|
43365
|
+
if (cell.colwidth && cell.colwidth > 0) attrs.push(`width="${cell.colwidth}"`);
|
|
43366
|
+
const open = attrs.length > 0 ? `<${tag} ${attrs.join(" ")}>` : `<${tag}>`;
|
|
43367
|
+
return `${open}${this.cellContentToHtml(this.asTextAst(cell.content))}</${tag}>`;
|
|
43368
|
+
}
|
|
43369
|
+
// --- cell content (TextAst -> HTML) ---------------------------------------
|
|
43370
|
+
asTextAst(content) {
|
|
43371
|
+
if (content == null) return [];
|
|
43372
|
+
if (typeof content === "string") return [{ type: "text", text: content }];
|
|
43373
|
+
return content;
|
|
43374
|
+
}
|
|
43375
|
+
cellContentToHtml(blocks) {
|
|
43376
|
+
if (blocks.length === 0) return "";
|
|
43377
|
+
if (blocks.length === 1 && blocks[0].type === "paragraph") {
|
|
43378
|
+
return this.inlineToHtml(blocks[0].content ?? []);
|
|
43379
|
+
}
|
|
43380
|
+
return blocks.map((b) => this.blockToHtml(b)).join("");
|
|
43381
|
+
}
|
|
43382
|
+
blockToHtml(node) {
|
|
43383
|
+
switch (node.type) {
|
|
43384
|
+
case "paragraph":
|
|
43385
|
+
return `<p>${this.inlineToHtml(node.content ?? [])}</p>`;
|
|
43386
|
+
case "bulletList":
|
|
43387
|
+
case "noBulletList":
|
|
43388
|
+
case "orderedList":
|
|
43389
|
+
case "orderedListRoman":
|
|
43390
|
+
case "orderedListRomanLower":
|
|
43391
|
+
case "letteredList":
|
|
43392
|
+
case "letteredListLower":
|
|
43393
|
+
case "taskList":
|
|
43394
|
+
return this.listToHtml(node);
|
|
43395
|
+
case "image":
|
|
43396
|
+
case "imageInline":
|
|
43397
|
+
return this.imageToHtml(node);
|
|
43398
|
+
default:
|
|
43399
|
+
return this.inlineToHtml([node]);
|
|
43400
|
+
}
|
|
43401
|
+
}
|
|
43402
|
+
inlineToHtml(nodes) {
|
|
43403
|
+
return nodes.map((n) => this.inlineNodeToHtml(n)).join("");
|
|
43404
|
+
}
|
|
43405
|
+
inlineNodeToHtml(node) {
|
|
43406
|
+
if (node.type === "hardBreak") return "<br>";
|
|
43407
|
+
if (node.type === "image" || node.type === "imageInline") return this.imageToHtml(node);
|
|
43408
|
+
if (node.type === "text") {
|
|
43409
|
+
return this.wrapMarks(this.escapeText(node.text ?? ""), node.marks);
|
|
43410
|
+
}
|
|
43411
|
+
if (node.content) return this.inlineToHtml(node.content);
|
|
43412
|
+
return this.escapeText(node.text ?? "");
|
|
43413
|
+
}
|
|
43414
|
+
wrapMarks(text, marks) {
|
|
43415
|
+
if (!marks || marks.length === 0) return text;
|
|
43416
|
+
let open = "";
|
|
43417
|
+
let close = "";
|
|
43418
|
+
for (const mark of marks) {
|
|
43419
|
+
if (mark.type === "link") {
|
|
43420
|
+
const href = mark.attrs?.href ?? "";
|
|
43421
|
+
open += `<a href="${this.escapeAttr(href)}">`;
|
|
43422
|
+
close = `</a>${close}`;
|
|
43423
|
+
} else {
|
|
43424
|
+
const tag = MARK_TO_TAG[mark.type];
|
|
43425
|
+
if (tag) {
|
|
43426
|
+
open += `<${tag}>`;
|
|
43427
|
+
close = `</${tag}>${close}`;
|
|
43428
|
+
}
|
|
43429
|
+
}
|
|
43430
|
+
}
|
|
43431
|
+
return `${open}${text}${close}`;
|
|
43432
|
+
}
|
|
43433
|
+
// --- lists ----------------------------------------------------------------
|
|
43434
|
+
listToHtml(node) {
|
|
43435
|
+
const { tag, attrs } = this.listTag(node);
|
|
43436
|
+
const items = (node.content ?? []).map((item) => this.listItemToHtml(item, node.type === "taskList")).join("");
|
|
43437
|
+
return `<${tag}${attrs}>${items}</${tag}>`;
|
|
43438
|
+
}
|
|
43439
|
+
listTag(node) {
|
|
43440
|
+
const start = node.attrs?.start;
|
|
43441
|
+
const startAttr = typeof start === "number" && start !== 1 ? ` start="${start}"` : "";
|
|
43442
|
+
switch (node.type) {
|
|
43443
|
+
case "orderedList":
|
|
43444
|
+
return { tag: "ol", attrs: startAttr };
|
|
43445
|
+
case "orderedListRoman":
|
|
43446
|
+
return { tag: "ol", attrs: ` type="I"${startAttr}` };
|
|
43447
|
+
case "orderedListRomanLower":
|
|
43448
|
+
return { tag: "ol", attrs: ` type="i"${startAttr}` };
|
|
43449
|
+
case "letteredList":
|
|
43450
|
+
return { tag: "ol", attrs: ` type="A"${startAttr}` };
|
|
43451
|
+
case "letteredListLower":
|
|
43452
|
+
return { tag: "ol", attrs: ` type="a"${startAttr}` };
|
|
43453
|
+
case "noBulletList":
|
|
43454
|
+
return { tag: "ul", attrs: ' style="list-style:none"' };
|
|
43455
|
+
case "taskList":
|
|
43456
|
+
case "bulletList":
|
|
43457
|
+
default:
|
|
43458
|
+
return { tag: "ul", attrs: "" };
|
|
43459
|
+
}
|
|
43460
|
+
}
|
|
43461
|
+
listItemToHtml(item, task) {
|
|
43462
|
+
const inner = (item.content ?? []).map((b) => {
|
|
43463
|
+
if (b.type === "paragraph") return this.inlineToHtml(b.content ?? []);
|
|
43464
|
+
return this.blockToHtml(b);
|
|
43465
|
+
}).join("");
|
|
43466
|
+
if (task) {
|
|
43467
|
+
const checked = item.attrs?.checked ? " checked" : "";
|
|
43468
|
+
return `<li><input type="checkbox"${checked}>${inner}</li>`;
|
|
43469
|
+
}
|
|
43470
|
+
return `<li>${inner}</li>`;
|
|
43471
|
+
}
|
|
43472
|
+
// --- images ---------------------------------------------------------------
|
|
43473
|
+
imageToHtml(node) {
|
|
43474
|
+
const attrs = node.attrs ?? {};
|
|
43475
|
+
const parts = [];
|
|
43476
|
+
const src = attrs.src;
|
|
43477
|
+
parts.push(`src="${this.escapeAttr(typeof src === "string" ? src : "")}"`);
|
|
43478
|
+
if (typeof attrs.alt === "string") parts.push(`alt="${this.escapeAttr(attrs.alt)}"`);
|
|
43479
|
+
if (typeof attrs.title === "string") parts.push(`title="${this.escapeAttr(attrs.title)}"`);
|
|
43480
|
+
if (attrs.width != null) parts.push(`width="${attrs.width}"`);
|
|
43481
|
+
if (attrs.height != null) parts.push(`height="${attrs.height}"`);
|
|
43482
|
+
if (typeof attrs.class === "string" && attrs.class) {
|
|
43483
|
+
parts.push(`class="${this.escapeAttr(attrs.class)}"`);
|
|
43484
|
+
}
|
|
43485
|
+
return `<img ${parts.join(" ")}>`;
|
|
43486
|
+
}
|
|
43487
|
+
// --- escaping -------------------------------------------------------------
|
|
43488
|
+
escapeText(text) {
|
|
43489
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
43490
|
+
}
|
|
43491
|
+
escapeAttr(text) {
|
|
43492
|
+
return this.escapeText(text).replace(/"/g, """);
|
|
43493
|
+
}
|
|
43494
|
+
};
|
|
43495
|
+
|
|
43496
|
+
// src/parser/html/HtmlDom.ts
|
|
43497
|
+
var VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
43498
|
+
"area",
|
|
43499
|
+
"base",
|
|
43500
|
+
"br",
|
|
43501
|
+
"col",
|
|
43502
|
+
"embed",
|
|
43503
|
+
"hr",
|
|
43504
|
+
"img",
|
|
43505
|
+
"input",
|
|
43506
|
+
"link",
|
|
43507
|
+
"meta",
|
|
43508
|
+
"param",
|
|
43509
|
+
"source",
|
|
43510
|
+
"track",
|
|
43511
|
+
"wbr"
|
|
43512
|
+
]);
|
|
43513
|
+
var IMPLIED_CLOSE = {
|
|
43514
|
+
li: /* @__PURE__ */ new Set(["li"]),
|
|
43515
|
+
td: /* @__PURE__ */ new Set(["td", "th"]),
|
|
43516
|
+
th: /* @__PURE__ */ new Set(["td", "th"]),
|
|
43517
|
+
tr: /* @__PURE__ */ new Set(["td", "th", "tr"]),
|
|
43518
|
+
thead: /* @__PURE__ */ new Set(["td", "th", "tr", "thead", "tbody", "tfoot"]),
|
|
43519
|
+
tbody: /* @__PURE__ */ new Set(["td", "th", "tr", "thead", "tbody", "tfoot"]),
|
|
43520
|
+
tfoot: /* @__PURE__ */ new Set(["td", "th", "tr", "thead", "tbody", "tfoot"]),
|
|
43521
|
+
p: /* @__PURE__ */ new Set(["p"]),
|
|
43522
|
+
option: /* @__PURE__ */ new Set(["option"])
|
|
43523
|
+
};
|
|
43524
|
+
var TAG_RE = /<(\/)?([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:"[^"]*"|'[^']*'|[^<>"'])*)?)(\/)?>/g;
|
|
43525
|
+
var ATTR_RE = /([a-zA-Z_:][a-zA-Z0-9:._-]*)(?:\s*=\s*("[^"]*"|'[^']*'|[^\s"'>]+))?/g;
|
|
43526
|
+
function parseAttrs(raw) {
|
|
43527
|
+
const attrs = {};
|
|
43528
|
+
if (!raw) return attrs;
|
|
43529
|
+
ATTR_RE.lastIndex = 0;
|
|
43530
|
+
let m;
|
|
43531
|
+
while ((m = ATTR_RE.exec(raw)) !== null) {
|
|
43532
|
+
const name = m[1].toLowerCase();
|
|
43533
|
+
let value = m[2] ?? "";
|
|
43534
|
+
if (value.length >= 2 && (value[0] === '"' || value[0] === "'")) {
|
|
43535
|
+
value = value.slice(1, -1);
|
|
43536
|
+
}
|
|
43537
|
+
attrs[name] = value;
|
|
43538
|
+
}
|
|
43539
|
+
return attrs;
|
|
43540
|
+
}
|
|
43541
|
+
function stripNonContent(html) {
|
|
43542
|
+
return html.replace(/<!--[\s\S]*?-->/g, "").replace(/<!\[CDATA\[[\s\S]*?\]\]>/g, "").replace(/<!doctype[^>]*>/gi, "").replace(/<script\b[\s\S]*?<\/script>/gi, "").replace(/<style\b[\s\S]*?<\/style>/gi, "");
|
|
43543
|
+
}
|
|
43544
|
+
function tokenize(html) {
|
|
43545
|
+
const tokens = [];
|
|
43546
|
+
const clean = stripNonContent(html);
|
|
43547
|
+
TAG_RE.lastIndex = 0;
|
|
43548
|
+
let lastIndex = 0;
|
|
43549
|
+
let m;
|
|
43550
|
+
while ((m = TAG_RE.exec(clean)) !== null) {
|
|
43551
|
+
if (m.index > lastIndex) {
|
|
43552
|
+
tokens.push({ kind: "text", text: clean.slice(lastIndex, m.index) });
|
|
43553
|
+
}
|
|
43554
|
+
lastIndex = TAG_RE.lastIndex;
|
|
43555
|
+
const isClose = m[1] === "/";
|
|
43556
|
+
const name = m[2].toLowerCase();
|
|
43557
|
+
if (isClose) {
|
|
43558
|
+
tokens.push({ kind: "close", name });
|
|
43559
|
+
} else {
|
|
43560
|
+
tokens.push({
|
|
43561
|
+
kind: "open",
|
|
43562
|
+
name,
|
|
43563
|
+
attrs: parseAttrs(m[3]),
|
|
43564
|
+
selfClose: m[4] === "/"
|
|
43565
|
+
});
|
|
43566
|
+
}
|
|
43567
|
+
}
|
|
43568
|
+
if (lastIndex < clean.length) {
|
|
43569
|
+
tokens.push({ kind: "text", text: clean.slice(lastIndex) });
|
|
43570
|
+
}
|
|
43571
|
+
return tokens;
|
|
43572
|
+
}
|
|
43573
|
+
function parseHtml(html) {
|
|
43574
|
+
const root = { type: "element", name: "#root", attrs: {}, children: [] };
|
|
43575
|
+
const stack = [root];
|
|
43576
|
+
const top = () => stack[stack.length - 1];
|
|
43577
|
+
for (const token of tokenize(html)) {
|
|
43578
|
+
if (token.kind === "text") {
|
|
43579
|
+
if (token.text) top().children.push({ type: "text", value: token.text });
|
|
43580
|
+
continue;
|
|
43581
|
+
}
|
|
43582
|
+
if (token.kind === "open") {
|
|
43583
|
+
const name = token.name;
|
|
43584
|
+
const closes = IMPLIED_CLOSE[name];
|
|
43585
|
+
if (closes) {
|
|
43586
|
+
while (stack.length > 1 && closes.has(top().name)) stack.pop();
|
|
43587
|
+
}
|
|
43588
|
+
const el = {
|
|
43589
|
+
type: "element",
|
|
43590
|
+
name,
|
|
43591
|
+
attrs: token.attrs ?? {},
|
|
43592
|
+
children: []
|
|
43593
|
+
};
|
|
43594
|
+
top().children.push(el);
|
|
43595
|
+
if (!token.selfClose && !VOID_ELEMENTS.has(name)) {
|
|
43596
|
+
stack.push(el);
|
|
43597
|
+
}
|
|
43598
|
+
continue;
|
|
43599
|
+
}
|
|
43600
|
+
for (let i = stack.length - 1; i > 0; i--) {
|
|
43601
|
+
if (stack[i].name === token.name) {
|
|
43602
|
+
stack.length = i;
|
|
43603
|
+
break;
|
|
43604
|
+
}
|
|
43605
|
+
}
|
|
43606
|
+
}
|
|
43607
|
+
return root.children;
|
|
43608
|
+
}
|
|
43609
|
+
function childElements(el, names) {
|
|
43610
|
+
return el.children.filter((c) => c.type === "element" && names.has(c.name));
|
|
43611
|
+
}
|
|
43612
|
+
|
|
43613
|
+
// src/parser/html/HtmlTableParser.ts
|
|
43614
|
+
var MARK_TAGS = {
|
|
43615
|
+
b: "bold",
|
|
43616
|
+
strong: "bold",
|
|
43617
|
+
i: "italic",
|
|
43618
|
+
em: "italic",
|
|
43619
|
+
sup: "superscript",
|
|
43620
|
+
sub: "subscript",
|
|
43621
|
+
s: "strike",
|
|
43622
|
+
strike: "strike",
|
|
43623
|
+
del: "del",
|
|
43624
|
+
ins: "ins",
|
|
43625
|
+
u: "underline",
|
|
43626
|
+
mark: "highlight",
|
|
43627
|
+
code: "code"
|
|
43628
|
+
};
|
|
43629
|
+
var SECTION_TAGS = /* @__PURE__ */ new Set(["thead", "tbody", "tfoot"]);
|
|
43630
|
+
var ROW_TAGS = /* @__PURE__ */ new Set(["tr"]);
|
|
43631
|
+
var CELL_TAGS = /* @__PURE__ */ new Set(["td", "th"]);
|
|
43632
|
+
var LI_TAGS = /* @__PURE__ */ new Set(["li"]);
|
|
43633
|
+
var VALID_SCOPES = /* @__PURE__ */ new Set(["row", "col", "rowgroup", "colgroup"]);
|
|
43634
|
+
var NAMED_ENTITIES = {
|
|
43635
|
+
amp: "&",
|
|
43636
|
+
lt: "<",
|
|
43637
|
+
gt: ">",
|
|
43638
|
+
quot: '"',
|
|
43639
|
+
apos: "'",
|
|
43640
|
+
nbsp: "\xA0"
|
|
43641
|
+
};
|
|
43642
|
+
function decodeEntities(text) {
|
|
43643
|
+
return text.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z][a-zA-Z0-9]*);/g, (whole, body) => {
|
|
43644
|
+
if (body[0] === "#") {
|
|
43645
|
+
const code = body[1] === "x" || body[1] === "X" ? Number.parseInt(body.slice(2), 16) : Number.parseInt(body.slice(1), 10);
|
|
43646
|
+
if (Number.isFinite(code) && code >= 0 && code <= 1114111) {
|
|
43647
|
+
try {
|
|
43648
|
+
return String.fromCodePoint(code);
|
|
43649
|
+
} catch {
|
|
43650
|
+
return whole;
|
|
43651
|
+
}
|
|
43652
|
+
}
|
|
43653
|
+
return whole;
|
|
43654
|
+
}
|
|
43655
|
+
return NAMED_ENTITIES[body] ?? whole;
|
|
43656
|
+
});
|
|
43657
|
+
}
|
|
43658
|
+
function intAttr(value) {
|
|
43659
|
+
if (value == null) return void 0;
|
|
43660
|
+
const n = Number.parseInt(value, 10);
|
|
43661
|
+
return Number.isInteger(n) ? n : void 0;
|
|
43662
|
+
}
|
|
43663
|
+
function isElement(node) {
|
|
43664
|
+
return node.type === "element";
|
|
43665
|
+
}
|
|
43666
|
+
var HtmlTableParser2 = class {
|
|
43667
|
+
constructor() {
|
|
43668
|
+
__publicField(this, "keepUnknownTags", false);
|
|
43669
|
+
}
|
|
43670
|
+
/**
|
|
43671
|
+
* Parse an HTML string and return one table bit per top-level `<table>`.
|
|
43672
|
+
*/
|
|
43673
|
+
parse(html, options) {
|
|
43674
|
+
this.keepUnknownTags = options?.keepUnknownTags ?? false;
|
|
43675
|
+
const tableFormat = options?.tableFormat ?? "table-extended";
|
|
43676
|
+
const onWarning = options?.onWarning;
|
|
43677
|
+
const tables = this.collectTopLevelTables(parseHtml(html));
|
|
43678
|
+
const bits = [];
|
|
43679
|
+
for (const table of tables) {
|
|
43680
|
+
const bit = this.tableToBit(table, tableFormat, onWarning);
|
|
43681
|
+
if (bit) bits.push(bit);
|
|
43682
|
+
}
|
|
43683
|
+
return bits;
|
|
43684
|
+
}
|
|
43685
|
+
// --- table extraction -----------------------------------------------------
|
|
43686
|
+
/** Collect every `<table>` element, NOT descending into nested tables. */
|
|
43687
|
+
collectTopLevelTables(nodes) {
|
|
43688
|
+
const tables = [];
|
|
43689
|
+
const visit = (node) => {
|
|
43690
|
+
if (!isElement(node)) return;
|
|
43691
|
+
if (node.name === "table") {
|
|
43692
|
+
tables.push(node);
|
|
43693
|
+
return;
|
|
43694
|
+
}
|
|
43695
|
+
node.children.forEach(visit);
|
|
43696
|
+
};
|
|
43697
|
+
nodes.forEach(visit);
|
|
43698
|
+
return tables;
|
|
43699
|
+
}
|
|
43700
|
+
tableToBit(table, tableFormat, onWarning) {
|
|
43701
|
+
const header = [];
|
|
43702
|
+
const body = [];
|
|
43703
|
+
const footer = [];
|
|
43704
|
+
let caption;
|
|
43705
|
+
for (const child of table.children) {
|
|
43706
|
+
if (!isElement(child)) continue;
|
|
43707
|
+
if (child.name === "caption") {
|
|
43708
|
+
const capContent = this.inlineNodes(child.children, []);
|
|
43709
|
+
const trimmed = this.trimInline(capContent);
|
|
43710
|
+
if (trimmed.length > 0) caption = trimmed;
|
|
43711
|
+
} else if (SECTION_TAGS.has(child.name)) {
|
|
43712
|
+
const target = child.name === "thead" ? header : child.name === "tfoot" ? footer : body;
|
|
43713
|
+
for (const tr of childElements(child, ROW_TAGS)) {
|
|
43714
|
+
target.push(this.rowToCells(tr));
|
|
43715
|
+
}
|
|
43716
|
+
} else if (ROW_TAGS.has(child.name)) {
|
|
43717
|
+
body.push(this.rowToCells(child));
|
|
43718
|
+
}
|
|
43719
|
+
}
|
|
43720
|
+
if (header.length === 0 && body.length === 0 && footer.length === 0) {
|
|
43721
|
+
return void 0;
|
|
43722
|
+
}
|
|
43723
|
+
const tableExtended = {};
|
|
43724
|
+
if (header.length > 0) tableExtended.header = { rows: header };
|
|
43725
|
+
if (body.length > 0) tableExtended.body = { rows: body };
|
|
43726
|
+
if (footer.length > 0) tableExtended.footer = { rows: footer };
|
|
43727
|
+
let tableData = tableExtended;
|
|
43728
|
+
if (tableFormat === "table") {
|
|
43729
|
+
if (this.isLossyAsBasic(tableExtended)) {
|
|
43730
|
+
onWarning?.(
|
|
43731
|
+
"Converting an HTML table to [.table] loses rowspan/colspan/scope and multi-section structure; use --tableFormat table-extended to preserve them."
|
|
43732
|
+
);
|
|
43733
|
+
}
|
|
43734
|
+
tableData = convertExtendedToBasicTableFormat(tableExtended);
|
|
43735
|
+
}
|
|
43736
|
+
const bit = {
|
|
43737
|
+
type: tableFormat,
|
|
43738
|
+
format: "bitmark++",
|
|
43739
|
+
table: tableData
|
|
43740
|
+
};
|
|
43741
|
+
if (caption) bit.caption = caption;
|
|
43742
|
+
return bit;
|
|
43743
|
+
}
|
|
43744
|
+
rowToCells(tr) {
|
|
43745
|
+
const cells = [];
|
|
43746
|
+
for (const cell of childElements(tr, CELL_TAGS)) {
|
|
43747
|
+
cells.push(this.cellToJson(cell));
|
|
43748
|
+
}
|
|
43749
|
+
return { cells };
|
|
43750
|
+
}
|
|
43751
|
+
cellToJson(cell) {
|
|
43752
|
+
const json = {
|
|
43753
|
+
content: this.blockNodes(cell.children)
|
|
43754
|
+
};
|
|
43755
|
+
if (cell.name === "th") json.title = true;
|
|
43756
|
+
const rowspan = intAttr(cell.attrs.rowspan);
|
|
43757
|
+
if (rowspan != null && rowspan >= 2) json.rowspan = rowspan;
|
|
43758
|
+
const colspan = intAttr(cell.attrs.colspan);
|
|
43759
|
+
if (colspan != null && colspan >= 2) json.colspan = colspan;
|
|
43760
|
+
const scope = cell.attrs.scope?.toLowerCase();
|
|
43761
|
+
if (scope && VALID_SCOPES.has(scope)) {
|
|
43762
|
+
json.scope = scope;
|
|
43763
|
+
}
|
|
43764
|
+
const width = this.widthFromCell(cell);
|
|
43765
|
+
if (width != null) json.colwidth = width;
|
|
43766
|
+
return json;
|
|
43767
|
+
}
|
|
43768
|
+
widthFromCell(cell) {
|
|
43769
|
+
const attrWidth = intAttr(cell.attrs.width);
|
|
43770
|
+
if (attrWidth != null && attrWidth > 0) return attrWidth;
|
|
43771
|
+
const style = cell.attrs.style;
|
|
43772
|
+
if (style) {
|
|
43773
|
+
const m = style.match(/width\s*:\s*(\d+)\s*px/i);
|
|
43774
|
+
if (m) {
|
|
43775
|
+
const n = Number.parseInt(m[1], 10);
|
|
43776
|
+
if (Number.isInteger(n) && n > 0) return n;
|
|
43777
|
+
}
|
|
43778
|
+
}
|
|
43779
|
+
return void 0;
|
|
43780
|
+
}
|
|
43781
|
+
isLossyAsBasic(table) {
|
|
43782
|
+
if (table.footer) return true;
|
|
43783
|
+
if (table.header && table.header.rows.length > 1) return true;
|
|
43784
|
+
const sections = [table.header, table.body, table.footer];
|
|
43785
|
+
for (const section of sections) {
|
|
43786
|
+
if (!section) continue;
|
|
43787
|
+
for (const row of section.rows) {
|
|
43788
|
+
for (const cell of row.cells) {
|
|
43789
|
+
if (cell.rowspan || cell.colspan || cell.scope) return true;
|
|
43790
|
+
}
|
|
43791
|
+
}
|
|
43792
|
+
}
|
|
43793
|
+
return false;
|
|
43794
|
+
}
|
|
43795
|
+
// --- content conversion (HTML -> TextAst) ---------------------------------
|
|
43796
|
+
/**
|
|
43797
|
+
* Convert a cell/li's child nodes into block-level TextAst nodes (paragraphs, lists, images).
|
|
43798
|
+
*/
|
|
43799
|
+
blockNodes(nodes) {
|
|
43800
|
+
const blocks = [];
|
|
43801
|
+
let inline = [];
|
|
43802
|
+
const flush = () => {
|
|
43803
|
+
const trimmed = this.trimInline(inline);
|
|
43804
|
+
inline = [];
|
|
43805
|
+
if (trimmed.length === 0) return;
|
|
43806
|
+
if (trimmed.length === 1 && trimmed[0].type === "imageInline") {
|
|
43807
|
+
blocks.push({ ...trimmed[0], type: "image" });
|
|
43808
|
+
} else {
|
|
43809
|
+
blocks.push({ type: "paragraph", content: trimmed, attrs: {} });
|
|
43810
|
+
}
|
|
43811
|
+
};
|
|
43812
|
+
for (const node of nodes) {
|
|
43813
|
+
if (!isElement(node)) {
|
|
43814
|
+
inline.push(...this.inlineText(node.value, []));
|
|
43815
|
+
continue;
|
|
43816
|
+
}
|
|
43817
|
+
const name = node.name;
|
|
43818
|
+
if (name === "p") {
|
|
43819
|
+
flush();
|
|
43820
|
+
const content = this.trimInline(this.inlineNodes(node.children, []));
|
|
43821
|
+
if (content.length > 0) {
|
|
43822
|
+
blocks.push({ type: "paragraph", content, attrs: {} });
|
|
43823
|
+
}
|
|
43824
|
+
} else if (this.isListTag(name)) {
|
|
43825
|
+
flush();
|
|
43826
|
+
const list = this.listNode(node);
|
|
43827
|
+
if (list) blocks.push(list);
|
|
43828
|
+
} else {
|
|
43829
|
+
inline.push(...this.inlineFromElement(node, []));
|
|
43830
|
+
}
|
|
43831
|
+
}
|
|
43832
|
+
flush();
|
|
43833
|
+
return blocks;
|
|
43834
|
+
}
|
|
43835
|
+
/** Convert child nodes to a flat list of inline TextNodes, applying the given marks. */
|
|
43836
|
+
inlineNodes(nodes, marks) {
|
|
43837
|
+
const out = [];
|
|
43838
|
+
for (const node of nodes) {
|
|
43839
|
+
if (!isElement(node)) {
|
|
43840
|
+
out.push(...this.inlineText(node.value, marks));
|
|
43841
|
+
} else {
|
|
43842
|
+
out.push(...this.inlineFromElement(node, marks));
|
|
43843
|
+
}
|
|
43844
|
+
}
|
|
43845
|
+
return out;
|
|
43846
|
+
}
|
|
43847
|
+
inlineFromElement(el, marks) {
|
|
43848
|
+
const name = el.name;
|
|
43849
|
+
if (name === "br") {
|
|
43850
|
+
return [{ type: "hardBreak" }];
|
|
43851
|
+
}
|
|
43852
|
+
if (name === "img") {
|
|
43853
|
+
return [this.imageNode(el, true)];
|
|
43854
|
+
}
|
|
43855
|
+
const markType = MARK_TAGS[name];
|
|
43856
|
+
if (markType) {
|
|
43857
|
+
return this.inlineNodes(el.children, [...marks, { type: markType }]);
|
|
43858
|
+
}
|
|
43859
|
+
if (name === "a") {
|
|
43860
|
+
const linkMark = {
|
|
43861
|
+
type: "link",
|
|
43862
|
+
attrs: {
|
|
43863
|
+
href: el.attrs.href ?? "",
|
|
43864
|
+
...el.attrs.target ? { target: el.attrs.target } : {}
|
|
43865
|
+
}
|
|
43866
|
+
};
|
|
43867
|
+
return this.inlineNodes(el.children, [...marks, linkMark]);
|
|
43868
|
+
}
|
|
43869
|
+
if (this.keepUnknownTags) {
|
|
43870
|
+
const open = this.serializeOpenTag(el);
|
|
43871
|
+
const close = `</${name}>`;
|
|
43872
|
+
return [
|
|
43873
|
+
...this.inlineText(open, marks),
|
|
43874
|
+
...this.inlineNodes(el.children, marks),
|
|
43875
|
+
...this.inlineText(close, marks)
|
|
43876
|
+
];
|
|
43877
|
+
}
|
|
43878
|
+
return this.inlineNodes(el.children, marks);
|
|
43879
|
+
}
|
|
43880
|
+
inlineText(raw, marks) {
|
|
43881
|
+
const text = decodeEntities(raw).replace(/\s+/g, " ");
|
|
43882
|
+
if (text === "") return [];
|
|
43883
|
+
const node = { text, type: "text" };
|
|
43884
|
+
if (marks.length > 0) node.marks = marks.map((m) => ({ ...m }));
|
|
43885
|
+
return [node];
|
|
43886
|
+
}
|
|
43887
|
+
serializeOpenTag(el) {
|
|
43888
|
+
const attrs = Object.entries(el.attrs).map(([k, v]) => v === "" ? ` ${k}` : ` ${k}="${v}"`).join("");
|
|
43889
|
+
return `<${el.name}${attrs}>`;
|
|
43890
|
+
}
|
|
43891
|
+
// --- lists ----------------------------------------------------------------
|
|
43892
|
+
isListTag(name) {
|
|
43893
|
+
return name === "ul" || name === "ol";
|
|
43894
|
+
}
|
|
43895
|
+
listNode(el) {
|
|
43896
|
+
const items = childElements(el, LI_TAGS);
|
|
43897
|
+
if (items.length === 0) return void 0;
|
|
43898
|
+
const isTask = el.name === "ul" && items.some((li) => {
|
|
43899
|
+
const firstEl = li.children.find(isElement);
|
|
43900
|
+
return firstEl?.name === "input" && firstEl.attrs.type?.toLowerCase() === "checkbox";
|
|
43901
|
+
});
|
|
43902
|
+
if (isTask) {
|
|
43903
|
+
return {
|
|
43904
|
+
type: "taskList",
|
|
43905
|
+
content: items.map((li) => this.taskItemNode(li))
|
|
43906
|
+
};
|
|
43907
|
+
}
|
|
43908
|
+
const type = this.listType(el);
|
|
43909
|
+
const node = {
|
|
43910
|
+
type,
|
|
43911
|
+
content: items.map((li) => this.listItemNode(li))
|
|
43912
|
+
};
|
|
43913
|
+
if (el.name === "ol") {
|
|
43914
|
+
const start = intAttr(el.attrs.start);
|
|
43915
|
+
if (start != null) {
|
|
43916
|
+
node.attrs = { start };
|
|
43917
|
+
}
|
|
43918
|
+
}
|
|
43919
|
+
return node;
|
|
43920
|
+
}
|
|
43921
|
+
listType(el) {
|
|
43922
|
+
if (el.name === "ol") {
|
|
43923
|
+
switch (el.attrs.type) {
|
|
43924
|
+
case "i":
|
|
43925
|
+
return "orderedListRomanLower";
|
|
43926
|
+
case "I":
|
|
43927
|
+
return "orderedListRoman";
|
|
43928
|
+
case "a":
|
|
43929
|
+
return "letteredListLower";
|
|
43930
|
+
case "A":
|
|
43931
|
+
return "letteredList";
|
|
43932
|
+
default:
|
|
43933
|
+
return "orderedList";
|
|
43934
|
+
}
|
|
43935
|
+
}
|
|
43936
|
+
const style = el.attrs.style ?? "";
|
|
43937
|
+
if (/list-style(-type)?\s*:\s*none/i.test(style)) return "noBulletList";
|
|
43938
|
+
return "bulletList";
|
|
43939
|
+
}
|
|
43940
|
+
listItemNode(li) {
|
|
43941
|
+
let content = this.blockNodes(li.children);
|
|
43942
|
+
if (content.length === 0) {
|
|
43943
|
+
content = [{ type: "paragraph", content: [], attrs: {} }];
|
|
43944
|
+
}
|
|
43945
|
+
return { type: "listItem", content };
|
|
43946
|
+
}
|
|
43947
|
+
taskItemNode(li) {
|
|
43948
|
+
const checkbox = li.children.find(
|
|
43949
|
+
(c) => isElement(c) && c.name === "input" && c.attrs.type?.toLowerCase() === "checkbox"
|
|
43950
|
+
);
|
|
43951
|
+
const checked = checkbox ? "checked" in checkbox.attrs : false;
|
|
43952
|
+
const rest = li.children.filter((c) => c !== checkbox);
|
|
43953
|
+
let content = this.blockNodes(rest);
|
|
43954
|
+
if (content.length === 0) {
|
|
43955
|
+
content = [{ type: "paragraph", content: [], attrs: {} }];
|
|
43956
|
+
}
|
|
43957
|
+
return { type: "taskItem", attrs: { checked }, content };
|
|
43958
|
+
}
|
|
43959
|
+
// --- images ---------------------------------------------------------------
|
|
43960
|
+
imageNode(el, inline) {
|
|
43961
|
+
const attrs = { src: el.attrs.src ?? "" };
|
|
43962
|
+
attrs.alt = el.attrs.alt ?? null;
|
|
43963
|
+
attrs.title = el.attrs.title ?? null;
|
|
43964
|
+
const width = intAttr(el.attrs.width);
|
|
43965
|
+
if (width != null) attrs.width = width;
|
|
43966
|
+
const height = intAttr(el.attrs.height);
|
|
43967
|
+
if (height != null) attrs.height = height;
|
|
43968
|
+
if (el.attrs.class) attrs.class = el.attrs.class;
|
|
43969
|
+
return { type: inline ? "imageInline" : "image", attrs };
|
|
43970
|
+
}
|
|
43971
|
+
// --- whitespace -----------------------------------------------------------
|
|
43972
|
+
/** Trim leading/trailing whitespace from inline content (edges only). */
|
|
43973
|
+
trimInline(nodes) {
|
|
43974
|
+
const out = nodes.slice();
|
|
43975
|
+
const isWs = (n) => n.type === "text" && /^\s*$/.test(n.text ?? "");
|
|
43976
|
+
while (out.length > 0 && isWs(out[0])) out.shift();
|
|
43977
|
+
if (out.length > 0 && out[0].type === "text") {
|
|
43978
|
+
out[0] = { ...out[0], text: (out[0].text ?? "").replace(/^\s+/, "") };
|
|
43979
|
+
}
|
|
43980
|
+
while (out.length > 0 && isWs(out[out.length - 1])) out.pop();
|
|
43981
|
+
if (out.length > 0 && out[out.length - 1].type === "text") {
|
|
43982
|
+
const last = out.length - 1;
|
|
43983
|
+
out[last] = { ...out[last], text: (out[last].text ?? "").replace(/\s+$/, "") };
|
|
43984
|
+
}
|
|
43985
|
+
return out.filter((n) => !(n.type === "text" && n.text === ""));
|
|
43986
|
+
}
|
|
43987
|
+
};
|
|
43988
|
+
|
|
42973
43989
|
// src/index.ts
|
|
42974
43990
|
init();
|
|
42975
43991
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -42986,6 +44002,8 @@ init();
|
|
|
42986
44002
|
BoundingBoxIndex,
|
|
42987
44003
|
Builder,
|
|
42988
44004
|
CardSetVersion,
|
|
44005
|
+
HtmlTableGenerator,
|
|
44006
|
+
HtmlTableParser,
|
|
42989
44007
|
InfoFormat,
|
|
42990
44008
|
InfoType,
|
|
42991
44009
|
Input,
|