@mathscan/math-exercise-engine 1.0.4 → 1.0.6

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.d.ts CHANGED
@@ -19,6 +19,10 @@ export declare const AST_TYPES: {
19
19
  readonly SPACE: "Space";
20
20
  /** Text with optional character-range highlighting */
21
21
  readonly HIGHLIGHTED_TEXT: "HighlightedText";
22
+ /** Text with color and optional character-range coloring */
23
+ readonly COLOR_TEXT: "ColorText";
24
+ /** Bold text with optional character-range bolding */
25
+ readonly BOLD_TEXT: "BoldText";
22
26
  /** Inline input widget (string or numeric) */
23
27
  readonly INLINE_INPUT: "InlineInput";
24
28
  /** Question/instruction text block */
@@ -42,6 +46,108 @@ export declare const AST_TYPES: {
42
46
  */
43
47
  export declare type ASTType = typeof AST_TYPES[keyof typeof AST_TYPES];
44
48
 
49
+ export declare type BoldText = z.infer<typeof BoldTextSchema>;
50
+
51
+ export declare type BoldTextInline = z.infer<typeof BoldTextInlineSchema>;
52
+
53
+ /**
54
+ * Bold text inline schema - text with optional range bolding
55
+ *
56
+ * highlight: [start, end] character positions for bold range
57
+ *
58
+ * @example
59
+ * {
60
+ * type: "BoldText",
61
+ * value: "123456",
62
+ * highlight: [0, 3] // Bolds "123"
63
+ * }
64
+ */
65
+ export declare const BoldTextInlineSchema: z.ZodObject<{
66
+ type: z.ZodLiteral<"BoldText">;
67
+ value: z.ZodString;
68
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
69
+ }, "strip", z.ZodTypeAny, {
70
+ value: string;
71
+ type: "BoldText";
72
+ highlight?: [number, number] | undefined;
73
+ }, {
74
+ value: string;
75
+ type: "BoldText";
76
+ highlight?: [number, number] | undefined;
77
+ }>;
78
+
79
+ export declare const BoldTextSchema: z.ZodObject<{
80
+ id: z.ZodString;
81
+ type: z.ZodLiteral<"bold-text">;
82
+ value: z.ZodString;
83
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
84
+ }, "strip", z.ZodTypeAny, {
85
+ value: string;
86
+ type: "bold-text";
87
+ id: string;
88
+ highlight?: [number, number] | undefined;
89
+ }, {
90
+ value: string;
91
+ type: "bold-text";
92
+ id: string;
93
+ highlight?: [number, number] | undefined;
94
+ }>;
95
+
96
+ export declare type ColorText = z.infer<typeof ColorTextSchema>;
97
+
98
+ export declare type ColorTextInline = z.infer<typeof ColorTextInlineSchema>;
99
+
100
+ /**
101
+ * Color text inline schema - text with color and optional range coloring
102
+ *
103
+ * highlight: [start, end] character positions for colored range
104
+ * color: CSS color value (e.g., "red", "#ff0000")
105
+ *
106
+ * @example
107
+ * {
108
+ * type: "ColorText",
109
+ * value: "123456",
110
+ * color: "red",
111
+ * highlight: [0, 3] // Colors "123" in red
112
+ * }
113
+ */
114
+ export declare const ColorTextInlineSchema: z.ZodObject<{
115
+ type: z.ZodLiteral<"ColorText">;
116
+ value: z.ZodString;
117
+ color: z.ZodString;
118
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
119
+ }, "strip", z.ZodTypeAny, {
120
+ value: string;
121
+ type: "ColorText";
122
+ color: string;
123
+ highlight?: [number, number] | undefined;
124
+ }, {
125
+ value: string;
126
+ type: "ColorText";
127
+ color: string;
128
+ highlight?: [number, number] | undefined;
129
+ }>;
130
+
131
+ export declare const ColorTextSchema: z.ZodObject<{
132
+ id: z.ZodString;
133
+ type: z.ZodLiteral<"color-text">;
134
+ value: z.ZodString;
135
+ color: z.ZodString;
136
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
137
+ }, "strip", z.ZodTypeAny, {
138
+ value: string;
139
+ type: "color-text";
140
+ color: string;
141
+ id: string;
142
+ highlight?: [number, number] | undefined;
143
+ }, {
144
+ value: string;
145
+ type: "color-text";
146
+ color: string;
147
+ id: string;
148
+ highlight?: [number, number] | undefined;
149
+ }>;
150
+
45
151
  /**
46
152
  * Compile DSL text directly to JSON (convenience function)
47
153
  *
@@ -91,6 +197,15 @@ export declare function compileWithAST(dsl: string): {
91
197
  value: string;
92
198
  type: "HighlightedText";
93
199
  highlight?: [number, number] | undefined;
200
+ } | {
201
+ value: string;
202
+ type: "ColorText";
203
+ color: string;
204
+ highlight?: [number, number] | undefined;
205
+ } | {
206
+ value: string;
207
+ type: "BoldText";
208
+ highlight?: [number, number] | undefined;
94
209
  } | {
95
210
  length: number;
96
211
  type: "InlineInput";
@@ -153,6 +268,16 @@ export declare function compileWithAST(dsl: string): {
153
268
  };
154
269
  };
155
270
 
271
+ /**
272
+ * Create a bold text inline element
273
+ */
274
+ export declare function createBoldText(value: string, highlight?: [number, number]): BoldTextInline;
275
+
276
+ /**
277
+ * Create a color text inline element
278
+ */
279
+ export declare function createColorText(value: string, color: string, highlight?: [number, number]): ColorTextInline;
280
+
156
281
  /**
157
282
  * Create a drag options tool
158
283
  */
@@ -347,6 +472,33 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
347
472
  value: string;
348
473
  type: "HighlightedText";
349
474
  highlight?: [number, number] | undefined;
475
+ }>, z.ZodObject<{
476
+ type: z.ZodLiteral<"ColorText">;
477
+ value: z.ZodString;
478
+ color: z.ZodString;
479
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
480
+ }, "strip", z.ZodTypeAny, {
481
+ value: string;
482
+ type: "ColorText";
483
+ color: string;
484
+ highlight?: [number, number] | undefined;
485
+ }, {
486
+ value: string;
487
+ type: "ColorText";
488
+ color: string;
489
+ highlight?: [number, number] | undefined;
490
+ }>, z.ZodObject<{
491
+ type: z.ZodLiteral<"BoldText">;
492
+ value: z.ZodString;
493
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
494
+ }, "strip", z.ZodTypeAny, {
495
+ value: string;
496
+ type: "BoldText";
497
+ highlight?: [number, number] | undefined;
498
+ }, {
499
+ value: string;
500
+ type: "BoldText";
501
+ highlight?: [number, number] | undefined;
350
502
  }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
351
503
  type: z.ZodLiteral<"InlineInput">;
352
504
  name: z.ZodString;
@@ -395,6 +547,15 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
395
547
  value: string;
396
548
  type: "HighlightedText";
397
549
  highlight?: [number, number] | undefined;
550
+ } | {
551
+ value: string;
552
+ type: "ColorText";
553
+ color: string;
554
+ highlight?: [number, number] | undefined;
555
+ } | {
556
+ value: string;
557
+ type: "BoldText";
558
+ highlight?: [number, number] | undefined;
398
559
  } | {
399
560
  length: number;
400
561
  type: "InlineInput";
@@ -419,6 +580,15 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
419
580
  value: string;
420
581
  type: "HighlightedText";
421
582
  highlight?: [number, number] | undefined;
583
+ } | {
584
+ value: string;
585
+ type: "ColorText";
586
+ color: string;
587
+ highlight?: [number, number] | undefined;
588
+ } | {
589
+ value: string;
590
+ type: "BoldText";
591
+ highlight?: [number, number] | undefined;
422
592
  } | {
423
593
  length: number;
424
594
  type: "InlineInput";
@@ -490,6 +660,15 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
490
660
  value: string;
491
661
  type: "HighlightedText";
492
662
  highlight?: [number, number] | undefined;
663
+ } | {
664
+ value: string;
665
+ type: "ColorText";
666
+ color: string;
667
+ highlight?: [number, number] | undefined;
668
+ } | {
669
+ value: string;
670
+ type: "BoldText";
671
+ highlight?: [number, number] | undefined;
493
672
  } | {
494
673
  length: number;
495
674
  type: "InlineInput";
@@ -535,6 +714,15 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
535
714
  value: string;
536
715
  type: "HighlightedText";
537
716
  highlight?: [number, number] | undefined;
717
+ } | {
718
+ value: string;
719
+ type: "ColorText";
720
+ color: string;
721
+ highlight?: [number, number] | undefined;
722
+ } | {
723
+ value: string;
724
+ type: "BoldText";
725
+ highlight?: [number, number] | undefined;
538
726
  } | {
539
727
  length: number;
540
728
  type: "InlineInput";
@@ -1021,6 +1209,33 @@ export declare const InlineNodeSchema: z.ZodUnion<[z.ZodObject<{
1021
1209
  value: string;
1022
1210
  type: "HighlightedText";
1023
1211
  highlight?: [number, number] | undefined;
1212
+ }>, z.ZodObject<{
1213
+ type: z.ZodLiteral<"ColorText">;
1214
+ value: z.ZodString;
1215
+ color: z.ZodString;
1216
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1217
+ }, "strip", z.ZodTypeAny, {
1218
+ value: string;
1219
+ type: "ColorText";
1220
+ color: string;
1221
+ highlight?: [number, number] | undefined;
1222
+ }, {
1223
+ value: string;
1224
+ type: "ColorText";
1225
+ color: string;
1226
+ highlight?: [number, number] | undefined;
1227
+ }>, z.ZodObject<{
1228
+ type: z.ZodLiteral<"BoldText">;
1229
+ value: z.ZodString;
1230
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1231
+ }, "strip", z.ZodTypeAny, {
1232
+ value: string;
1233
+ type: "BoldText";
1234
+ highlight?: [number, number] | undefined;
1235
+ }, {
1236
+ value: string;
1237
+ type: "BoldText";
1238
+ highlight?: [number, number] | undefined;
1024
1239
  }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
1025
1240
  type: z.ZodLiteral<"InlineInput">;
1026
1241
  name: z.ZodString;
@@ -1059,6 +1274,20 @@ export declare const InlineNodeSchema: z.ZodUnion<[z.ZodObject<{
1059
1274
  answer?: string | number | undefined;
1060
1275
  }>]>]>;
1061
1276
 
1277
+ /**
1278
+ * Type guard for BoldText
1279
+ */
1280
+ export declare function isBoldText(item: LayoutItem): item is Extract<LayoutItem, {
1281
+ type: 'bold-text';
1282
+ }>;
1283
+
1284
+ /**
1285
+ * Type guard for ColorText
1286
+ */
1287
+ export declare function isColorText(item: LayoutItem): item is Extract<LayoutItem, {
1288
+ type: 'color-text';
1289
+ }>;
1290
+
1062
1291
  export declare function isDragOptions(value: unknown): value is DragOptionsTool;
1063
1292
 
1064
1293
  /**
@@ -1177,6 +1406,10 @@ export declare const JSON_TYPES: {
1177
1406
  readonly SPACE: "space";
1178
1407
  /** Text with optional highlighting */
1179
1408
  readonly HIGHLIGHTED_TEXT: "highlighted-text";
1409
+ /** Text with color styling */
1410
+ readonly COLOR_TEXT: "color-text";
1411
+ /** Bold text */
1412
+ readonly BOLD_TEXT: "bold-text";
1180
1413
  /** Reference to a widget */
1181
1414
  readonly WIDGET_REF: "widget-ref";
1182
1415
  /** Line break element */
@@ -1272,6 +1505,33 @@ export declare const LineBlockSchema: z.ZodObject<{
1272
1505
  value: string;
1273
1506
  type: "HighlightedText";
1274
1507
  highlight?: [number, number] | undefined;
1508
+ }>, z.ZodObject<{
1509
+ type: z.ZodLiteral<"ColorText">;
1510
+ value: z.ZodString;
1511
+ color: z.ZodString;
1512
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1513
+ }, "strip", z.ZodTypeAny, {
1514
+ value: string;
1515
+ type: "ColorText";
1516
+ color: string;
1517
+ highlight?: [number, number] | undefined;
1518
+ }, {
1519
+ value: string;
1520
+ type: "ColorText";
1521
+ color: string;
1522
+ highlight?: [number, number] | undefined;
1523
+ }>, z.ZodObject<{
1524
+ type: z.ZodLiteral<"BoldText">;
1525
+ value: z.ZodString;
1526
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1527
+ }, "strip", z.ZodTypeAny, {
1528
+ value: string;
1529
+ type: "BoldText";
1530
+ highlight?: [number, number] | undefined;
1531
+ }, {
1532
+ value: string;
1533
+ type: "BoldText";
1534
+ highlight?: [number, number] | undefined;
1275
1535
  }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
1276
1536
  type: z.ZodLiteral<"InlineInput">;
1277
1537
  name: z.ZodString;
@@ -1320,6 +1580,15 @@ export declare const LineBlockSchema: z.ZodObject<{
1320
1580
  value: string;
1321
1581
  type: "HighlightedText";
1322
1582
  highlight?: [number, number] | undefined;
1583
+ } | {
1584
+ value: string;
1585
+ type: "ColorText";
1586
+ color: string;
1587
+ highlight?: [number, number] | undefined;
1588
+ } | {
1589
+ value: string;
1590
+ type: "BoldText";
1591
+ highlight?: [number, number] | undefined;
1323
1592
  } | {
1324
1593
  length: number;
1325
1594
  type: "InlineInput";
@@ -1344,6 +1613,15 @@ export declare const LineBlockSchema: z.ZodObject<{
1344
1613
  value: string;
1345
1614
  type: "HighlightedText";
1346
1615
  highlight?: [number, number] | undefined;
1616
+ } | {
1617
+ value: string;
1618
+ type: "ColorText";
1619
+ color: string;
1620
+ highlight?: [number, number] | undefined;
1621
+ } | {
1622
+ value: string;
1623
+ type: "BoldText";
1624
+ highlight?: [number, number] | undefined;
1347
1625
  } | {
1348
1626
  length: number;
1349
1627
  type: "InlineInput";
package/dist/index.js CHANGED
@@ -16,6 +16,10 @@ const AST_TYPES = {
16
16
  SPACE: "Space",
17
17
  /** Text with optional character-range highlighting */
18
18
  HIGHLIGHTED_TEXT: "HighlightedText",
19
+ /** Text with color and optional character-range coloring */
20
+ COLOR_TEXT: "ColorText",
21
+ /** Bold text with optional character-range bolding */
22
+ BOLD_TEXT: "BoldText",
19
23
  /** Inline input widget (string or numeric) */
20
24
  INLINE_INPUT: "InlineInput",
21
25
  // ═══════════════════════════════════════════════════════════════════════════
@@ -57,6 +61,10 @@ const JSON_TYPES = {
57
61
  SPACE: "space",
58
62
  /** Text with optional highlighting */
59
63
  HIGHLIGHTED_TEXT: "highlighted-text",
64
+ /** Text with color styling */
65
+ COLOR_TEXT: "color-text",
66
+ /** Bold text */
67
+ BOLD_TEXT: "bold-text",
60
68
  /** Reference to a widget */
61
69
  WIDGET_REF: "widget-ref",
62
70
  /** Line break element */
@@ -116,6 +124,14 @@ const TEXT_HIGHLIGHTER = chevrotain.createToken({
116
124
  name: "TEXT_HIGHLIGHTER",
117
125
  pattern: /TEXT_HIGHLIGHTER/
118
126
  });
127
+ const COLOR_TEXT = chevrotain.createToken({
128
+ name: "COLOR_TEXT",
129
+ pattern: /COLOR_TEXT/
130
+ });
131
+ const BOLD_TEXT = chevrotain.createToken({
132
+ name: "BOLD_TEXT",
133
+ pattern: /BOLD_TEXT/
134
+ });
119
135
  const HIGHLIGHT_TEXT = chevrotain.createToken({
120
136
  name: "HIGHLIGHT_TEXT",
121
137
  pattern: /HIGHLIGHT_TEXT/
@@ -231,6 +247,8 @@ const allTokens = [
231
247
  // Component keywords (before Identifier!)
232
248
  QUESTION_TEXT,
233
249
  TEXT_HIGHLIGHTER,
250
+ COLOR_TEXT,
251
+ BOLD_TEXT,
234
252
  HIGHLIGHT_TEXT,
235
253
  W_S_I,
236
254
  STRING_INPUT,
@@ -420,6 +438,10 @@ class MathExerciseParser extends chevrotain.CstParser {
420
438
  { ALT: () => this.CONSUME(RParen) },
421
439
  // TEXT_HIGHLIGHTER / HIGHLIGHT_TEXT (for highlighting)
422
440
  { ALT: () => this.SUBRULE(this.textHighlighter) },
441
+ // COLOR_TEXT (for colored text)
442
+ { ALT: () => this.SUBRULE(this.colorText) },
443
+ // BOLD_TEXT (for bold text)
444
+ { ALT: () => this.SUBRULE(this.boldText) },
423
445
  // W_S_I (inline input widget)
424
446
  { ALT: () => this.SUBRULE(this.inlineInput) }
425
447
  ]);
@@ -433,6 +455,18 @@ class MathExerciseParser extends chevrotain.CstParser {
433
455
  this.SUBRULE(this.parameterList);
434
456
  this.CONSUME(RBracket);
435
457
  });
458
+ this.colorText = this.RULE("colorText", () => {
459
+ this.CONSUME(COLOR_TEXT);
460
+ this.CONSUME(LBracket);
461
+ this.SUBRULE(this.parameterList);
462
+ this.CONSUME(RBracket);
463
+ });
464
+ this.boldText = this.RULE("boldText", () => {
465
+ this.CONSUME(BOLD_TEXT);
466
+ this.CONSUME(LBracket);
467
+ this.SUBRULE(this.parameterList);
468
+ this.CONSUME(RBracket);
469
+ });
436
470
  this.inlineInput = this.RULE("inlineInput", () => {
437
471
  this.OR([
438
472
  { ALT: () => this.CONSUME(W_S_I, { LABEL: "stringInput" }) },
@@ -575,6 +609,17 @@ const HighlightedTextInlineSchema = zod.z.object({
575
609
  value: zod.z.string(),
576
610
  highlight: zod.z.tuple([zod.z.number(), zod.z.number()]).optional()
577
611
  });
612
+ const ColorTextInlineSchema = zod.z.object({
613
+ type: zod.z.literal(AST_TYPES.COLOR_TEXT),
614
+ value: zod.z.string(),
615
+ color: zod.z.string(),
616
+ highlight: zod.z.tuple([zod.z.number(), zod.z.number()]).optional()
617
+ });
618
+ const BoldTextInlineSchema = zod.z.object({
619
+ type: zod.z.literal(AST_TYPES.BOLD_TEXT),
620
+ value: zod.z.string(),
621
+ highlight: zod.z.tuple([zod.z.number(), zod.z.number()]).optional()
622
+ });
578
623
  const InlineInputWidgetSchema = zod.z.discriminatedUnion("inputType", [
579
624
  zod.z.object({
580
625
  type: zod.z.literal(AST_TYPES.INLINE_INPUT),
@@ -595,6 +640,8 @@ const InlineNodeSchema = zod.z.union([
595
640
  FreeTextInlineSchema,
596
641
  SpaceInlineSchema,
597
642
  HighlightedTextInlineSchema,
643
+ ColorTextInlineSchema,
644
+ BoldTextInlineSchema,
598
645
  InlineInputWidgetSchema
599
646
  ]);
600
647
  function createFreeText(value) {
@@ -615,6 +662,21 @@ function createHighlightedText(value, highlight) {
615
662
  highlight
616
663
  });
617
664
  }
665
+ function createColorText(value, color, highlight) {
666
+ return ColorTextInlineSchema.parse({
667
+ type: AST_TYPES.COLOR_TEXT,
668
+ value,
669
+ color,
670
+ highlight
671
+ });
672
+ }
673
+ function createBoldText(value, highlight) {
674
+ return BoldTextInlineSchema.parse({
675
+ type: AST_TYPES.BOLD_TEXT,
676
+ value,
677
+ highlight
678
+ });
679
+ }
618
680
  function createStringInput(name, length, answer) {
619
681
  return InlineInputWidgetSchema.parse({
620
682
  type: AST_TYPES.INLINE_INPUT,
@@ -858,6 +920,12 @@ class NaturalDSLVisitor extends BaseCstVisitor {
858
920
  if (ctx.textHighlighter) {
859
921
  return this.visit(ctx.textHighlighter);
860
922
  }
923
+ if (ctx.colorText) {
924
+ return this.visit(ctx.colorText);
925
+ }
926
+ if (ctx.boldText) {
927
+ return this.visit(ctx.boldText);
928
+ }
861
929
  if (ctx.inlineInput) {
862
930
  return this.visit(ctx.inlineInput);
863
931
  }
@@ -872,6 +940,25 @@ class NaturalDSLVisitor extends BaseCstVisitor {
872
940
  }
873
941
  return createHighlightedText(value, highlight);
874
942
  }
943
+ colorText(ctx) {
944
+ const params = this.visit(ctx.parameterList);
945
+ const value = params.value;
946
+ const color = params.color;
947
+ let highlight = void 0;
948
+ if (params.start !== void 0 && params.end !== void 0) {
949
+ highlight = [params.start, params.end];
950
+ }
951
+ return createColorText(value, color, highlight);
952
+ }
953
+ boldText(ctx) {
954
+ const params = this.visit(ctx.parameterList);
955
+ const value = params.value;
956
+ let highlight = void 0;
957
+ if (params.start !== void 0 && params.end !== void 0) {
958
+ highlight = [params.start, params.end];
959
+ }
960
+ return createBoldText(value, highlight);
961
+ }
875
962
  inlineInput(ctx) {
876
963
  const params = this.visit(ctx.parameterList);
877
964
  const name = params.name;
@@ -1014,6 +1101,19 @@ const HighlightedTextSchema = zod.z.object({
1014
1101
  value: zod.z.string(),
1015
1102
  highlight: zod.z.tuple([zod.z.number(), zod.z.number()]).optional()
1016
1103
  });
1104
+ const ColorTextSchema = zod.z.object({
1105
+ id: zod.z.string(),
1106
+ type: zod.z.literal(JSON_TYPES.COLOR_TEXT),
1107
+ value: zod.z.string(),
1108
+ color: zod.z.string(),
1109
+ highlight: zod.z.tuple([zod.z.number(), zod.z.number()]).optional()
1110
+ });
1111
+ const BoldTextSchema = zod.z.object({
1112
+ id: zod.z.string(),
1113
+ type: zod.z.literal(JSON_TYPES.BOLD_TEXT),
1114
+ value: zod.z.string(),
1115
+ highlight: zod.z.tuple([zod.z.number(), zod.z.number()]).optional()
1116
+ });
1017
1117
  const LinebreakSchema = zod.z.object({
1018
1118
  id: zod.z.string(),
1019
1119
  type: zod.z.literal(JSON_TYPES.LINEBREAK)
@@ -1030,6 +1130,8 @@ const LayoutItemSchema = zod.z.lazy(
1030
1130
  TextItemSchema,
1031
1131
  WidgetRefSchema,
1032
1132
  HighlightedTextSchema,
1133
+ ColorTextSchema,
1134
+ BoldTextSchema,
1033
1135
  LinebreakSchema,
1034
1136
  GroupItemSchema,
1035
1137
  OperatorItemSchema
@@ -1112,6 +1214,12 @@ function isWidgetRef(item) {
1112
1214
  function isHighlightedText(item) {
1113
1215
  return item.type === JSON_TYPES.HIGHLIGHTED_TEXT;
1114
1216
  }
1217
+ function isColorText(item) {
1218
+ return item.type === JSON_TYPES.COLOR_TEXT;
1219
+ }
1220
+ function isBoldText(item) {
1221
+ return item.type === JSON_TYPES.BOLD_TEXT;
1222
+ }
1115
1223
  function isLinebreak(item) {
1116
1224
  return item.type === JSON_TYPES.LINEBREAK;
1117
1225
  }
@@ -1244,6 +1352,21 @@ function transformInline(inline, idGenerator) {
1244
1352
  value: inline.value,
1245
1353
  highlight: inline.highlight
1246
1354
  };
1355
+ case AST_TYPES.COLOR_TEXT:
1356
+ return {
1357
+ id: idGenerator.generate(JSON_TYPES.COLOR_TEXT),
1358
+ type: JSON_TYPES.COLOR_TEXT,
1359
+ value: inline.value,
1360
+ color: inline.color,
1361
+ highlight: inline.highlight
1362
+ };
1363
+ case AST_TYPES.BOLD_TEXT:
1364
+ return {
1365
+ id: idGenerator.generate(JSON_TYPES.BOLD_TEXT),
1366
+ type: JSON_TYPES.BOLD_TEXT,
1367
+ value: inline.value,
1368
+ highlight: inline.highlight
1369
+ };
1247
1370
  case AST_TYPES.INLINE_INPUT:
1248
1371
  return {
1249
1372
  id: idGenerator.generate(JSON_TYPES.WIDGET_REF),
@@ -5860,7 +5983,7 @@ function itemContainsLatin(item) {
5860
5983
  return false;
5861
5984
  }
5862
5985
  function isTextItem(item) {
5863
- return item.type === JSON_TYPES.TEXT || item.type === JSON_TYPES.HIGHLIGHTED_TEXT || item.type === JSON_TYPES.OPERATOR || item.type === JSON_TYPES.SPACE || item.type === JSON_TYPES.GROUP;
5986
+ return item.type === JSON_TYPES.TEXT || item.type === JSON_TYPES.HIGHLIGHTED_TEXT || item.type === JSON_TYPES.BOLD_TEXT || item.type === JSON_TYPES.COLOR_TEXT || item.type === JSON_TYPES.OPERATOR || item.type === JSON_TYPES.SPACE || item.type === JSON_TYPES.GROUP;
5864
5987
  }
5865
5988
  function groupLineItems(items) {
5866
5989
  const groups = [];
@@ -5907,13 +6030,39 @@ const LayoutRenderer = ({
5907
6030
  const dirAttr = !hasArabic ? "ltr" : void 0;
5908
6031
  if (item.highlight) {
5909
6032
  const [start, end] = item.highlight;
5910
- return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "highlighted-text", dir: dirAttr, children: [
6033
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "highlighted-text text-item", dir: dirAttr, children: [
6034
+ item.value.slice(0, start),
6035
+ /* @__PURE__ */ jsxRuntime.jsx("mark", { className: "highlight text-item", children: item.value.slice(start, end) }),
6036
+ item.value.slice(end)
6037
+ ] });
6038
+ }
6039
+ return /* @__PURE__ */ jsxRuntime.jsx("mark", { className: "highlighted-text text-item", dir: dirAttr, children: item.value });
6040
+ }
6041
+ case JSON_TYPES.COLOR_TEXT: {
6042
+ const hasArabic = isArabic(item.value);
6043
+ const dirAttr = !hasArabic ? "ltr" : void 0;
6044
+ if (item.highlight) {
6045
+ const [start, end] = item.highlight;
6046
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "color-text text-item", dir: dirAttr, children: [
6047
+ item.value.slice(0, start),
6048
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "color-text-colored", style: { color: item.color }, children: item.value.slice(start, end) }),
6049
+ item.value.slice(end)
6050
+ ] });
6051
+ }
6052
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "color-text text-item", style: { color: item.color }, dir: dirAttr, children: item.value });
6053
+ }
6054
+ case JSON_TYPES.BOLD_TEXT: {
6055
+ const hasArabic = isArabic(item.value);
6056
+ const dirAttr = !hasArabic ? "ltr" : void 0;
6057
+ if (item.highlight) {
6058
+ const [start, end] = item.highlight;
6059
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "bold-text text-item", dir: dirAttr, children: [
5911
6060
  item.value.slice(0, start),
5912
- /* @__PURE__ */ jsxRuntime.jsx("mark", { className: "highlight", children: item.value.slice(start, end) }),
6061
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { className: "bold-text-strong text-item", children: item.value.slice(start, end) }),
5913
6062
  item.value.slice(end)
5914
6063
  ] });
5915
6064
  }
5916
- return /* @__PURE__ */ jsxRuntime.jsx("mark", { className: "highlighted-text", dir: dirAttr, children: item.value });
6065
+ return /* @__PURE__ */ jsxRuntime.jsx("strong", { className: "bold-text text-item", dir: dirAttr, children: item.value });
5917
6066
  }
5918
6067
  case JSON_TYPES.WIDGET_REF: {
5919
6068
  const widget = widgets[item.widgetId];
@@ -38140,6 +38289,10 @@ function compileWithAST(dsl) {
38140
38289
  return { ast, json };
38141
38290
  }
38142
38291
  exports.AST_TYPES = AST_TYPES;
38292
+ exports.BoldTextInlineSchema = BoldTextInlineSchema;
38293
+ exports.BoldTextSchema = BoldTextSchema;
38294
+ exports.ColorTextInlineSchema = ColorTextInlineSchema;
38295
+ exports.ColorTextSchema = ColorTextSchema;
38143
38296
  exports.DragOptionsJSONSchema = DragOptionsJSONSchema;
38144
38297
  exports.DragOptionsToolSchema = DragOptionsToolSchema;
38145
38298
  exports.EngineError = EngineError;
@@ -38181,6 +38334,8 @@ exports.WidgetRefSchema = WidgetRefSchema;
38181
38334
  exports.WidgetRenderer = WidgetRenderer;
38182
38335
  exports.compile = compile;
38183
38336
  exports.compileWithAST = compileWithAST;
38337
+ exports.createBoldText = createBoldText;
38338
+ exports.createColorText = createColorText;
38184
38339
  exports.createDragOptions = createDragOptions;
38185
38340
  exports.createExerciseDocument = createExerciseDocument;
38186
38341
  exports.createExpressionValidation = createExpressionValidation;
@@ -38197,6 +38352,8 @@ exports.evaluate = evaluate;
38197
38352
  exports.extractExpressionVariables = extractVariables;
38198
38353
  exports.findValidCombination = findValidCombination;
38199
38354
  exports.getMissingInputs = getMissingInputs;
38355
+ exports.isBoldText = isBoldText;
38356
+ exports.isColorText = isColorText;
38200
38357
  exports.isDragOptions = isDragOptions;
38201
38358
  exports.isDragOptionsJSON = isDragOptionsJSON;
38202
38359
  exports.isExerciseDocument = isExerciseDocument;