pro-editor-schema 0.1.1 → 0.1.13

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.js CHANGED
@@ -50,7 +50,6 @@ __export(index_exports, {
50
50
  DELETION_SCHEMA: () => DELETION_SCHEMA,
51
51
  DIALOGUE_SCHEMA: () => DIALOGUE_SCHEMA,
52
52
  DIALOGUE_TAG: () => DIALOGUE_TAG,
53
- ELEMENT_ROLE: () => ELEMENT_ROLE,
54
53
  ELEMENT_SCHEMAS: () => ELEMENT_SCHEMAS,
55
54
  ELEMENT_TAGS: () => ELEMENT_TAGS,
56
55
  ELE_ID_ATTRIBUTE: () => ELE_ID_ATTRIBUTE,
@@ -205,28 +204,38 @@ __export(index_exports, {
205
204
  U_SCHEMA: () => U_SCHEMA,
206
205
  createElement: () => createElement,
207
206
  findAttributeDefinitionByName: () => findAttributeDefinitionByName,
207
+ findSchemaByCode: () => findSchemaByCode,
208
208
  findSchemaByElement: () => findSchemaByElement,
209
- findSchemaByTag: () => findSchemaByTag,
210
209
  getAttributeName: () => getAttributeName,
211
210
  isAttributeRestricted: () => isAttributeRestricted,
212
211
  isIgnoredAttribute: () => isIgnoredAttribute,
213
- isIgnoredElement: () => isIgnoredElement
212
+ isIgnoredElement: () => isIgnoredElement,
213
+ validateAttributes: () => validateAttributes,
214
+ validateConsecutiveFootnoteCues: () => validateConsecutiveFootnoteCues,
215
+ validateConsecutiveFootnotes: () => validateConsecutiveFootnotes,
216
+ validateElement: () => validateElement,
217
+ validateElementAgainstSchema: () => validateElementAgainstSchema,
218
+ validateFootnoteCue: () => validateFootnoteCue,
219
+ validateFootnotes: () => validateFootnotes,
220
+ validateLinkend: () => validateLinkend,
221
+ validateLinkends: () => validateLinkends,
222
+ validateXml: () => validateXml
214
223
  });
215
224
  module.exports = __toCommonJS(index_exports);
216
225
 
217
226
  // src/schema/utils/createSchema.ts
218
227
  var createSchema = ({
228
+ code,
219
229
  kind,
220
230
  tag,
221
- role,
222
231
  requiredAttributes,
223
232
  optionalAttributes,
224
233
  allowedChildTagNames
225
234
  }) => {
226
235
  return {
236
+ code,
227
237
  kind,
228
238
  tag,
229
- role,
230
239
  requiredAttributes,
231
240
  optionalAttributes,
232
241
  allowedChildTagNames: new Set(allowedChildTagNames)
@@ -308,6 +317,7 @@ var ATOM_TAGS_ALLOWED_CHILDREN = [
308
317
 
309
318
  // src/schema/elementSchemas/atoms/b.ts
310
319
  var B_SCHEMA = createSchema({
320
+ code: "b",
311
321
  kind: "atom",
312
322
  tag: B_TAG,
313
323
  requiredAttributes: [...ID_ATTRS],
@@ -315,21 +325,11 @@ var B_SCHEMA = createSchema({
315
325
  allowedChildTagNames: [...ATOM_TAGS_ALLOWED_CHILDREN]
316
326
  });
317
327
 
318
- // src/schema/schema.types.ts
319
- var ELEMENT_ROLE = /* @__PURE__ */ ((ELEMENT_ROLE2) => {
320
- ELEMENT_ROLE2["QUERYCOMMENTSWRAPPER"] = "QUERYCOMMENTSWRAPPER";
321
- ELEMENT_ROLE2["HEADING"] = "HEADING";
322
- ELEMENT_ROLE2["FOOTNOTE"] = "FOOTNOTE";
323
- ELEMENT_ROLE2["INS"] = "INS";
324
- ELEMENT_ROLE2["DEL"] = "DEL";
325
- return ELEMENT_ROLE2;
326
- })(ELEMENT_ROLE || {});
327
-
328
328
  // src/schema/elementSchemas/atoms/commentQuerySection.ts
329
329
  var COMMENT_QUERY_SECTION_SCHEMA = createSchema({
330
330
  kind: "atom",
331
331
  tag: SPAN_TAG,
332
- role: "QUERYCOMMENTSWRAPPER" /* QUERYCOMMENTSWRAPPER */,
332
+ code: "commentQuerySection",
333
333
  requiredAttributes: [...ID_ATTRS, "id"],
334
334
  optionalAttributes: [...TRACK_CHANGES_ATTRS, "title"],
335
335
  allowedChildTagNames: [...ATOM_TAGS_ALLOWED_CHILDREN]
@@ -338,7 +338,7 @@ var COMMENT_QUERY_SECTION_SCHEMA = createSchema({
338
338
  // src/schema/elementSchemas/inlineElements/inlineElementsTags.ts
339
339
  var FOOTNOTE_LINK_TAG = "FOOTNOTE1";
340
340
  var INLINEEQUATION_TAG = "INLINEEQUATION";
341
- var LINK_TAG = "LINK";
341
+ var LINK_TAG = "LINK1";
342
342
  var URI_TAG = "URI";
343
343
  var INLINE_ELEMENT_TAGS_ALLOWED_CHILDREN = [
344
344
  { tagName: FOOTNOTE_LINK_TAG, required: false },
@@ -349,9 +349,9 @@ var INLINE_ELEMENT_TAGS_ALLOWED_CHILDREN = [
349
349
 
350
350
  // src/schema/elementSchemas/atoms/deletion.ts
351
351
  var DELETION_SCHEMA = createSchema({
352
+ code: "deletion",
352
353
  kind: "atom",
353
354
  tag: SPAN_TAG,
354
- role: "DEL" /* DEL */,
355
355
  requiredAttributes: [...TRACK_CHANGES_ATTRS, ...ID_ATTRS],
356
356
  optionalAttributes: [],
357
357
  allowedChildTagNames: [
@@ -362,6 +362,7 @@ var DELETION_SCHEMA = createSchema({
362
362
 
363
363
  // src/schema/elementSchemas/atoms/emphasis.ts
364
364
  var EMPHASIS_SCHEMA = createSchema({
365
+ code: "emphasis",
365
366
  kind: "atom",
366
367
  tag: EMPHASIS_TAG,
367
368
  requiredAttributes: [...ID_ATTRS],
@@ -378,6 +379,7 @@ var EMPHASIS_SCHEMA = createSchema({
378
379
 
379
380
  // src/schema/elementSchemas/atoms/highlightmark.ts
380
381
  var HIGHLIGHTMARK_SCHEMA = createSchema({
382
+ code: "highlightmark",
381
383
  kind: "atom",
382
384
  tag: HIGHLIGHTMARK_TAG,
383
385
  requiredAttributes: [...ID_ATTRS],
@@ -387,6 +389,7 @@ var HIGHLIGHTMARK_SCHEMA = createSchema({
387
389
 
388
390
  // src/schema/elementSchemas/atoms/i.ts
389
391
  var I_SCHEMA = createSchema({
392
+ code: "i",
390
393
  kind: "atom",
391
394
  tag: I_TAG,
392
395
  requiredAttributes: [...ID_ATTRS],
@@ -396,9 +399,9 @@ var I_SCHEMA = createSchema({
396
399
 
397
400
  // src/schema/elementSchemas/atoms/insertion.ts
398
401
  var INSERTION_SCHEMA = createSchema({
402
+ code: "insertion",
399
403
  kind: "atom",
400
404
  tag: SPAN_TAG,
401
- role: "INS" /* INS */,
402
405
  requiredAttributes: [...TRACK_CHANGES_ATTRS, ...ID_ATTRS],
403
406
  optionalAttributes: [],
404
407
  allowedChildTagNames: [
@@ -409,6 +412,7 @@ var INSERTION_SCHEMA = createSchema({
409
412
 
410
413
  // src/schema/elementSchemas/atoms/sc.ts
411
414
  var SC_SCHEMA = createSchema({
415
+ code: "sc",
412
416
  kind: "atom",
413
417
  tag: SC_TAG,
414
418
  requiredAttributes: [...ID_ATTRS],
@@ -418,6 +422,7 @@ var SC_SCHEMA = createSchema({
418
422
 
419
423
  // src/schema/elementSchemas/atoms/strike.ts
420
424
  var STRIKE_SCHEMA = createSchema({
425
+ code: "strike",
421
426
  kind: "atom",
422
427
  tag: STRIKE_TAG,
423
428
  requiredAttributes: [...ID_ATTRS],
@@ -427,6 +432,7 @@ var STRIKE_SCHEMA = createSchema({
427
432
 
428
433
  // src/schema/elementSchemas/atoms/sub.ts
429
434
  var SUB_SCHEMA = createSchema({
435
+ code: "sub",
430
436
  kind: "atom",
431
437
  tag: SUB_TAG,
432
438
  requiredAttributes: [...ID_ATTRS],
@@ -436,6 +442,7 @@ var SUB_SCHEMA = createSchema({
436
442
 
437
443
  // src/schema/elementSchemas/atoms/sup.ts
438
444
  var SUP_SCHEMA = createSchema({
445
+ code: "sup",
439
446
  kind: "atom",
440
447
  tag: SUP_TAG,
441
448
  requiredAttributes: [...ID_ATTRS],
@@ -445,6 +452,7 @@ var SUP_SCHEMA = createSchema({
445
452
 
446
453
  // src/schema/elementSchemas/atoms/u.ts
447
454
  var U_SCHEMA = createSchema({
455
+ code: "u",
448
456
  kind: "atom",
449
457
  tag: U_TAG,
450
458
  requiredAttributes: [...ID_ATTRS],
@@ -454,6 +462,7 @@ var U_SCHEMA = createSchema({
454
462
 
455
463
  // src/schema/elementSchemas/atoms/content.ts
456
464
  var CONTENT_SCHEMA = createSchema({
465
+ code: "content",
457
466
  kind: "inline",
458
467
  tag: CONTENT_TAG,
459
468
  requiredAttributes: [...ID_ATTRS],
@@ -472,6 +481,7 @@ var CONTENT_SCHEMA = createSchema({
472
481
 
473
482
  // src/schema/elementSchemas/atoms/comment.ts
474
483
  var COMMENT_SCHEMA = createSchema({
484
+ code: "comment",
475
485
  kind: "inline",
476
486
  tag: COMMENT_TAG,
477
487
  requiredAttributes: [...ID_ATTRS, "id"],
@@ -494,6 +504,7 @@ var COMMENT_SCHEMA = createSchema({
494
504
 
495
505
  // src/schema/elementSchemas/atoms/query.ts
496
506
  var QUERY_SCHEMA = createSchema({
507
+ code: "query",
497
508
  kind: "inline",
498
509
  tag: QUERY_TAG,
499
510
  requiredAttributes: [...ID_ATTRS, "id"],
@@ -516,6 +527,7 @@ var QUERY_SCHEMA = createSchema({
516
527
 
517
528
  // src/schema/elementSchemas/atoms/reply.ts
518
529
  var REPLY_SCHEMA = createSchema({
530
+ code: "reply",
519
531
  kind: "inline",
520
532
  tag: REPLY_TAG,
521
533
  requiredAttributes: [...ID_ATTRS, "id"],
@@ -687,6 +699,7 @@ var GROUP_ELEMENTS_TAGS = [
687
699
 
688
700
  // src/schema/elementSchemas/elements/authors/authorgroup.ts
689
701
  var AUTHORGROUP_SCHEMA = createSchema({
702
+ code: "authorgroup",
690
703
  kind: "group",
691
704
  tag: AUTHORGROUP_TAG,
692
705
  requiredAttributes: [...ID_ATTRS],
@@ -699,6 +712,7 @@ var AUTHORGROUP_SCHEMA = createSchema({
699
712
 
700
713
  // src/schema/elementSchemas/elements/authors/author.ts
701
714
  var AUTHOR_SCHEMA = createSchema({
715
+ code: "author",
702
716
  kind: "group",
703
717
  tag: AUTHOR_TAG,
704
718
  requiredAttributes: [...ID_ATTRS],
@@ -715,6 +729,7 @@ var AUTHOR_SCHEMA = createSchema({
715
729
 
716
730
  // src/schema/elementSchemas/elements/authors/olink.ts
717
731
  var OLINK_SCHEMA = createSchema({
732
+ code: "olink",
718
733
  kind: "element",
719
734
  tag: OLINK_TAG,
720
735
  requiredAttributes: [...ID_ATTRS],
@@ -724,6 +739,7 @@ var OLINK_SCHEMA = createSchema({
724
739
 
725
740
  // src/schema/elementSchemas/elements/authors/personname.ts
726
741
  var PERSONNAME_SCHEMA = createSchema({
742
+ code: "personname",
727
743
  kind: "group",
728
744
  tag: PERSONNAME_TAG,
729
745
  requiredAttributes: [...ID_ATTRS],
@@ -737,6 +753,7 @@ var PERSONNAME_SCHEMA = createSchema({
737
753
 
738
754
  // src/schema/elementSchemas/elements/authors/firstname.ts
739
755
  var FIRSTNAME_SCHEMA = createSchema({
756
+ code: "firstname",
740
757
  kind: "element",
741
758
  tag: FIRSTNAME_TAG,
742
759
  requiredAttributes: [...ID_ATTRS],
@@ -746,6 +763,7 @@ var FIRSTNAME_SCHEMA = createSchema({
746
763
 
747
764
  // src/schema/elementSchemas/elements/authors/surname.ts
748
765
  var SURNAME_SCHEMA = createSchema({
766
+ code: "surname",
749
767
  kind: "element",
750
768
  tag: SURNAME_TAG,
751
769
  requiredAttributes: [...ID_ATTRS],
@@ -755,6 +773,7 @@ var SURNAME_SCHEMA = createSchema({
755
773
 
756
774
  // src/schema/elementSchemas/elements/authors/honorific.ts
757
775
  var HONORIFIC_SCHEMA = createSchema({
776
+ code: "honorific",
758
777
  kind: "element",
759
778
  tag: HONORIFIC_TAG,
760
779
  requiredAttributes: [...ID_ATTRS],
@@ -764,6 +783,7 @@ var HONORIFIC_SCHEMA = createSchema({
764
783
 
765
784
  // src/schema/elementSchemas/elements/authors/orgname.ts
766
785
  var ORGNAME_SCHEMA = createSchema({
786
+ code: "orgname",
767
787
  kind: "element",
768
788
  tag: ORGNAME_TAG,
769
789
  requiredAttributes: [...ID_ATTRS],
@@ -773,6 +793,7 @@ var ORGNAME_SCHEMA = createSchema({
773
793
 
774
794
  // src/schema/elementSchemas/elements/authors/email.ts
775
795
  var EMAIL_SCHEMA = createSchema({
796
+ code: "email",
776
797
  kind: "element",
777
798
  tag: EMAIL_TAG,
778
799
  requiredAttributes: [...ID_ATTRS],
@@ -782,6 +803,7 @@ var EMAIL_SCHEMA = createSchema({
782
803
 
783
804
  // src/schema/elementSchemas/elements/authors/org.ts
784
805
  var ORG_SCHEMA = createSchema({
806
+ code: "org",
785
807
  kind: "element",
786
808
  tag: ORG_TAG,
787
809
  requiredAttributes: [...ID_ATTRS],
@@ -791,6 +813,7 @@ var ORG_SCHEMA = createSchema({
791
813
 
792
814
  // src/schema/elementSchemas/elements/authors/affiliation.ts
793
815
  var AFFILIATION_SCHEMA = createSchema({
816
+ code: "affiliation",
794
817
  kind: "group",
795
818
  tag: AFFILIATION_TAG,
796
819
  requiredAttributes: [...ID_ATTRS],
@@ -800,6 +823,7 @@ var AFFILIATION_SCHEMA = createSchema({
800
823
 
801
824
  // src/schema/elementSchemas/elements/degrees.ts
802
825
  var DEGREES_SCHEMA = createSchema({
826
+ code: "degrees",
803
827
  kind: "element",
804
828
  tag: DEGREES_TAG,
805
829
  requiredAttributes: [...ID_ATTRS],
@@ -809,6 +833,7 @@ var DEGREES_SCHEMA = createSchema({
809
833
 
810
834
  // src/schema/elementSchemas/elements/dialogue/line.ts
811
835
  var LINE_SCHEMA = createSchema({
836
+ code: "line",
812
837
  kind: "element",
813
838
  tag: LINE_TAG,
814
839
  requiredAttributes: [...ID_ATTRS],
@@ -824,6 +849,7 @@ var LINE_SCHEMA = createSchema({
824
849
 
825
850
  // src/schema/elementSchemas/elements/dialogue/speaker.ts
826
851
  var SPEAKER_SCHEMA = createSchema({
852
+ code: "speaker",
827
853
  kind: "element",
828
854
  tag: SPEAKER_TAG,
829
855
  requiredAttributes: [...ID_ATTRS],
@@ -839,6 +865,7 @@ var SPEAKER_SCHEMA = createSchema({
839
865
 
840
866
  // src/schema/elementSchemas/elements/dialogue/dialogue.ts
841
867
  var DIALOGUE_SCHEMA = createSchema({
868
+ code: "dialogue",
842
869
  kind: "group",
843
870
  tag: DIALOGUE_TAG,
844
871
  requiredAttributes: [...ID_ATTRS],
@@ -858,6 +885,7 @@ var DIALOGUE_SCHEMA = createSchema({
858
885
 
859
886
  // src/schema/elementSchemas/elements/equation.ts
860
887
  var EQUATION_SCHEMA = createSchema({
888
+ code: "equation",
861
889
  kind: "element",
862
890
  tag: EQUATION_TAG,
863
891
  requiredAttributes: [],
@@ -867,6 +895,7 @@ var EQUATION_SCHEMA = createSchema({
867
895
 
868
896
  // src/schema/elementSchemas/elements/figure/img.ts
869
897
  var IMG_SCHEMA = createSchema({
898
+ code: "img",
870
899
  kind: "element",
871
900
  tag: IMG_TAG,
872
901
  requiredAttributes: [...ID_ATTRS, "src", "format"],
@@ -887,6 +916,7 @@ var IMG_SCHEMA = createSchema({
887
916
 
888
917
  // src/schema/elementSchemas/elements/figure/alttext.ts
889
918
  var ALTTEXT_SCHEMA = createSchema({
919
+ code: "alttext",
890
920
  kind: "group",
891
921
  tag: ALTTEXT_TAG,
892
922
  requiredAttributes: [],
@@ -896,6 +926,7 @@ var ALTTEXT_SCHEMA = createSchema({
896
926
 
897
927
  // src/schema/elementSchemas/elements/figure/imageobject.ts
898
928
  var IMAGEOBJECT_SCHEMA = createSchema({
929
+ code: "imageobject",
899
930
  kind: "group",
900
931
  tag: IMAGEOBJECT_TAG,
901
932
  requiredAttributes: [...ID_ATTRS],
@@ -908,6 +939,7 @@ var IMAGEOBJECT_SCHEMA = createSchema({
908
939
 
909
940
  // src/schema/elementSchemas/elements/figure/mediaobject.ts
910
941
  var MEDIAOBJECT_SCHEMA = createSchema({
942
+ code: "mediaobject",
911
943
  kind: "group",
912
944
  tag: MEDIAOBJECT_TAG,
913
945
  requiredAttributes: [...ID_ATTRS],
@@ -917,6 +949,7 @@ var MEDIAOBJECT_SCHEMA = createSchema({
917
949
 
918
950
  // src/schema/elementSchemas/elements/figure/caption1.ts
919
951
  var CAPTION_SCHEMA = createSchema({
952
+ code: "caption1",
920
953
  kind: "group",
921
954
  tag: CAPTION_TAG,
922
955
  requiredAttributes: [...ID_ATTRS],
@@ -926,24 +959,33 @@ var CAPTION_SCHEMA = createSchema({
926
959
 
927
960
  // src/schema/elementSchemas/elements/figure/figsource.ts
928
961
  var FIGSOURCE_SCHEMA = createSchema({
962
+ code: "figsource",
929
963
  kind: "element",
930
964
  tag: FIGSOURCE_TAG,
931
965
  requiredAttributes: [...ID_ATTRS],
932
966
  optionalAttributes: [],
933
- allowedChildTagNames: [...ATOM_TAGS_ALLOWED_CHILDREN]
967
+ allowedChildTagNames: [
968
+ ...ATOM_TAGS_ALLOWED_CHILDREN,
969
+ ...INLINE_ELEMENT_TAGS_ALLOWED_CHILDREN
970
+ ]
934
971
  });
935
972
 
936
973
  // src/schema/elementSchemas/elements/figure/fignote.ts
937
974
  var FIGNOTE_SCHEMA = createSchema({
975
+ code: "fignote",
938
976
  kind: "element",
939
977
  tag: FIGNOTE_TAG,
940
978
  requiredAttributes: [...ID_ATTRS],
941
979
  optionalAttributes: [],
942
- allowedChildTagNames: [...ATOM_TAGS_ALLOWED_CHILDREN]
980
+ allowedChildTagNames: [
981
+ ...ATOM_TAGS_ALLOWED_CHILDREN,
982
+ ...INLINE_ELEMENT_TAGS_ALLOWED_CHILDREN
983
+ ]
943
984
  });
944
985
 
945
986
  // src/schema/elementSchemas/elements/figure/figure.ts
946
987
  var FIGURE_SCHEMA = createSchema({
988
+ code: "figure1",
947
989
  kind: "group",
948
990
  tag: FIGURE_TAG,
949
991
  requiredAttributes: [...ID_ATTRS, "xmlid"],
@@ -964,6 +1006,7 @@ var FIGURE_SCHEMA = createSchema({
964
1006
 
965
1007
  // src/schema/elementSchemas/elements/footnote.ts
966
1008
  var FOOTNOTE_SCHEMA = createSchema({
1009
+ code: "footnote",
967
1010
  kind: "element",
968
1011
  tag: FOOTNOTE_TAG,
969
1012
  requiredAttributes: [
@@ -985,6 +1028,7 @@ var FOOTNOTE_SCHEMA = createSchema({
985
1028
 
986
1029
  // src/schema/elementSchemas/elements/footnoteNumber.ts
987
1030
  var FOOTNOTE_NUMBER_SCHEMA = createSchema({
1031
+ code: "footnoteno",
988
1032
  kind: "element",
989
1033
  tag: FOOTNOTE_NUMBER_TAG,
990
1034
  requiredAttributes: [...ID_ATTRS],
@@ -994,6 +1038,7 @@ var FOOTNOTE_NUMBER_SCHEMA = createSchema({
994
1038
 
995
1039
  // src/schema/elementSchemas/elements/informalfigure.ts
996
1040
  var INFORMALFIGURE_SCHEMA = createSchema({
1041
+ code: "informalfigure",
997
1042
  kind: "element",
998
1043
  tag: INFORMALFIGURE_TAG,
999
1044
  requiredAttributes: [...ID_ATTRS],
@@ -1006,6 +1051,7 @@ var INFORMALFIGURE_SCHEMA = createSchema({
1006
1051
 
1007
1052
  // src/schema/elementSchemas/elements/keywords/keywordset.ts
1008
1053
  var KEYWORDSET_SCHEMA = createSchema({
1054
+ code: "keywordset",
1009
1055
  kind: "group",
1010
1056
  tag: KEYWORDSET_TAG,
1011
1057
  requiredAttributes: [
@@ -1026,6 +1072,7 @@ var KEYWORDSET_SCHEMA = createSchema({
1026
1072
 
1027
1073
  // src/schema/elementSchemas/elements/keywords/keyword.ts
1028
1074
  var KEYWORD_SCHEMA = createSchema({
1075
+ code: "keyword",
1029
1076
  kind: "element",
1030
1077
  tag: KEYWORD_TAG,
1031
1078
  requiredAttributes: [...ID_ATTRS],
@@ -1035,6 +1082,7 @@ var KEYWORD_SCHEMA = createSchema({
1035
1082
 
1036
1083
  // src/schema/elementSchemas/elements/keywords/punc.ts
1037
1084
  var PUNC_SCHEMA = createSchema({
1085
+ code: "punc",
1038
1086
  kind: "element",
1039
1087
  tag: PUNC_TAG,
1040
1088
  requiredAttributes: [...ID_ATTRS],
@@ -1042,8 +1090,66 @@ var PUNC_SCHEMA = createSchema({
1042
1090
  allowedChildTagNames: [...ATOM_TAGS_ALLOWED_CHILDREN]
1043
1091
  });
1044
1092
 
1093
+ // src/schema/elementSchemas/inlineElements/footnoteLink.ts
1094
+ var FOOTNOTE_LINK_SCHEMA = createSchema({
1095
+ code: "footnote1",
1096
+ kind: "inline",
1097
+ tag: FOOTNOTE_LINK_TAG,
1098
+ requiredAttributes: [...ID_ATTRS],
1099
+ optionalAttributes: ["linkend"],
1100
+ allowedChildTagNames: [{ tagName: SUP_TAG, required: true }]
1101
+ });
1102
+
1103
+ // src/schema/elementSchemas/inlineElements/inlineequation.ts
1104
+ var INLINEEQUATION_SCHEMA = createSchema({
1105
+ code: "inlineequation",
1106
+ kind: "inline",
1107
+ tag: INLINEEQUATION_TAG,
1108
+ requiredAttributes: [...ID_ATTRS],
1109
+ optionalAttributes: ["linkend"],
1110
+ allowedChildTagNames: []
1111
+ });
1112
+
1113
+ // src/schema/elementSchemas/inlineElements/link.ts
1114
+ var LINK_SCHEMA = createSchema({
1115
+ code: "link",
1116
+ kind: "inline",
1117
+ tag: LINK_TAG,
1118
+ requiredAttributes: [
1119
+ ...ID_ATTRS,
1120
+ "linkend",
1121
+ "data-target-id",
1122
+ {
1123
+ name: "role",
1124
+ values: ["table", "figure", "equation", "footnote", "bibr"],
1125
+ defaultValue: ""
1126
+ }
1127
+ ],
1128
+ optionalAttributes: [],
1129
+ allowedChildTagNames: [...ATOM_TAGS_ALLOWED_CHILDREN]
1130
+ });
1131
+
1132
+ // src/schema/elementSchemas/inlineElements/uri.ts
1133
+ var URI_SCHEMA = createSchema({
1134
+ code: "uri",
1135
+ kind: "inline",
1136
+ tag: URI_TAG,
1137
+ requiredAttributes: [...ID_ATTRS],
1138
+ optionalAttributes: ["linkend"],
1139
+ allowedChildTagNames: [...ATOM_TAGS_ALLOWED_CHILDREN]
1140
+ });
1141
+
1142
+ // src/schema/elementSchemas/inlineElements/index.ts
1143
+ var INLINE_ELEMENT_SCHEMAS = [
1144
+ URI_SCHEMA,
1145
+ FOOTNOTE_LINK_SCHEMA,
1146
+ LINK_SCHEMA,
1147
+ INLINEEQUATION_SCHEMA
1148
+ ];
1149
+
1045
1150
  // src/schema/elementSchemas/elements/label.ts
1046
1151
  var LABEL_SCHEMA = createSchema({
1152
+ code: "label1",
1047
1153
  kind: "element",
1048
1154
  tag: LABEL_TAG,
1049
1155
  requiredAttributes: [...ID_ATTRS],
@@ -1055,11 +1161,18 @@ var LABEL_SCHEMA = createSchema({
1055
1161
  defaultValue: "false"
1056
1162
  }
1057
1163
  ],
1058
- allowedChildTagNames: [...ATOM_TAGS_ALLOWED_CHILDREN]
1164
+ allowedChildTagNames: [
1165
+ ...ATOM_TAGS_ALLOWED_CHILDREN,
1166
+ {
1167
+ tagName: LINK_TAG,
1168
+ required: false
1169
+ }
1170
+ ]
1059
1171
  });
1060
1172
 
1061
1173
  // src/schema/elementSchemas/elements/list/token.ts
1062
1174
  var TOKEN_SCHEMA = createSchema({
1175
+ code: "token",
1063
1176
  kind: "element",
1064
1177
  tag: TOKEN_TAG,
1065
1178
  requiredAttributes: [...ID_ATTRS],
@@ -1069,6 +1182,7 @@ var TOKEN_SCHEMA = createSchema({
1069
1182
 
1070
1183
  // src/schema/elementSchemas/elements/list/li.ts
1071
1184
  var LI_SCHEMA = createSchema({
1185
+ code: "li",
1072
1186
  kind: "element",
1073
1187
  tag: LI_TAG,
1074
1188
  requiredAttributes: [...ID_ATTRS],
@@ -1097,6 +1211,7 @@ var LI_SCHEMA = createSchema({
1097
1211
 
1098
1212
  // src/schema/elementSchemas/elements/list/ol.ts
1099
1213
  var OL_SCHEMA = createSchema({
1214
+ code: "ol",
1100
1215
  kind: "group",
1101
1216
  tag: OL_TAG,
1102
1217
  requiredAttributes: [...ID_ATTRS],
@@ -1133,6 +1248,7 @@ var OL_SCHEMA = createSchema({
1133
1248
 
1134
1249
  // src/schema/elementSchemas/elements/list/ul.ts
1135
1250
  var UL_SCHEMA = createSchema({
1251
+ code: "ul",
1136
1252
  kind: "group",
1137
1253
  tag: UL_TAG,
1138
1254
  requiredAttributes: [...ID_ATTRS],
@@ -1173,6 +1289,7 @@ var UL_SCHEMA = createSchema({
1173
1289
 
1174
1290
  // src/schema/elementSchemas/elements/para.ts
1175
1291
  var PARA_SCHEMA = createSchema({
1292
+ code: "para",
1176
1293
  kind: "element",
1177
1294
  tag: PARA_TAG,
1178
1295
  requiredAttributes: [...ID_ATTRS],
@@ -1198,6 +1315,7 @@ var PARA_SCHEMA = createSchema({
1198
1315
 
1199
1316
  // src/schema/elementSchemas/elements/paragraphNumberTag.ts
1200
1317
  var TAG_SCHEMA = createSchema({
1318
+ code: "tag",
1201
1319
  kind: "element",
1202
1320
  tag: TAG_TAG,
1203
1321
  requiredAttributes: [...ID_ATTRS, "data-id"],
@@ -1207,6 +1325,7 @@ var TAG_SCHEMA = createSchema({
1207
1325
 
1208
1326
  // src/schema/elementSchemas/elements/runningHeads/lrh.ts
1209
1327
  var LRH_SCHEMA = createSchema({
1328
+ code: "lrh",
1210
1329
  kind: "element",
1211
1330
  tag: LRH_TAG,
1212
1331
  requiredAttributes: [...ID_ATTRS],
@@ -1216,6 +1335,7 @@ var LRH_SCHEMA = createSchema({
1216
1335
 
1217
1336
  // src/schema/elementSchemas/elements/runningHeads/rrh.ts
1218
1337
  var RRH_SCHEMA = createSchema({
1338
+ code: "rrh",
1219
1339
  kind: "element",
1220
1340
  tag: RRH_TAG,
1221
1341
  requiredAttributes: [...ID_ATTRS],
@@ -1225,6 +1345,7 @@ var RRH_SCHEMA = createSchema({
1225
1345
 
1226
1346
  // src/schema/elementSchemas/elements/source.ts
1227
1347
  var SOURCE_SCHEMA = createSchema({
1348
+ code: "source1",
1228
1349
  kind: "element",
1229
1350
  tag: SOURCE_TAG,
1230
1351
  requiredAttributes: [...ID_ATTRS],
@@ -1241,6 +1362,7 @@ var SOURCE_SCHEMA = createSchema({
1241
1362
 
1242
1363
  // src/schema/elementSchemas/elements/subtitle.ts
1243
1364
  var SUBTITLE_SCHEMA = createSchema({
1365
+ code: "subtitle1",
1244
1366
  kind: "element",
1245
1367
  tag: SUBTITLE_TAG,
1246
1368
  requiredAttributes: [...ID_ATTRS],
@@ -1256,15 +1378,20 @@ var SUBTITLE_SCHEMA = createSchema({
1256
1378
 
1257
1379
  // src/schema/elementSchemas/elements/table/tp.ts
1258
1380
  var TP_SCHEMA = createSchema({
1381
+ code: "tp",
1259
1382
  kind: "element",
1260
1383
  tag: TP_TAG,
1261
1384
  requiredAttributes: [],
1262
- optionalAttributes: [ID_ATTRS[0], ID_ATTRS[1]],
1263
- allowedChildTagNames: []
1385
+ optionalAttributes: [...ID_ATTRS],
1386
+ allowedChildTagNames: [
1387
+ ...ATOM_TAGS_ALLOWED_CHILDREN,
1388
+ ...INLINE_ELEMENT_TAGS_ALLOWED_CHILDREN
1389
+ ]
1264
1390
  });
1265
1391
 
1266
1392
  // src/schema/elementSchemas/elements/table/td.ts
1267
1393
  var TD_SCHEMA = createSchema({
1394
+ code: "td",
1268
1395
  kind: "group",
1269
1396
  tag: TD_TAG,
1270
1397
  requiredAttributes: [...ID_ATTRS],
@@ -1278,37 +1405,41 @@ var TD_SCHEMA = createSchema({
1278
1405
 
1279
1406
  // src/schema/elementSchemas/elements/table/tr.ts
1280
1407
  var TR_SCHEMA = createSchema({
1408
+ code: "tr",
1281
1409
  kind: "group",
1282
1410
  tag: TR_TAG,
1283
1411
  requiredAttributes: [],
1284
- optionalAttributes: [...LAYOUT_ATTRIBUTES, ID_ATTRS[0], ID_ATTRS[1], "width"],
1412
+ optionalAttributes: [...LAYOUT_ATTRIBUTES, ...ID_ATTRS, "width"],
1285
1413
  allowedChildTagNames: [{ tagName: TD_TAG, required: true }]
1286
1414
  });
1287
1415
 
1288
1416
  // src/schema/elementSchemas/elements/table/thead.ts
1289
1417
  var THEAD_SCHEMA = createSchema({
1418
+ code: "thead",
1290
1419
  kind: "element",
1291
1420
  tag: THEAD_TAG,
1292
1421
  requiredAttributes: [],
1293
- optionalAttributes: [ID_ATTRS[0], ID_ATTRS[1]],
1422
+ optionalAttributes: [...ID_ATTRS],
1294
1423
  allowedChildTagNames: [{ tagName: TR_TAG, required: true }]
1295
1424
  });
1296
1425
 
1297
1426
  // src/schema/elementSchemas/elements/table/tbody.ts
1298
1427
  var TBODY_SCHEMA = createSchema({
1428
+ code: "tbody",
1299
1429
  kind: "group",
1300
1430
  tag: TBODY_TAG,
1301
1431
  requiredAttributes: [],
1302
- optionalAttributes: [ID_ATTRS[0], ID_ATTRS[1]],
1432
+ optionalAttributes: [...ID_ATTRS],
1303
1433
  allowedChildTagNames: [{ tagName: TR_TAG, required: true }]
1304
1434
  });
1305
1435
 
1306
1436
  // src/schema/elementSchemas/elements/table/htmlTable.ts
1307
1437
  var HTML_TABLE_SCHEMA = createSchema({
1438
+ code: "table",
1308
1439
  kind: "group",
1309
1440
  tag: HTML_TABLE_TAG,
1310
1441
  requiredAttributes: [],
1311
- optionalAttributes: [ID_ATTRS[0], ID_ATTRS[1]],
1442
+ optionalAttributes: [...ID_ATTRS],
1312
1443
  allowedChildTagNames: [
1313
1444
  { tagName: THEAD_TAG, required: false },
1314
1445
  { tagName: TBODY_TAG, required: true }
@@ -1317,6 +1448,7 @@ var HTML_TABLE_SCHEMA = createSchema({
1317
1448
 
1318
1449
  // src/schema/elementSchemas/elements/table/tgroup.ts
1319
1450
  var TGROUP_SCHEMA = createSchema({
1451
+ code: "tgroup",
1320
1452
  kind: "group",
1321
1453
  tag: TGROUP_TAG,
1322
1454
  requiredAttributes: [...ID_ATTRS, "cols"],
@@ -1326,24 +1458,30 @@ var TGROUP_SCHEMA = createSchema({
1326
1458
 
1327
1459
  // src/schema/elementSchemas/elements/table/tblfn.ts
1328
1460
  var TBLFN_SCHEMA = createSchema({
1461
+ code: "tblfn",
1329
1462
  kind: "element",
1330
1463
  tag: TBLFN_TAG,
1331
1464
  requiredAttributes: [...ID_ATTRS],
1332
1465
  optionalAttributes: [],
1333
- allowedChildTagNames: []
1466
+ allowedChildTagNames: [
1467
+ ...ATOM_TAGS_ALLOWED_CHILDREN,
1468
+ ...INLINE_ELEMENT_TAGS_ALLOWED_CHILDREN
1469
+ ]
1334
1470
  });
1335
1471
 
1336
1472
  // src/schema/elementSchemas/elements/table/tblsource.ts
1337
1473
  var TBLSOURCE_SCHEMA = createSchema({
1474
+ code: "tblsource",
1338
1475
  kind: "element",
1339
1476
  tag: TBLSOURCE_TAG,
1340
1477
  requiredAttributes: [],
1341
1478
  optionalAttributes: [],
1342
- allowedChildTagNames: []
1479
+ allowedChildTagNames: [...ATOM_TAGS_ALLOWED_CHILDREN]
1343
1480
  });
1344
1481
 
1345
1482
  // src/schema/elementSchemas/elements/table/table1.ts
1346
1483
  var TABLE_SCHEMA = createSchema({
1484
+ code: "table1",
1347
1485
  kind: "group",
1348
1486
  tag: TABLE_TAG,
1349
1487
  requiredAttributes: [...ID_ATTRS, "xmlid", "role"],
@@ -1366,6 +1504,7 @@ var TABLE_SCHEMA = createSchema({
1366
1504
 
1367
1505
  // src/schema/elementSchemas/elements/title.ts
1368
1506
  var TITLE_SCHEMA = createSchema({
1507
+ code: "title1",
1369
1508
  kind: "element",
1370
1509
  tag: TITLE_TAG,
1371
1510
  requiredAttributes: [...ID_ATTRS],
@@ -1441,6 +1580,7 @@ var ELEMENT_SCHEMAS = [
1441
1580
 
1442
1581
  // src/schema/elementSchemas/groupElements/abstract.ts
1443
1582
  var ABSTRACT_SCHEMA = createSchema({
1583
+ code: "abstract1",
1444
1584
  kind: "group",
1445
1585
  tag: ABSTRACT_TAG,
1446
1586
  requiredAttributes: [
@@ -1469,6 +1609,7 @@ var ABSTRACT_SCHEMA = createSchema({
1469
1609
 
1470
1610
  // src/schema/elementSchemas/groupElements/appendix.ts
1471
1611
  var APPENDIX_SCHEMA = createSchema({
1612
+ code: "appendix",
1472
1613
  kind: "group",
1473
1614
  tag: APPENDIX_TAG,
1474
1615
  requiredAttributes: [...ID_ATTRS, "id", "xmlid"],
@@ -1482,6 +1623,7 @@ var APPENDIX_SCHEMA = createSchema({
1482
1623
 
1483
1624
  // src/schema/elementSchemas/groupElements/blockquote.ts
1484
1625
  var BLOCKQUOTE_SCHEMA = createSchema({
1626
+ code: "blockquote",
1485
1627
  kind: "group",
1486
1628
  tag: BLOCKQUOTE_TAG,
1487
1629
  requiredAttributes: [...ID_ATTRS],
@@ -1507,6 +1649,7 @@ var BLOCKQUOTE_SCHEMA = createSchema({
1507
1649
 
1508
1650
  // src/schema/elementSchemas/groupElements/box.ts
1509
1651
  var BOX_SCHEMA = createSchema({
1652
+ code: "sidebar",
1510
1653
  kind: "group",
1511
1654
  tag: SIDEBAR_TAG,
1512
1655
  requiredAttributes: [
@@ -1534,6 +1677,7 @@ var BOX_SCHEMA = createSchema({
1534
1677
 
1535
1678
  // src/schema/elementSchemas/groupElements/chapter.ts
1536
1679
  var CHAPTER_SCHEMA = createSchema({
1680
+ code: "chapter",
1537
1681
  kind: "group",
1538
1682
  tag: CHAPTER_TAG,
1539
1683
  requiredAttributes: [...ID_ATTRS, "xmlid"],
@@ -1567,6 +1711,7 @@ var CHAPTER_SCHEMA = createSchema({
1567
1711
 
1568
1712
  // src/schema/elementSchemas/groupElements/epigraph.ts
1569
1713
  var EPIGRAPH_SCHEMA = createSchema({
1714
+ code: "epigraph",
1570
1715
  kind: "group",
1571
1716
  tag: EPIGRAPH_TAG,
1572
1717
  requiredAttributes: [...ID_ATTRS],
@@ -1584,9 +1729,9 @@ var EPIGRAPH_SCHEMA = createSchema({
1584
1729
 
1585
1730
  // src/schema/elementSchemas/groupElements/footnoteSection.ts
1586
1731
  var FOOTNOTE_SECTION_SCHEMA = createSchema({
1732
+ code: "footnoteSection",
1587
1733
  kind: "group",
1588
1734
  tag: SECTION_TAG,
1589
- role: "FOOTNOTE" /* FOOTNOTE */,
1590
1735
  requiredAttributes: [
1591
1736
  ...ID_ATTRS,
1592
1737
  {
@@ -1604,9 +1749,9 @@ var FOOTNOTE_SECTION_SCHEMA = createSchema({
1604
1749
 
1605
1750
  // src/schema/elementSchemas/groupElements/heading.ts
1606
1751
  var HEADING_SCHEMA = createSchema({
1752
+ code: "heading",
1607
1753
  kind: "group",
1608
1754
  tag: SECTION_TAG,
1609
- role: "HEADING" /* HEADING */,
1610
1755
  requiredAttributes: [
1611
1756
  ...ID_ATTRS,
1612
1757
  "xmlid",
@@ -1639,6 +1784,7 @@ var HEADING_SCHEMA = createSchema({
1639
1784
 
1640
1785
  // src/schema/elementSchemas/groupElements/info.ts
1641
1786
  var INFO_SCHEMA = createSchema({
1787
+ code: "info1",
1642
1788
  kind: "group",
1643
1789
  tag: INFO_TAG,
1644
1790
  requiredAttributes: [...ID_ATTRS],
@@ -1655,6 +1801,7 @@ var INFO_SCHEMA = createSchema({
1655
1801
 
1656
1802
  // src/schema/elementSchemas/groupElements/poem.ts
1657
1803
  var POEM_SCHEMA = createSchema({
1804
+ code: "poem",
1658
1805
  kind: "group",
1659
1806
  tag: POEM_TAG,
1660
1807
  requiredAttributes: [...ID_ATTRS],
@@ -1683,59 +1830,6 @@ var GROUP_ELEMENT_SCHEMAS = [
1683
1830
  AFFILIATION_SCHEMA
1684
1831
  ];
1685
1832
 
1686
- // src/schema/elementSchemas/inlineElements/footnoteLink.ts
1687
- var FOOTNOTE_LINK_SCHEMA = createSchema({
1688
- kind: "inline",
1689
- tag: FOOTNOTE_LINK_TAG,
1690
- requiredAttributes: [...ID_ATTRS],
1691
- optionalAttributes: ["linkend"],
1692
- allowedChildTagNames: [{ tagName: SUP_TAG, required: true }]
1693
- });
1694
-
1695
- // src/schema/elementSchemas/inlineElements/inlineequation.ts
1696
- var INLINEEQUATION_SCHEMA = createSchema({
1697
- kind: "inline",
1698
- tag: INLINEEQUATION_TAG,
1699
- requiredAttributes: [...ID_ATTRS],
1700
- optionalAttributes: ["linkend"],
1701
- allowedChildTagNames: []
1702
- });
1703
-
1704
- // src/schema/elementSchemas/inlineElements/link.ts
1705
- var LINK_SCHEMA = createSchema({
1706
- kind: "inline",
1707
- tag: LINK_TAG,
1708
- requiredAttributes: [
1709
- ...ID_ATTRS,
1710
- "linkend",
1711
- "data-target-id",
1712
- {
1713
- name: "role",
1714
- values: ["table", "figure", "equation", "footnote"],
1715
- defaultValue: ""
1716
- }
1717
- ],
1718
- optionalAttributes: [],
1719
- allowedChildTagNames: [...ATOM_TAGS_ALLOWED_CHILDREN]
1720
- });
1721
-
1722
- // src/schema/elementSchemas/inlineElements/uri.ts
1723
- var URI_SCHEMA = createSchema({
1724
- kind: "inline",
1725
- tag: URI_TAG,
1726
- requiredAttributes: [...ID_ATTRS],
1727
- optionalAttributes: ["linkend"],
1728
- allowedChildTagNames: [...ATOM_TAGS_ALLOWED_CHILDREN]
1729
- });
1730
-
1731
- // src/schema/elementSchemas/inlineElements/index.ts
1732
- var INLINE_ELEMENT_SCHEMAS = [
1733
- URI_SCHEMA,
1734
- FOOTNOTE_LINK_SCHEMA,
1735
- LINK_SCHEMA,
1736
- INLINEEQUATION_SCHEMA
1737
- ];
1738
-
1739
1833
  // src/schema/schemas.ts
1740
1834
  var SCHEMAS = [
1741
1835
  ...ATOM_SCHEMAS,
@@ -1744,10 +1838,7 @@ var SCHEMAS = [
1744
1838
  ...INLINE_ELEMENT_SCHEMAS
1745
1839
  ];
1746
1840
  var SCHEMA_MAP = new Map(
1747
- SCHEMAS.map((schema) => [
1748
- schema.tag.toUpperCase() + (schema.role?.toUpperCase() ?? ""),
1749
- schema
1750
- ])
1841
+ SCHEMAS.map((schema) => [schema.code, schema])
1751
1842
  );
1752
1843
 
1753
1844
  // src/schema/shared/ignoredElements.ts
@@ -1782,41 +1873,36 @@ var isIgnoredAttribute = (attribute) => IGNORED_ATTRIBUTES.includes(attribute) |
1782
1873
  (startsWith) => attribute.startsWith(startsWith)
1783
1874
  );
1784
1875
  var isIgnoredElement = (element) => IGNORED_ELEMENT_SELECTORS.some((selector) => element.matches(selector));
1785
- var findSchemaByTag = (tagName, role) => {
1786
- if (role) {
1787
- return SCHEMA_MAP.get(tagName.toUpperCase() + role);
1788
- }
1789
- return SCHEMA_MAP.get(tagName.toUpperCase());
1790
- };
1876
+ var findSchemaByCode = (code) => SCHEMA_MAP.get(code);
1791
1877
  var findSchemaByElement = (element) => {
1792
1878
  const isInsertion = element.classList.contains("ins");
1793
1879
  const isDeletion = element.classList.contains("del");
1794
1880
  const isQueryComment = element.classList.contains("cmtQurySection");
1795
1881
  const role = element.getAttribute("role");
1882
+ if (isQueryComment) {
1883
+ return findSchemaByCode("commentQuerySection");
1884
+ }
1885
+ if (isInsertion) {
1886
+ return findSchemaByCode("insertion");
1887
+ }
1888
+ if (isDeletion) {
1889
+ return findSchemaByCode("deletion");
1890
+ }
1796
1891
  if (role) {
1797
1892
  if (role.startsWith("H")) {
1798
- return SCHEMA_MAP.get(
1799
- element.tagName.toUpperCase() + "HEADING" /* HEADING */
1800
- );
1893
+ return findSchemaByCode("heading");
1801
1894
  }
1802
1895
  if (role === "ch" || role === "bk") {
1803
- return SCHEMA_MAP.get(
1804
- element.tagName.toUpperCase() + "FOOTNOTE" /* FOOTNOTE */
1805
- );
1896
+ return findSchemaByCode("footnoteSection");
1806
1897
  }
1807
1898
  }
1808
- if (isInsertion) {
1809
- return SCHEMA_MAP.get(element.tagName.toUpperCase() + "INS" /* INS */);
1899
+ const candidates = [...SCHEMA_MAP.values()].filter(
1900
+ (schema) => schema.tag === element.tagName.toUpperCase()
1901
+ );
1902
+ if (candidates.length > 0) {
1903
+ return candidates[0];
1810
1904
  }
1811
- if (isDeletion) {
1812
- return SCHEMA_MAP.get(element.tagName.toUpperCase() + "DEL" /* DEL */);
1813
- }
1814
- if (isQueryComment) {
1815
- return SCHEMA_MAP.get(
1816
- element.tagName.toUpperCase() + "QUERYCOMMENTSWRAPPER" /* QUERYCOMMENTSWRAPPER */
1817
- );
1818
- }
1819
- return SCHEMA_MAP.get(element.tagName.toUpperCase());
1905
+ return void 0;
1820
1906
  };
1821
1907
  var isAttributeRestricted = (attr) => typeof attr !== "string";
1822
1908
  var getAttributeName = (attribute) => typeof attribute === "string" ? attribute : attribute.name;
@@ -1843,6 +1929,420 @@ var createElement = ({
1843
1929
  }
1844
1930
  return element;
1845
1931
  };
1932
+
1933
+ // src/validation/utils/retrieveTextIgnoringNodesWithSelector.ts
1934
+ var retrieveTextIgnoringNodesWithSelector = (element, selector = ".del") => {
1935
+ const clonedElement = element.cloneNode(true);
1936
+ for (const delElement of clonedElement.querySelectorAll(selector)) {
1937
+ delElement.remove();
1938
+ }
1939
+ return clonedElement.textContent || "";
1940
+ };
1941
+
1942
+ // src/validation/validateFootnotes.ts
1943
+ var extractFootnoteNumber = (footnote) => {
1944
+ if (!footnote) return "no label";
1945
+ const footnoteNumberText = retrieveTextIgnoringNodesWithSelector(footnote);
1946
+ const footnoteNumber = Number(footnoteNumberText);
1947
+ if (!Number.isInteger(footnoteNumber) || footnoteNumber <= 0) {
1948
+ return "no label";
1949
+ }
1950
+ return footnoteNumber;
1951
+ };
1952
+ var validateFootnoteCue = (footnoteElement, root) => {
1953
+ const errors = [];
1954
+ const store = footnoteElement.getAttribute("store");
1955
+ if (!store) {
1956
+ return errors;
1957
+ }
1958
+ const linkend = footnoteElement.getAttribute("xmlid") || "";
1959
+ const footnoteNumber = footnoteElement.querySelector(
1960
+ FOOTNOTE_NUMBER_SCHEMA.tag
1961
+ );
1962
+ const footnoteLink = root.querySelector(
1963
+ `${FOOTNOTE_LINK_SCHEMA.tag}[linkend='${CSS.escape(linkend)}']`
1964
+ );
1965
+ if (footnoteLink) {
1966
+ return errors;
1967
+ }
1968
+ if (!footnoteNumber) {
1969
+ errors.push({
1970
+ id: `footnote-number-missing-${store}`,
1971
+ store,
1972
+ title: "Footnote number missing",
1973
+ kind: "missing",
1974
+ description: "The footnote number is missing. Please add it to the footnote.",
1975
+ level: "blocker"
1976
+ });
1977
+ }
1978
+ const label = extractFootnoteNumber(footnoteNumber);
1979
+ errors.push({
1980
+ id: `unreferenced-footnote-${store}`,
1981
+ store,
1982
+ title: "Unreferenced footnote",
1983
+ kind: "unlinked",
1984
+ description: `The footnote ${label} is not referenced to any footnote cue in this chapter. Please reference it in the chapter.`,
1985
+ level: "blocker"
1986
+ });
1987
+ return errors;
1988
+ };
1989
+ var validateConsecutiveFootnotes = (root) => {
1990
+ const footnotes = Array.from(root.querySelectorAll(FOOTNOTE_SCHEMA.tag));
1991
+ if (footnotes.length === 0) {
1992
+ return [];
1993
+ }
1994
+ for (const [index, footnote] of footnotes.entries()) {
1995
+ const store = footnote.getAttribute("store") || "";
1996
+ const expectedNumber = index + 1;
1997
+ const footnoteNumberElement = footnote.querySelector(
1998
+ FOOTNOTE_NUMBER_SCHEMA.tag
1999
+ );
2000
+ if (!footnoteNumberElement) {
2001
+ continue;
2002
+ }
2003
+ const label = extractFootnoteNumber(footnoteNumberElement);
2004
+ if (label === expectedNumber) {
2005
+ continue;
2006
+ }
2007
+ return [
2008
+ {
2009
+ id: `non-consecutive-footnote-numbers-${store}`,
2010
+ store,
2011
+ title: "Non-consecutive footnote numbers",
2012
+ kind: "missing",
2013
+ description: "Footnote numbers must be consecutive. Please reorder the footnotes.",
2014
+ level: "warning"
2015
+ }
2016
+ ];
2017
+ }
2018
+ return [];
2019
+ };
2020
+ var validateConsecutiveFootnoteCues = (root) => {
2021
+ const footnoteLinks = Array.from(
2022
+ root.querySelectorAll(FOOTNOTE_LINK_SCHEMA.tag)
2023
+ );
2024
+ if (footnoteLinks.length === 0) {
2025
+ return [];
2026
+ }
2027
+ for (const [index, footnoteLink] of footnoteLinks.entries()) {
2028
+ const store = footnoteLink.getAttribute("store") || "";
2029
+ const expectedNumber = index + 1;
2030
+ const label = extractFootnoteNumber(footnoteLink);
2031
+ if (label === expectedNumber) {
2032
+ continue;
2033
+ }
2034
+ return [
2035
+ {
2036
+ id: `non-consecutive-footnote-cues-${store}`,
2037
+ store,
2038
+ title: "Non-consecutive footnote cues",
2039
+ kind: "missing",
2040
+ description: "Footnote cues must be consecutive. Please reorder the footnote cues.",
2041
+ level: "warning"
2042
+ }
2043
+ ];
2044
+ }
2045
+ return [];
2046
+ };
2047
+ var validateFootnotes = (root) => {
2048
+ const errors = [];
2049
+ for (const footnote of root.querySelectorAll(FOOTNOTE_SCHEMA.tag)) {
2050
+ errors.push(...validateFootnoteCue(footnote, root));
2051
+ }
2052
+ errors.push(...validateConsecutiveFootnotes(root));
2053
+ errors.push(...validateConsecutiveFootnoteCues(root));
2054
+ return errors;
2055
+ };
2056
+
2057
+ // src/validation/validateLinkend.ts
2058
+ var findElementInCurrentChapter = (root, linkend) => {
2059
+ return !!root.querySelector(`[xmlid='${CSS.escape(linkend)}']`);
2060
+ };
2061
+ var findElementInReferenceChapters = (linkend, referenceChapterLinkends) => {
2062
+ return referenceChapterLinkends.includes(linkend);
2063
+ };
2064
+ var validateLinkend = (linkElement, root, referenceChapterLinkends = []) => {
2065
+ const store = linkElement.getAttribute("store");
2066
+ if (!store) {
2067
+ return [];
2068
+ }
2069
+ const linkend = linkElement.getAttribute("linkend");
2070
+ if (!linkend) {
2071
+ return [];
2072
+ }
2073
+ const isLinkFootnoteCue = linkElement.tagName.toUpperCase() === FOOTNOTE_LINK_SCHEMA.tag;
2074
+ if (isLinkFootnoteCue) {
2075
+ if (findElementInCurrentChapter(root, linkend)) {
2076
+ return [];
2077
+ }
2078
+ return [
2079
+ {
2080
+ id: `unlinked-footnote-cue-${store}`,
2081
+ store,
2082
+ title: "Unlinked footnote cue",
2083
+ kind: "unlinked",
2084
+ description: "This footnote cue is not referenced to any footnote in this chapter. Please link it again manually.",
2085
+ level: "blocker"
2086
+ }
2087
+ ];
2088
+ }
2089
+ if (findElementInCurrentChapter(root, linkend) || findElementInReferenceChapters(linkend, referenceChapterLinkends)) {
2090
+ return [];
2091
+ }
2092
+ return [
2093
+ {
2094
+ id: `unlinked-element-${store}`,
2095
+ store,
2096
+ title: "Unlinked element",
2097
+ kind: "unlinked",
2098
+ description: "This link is not referenced to any element in the current chapter or reference chapters. Please link it again manually.",
2099
+ level: "blocker"
2100
+ }
2101
+ ];
2102
+ };
2103
+ var validateLinkends = (root, referenceChapterLinkends = []) => {
2104
+ const errors = [];
2105
+ for (const linkElement of root.querySelectorAll("[linkend]")) {
2106
+ errors.push(
2107
+ ...validateLinkend(linkElement, root, referenceChapterLinkends)
2108
+ );
2109
+ }
2110
+ return errors;
2111
+ };
2112
+
2113
+ // src/validation/validateAttributes.ts
2114
+ var validateAttributes = (element, schema) => {
2115
+ const errors = [];
2116
+ const definitions = [
2117
+ ...schema.requiredAttributes,
2118
+ ...schema.optionalAttributes
2119
+ ];
2120
+ for (const attribute of schema.requiredAttributes) {
2121
+ const name = getAttributeName(attribute);
2122
+ if (!element.hasAttribute(name)) {
2123
+ errors.push({
2124
+ id: `missing-required-attribute-${name}`,
2125
+ store: element.id,
2126
+ title: `Missing required attribute "${name}"`,
2127
+ level: "warning",
2128
+ kind: "missing",
2129
+ description: `The attribute "${name}" is required but not present in the element.`
2130
+ });
2131
+ }
2132
+ }
2133
+ for (const name of element.getAttributeNames()) {
2134
+ if (isIgnoredAttribute(name)) {
2135
+ continue;
2136
+ }
2137
+ const definition = findAttributeDefinitionByName(definitions, name);
2138
+ if (!definition) {
2139
+ errors.push({
2140
+ id: `unexpected-attribute-${name}`,
2141
+ store: element.id,
2142
+ title: `Unexpected attribute "${name}"`,
2143
+ level: "warning",
2144
+ kind: "forbidden",
2145
+ description: `The attribute "${name}" is not allowed in this element.`
2146
+ });
2147
+ continue;
2148
+ }
2149
+ if (!isAttributeRestricted(definition)) {
2150
+ continue;
2151
+ }
2152
+ const value = element.getAttribute(name);
2153
+ if (value === null) {
2154
+ continue;
2155
+ }
2156
+ if (!definition.values.includes(value)) {
2157
+ errors.push({
2158
+ id: `forbidden-attribute-value-${name}-${value}`,
2159
+ store: element.id,
2160
+ title: `Invalid attribute value "${value}"`,
2161
+ level: "warning",
2162
+ kind: "forbidden",
2163
+ description: `The attribute "${name}" has an invalid value "${value}".`
2164
+ });
2165
+ }
2166
+ }
2167
+ return errors;
2168
+ };
2169
+
2170
+ // src/validation/validateChildren.ts
2171
+ var validateElementAgainstSchema = (element, schema) => {
2172
+ const errors = [];
2173
+ if (element.tagName.toUpperCase() !== schema.tag) {
2174
+ errors.push({
2175
+ id: `expected-element-${schema.tag}`,
2176
+ store: element.id,
2177
+ title: `Expected ${schema.tag}, got ${element.tagName}`,
2178
+ level: "warning",
2179
+ kind: "forbidden",
2180
+ description: `The element is not allowed in this context.`
2181
+ });
2182
+ }
2183
+ if (schema.code === "insertion" && !element.classList.contains("ins")) {
2184
+ errors.push({
2185
+ id: `missing-class-ins-${element.id}`,
2186
+ store: element.id,
2187
+ title: 'Missing class "ins" for insertion element',
2188
+ level: "warning",
2189
+ kind: "missing",
2190
+ description: `The element is missing the class "ins".`
2191
+ });
2192
+ }
2193
+ if (schema.code === "deletion" && !element.classList.contains("del")) {
2194
+ errors.push({
2195
+ id: `missing-class-del-${element.id}`,
2196
+ store: element.id,
2197
+ title: 'Missing class "del" for deletion element',
2198
+ level: "warning",
2199
+ kind: "missing",
2200
+ description: `The element is missing the class "del".`
2201
+ });
2202
+ }
2203
+ if (schema.code === "commentQuerySection" && !element.classList.contains("cmtQurySection")) {
2204
+ errors.push({
2205
+ id: `missing-class-cmtQurySection-${element.id}`,
2206
+ store: element.id,
2207
+ title: 'Missing class "cmtQurySection" for comment query section',
2208
+ level: "warning",
2209
+ kind: "missing",
2210
+ description: `The element is missing the class "cmtQurySection".`
2211
+ });
2212
+ }
2213
+ errors.push(...validateAttributes(element, schema));
2214
+ errors.push(...validateChildren(element, schema));
2215
+ return errors;
2216
+ };
2217
+ var validateChildren = (element, schema) => {
2218
+ const errors = [];
2219
+ const childElements = [...element.children].filter(
2220
+ (child) => !isIgnoredElement(child)
2221
+ );
2222
+ const allowedChildren = [...schema.allowedChildTagNames];
2223
+ for (const child of childElements) {
2224
+ const childTag = child.tagName.toUpperCase();
2225
+ const allowedChild = allowedChildren.find(
2226
+ (candidate) => candidate.tagName === childTag
2227
+ );
2228
+ if (!allowedChild) {
2229
+ errors.push({
2230
+ id: `forbidden-child-element-${child.tagName}`,
2231
+ store: child.id,
2232
+ title: `Forbidden child element ${child.tagName}`,
2233
+ level: "warning",
2234
+ kind: "forbidden",
2235
+ description: `The child element ${child.tagName} is not allowed in this context.`
2236
+ });
2237
+ continue;
2238
+ }
2239
+ const childSchema = findSchemaByElement(child);
2240
+ if (!childSchema) {
2241
+ errors.push({
2242
+ id: `no-schema-found-for-child-element-${child.tagName}`,
2243
+ store: child.id,
2244
+ title: `No schema found for child element ${child.tagName}`,
2245
+ level: "warning",
2246
+ kind: "missing",
2247
+ description: `No schema found for child element ${child.tagName}.`
2248
+ });
2249
+ continue;
2250
+ }
2251
+ errors.push(...validateElementAgainstSchema(child, childSchema));
2252
+ }
2253
+ for (const allowedChild of allowedChildren) {
2254
+ if (!allowedChild.required) {
2255
+ continue;
2256
+ }
2257
+ const hasChild = childElements.some(
2258
+ (child) => child.tagName.toUpperCase() === allowedChild.tagName
2259
+ );
2260
+ if (!hasChild) {
2261
+ errors.push({
2262
+ id: `missing-required-child-element-${allowedChild.tagName}`,
2263
+ store: element.id,
2264
+ title: `Missing required child element ${allowedChild.tagName}`,
2265
+ level: "warning",
2266
+ kind: "missing",
2267
+ description: `The child element ${allowedChild.tagName} is required but not present.`
2268
+ });
2269
+ }
2270
+ }
2271
+ if (schema.allowedChildTagNames.size === 0 && childElements.length > 0) {
2272
+ errors.push({
2273
+ id: `leaf-element-cannot-contain-child-elements-${element.id}`,
2274
+ store: element.id,
2275
+ title: "Leaf element cannot contain child elements",
2276
+ level: "warning",
2277
+ kind: "forbidden",
2278
+ description: `The element is a leaf element and cannot contain child elements.`
2279
+ });
2280
+ }
2281
+ return errors;
2282
+ };
2283
+
2284
+ // src/validation/utils/parseXML.ts
2285
+ var parseXml = (xml) => {
2286
+ const doc = new DOMParser().parseFromString(xml.trim(), "application/xml");
2287
+ const parserError = doc.querySelector("parsererror");
2288
+ if (parserError) {
2289
+ throw new Error(
2290
+ `Unable to parse XML: ${parserError.textContent ?? "unknown error"}`
2291
+ );
2292
+ }
2293
+ const element = doc.documentElement;
2294
+ if (!element) {
2295
+ throw new Error("XML string did not produce an element");
2296
+ }
2297
+ return element;
2298
+ };
2299
+
2300
+ // src/validation/validateXml.ts
2301
+ var getLinkableRoles = () => {
2302
+ const linkRoleDefinition = findAttributeDefinitionByName(
2303
+ LINK_SCHEMA.requiredAttributes,
2304
+ "role"
2305
+ );
2306
+ if (!linkRoleDefinition) {
2307
+ return [];
2308
+ }
2309
+ if (isAttributeRestricted(linkRoleDefinition)) {
2310
+ return linkRoleDefinition.values;
2311
+ }
2312
+ return [];
2313
+ };
2314
+ var validateElement = (element, root, referenceChapterLinkends) => {
2315
+ if (isIgnoredElement(element)) {
2316
+ return [];
2317
+ }
2318
+ const errors = [];
2319
+ const schema = findSchemaByElement(element);
2320
+ if (schema) {
2321
+ errors.push(...validateElementAgainstSchema(element, schema));
2322
+ const role = element.getAttribute("role") || "";
2323
+ const linkableRoles = getLinkableRoles();
2324
+ if (schema.tag === LINK_SCHEMA.tag && linkableRoles.includes(role) || schema.tag === FOOTNOTE_LINK_SCHEMA.tag) {
2325
+ errors.push(...validateLinkend(element, root, referenceChapterLinkends));
2326
+ }
2327
+ if (schema.tag === FOOTNOTE_SCHEMA.tag) {
2328
+ errors.push(...validateFootnoteCue(element, root));
2329
+ }
2330
+ }
2331
+ for (const child of Array.from(element.children)) {
2332
+ errors.push(...validateElement(child, root, referenceChapterLinkends));
2333
+ }
2334
+ return errors;
2335
+ };
2336
+ var validateXml = (xml, referenceChapterLinkends) => {
2337
+ const root = parseXml(xml);
2338
+ const errors = [];
2339
+ errors.push(...validateConsecutiveFootnotes(root));
2340
+ errors.push(...validateConsecutiveFootnoteCues(root));
2341
+ for (const child of Array.from(root.children)) {
2342
+ errors.push(...validateElement(child, root, referenceChapterLinkends));
2343
+ }
2344
+ return errors;
2345
+ };
1846
2346
  // Annotate the CommonJS export names for ESM import in node:
1847
2347
  0 && (module.exports = {
1848
2348
  ABSTRACT_SCHEMA,
@@ -1875,7 +2375,6 @@ var createElement = ({
1875
2375
  DELETION_SCHEMA,
1876
2376
  DIALOGUE_SCHEMA,
1877
2377
  DIALOGUE_TAG,
1878
- ELEMENT_ROLE,
1879
2378
  ELEMENT_SCHEMAS,
1880
2379
  ELEMENT_TAGS,
1881
2380
  ELE_ID_ATTRIBUTE,
@@ -2030,10 +2529,20 @@ var createElement = ({
2030
2529
  U_SCHEMA,
2031
2530
  createElement,
2032
2531
  findAttributeDefinitionByName,
2532
+ findSchemaByCode,
2033
2533
  findSchemaByElement,
2034
- findSchemaByTag,
2035
2534
  getAttributeName,
2036
2535
  isAttributeRestricted,
2037
2536
  isIgnoredAttribute,
2038
- isIgnoredElement
2537
+ isIgnoredElement,
2538
+ validateAttributes,
2539
+ validateConsecutiveFootnoteCues,
2540
+ validateConsecutiveFootnotes,
2541
+ validateElement,
2542
+ validateElementAgainstSchema,
2543
+ validateFootnoteCue,
2544
+ validateFootnotes,
2545
+ validateLinkend,
2546
+ validateLinkends,
2547
+ validateXml
2039
2548
  });