@gmb/bitmark-parser-generator 1.35.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (290) hide show
  1. package/dist/browser/bitmark-parser-generator.min.js +1 -1
  2. package/dist/browser/bundle-report.html +2 -2
  3. package/dist/cjs/BitmarkParserGenerator.js +8 -3
  4. package/dist/cjs/BitmarkParserGenerator.js.map +1 -1
  5. package/dist/cjs/ast/Ast.js +1 -0
  6. package/dist/cjs/ast/Ast.js.map +1 -1
  7. package/dist/cjs/ast/BaseBuilder.js +91 -54
  8. package/dist/cjs/ast/BaseBuilder.js.map +1 -1
  9. package/dist/cjs/ast/Builder.js +776 -389
  10. package/dist/cjs/ast/Builder.js.map +1 -1
  11. package/dist/cjs/ast/ResourceBuilder.js +516 -252
  12. package/dist/cjs/ast/ResourceBuilder.js.map +1 -1
  13. package/dist/cjs/ast/rules/NodeValidator.js +61 -22
  14. package/dist/cjs/ast/rules/NodeValidator.js.map +1 -1
  15. package/dist/cjs/breakscaping/Breakscape.js +96 -71
  16. package/dist/cjs/breakscaping/Breakscape.js.map +1 -1
  17. package/dist/cjs/config/raw/bits.js +14 -5
  18. package/dist/cjs/config/raw/bits.js.map +1 -1
  19. package/dist/cjs/config/raw/properties.js +7 -2
  20. package/dist/cjs/config/raw/properties.js.map +1 -1
  21. package/dist/cjs/generated/build-info.js +1 -1
  22. package/dist/cjs/generated/build-info.js.map +1 -1
  23. package/dist/cjs/generated/parser/bitmark/bitmark-peggy-parser.js +1 -0
  24. package/dist/cjs/generated/parser/bitmark/bitmark-peggy-parser.js.map +1 -1
  25. package/dist/cjs/generator/AstWalkerGenerator.js +4 -1
  26. package/dist/cjs/generator/AstWalkerGenerator.js.map +1 -1
  27. package/dist/cjs/generator/bitmark/BitmarkGenerator.js +959 -338
  28. package/dist/cjs/generator/bitmark/BitmarkGenerator.js.map +1 -1
  29. package/dist/cjs/generator/json/JsonGenerator.js +308 -1982
  30. package/dist/cjs/generator/json/JsonGenerator.js.map +1 -1
  31. package/dist/cjs/generator/text/TextGenerator.js +26 -8
  32. package/dist/cjs/generator/text/TextGenerator.js.map +1 -1
  33. package/dist/cjs/index.js.map +1 -1
  34. package/dist/cjs/model/ast/NodeType.js +27 -8
  35. package/dist/cjs/model/ast/NodeType.js.map +1 -1
  36. package/dist/cjs/model/config/enum/PropertyConfigKey.js +1 -0
  37. package/dist/cjs/model/config/enum/PropertyConfigKey.js.map +1 -1
  38. package/dist/cjs/model/enum/BitType.js +1 -2
  39. package/dist/cjs/model/enum/BitType.js.map +1 -1
  40. package/dist/cjs/model/enum/PropertyFormat.js +3 -1
  41. package/dist/cjs/model/enum/PropertyFormat.js.map +1 -1
  42. package/dist/cjs/model/enum/TextFormat.js +1 -1
  43. package/dist/cjs/parser/bitmark/peg/BitmarkPegParserHelper.js +9 -3
  44. package/dist/cjs/parser/bitmark/peg/BitmarkPegParserHelper.js.map +1 -1
  45. package/dist/cjs/parser/bitmark/peg/BitmarkPegParserProcessor.js +49 -131
  46. package/dist/cjs/parser/bitmark/peg/BitmarkPegParserProcessor.js.map +1 -1
  47. package/dist/cjs/parser/bitmark/peg/BitmarkPegParserTypes.js.map +1 -1
  48. package/dist/cjs/parser/bitmark/peg/BitmarkPegParserValidator.js +7 -31
  49. package/dist/cjs/parser/bitmark/peg/BitmarkPegParserValidator.js.map +1 -1
  50. package/dist/cjs/parser/bitmark/peg/contentProcessors/BodyContentProcessor.js +255 -0
  51. package/dist/cjs/parser/bitmark/peg/contentProcessors/BodyContentProcessor.js.map +1 -0
  52. package/dist/cjs/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.js +2 -1
  53. package/dist/cjs/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.js.map +1 -1
  54. package/dist/cjs/parser/bitmark/peg/contentProcessors/CardContentProcessor.js +175 -129
  55. package/dist/cjs/parser/bitmark/peg/contentProcessors/CardContentProcessor.js.map +1 -1
  56. package/dist/cjs/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.js +8 -2
  57. package/dist/cjs/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.js.map +1 -1
  58. package/dist/cjs/parser/bitmark/peg/contentProcessors/ContentProcessorUtils.js +61 -0
  59. package/dist/cjs/parser/bitmark/peg/contentProcessors/ContentProcessorUtils.js.map +1 -0
  60. package/dist/cjs/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.js +11 -5
  61. package/dist/cjs/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.js.map +1 -1
  62. package/dist/cjs/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js +21 -17
  63. package/dist/cjs/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js.map +1 -1
  64. package/dist/cjs/parser/bitmark/peg/contentProcessors/FooterContentProcessor.js +50 -0
  65. package/dist/cjs/parser/bitmark/peg/contentProcessors/FooterContentProcessor.js.map +1 -0
  66. package/dist/cjs/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.js +2 -15
  67. package/dist/cjs/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.js.map +1 -1
  68. package/dist/cjs/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.js +2 -4
  69. package/dist/cjs/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.js.map +1 -1
  70. package/dist/cjs/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.js +4 -1
  71. package/dist/cjs/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.js.map +1 -1
  72. package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.js +2 -4
  73. package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.js.map +1 -1
  74. package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.js +5 -5
  75. package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.js.map +1 -1
  76. package/dist/cjs/parser/bitmark/peg/contentProcessors/PersonChainContentProcessor.js +5 -6
  77. package/dist/cjs/parser/bitmark/peg/contentProcessors/PersonChainContentProcessor.js.map +1 -1
  78. package/dist/cjs/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js +23 -7
  79. package/dist/cjs/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js.map +1 -1
  80. package/dist/cjs/parser/bitmark/peg/contentProcessors/RatingLevelChainContentProcessor.js +5 -5
  81. package/dist/cjs/parser/bitmark/peg/contentProcessors/RatingLevelChainContentProcessor.js.map +1 -1
  82. package/dist/cjs/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.js +3 -2
  83. package/dist/cjs/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.js.map +1 -1
  84. package/dist/cjs/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.js +19 -8
  85. package/dist/cjs/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.js.map +1 -1
  86. package/dist/cjs/parser/bitmark/peg/contentProcessors/ServingsChainContentProcessor.js +4 -6
  87. package/dist/cjs/parser/bitmark/peg/contentProcessors/ServingsChainContentProcessor.js.map +1 -1
  88. package/dist/cjs/parser/bitmark/peg/contentProcessors/TechnicalTermChainContentProcessor.js +4 -5
  89. package/dist/cjs/parser/bitmark/peg/contentProcessors/TechnicalTermChainContentProcessor.js.map +1 -1
  90. package/dist/cjs/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.js +14 -5
  91. package/dist/cjs/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.js.map +1 -1
  92. package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.js +37 -21
  93. package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.js.map +1 -1
  94. package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js +3 -2
  95. package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js.map +1 -1
  96. package/dist/cjs/parser/json/JsonParser.js +73 -765
  97. package/dist/cjs/parser/json/JsonParser.js.map +1 -1
  98. package/dist/cjs/parser/text/TextParser.js +61 -2
  99. package/dist/cjs/parser/text/TextParser.js.map +1 -1
  100. package/dist/cjs/utils/BitUtils.js +15 -13
  101. package/dist/cjs/utils/BitUtils.js.map +1 -1
  102. package/dist/esm/BitmarkParserGenerator.js +8 -3
  103. package/dist/esm/BitmarkParserGenerator.js.map +1 -1
  104. package/dist/esm/ast/Ast.js +1 -0
  105. package/dist/esm/ast/Ast.js.map +1 -1
  106. package/dist/esm/ast/BaseBuilder.js +91 -54
  107. package/dist/esm/ast/BaseBuilder.js.map +1 -1
  108. package/dist/esm/ast/Builder.js +776 -389
  109. package/dist/esm/ast/Builder.js.map +1 -1
  110. package/dist/esm/ast/ResourceBuilder.js +516 -252
  111. package/dist/esm/ast/ResourceBuilder.js.map +1 -1
  112. package/dist/esm/ast/rules/NodeValidator.js +61 -22
  113. package/dist/esm/ast/rules/NodeValidator.js.map +1 -1
  114. package/dist/esm/breakscaping/Breakscape.js +96 -71
  115. package/dist/esm/breakscaping/Breakscape.js.map +1 -1
  116. package/dist/esm/config/raw/bits.js +14 -5
  117. package/dist/esm/config/raw/bits.js.map +1 -1
  118. package/dist/esm/config/raw/properties.js +7 -2
  119. package/dist/esm/config/raw/properties.js.map +1 -1
  120. package/dist/esm/generated/build-info.js +1 -1
  121. package/dist/esm/generated/build-info.js.map +1 -1
  122. package/dist/esm/generated/parser/bitmark/bitmark-peggy-parser.js +1 -0
  123. package/dist/esm/generated/parser/bitmark/bitmark-peggy-parser.js.map +1 -1
  124. package/dist/esm/generator/AstWalkerGenerator.js +4 -1
  125. package/dist/esm/generator/AstWalkerGenerator.js.map +1 -1
  126. package/dist/esm/generator/bitmark/BitmarkGenerator.js +959 -338
  127. package/dist/esm/generator/bitmark/BitmarkGenerator.js.map +1 -1
  128. package/dist/esm/generator/json/JsonGenerator.js +308 -1982
  129. package/dist/esm/generator/json/JsonGenerator.js.map +1 -1
  130. package/dist/esm/generator/text/TextGenerator.js +26 -8
  131. package/dist/esm/generator/text/TextGenerator.js.map +1 -1
  132. package/dist/esm/index.js.map +1 -1
  133. package/dist/esm/model/ast/NodeType.js +27 -8
  134. package/dist/esm/model/ast/NodeType.js.map +1 -1
  135. package/dist/esm/model/config/enum/PropertyConfigKey.js +1 -0
  136. package/dist/esm/model/config/enum/PropertyConfigKey.js.map +1 -1
  137. package/dist/esm/model/enum/BitType.js +1 -2
  138. package/dist/esm/model/enum/BitType.js.map +1 -1
  139. package/dist/esm/model/enum/PropertyFormat.js +3 -1
  140. package/dist/esm/model/enum/PropertyFormat.js.map +1 -1
  141. package/dist/esm/model/enum/TextFormat.js +1 -1
  142. package/dist/esm/parser/bitmark/peg/BitmarkPegParserHelper.js +9 -3
  143. package/dist/esm/parser/bitmark/peg/BitmarkPegParserHelper.js.map +1 -1
  144. package/dist/esm/parser/bitmark/peg/BitmarkPegParserProcessor.js +49 -131
  145. package/dist/esm/parser/bitmark/peg/BitmarkPegParserProcessor.js.map +1 -1
  146. package/dist/esm/parser/bitmark/peg/BitmarkPegParserTypes.js.map +1 -1
  147. package/dist/esm/parser/bitmark/peg/BitmarkPegParserValidator.js +7 -31
  148. package/dist/esm/parser/bitmark/peg/BitmarkPegParserValidator.js.map +1 -1
  149. package/dist/esm/parser/bitmark/peg/contentProcessors/BodyContentProcessor.js +252 -0
  150. package/dist/esm/parser/bitmark/peg/contentProcessors/BodyContentProcessor.js.map +1 -0
  151. package/dist/esm/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.js +2 -1
  152. package/dist/esm/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.js.map +1 -1
  153. package/dist/esm/parser/bitmark/peg/contentProcessors/CardContentProcessor.js +175 -129
  154. package/dist/esm/parser/bitmark/peg/contentProcessors/CardContentProcessor.js.map +1 -1
  155. package/dist/esm/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.js +8 -2
  156. package/dist/esm/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.js.map +1 -1
  157. package/dist/esm/parser/bitmark/peg/contentProcessors/ContentProcessorUtils.js +58 -0
  158. package/dist/esm/parser/bitmark/peg/contentProcessors/ContentProcessorUtils.js.map +1 -0
  159. package/dist/esm/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.js +11 -5
  160. package/dist/esm/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.js.map +1 -1
  161. package/dist/esm/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js +21 -17
  162. package/dist/esm/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js.map +1 -1
  163. package/dist/esm/parser/bitmark/peg/contentProcessors/FooterContentProcessor.js +47 -0
  164. package/dist/esm/parser/bitmark/peg/contentProcessors/FooterContentProcessor.js.map +1 -0
  165. package/dist/esm/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.js +2 -15
  166. package/dist/esm/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.js.map +1 -1
  167. package/dist/esm/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.js +2 -4
  168. package/dist/esm/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.js.map +1 -1
  169. package/dist/esm/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.js +4 -1
  170. package/dist/esm/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.js.map +1 -1
  171. package/dist/esm/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.js +2 -4
  172. package/dist/esm/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.js.map +1 -1
  173. package/dist/esm/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.js +5 -5
  174. package/dist/esm/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.js.map +1 -1
  175. package/dist/esm/parser/bitmark/peg/contentProcessors/PersonChainContentProcessor.js +5 -6
  176. package/dist/esm/parser/bitmark/peg/contentProcessors/PersonChainContentProcessor.js.map +1 -1
  177. package/dist/esm/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js +23 -7
  178. package/dist/esm/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js.map +1 -1
  179. package/dist/esm/parser/bitmark/peg/contentProcessors/RatingLevelChainContentProcessor.js +5 -5
  180. package/dist/esm/parser/bitmark/peg/contentProcessors/RatingLevelChainContentProcessor.js.map +1 -1
  181. package/dist/esm/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.js +3 -2
  182. package/dist/esm/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.js.map +1 -1
  183. package/dist/esm/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.js +19 -8
  184. package/dist/esm/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.js.map +1 -1
  185. package/dist/esm/parser/bitmark/peg/contentProcessors/ServingsChainContentProcessor.js +4 -6
  186. package/dist/esm/parser/bitmark/peg/contentProcessors/ServingsChainContentProcessor.js.map +1 -1
  187. package/dist/esm/parser/bitmark/peg/contentProcessors/TechnicalTermChainContentProcessor.js +4 -5
  188. package/dist/esm/parser/bitmark/peg/contentProcessors/TechnicalTermChainContentProcessor.js.map +1 -1
  189. package/dist/esm/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.js +14 -5
  190. package/dist/esm/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.js.map +1 -1
  191. package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.js +37 -21
  192. package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.js.map +1 -1
  193. package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js +3 -2
  194. package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js.map +1 -1
  195. package/dist/esm/parser/json/JsonParser.js +73 -765
  196. package/dist/esm/parser/json/JsonParser.js.map +1 -1
  197. package/dist/esm/parser/text/TextParser.js +61 -2
  198. package/dist/esm/parser/text/TextParser.js.map +1 -1
  199. package/dist/esm/utils/BitUtils.js +15 -13
  200. package/dist/esm/utils/BitUtils.js.map +1 -1
  201. package/dist/types/BitmarkParserGenerator.d.ts +8 -0
  202. package/dist/types/BitmarkParserGenerator.d.ts.map +1 -1
  203. package/dist/types/ast/Ast.d.ts.map +1 -1
  204. package/dist/types/ast/BaseBuilder.d.ts +31 -21
  205. package/dist/types/ast/BaseBuilder.d.ts.map +1 -1
  206. package/dist/types/ast/Builder.d.ts +279 -441
  207. package/dist/types/ast/Builder.d.ts.map +1 -1
  208. package/dist/types/ast/ResourceBuilder.d.ts +177 -164
  209. package/dist/types/ast/ResourceBuilder.d.ts.map +1 -1
  210. package/dist/types/ast/rules/NodeValidator.d.ts +3 -2
  211. package/dist/types/ast/rules/NodeValidator.d.ts.map +1 -1
  212. package/dist/types/breakscaping/Breakscape.d.ts +6 -5
  213. package/dist/types/breakscaping/Breakscape.d.ts.map +1 -1
  214. package/dist/types/config/raw/bits.d.ts.map +1 -1
  215. package/dist/types/config/raw/properties.d.ts.map +1 -1
  216. package/dist/types/generated/parser/bitmark/bitmark-peggy-parser.d.ts.map +1 -1
  217. package/dist/types/generator/AstWalkerGenerator.d.ts.map +1 -1
  218. package/dist/types/generator/bitmark/BitmarkGenerator.d.ts +89 -55
  219. package/dist/types/generator/bitmark/BitmarkGenerator.d.ts.map +1 -1
  220. package/dist/types/generator/json/JsonGenerator.d.ts +88 -108
  221. package/dist/types/generator/json/JsonGenerator.d.ts.map +1 -1
  222. package/dist/types/generator/text/TextGenerator.d.ts +14 -2
  223. package/dist/types/generator/text/TextGenerator.d.ts.map +1 -1
  224. package/dist/types/index.d.ts +2 -2
  225. package/dist/types/index.d.ts.map +1 -1
  226. package/dist/types/model/ast/NodeType.d.ts +48 -16
  227. package/dist/types/model/ast/NodeType.d.ts.map +1 -1
  228. package/dist/types/model/ast/Nodes.d.ts +64 -440
  229. package/dist/types/model/ast/Nodes.d.ts.map +1 -1
  230. package/dist/types/model/config/enum/ConfigKey.d.ts +2 -0
  231. package/dist/types/model/config/enum/ConfigKey.d.ts.map +1 -1
  232. package/dist/types/model/config/enum/PropertyConfigKey.d.ts +3 -0
  233. package/dist/types/model/config/enum/PropertyConfigKey.d.ts.map +1 -1
  234. package/dist/types/model/enum/BitType.d.ts +2 -4
  235. package/dist/types/model/enum/BitType.d.ts.map +1 -1
  236. package/dist/types/model/enum/PropertyFormat.d.ts +4 -2
  237. package/dist/types/model/enum/PropertyFormat.d.ts.map +1 -1
  238. package/dist/types/model/enum/PropertyTag.d.ts +2 -0
  239. package/dist/types/model/enum/PropertyTag.d.ts.map +1 -1
  240. package/dist/types/model/json/BitJson.d.ts +32 -20
  241. package/dist/types/model/json/BitJson.d.ts.map +1 -1
  242. package/dist/types/model/json/BodyBitJson.d.ts +16 -12
  243. package/dist/types/model/json/BodyBitJson.d.ts.map +1 -1
  244. package/dist/types/model/json/ResourceJson.d.ts +2 -22
  245. package/dist/types/model/json/ResourceJson.d.ts.map +1 -1
  246. package/dist/types/parser/bitmark/peg/BitmarkPegParserHelper.d.ts +3 -2
  247. package/dist/types/parser/bitmark/peg/BitmarkPegParserHelper.d.ts.map +1 -1
  248. package/dist/types/parser/bitmark/peg/BitmarkPegParserProcessor.d.ts +2 -15
  249. package/dist/types/parser/bitmark/peg/BitmarkPegParserProcessor.d.ts.map +1 -1
  250. package/dist/types/parser/bitmark/peg/BitmarkPegParserTypes.d.ts +83 -71
  251. package/dist/types/parser/bitmark/peg/BitmarkPegParserTypes.d.ts.map +1 -1
  252. package/dist/types/parser/bitmark/peg/BitmarkPegParserValidator.d.ts +2 -2
  253. package/dist/types/parser/bitmark/peg/BitmarkPegParserValidator.d.ts.map +1 -1
  254. package/dist/types/parser/bitmark/peg/contentProcessors/BodyContentProcessor.d.ts +37 -0
  255. package/dist/types/parser/bitmark/peg/contentProcessors/BodyContentProcessor.d.ts.map +1 -0
  256. package/dist/types/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.d.ts.map +1 -1
  257. package/dist/types/parser/bitmark/peg/contentProcessors/CardContentProcessor.d.ts +2 -2
  258. package/dist/types/parser/bitmark/peg/contentProcessors/CardContentProcessor.d.ts.map +1 -1
  259. package/dist/types/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.d.ts.map +1 -1
  260. package/dist/types/parser/bitmark/peg/contentProcessors/ContentProcessorUtils.d.ts +15 -0
  261. package/dist/types/parser/bitmark/peg/contentProcessors/ContentProcessorUtils.d.ts.map +1 -0
  262. package/dist/types/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.d.ts.map +1 -1
  263. package/dist/types/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.d.ts.map +1 -1
  264. package/dist/types/parser/bitmark/peg/contentProcessors/FooterContentProcessor.d.ts +16 -0
  265. package/dist/types/parser/bitmark/peg/contentProcessors/FooterContentProcessor.d.ts.map +1 -0
  266. package/dist/types/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.d.ts.map +1 -1
  267. package/dist/types/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.d.ts.map +1 -1
  268. package/dist/types/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.d.ts.map +1 -1
  269. package/dist/types/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.d.ts.map +1 -1
  270. package/dist/types/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.d.ts.map +1 -1
  271. package/dist/types/parser/bitmark/peg/contentProcessors/PersonChainContentProcessor.d.ts.map +1 -1
  272. package/dist/types/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.d.ts.map +1 -1
  273. package/dist/types/parser/bitmark/peg/contentProcessors/RatingLevelChainContentProcessor.d.ts.map +1 -1
  274. package/dist/types/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.d.ts.map +1 -1
  275. package/dist/types/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.d.ts +2 -2
  276. package/dist/types/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.d.ts.map +1 -1
  277. package/dist/types/parser/bitmark/peg/contentProcessors/ServingsChainContentProcessor.d.ts.map +1 -1
  278. package/dist/types/parser/bitmark/peg/contentProcessors/TechnicalTermChainContentProcessor.d.ts.map +1 -1
  279. package/dist/types/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.d.ts +5 -2
  280. package/dist/types/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.d.ts.map +1 -1
  281. package/dist/types/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.d.ts +1 -1
  282. package/dist/types/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.d.ts.map +1 -1
  283. package/dist/types/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.d.ts.map +1 -1
  284. package/dist/types/parser/json/JsonParser.d.ts +9 -72
  285. package/dist/types/parser/json/JsonParser.d.ts.map +1 -1
  286. package/dist/types/parser/text/TextParser.d.ts +16 -1
  287. package/dist/types/parser/text/TextParser.d.ts.map +1 -1
  288. package/dist/types/utils/BitUtils.d.ts +8 -8
  289. package/dist/types/utils/BitUtils.d.ts.map +1 -1
  290. package/package.json +1 -1
@@ -9,7 +9,6 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import { Builder } from '../../../../ast/Builder';
13
12
  import { Breakscape } from '../../../../breakscaping/Breakscape';
14
13
  import { Config } from '../../../../config/Config';
15
14
  import { CardSetConfigKey } from '../../../../model/config/enum/CardSetConfigKey';
@@ -19,7 +18,6 @@ import { ResourceTag } from '../../../../model/enum/ResourceTag';
19
18
  import { NumberUtils } from '../../../../utils/NumberUtils';
20
19
  import { BitmarkPegParserValidator } from '../BitmarkPegParserValidator';
21
20
  import { BitContentLevel, } from '../BitmarkPegParserTypes';
22
- const builder = new Builder();
23
21
  function buildCards(context, bitType, textFormat, parsedCardSet, statementV1, statementsV1, choicesV1, responsesV1) {
24
22
  var _a;
25
23
  if (context.DEBUG_CARD_SET)
@@ -67,7 +65,7 @@ function buildCards(context, bitType, textFormat, parsedCardSet, statementV1, st
67
65
  break;
68
66
  case CardSetConfigKey._clozeList:
69
67
  case CardSetConfigKey._exampleBitList:
70
- result = parseCardBits(context, bitType, processedCardSet);
68
+ result = parseCardBits(context, bitType, textFormat, processedCardSet);
71
69
  break;
72
70
  case CardSetConfigKey._captionDefinitionsList:
73
71
  // ==> captionDefinitionsList
@@ -82,6 +80,7 @@ function buildCards(context, bitType, textFormat, parsedCardSet, statementV1, st
82
80
  return result;
83
81
  }
84
82
  function processCardSet(context, bitType, textFormat, parsedCardSet) {
83
+ var _a;
85
84
  const processedCardSet = {
86
85
  cards: [],
87
86
  internalComments: [],
@@ -119,7 +118,7 @@ function processCardSet(context, bitType, textFormat, parsedCardSet) {
119
118
  // Validate the cardBody
120
119
  tags.cardBody = BitmarkPegParserValidator.checkCardBody(context, BitContentLevel.Card, bitType, tags.cardBody, processedCard.no, processedSide.no, processedVariant.no);
121
120
  // Reduce the card body parts to a breakscaped string
122
- tags.cardBodyStr = cardBodyToBreakscapedString(tags.cardBody);
121
+ tags.cardBodyStr = (_a = tags.cardBody) === null || _a === void 0 ? void 0 : _a.bodyString;
123
122
  processedVariant.data = tags;
124
123
  // Add any internal comments
125
124
  if (tags.internalComments)
@@ -132,10 +131,12 @@ function processCardSet(context, bitType, textFormat, parsedCardSet) {
132
131
  return processedCardSet;
133
132
  }
134
133
  function parseFlashcardLike(context, bitType, cardSet) {
134
+ var _a;
135
135
  const flashcards = [];
136
136
  const definitions = [];
137
- let question = Breakscape.EMPTY_STRING;
138
- let answer;
137
+ let question = [];
138
+ let questionString = '';
139
+ let answer = [];
139
140
  let alternativeAnswers = [];
140
141
  let cardIndex = 0;
141
142
  let variantIndex = 0;
@@ -144,24 +145,25 @@ function parseFlashcardLike(context, bitType, cardSet) {
144
145
  const onlyOneCardAllowed = bitType === BitType.flashcard1;
145
146
  for (const card of cardSet.cards) {
146
147
  // Reset the question and answers
147
- question = Breakscape.EMPTY_STRING;
148
- answer = undefined;
148
+ question = [];
149
+ answer = [];
149
150
  alternativeAnswers = [];
150
151
  variantIndex = 0;
151
152
  extraTags = {};
152
153
  for (const side of card.sides) {
153
154
  for (const content of side.variants) {
154
- const _a = content.data, { cardBodyStr } = _a, tags = __rest(_a, ["cardBodyStr"]);
155
+ const _b = content.data, { cardBody } = _b, tags = __rest(_b, ["cardBody"]);
155
156
  extraTags = Object.assign(Object.assign({}, extraTags), tags);
156
157
  if (variantIndex === 0) {
157
158
  questionVariant = content;
158
- question = cardBodyStr !== null && cardBodyStr !== void 0 ? cardBodyStr : Breakscape.EMPTY_STRING;
159
+ question = cardBody === null || cardBody === void 0 ? void 0 : cardBody.body;
160
+ questionString = ((_a = cardBody === null || cardBody === void 0 ? void 0 : cardBody.bodyString) !== null && _a !== void 0 ? _a : '');
159
161
  }
160
162
  else if (variantIndex === 1) {
161
- answer = cardBodyStr !== null && cardBodyStr !== void 0 ? cardBodyStr : Breakscape.EMPTY_STRING;
163
+ answer = cardBody === null || cardBody === void 0 ? void 0 : cardBody.body;
162
164
  }
163
165
  else {
164
- alternativeAnswers.push(cardBodyStr !== null && cardBodyStr !== void 0 ? cardBodyStr : Breakscape.EMPTY_STRING);
166
+ alternativeAnswers.push(cardBody === null || cardBody === void 0 ? void 0 : cardBody.body);
165
167
  }
166
168
  variantIndex++;
167
169
  }
@@ -169,14 +171,19 @@ function parseFlashcardLike(context, bitType, cardSet) {
169
171
  // Add the flashcard
170
172
  if (cardIndex === 0 || !onlyOneCardAllowed) {
171
173
  if (Config.isOfBitType(bitType, BitType.definitionList)) {
172
- // .definitions-list
173
- definitions.push(builder.definitionListItem(Object.assign({ term: question, description: answer, alternativeDefinitions: alternativeAnswers.length > 0 ? alternativeAnswers : undefined }, extraTags)));
174
+ // .definition-list
175
+ const dl = Object.assign({ term: question, definition: answer, alternativeDefinitions: alternativeAnswers }, extraTags);
176
+ if (dl)
177
+ definitions.push(dl);
174
178
  }
175
179
  else {
176
180
  // .flashcard
177
181
  // if (question) {
178
- flashcards.push(builder.flashcard(Object.assign({ question,
179
- answer, alternativeAnswers: alternativeAnswers.length > 0 ? alternativeAnswers : undefined }, extraTags)));
182
+ const fc = Object.assign({ question,
183
+ answer,
184
+ alternativeAnswers }, extraTags);
185
+ if (fc)
186
+ flashcards.push(fc);
180
187
  // } else {
181
188
  // context.addWarning('Ignoring card with empty question', questionVariant);
182
189
  // }
@@ -184,7 +191,7 @@ function parseFlashcardLike(context, bitType, cardSet) {
184
191
  }
185
192
  else {
186
193
  // Only one card allowed, add a warning and ignore the card
187
- context.addWarning(`Bit '${bitType}' should only contain one card. Ignore subsequent card: '${question}'`, questionVariant);
194
+ context.addWarning(`Bit '${bitType}' should only contain one card. Ignore subsequent card: '${questionString}'`, questionVariant);
188
195
  break;
189
196
  }
190
197
  cardIndex++;
@@ -202,7 +209,7 @@ function parseElements(_context, _bitType, cardSet) {
202
209
  for (const content of side.variants) {
203
210
  const tags = content.data;
204
211
  // if (tags.cardBody) {
205
- elements.push((_a = tags.cardBodyStr) !== null && _a !== void 0 ? _a : Breakscape.EMPTY_STRING);
212
+ elements.push((_a = tags.cardBodyStr) !== null && _a !== void 0 ? _a : '');
206
213
  // } else {
207
214
  // context.addWarning('Ignoring card with empty element', content);
208
215
  // }
@@ -214,19 +221,23 @@ function parseElements(_context, _bitType, cardSet) {
214
221
  };
215
222
  }
216
223
  function parseStatements(_context, _bitType, cardSet, statementV1, statementsV1) {
224
+ var _a;
217
225
  const statements = [];
218
226
  for (const card of cardSet.cards) {
219
227
  for (const side of card.sides) {
220
228
  for (const content of side.variants) {
221
- const _a = content.data, { statements: chainedStatements } = _a, tags = __rest(_a, ["statements"]);
229
+ const _b = content.data, { statements: chainedStatements, statement: _ignore } = _b, tags = __rest(_b, ["statements", "statement"]);
230
+ // Remove statement from rest, tags
231
+ _ignore;
222
232
  // Re-build the statement, adding any tags that were not in the True/False chain
223
233
  // These tags are actually not in the correct place, but we can still interpret them and fix the data.
224
234
  // As .true-false only has one statement per card, we can just add the extra tags to the statement.
225
235
  if (Array.isArray(chainedStatements)) {
226
236
  for (const s of chainedStatements) {
227
237
  // if (s.text) {
228
- const statement = builder.statement(Object.assign(Object.assign(Object.assign({}, s), s.itemLead), tags));
229
- statements.push(statement);
238
+ const statement = Object.assign({ statement: (_a = s.statement) !== null && _a !== void 0 ? _a : '', isCorrect: s.isCorrect, item: s.item, lead: s.lead, hint: s.hint, instruction: s.instruction, example: s.example }, tags);
239
+ if (statement)
240
+ statements.push(statement);
230
241
  // } else {
231
242
  // context.addWarning('Ignoring card with empty statement', content);
232
243
  // }
@@ -257,24 +268,31 @@ function parseQuiz(_context, bitType, cardSet, choicesV1, responsesV1) {
257
268
  let exampleCard;
258
269
  for (const card of cardSet.cards) {
259
270
  isDefaultExampleCard = false;
260
- exampleCard = Breakscape.EMPTY_STRING;
271
+ exampleCard = undefined;
261
272
  for (const side of card.sides) {
262
273
  for (const content of side.variants) {
263
- const _a = content.data, { isDefaultExample, example } = _a, tags = __rest(_a, ["isDefaultExample", "example"]);
274
+ const _a = content.data, { __isDefaultExample, example } = _a, tags = __rest(_a, ["__isDefaultExample", "example"]);
264
275
  // Example
265
- isDefaultExampleCard = isDefaultExample === true ? true : isDefaultExampleCard;
276
+ isDefaultExampleCard = __isDefaultExample === true ? true : isDefaultExampleCard;
266
277
  exampleCard = example ? example : exampleCard;
267
278
  // Insert choices / responses
268
279
  if (tags.trueFalse && tags.trueFalse.length > 0) {
269
280
  const responsesOrChoices = [];
270
- const builderFunc = insertResponses ? builder.response : builder.choice;
271
281
  for (const tf of tags.trueFalse) {
272
- const { isDefaultExample: isDefaultExampleTf, example: exampleTf } = tf, tfTags = __rest(tf, ["isDefaultExample", "example"]);
273
- const isDefaultExample = isDefaultExampleTf || isDefaultExampleCard;
282
+ const { __isDefaultExample: isDefaultExampleTf, example: exampleTf } = tf, tfTags = __rest(tf, ["__isDefaultExample", "example"]);
283
+ const __isDefaultExample = isDefaultExampleTf || isDefaultExampleCard;
274
284
  const example = exampleTf || exampleCard;
275
- const response = builderFunc(Object.assign(Object.assign({}, tfTags), { isDefaultExample,
276
- example }));
277
- responsesOrChoices.push(response);
285
+ const response = {
286
+ isCorrect: tfTags.isCorrect,
287
+ __isDefaultExample,
288
+ example,
289
+ };
290
+ if (insertResponses)
291
+ response.response = tfTags.text;
292
+ else
293
+ response.choice = tfTags.text;
294
+ if (response)
295
+ responsesOrChoices.push(response);
278
296
  }
279
297
  if (insertResponses)
280
298
  tags.responses = responsesOrChoices;
@@ -282,8 +300,9 @@ function parseQuiz(_context, bitType, cardSet, choicesV1, responsesV1) {
282
300
  tags.choices = responsesOrChoices;
283
301
  }
284
302
  // if (tags.choices || tags.responses) {
285
- const quiz = builder.quiz(Object.assign(Object.assign({}, tags), { isDefaultExample: isDefaultExampleCard, example: exampleCard }));
286
- quizzes.push(quiz);
303
+ const quiz = Object.assign(Object.assign({}, tags), { choices: tags.choices, responses: tags.responses, __isDefaultExample: isDefaultExampleCard, __defaultExample: exampleCard });
304
+ if (quiz)
305
+ quizzes.push(quiz);
287
306
  // } else {
288
307
  // context.addWarning('Ignoring card with empty quiz', content);
289
308
  // }
@@ -292,16 +311,18 @@ function parseQuiz(_context, bitType, cardSet, choicesV1, responsesV1) {
292
311
  }
293
312
  // Add a quiz for the V1 choices / responses
294
313
  if (insertChoices && Array.isArray(choicesV1) && choicesV1.length > 0) {
295
- const quiz = builder.quiz({
314
+ const quiz = {
296
315
  choices: choicesV1,
297
- });
298
- quizzes.push(quiz);
316
+ };
317
+ if (quiz)
318
+ quizzes.push(quiz);
299
319
  }
300
320
  if (insertResponses && Array.isArray(responsesV1) && responsesV1.length > 0) {
301
- const quiz = builder.quiz({
321
+ const quiz = {
302
322
  responses: responsesV1,
303
- });
304
- quizzes.push(quiz);
323
+ };
324
+ if (quiz)
325
+ quizzes.push(quiz);
305
326
  }
306
327
  return {
307
328
  quizzes: quizzes.length > 0 ? quizzes : undefined,
@@ -315,8 +336,9 @@ function parseQuestions(_context, _bitType, cardSet) {
315
336
  for (const content of side.variants) {
316
337
  const tags = content.data;
317
338
  // if (tags.cardBody) {
318
- const q = builder.question(Object.assign({ question: (_a = tags.cardBodyStr) !== null && _a !== void 0 ? _a : Breakscape.EMPTY_STRING }, tags));
319
- questions.push(q);
339
+ const q = Object.assign({ question: (_a = tags.cardBodyStr) !== null && _a !== void 0 ? _a : '' }, tags);
340
+ if (q)
341
+ questions.push(q);
320
342
  // }
321
343
  // else {
322
344
  // context.addWarning('Ignoring card with empty body text', content);
@@ -328,7 +350,7 @@ function parseQuestions(_context, _bitType, cardSet) {
328
350
  questions: questions.length > 0 ? questions : undefined,
329
351
  };
330
352
  }
331
- function parseMatchPairs(_context, _bitType, cardSet) {
353
+ function parseMatchPairs(_context, bitType, cardSet) {
332
354
  let sideIdx = 0;
333
355
  let isHeading = false;
334
356
  let heading;
@@ -337,6 +359,7 @@ function parseMatchPairs(_context, _bitType, cardSet) {
337
359
  let forValues = [];
338
360
  let pairKey = undefined;
339
361
  let pairValues = [];
362
+ let _pairValuesAst = [];
340
363
  let keyAudio = undefined;
341
364
  let keyImage = undefined;
342
365
  let extraTags = {};
@@ -351,28 +374,29 @@ function parseMatchPairs(_context, _bitType, cardSet) {
351
374
  forValues = [];
352
375
  pairKey = undefined;
353
376
  pairValues = [];
377
+ _pairValuesAst = [];
354
378
  keyAudio = undefined;
355
379
  keyImage = undefined;
356
380
  sideIdx = 0;
357
381
  extraTags = {};
358
382
  isDefaultExampleCard = false;
359
- exampleCard = Breakscape.EMPTY_STRING;
383
+ exampleCard = undefined;
360
384
  for (const side of card.sides) {
361
385
  for (const content of side.variants) {
362
386
  // variant = content;
363
- const _a = content.data, { cardBodyStr, title, resources, isDefaultExample, example } = _a, tags = __rest(_a, ["cardBodyStr", "title", "resources", "isDefaultExample", "example"]);
387
+ const _a = content.data, { cardBody, cardBodyStr, title, resources, __isDefaultExample, example } = _a, tags = __rest(_a, ["cardBody", "cardBodyStr", "title", "resources", "__isDefaultExample", "example"]);
364
388
  // Example
365
- isDefaultExampleCard = isDefaultExample === true ? true : isDefaultExampleCard;
389
+ isDefaultExampleCard = __isDefaultExample === true ? true : isDefaultExampleCard;
366
390
  exampleCard = example ? example : exampleCard;
367
391
  // Get the 'heading' which is the [#title] at level 1
368
- const heading = title && title[1];
392
+ const heading = title && title[1].titleString;
369
393
  if (heading != null)
370
394
  isHeading = true;
371
395
  if (sideIdx === 0) {
372
396
  // First side
373
397
  forKeys = heading;
374
398
  if (heading != null) {
375
- isDefaultExampleCardSet = isDefaultExample === true ? true : isDefaultExampleCardSet;
399
+ isDefaultExampleCardSet = __isDefaultExample === true ? true : isDefaultExampleCardSet;
376
400
  exampleCardSet = example ? example : exampleCardSet;
377
401
  }
378
402
  else if (Array.isArray(resources) && resources.length > 0) {
@@ -380,10 +404,10 @@ function parseMatchPairs(_context, _bitType, cardSet) {
380
404
  const resource = resources[0];
381
405
  // console.log('WARNING: Match card has resource on first side', tags.resource);
382
406
  if (resource.type === ResourceTag.audio) {
383
- keyAudio = resource;
407
+ keyAudio = resource.audio;
384
408
  }
385
409
  else if (resource.type === ResourceTag.image) {
386
- keyImage = resource;
410
+ keyImage = resource.image;
387
411
  }
388
412
  }
389
413
  else {
@@ -393,17 +417,19 @@ function parseMatchPairs(_context, _bitType, cardSet) {
393
417
  }
394
418
  else {
395
419
  // Subsequent sides
396
- forValues.push(heading !== null && heading !== void 0 ? heading : Breakscape.EMPTY_STRING);
420
+ forValues.push(heading !== null && heading !== void 0 ? heading : '');
397
421
  if (heading != null) {
398
- isDefaultExampleCardSet = isDefaultExample === true ? true : isDefaultExampleCardSet;
422
+ isDefaultExampleCardSet = __isDefaultExample === true ? true : isDefaultExampleCardSet;
399
423
  exampleCardSet = example ? example : exampleCardSet;
400
424
  }
401
425
  else if (title == null) {
402
426
  // If not a heading, it is a pair
403
- const value = cardBodyStr !== null && cardBodyStr !== void 0 ? cardBodyStr : Breakscape.EMPTY_STRING;
427
+ const value = cardBodyStr !== null && cardBodyStr !== void 0 ? cardBodyStr : '';
428
+ const valueAst = cardBody === null || cardBody === void 0 ? void 0 : cardBody.body;
404
429
  pairValues.push(value);
430
+ _pairValuesAst.push(valueAst);
405
431
  if ((isDefaultExampleCardSet || isDefaultExampleCard) && !exampleCard)
406
- exampleCard = value;
432
+ exampleCard = valueAst;
407
433
  }
408
434
  // Fix: https://github.com/getMoreBrain/cosmic/issues/5454
409
435
  delete tags.item;
@@ -415,22 +441,37 @@ function parseMatchPairs(_context, _bitType, cardSet) {
415
441
  sideIdx++;
416
442
  }
417
443
  if (isHeading) {
418
- heading = builder.heading({
419
- forKeys: forKeys !== null && forKeys !== void 0 ? forKeys : Breakscape.EMPTY_STRING,
420
- forValues,
421
- });
444
+ let forValuesFinal = forValues;
445
+ if (Config.isOfBitType(bitType, BitType.matchMatrix)) {
446
+ // forValues is an array of values
447
+ forValuesFinal = forValues;
448
+ }
449
+ else {
450
+ // Standard match, forValues is a single value
451
+ if (forValues.length >= 1) {
452
+ forValuesFinal = forValues[forValues.length - 1];
453
+ }
454
+ else {
455
+ forValuesFinal = '';
456
+ }
457
+ }
458
+ heading = {
459
+ forKeys: forKeys !== null && forKeys !== void 0 ? forKeys : '',
460
+ forValues: forValuesFinal,
461
+ };
422
462
  }
423
463
  else {
424
464
  // if (pairKey || keyAudio || keyImage) {
425
- // Calculate final example and isDefaultExample
465
+ // Calculate final example and __isDefaultExample
426
466
  if (isDefaultExampleCard)
427
467
  exampleCardSet = undefined;
428
- const isDefaultExample = isDefaultExampleCard || isDefaultExampleCardSet;
468
+ const __isDefaultExample = isDefaultExampleCard || isDefaultExampleCardSet;
429
469
  const example = exampleCard || exampleCardSet;
430
- const pair = builder.pair(Object.assign(Object.assign({ key: pairKey !== null && pairKey !== void 0 ? pairKey : Breakscape.EMPTY_STRING, keyAudio,
431
- keyImage, values: pairValues }, extraTags), { isDefaultExample,
432
- example }));
433
- pairs.push(pair);
470
+ const pair = Object.assign(Object.assign({ key: pairKey !== null && pairKey !== void 0 ? pairKey : '', keyAudio,
471
+ keyImage, values: pairValues, __valuesAst: _pairValuesAst }, extraTags), { __isDefaultExample,
472
+ example });
473
+ if (pair)
474
+ pairs.push(pair);
434
475
  // } else {
435
476
  // context.addWarning('Ignoring card with empty body text', variant);
436
477
  // }
@@ -452,6 +493,7 @@ function parseMatchMatrix(_context, _bitType, cardSet) {
452
493
  const matrix = [];
453
494
  let matrixCells = [];
454
495
  let matrixCellValues = [];
496
+ let _matrixCellValuesAst = [];
455
497
  let matrixCellTags = {};
456
498
  let isDefaultExampleCardSet = false;
457
499
  let exampleCardSet;
@@ -474,27 +516,29 @@ function parseMatchMatrix(_context, _bitType, cardSet) {
474
516
  // keyImage = undefined;
475
517
  matrixCells = [];
476
518
  matrixCellValues = [];
519
+ _matrixCellValuesAst = [];
477
520
  sideIdx = 0;
478
521
  isDefaultExampleCard = false;
479
- exampleCard = Breakscape.EMPTY_STRING;
522
+ exampleCard = undefined;
480
523
  isCaseSensitiveMatrix = undefined;
481
524
  for (const side of card.sides) {
482
525
  matrixCellValues = [];
526
+ _matrixCellValuesAst = [];
483
527
  matrixCellTags = {};
484
528
  isDefaultExampleSide = false;
485
- exampleSide = Breakscape.EMPTY_STRING;
529
+ exampleSide = undefined;
486
530
  isCaseSensitiveCell = undefined;
487
531
  for (const content of side.variants) {
488
532
  // variant = content;
489
533
  const tags = content.data;
490
- const { title, cardBodyStr, isDefaultExample, example, isCaseSensitive } = tags, restTags = __rest(tags, ["title", "cardBodyStr", "isDefaultExample", "example", "isCaseSensitive"]);
534
+ const { title, cardBody, cardBodyStr, __isDefaultExample, example, isCaseSensitive } = tags, restTags = __rest(tags, ["title", "cardBody", "cardBodyStr", "__isDefaultExample", "example", "isCaseSensitive"]);
491
535
  // Example
492
- isDefaultExampleSide = isDefaultExample === true ? true : isDefaultExampleSide;
536
+ isDefaultExampleSide = __isDefaultExample === true ? true : isDefaultExampleSide;
493
537
  exampleSide = example ? example : exampleSide;
494
538
  // Merge the tags into the matrix cell tags
495
539
  Object.assign(matrixCellTags, restTags);
496
540
  // Get the 'heading' which is the [#title] at level 1
497
- const heading = title && title[1];
541
+ const heading = title && title[1].titleString;
498
542
  if (heading != null)
499
543
  isHeading = true;
500
544
  if (sideIdx === 0) {
@@ -508,14 +552,14 @@ function parseMatchMatrix(_context, _bitType, cardSet) {
508
552
  // } else if (tags.resource.type === ResourceTag.image) {
509
553
  // keyImage = tags.resource as ImageResource;
510
554
  // }
511
- isDefaultExampleCardSet = isDefaultExample === true ? true : isDefaultExampleCardSet;
555
+ isDefaultExampleCardSet = __isDefaultExample === true ? true : isDefaultExampleCardSet;
512
556
  exampleCardSet = example ? example : exampleCardSet;
513
557
  }
514
558
  else {
515
559
  // If not a heading or resource, it is a matrix
516
560
  matrixKey = cardBodyStr;
517
561
  matrixKeyTags = restTags;
518
- isDefaultExampleCard = isDefaultExample === true ? true : isDefaultExampleCard;
562
+ isDefaultExampleCard = __isDefaultExample === true ? true : isDefaultExampleCard;
519
563
  exampleCard = example ? example : exampleCard;
520
564
  isCaseSensitiveMatrix = isCaseSensitive != null ? isCaseSensitive : isCaseSensitiveMatrix;
521
565
  }
@@ -524,48 +568,51 @@ function parseMatchMatrix(_context, _bitType, cardSet) {
524
568
  // Subsequent sides
525
569
  forValues.push(heading !== null && heading !== void 0 ? heading : Breakscape.EMPTY_STRING);
526
570
  if (heading != null) {
527
- isDefaultExampleCardSet = isDefaultExample === true ? true : isDefaultExampleCardSet;
571
+ isDefaultExampleCardSet = __isDefaultExample === true ? true : isDefaultExampleCardSet;
528
572
  exampleCardSet = example ? example : exampleCardSet;
529
573
  }
530
574
  else if (tags.title == null) {
531
575
  // If not a heading, it is a matrix cell value
532
576
  const value = cardBodyStr !== null && cardBodyStr !== void 0 ? cardBodyStr : Breakscape.EMPTY_STRING;
577
+ const valueAst = cardBody === null || cardBody === void 0 ? void 0 : cardBody.body;
533
578
  matrixCellValues.push(value);
579
+ _matrixCellValuesAst.push(valueAst);
534
580
  if ((isDefaultExampleCardSet || isDefaultExampleSide) && !exampleSide)
535
- exampleSide = value;
581
+ exampleSide = valueAst;
536
582
  isCaseSensitiveCell = isCaseSensitive != null ? isCaseSensitive : isCaseSensitiveMatrix;
537
583
  }
538
584
  }
539
585
  }
540
586
  // Finished looping variants, create matrix cell
541
587
  if (sideIdx > 0) {
542
- // Calculate final example and isDefaultExample
588
+ // Calculate final example and __isDefaultExample
543
589
  if (isDefaultExampleSide)
544
590
  exampleCard = exampleCardSet = undefined;
545
591
  if (isDefaultExampleCard)
546
592
  exampleCardSet = undefined;
547
- const isDefaultExample = isDefaultExampleSide || isDefaultExampleCard || isDefaultExampleCardSet;
593
+ const __isDefaultExample = isDefaultExampleSide || isDefaultExampleCard || isDefaultExampleCardSet;
548
594
  const example = exampleSide || exampleCard || exampleCardSet;
549
- const matrixCell = builder.matrixCell(Object.assign(Object.assign({ values: matrixCellValues }, matrixCellTags), { isDefaultExample,
550
- example, isCaseSensitive: isCaseSensitiveCell }));
551
- matrixCells.push(matrixCell);
595
+ const matrixCell = Object.assign(Object.assign({ values: matrixCellValues, __valuesAst: _matrixCellValuesAst }, matrixCellTags), { __isDefaultExample: __isDefaultExample, example, isCaseSensitive: isCaseSensitiveCell });
596
+ if (matrixCell)
597
+ matrixCells.push(matrixCell);
552
598
  }
553
599
  sideIdx++;
554
600
  }
555
601
  if (isHeading) {
556
- heading = builder.heading({
602
+ heading = {
557
603
  forKeys: forKeys !== null && forKeys !== void 0 ? forKeys : Breakscape.EMPTY_STRING,
558
604
  forValues,
559
- });
605
+ };
560
606
  }
561
607
  else {
562
608
  // if (matrixKey) {
563
- const m = builder.matrix(Object.assign({ key: matrixKey !== null && matrixKey !== void 0 ? matrixKey : Breakscape.EMPTY_STRING,
609
+ const m = Object.assign({ key: matrixKey !== null && matrixKey !== void 0 ? matrixKey : Breakscape.EMPTY_STRING,
564
610
  // item: matrixItem ?? Breakscape.EMPTY_STRING,
565
611
  // keyAudio,
566
612
  // keyImage,
567
- cells: matrixCells }, matrixKeyTags));
568
- matrix.push(m);
613
+ cells: matrixCells }, matrixKeyTags);
614
+ if (m)
615
+ matrix.push(m);
569
616
  // } else {
570
617
  // context.addWarning('Ignoring card with empty body text', variant);
571
618
  // }
@@ -591,15 +638,15 @@ function parseTable(_context, _bitType, cardSet) {
591
638
  const tags = content.data;
592
639
  const { title, cardBodyStr } = tags;
593
640
  // Get the 'heading' which is the [#title] at level 1
594
- const heading = title && title[1];
641
+ const heading = title && title[1].titleString;
595
642
  if (cardIdx === 0 && heading != null)
596
643
  isHeading = true;
597
644
  if (isHeading) {
598
- columns.push(heading !== null && heading !== void 0 ? heading : Breakscape.EMPTY_STRING);
645
+ columns.push(heading !== null && heading !== void 0 ? heading : '');
599
646
  }
600
647
  else {
601
648
  // If not a heading, it is a row cell value
602
- const value = cardBodyStr !== null && cardBodyStr !== void 0 ? cardBodyStr : Breakscape.EMPTY_STRING;
649
+ const value = cardBodyStr !== null && cardBodyStr !== void 0 ? cardBodyStr : '';
603
650
  rowValues.push(value);
604
651
  }
605
652
  }
@@ -609,10 +656,10 @@ function parseTable(_context, _bitType, cardSet) {
609
656
  }
610
657
  cardIdx++;
611
658
  }
612
- const table = builder.table({
659
+ const table = {
613
660
  columns,
614
- rows,
615
- });
661
+ data: rows,
662
+ };
616
663
  return { table };
617
664
  }
618
665
  function parseBotActionResponses(_context, _bitType, cardSet) {
@@ -620,9 +667,10 @@ function parseBotActionResponses(_context, _bitType, cardSet) {
620
667
  for (const card of cardSet.cards) {
621
668
  for (const side of card.sides) {
622
669
  for (const content of side.variants) {
623
- const _a = content.data, { instruction, reaction, cardBodyStr: feedback } = _a, tags = __rest(_a, ["instruction", "reaction", "cardBodyStr"]);
624
- const botResponse = builder.botResponse(Object.assign({ response: instruction !== null && instruction !== void 0 ? instruction : Breakscape.EMPTY_STRING, reaction: reaction !== null && reaction !== void 0 ? reaction : Breakscape.EMPTY_STRING, feedback: feedback !== null && feedback !== void 0 ? feedback : Breakscape.EMPTY_STRING }, tags));
625
- botResponses.push(botResponse);
670
+ const _a = content.data, { __instructionString, reaction, cardBodyStr: feedback } = _a, tags = __rest(_a, ["__instructionString", "reaction", "cardBodyStr"]);
671
+ const botResponse = Object.assign({ response: __instructionString !== null && __instructionString !== void 0 ? __instructionString : Breakscape.EMPTY_STRING, reaction: reaction !== null && reaction !== void 0 ? reaction : Breakscape.EMPTY_STRING, feedback: feedback !== null && feedback !== void 0 ? feedback : Breakscape.EMPTY_STRING }, tags);
672
+ if (botResponse)
673
+ botResponses.push(botResponse);
626
674
  }
627
675
  }
628
676
  }
@@ -635,26 +683,32 @@ function parseIngredients(_context, _bitType, cardSet) {
635
683
  for (const card of cardSet.cards) {
636
684
  for (const side of card.sides) {
637
685
  for (const content of side.variants) {
638
- const _a = content.data, { title: titleArray, instruction, unit, unitAbbr, decimalPlaces, disableCalculation, cardBodyStr: item, cardBody } = _a, tags = __rest(_a, ["title", "instruction", "unit", "unitAbbr", "decimalPlaces", "disableCalculation", "cardBodyStr", "cardBody"]);
686
+ const _a = content.data, { title: titleArray, __instructionString, unit, unitAbbr, decimalPlaces, disableCalculation, cardBodyStr, cardBody } = _a, tags = __rest(_a, ["title", "__instructionString", "unit", "unitAbbr", "decimalPlaces", "disableCalculation", "cardBodyStr", "cardBody"]);
639
687
  // Extract 'title' from title array (if present)
640
688
  // Extract 'quantity' from either then unchained instruction, or from the select (otherwise use 0)
641
689
  // Extract checked from the select options (if present, otherwise checked is false))
642
- const title = Array.isArray(titleArray) && titleArray.length > 0 ? titleArray[titleArray.length - 1] : undefined;
690
+ const title = Array.isArray(titleArray) && titleArray.length > 0
691
+ ? titleArray[titleArray.length - 1].titleString
692
+ : undefined;
643
693
  let checked = false;
644
- let quantity = NumberUtils.asNumber(instruction);
645
- if (cardBody && cardBody.bodyParts) {
646
- const select = cardBody.bodyParts.find((part) => part.type === BodyBitType.select);
694
+ let quantity = NumberUtils.asNumber(__instructionString);
695
+ if (cardBody && cardBody.bodyBits) {
696
+ const select = cardBody.bodyBits.find((c) => c.type === BodyBitType.select);
647
697
  if (select) {
648
- quantity = select.data.instruction ? NumberUtils.asNumber(select.data.instruction) : quantity;
649
- if (select.data.options && select.data.options.length > 0) {
650
- checked = select.data.options[0].isCorrect;
698
+ quantity = select.__instructionString ? NumberUtils.asNumber(select.__instructionString) : quantity;
699
+ if (select.options && select.options.length > 0) {
700
+ checked = select.options[0].isCorrect;
651
701
  }
652
702
  }
653
703
  }
654
- const trimmedItem = item ? item.trim() : Breakscape.EMPTY_STRING;
655
- const ingredient = builder.ingredient(Object.assign({ title,
656
- checked, item: trimmedItem, quantity, unit: unit !== null && unit !== void 0 ? unit : Breakscape.EMPTY_STRING, unitAbbr: unitAbbr !== null && unitAbbr !== void 0 ? unitAbbr : Breakscape.EMPTY_STRING, decimalPlaces: decimalPlaces !== null && decimalPlaces !== void 0 ? decimalPlaces : 1, disableCalculation: disableCalculation }, tags));
657
- ingredients.push(ingredient);
704
+ const ingredient = Object.assign({ title,
705
+ checked,
706
+ // TS compiler very weird. It doesn't recognize that cardBodyStr is a string|undefined, even if cast!
707
+ // Casting to 'any' to avoid the error
708
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
709
+ item: cardBodyStr, quantity, unit: unit !== null && unit !== void 0 ? unit : Breakscape.EMPTY_STRING, unitAbbr: unitAbbr !== null && unitAbbr !== void 0 ? unitAbbr : Breakscape.EMPTY_STRING, decimalPlaces: decimalPlaces !== null && decimalPlaces !== void 0 ? decimalPlaces : 1, disableCalculation: disableCalculation }, tags);
710
+ if (ingredient)
711
+ ingredients.push(ingredient);
658
712
  }
659
713
  }
660
714
  }
@@ -677,15 +731,15 @@ function parseCaptionDefinitionsList(_context, _bitType, cardSet) {
677
731
  const tags = content.data;
678
732
  const { title, cardBodyStr } = tags;
679
733
  // Get the 'heading' which is the [#title] at level 1
680
- const heading = title && title[1];
734
+ const heading = title && title[1].titleString;
681
735
  if (cardIdx === 0 && heading != null)
682
736
  isHeading = true;
683
737
  if (isHeading) {
684
- columns.push(heading !== null && heading !== void 0 ? heading : Breakscape.EMPTY_STRING);
738
+ columns.push(heading !== null && heading !== void 0 ? heading : '');
685
739
  }
686
740
  else {
687
741
  // If not a heading, it is a row cell value
688
- const value = cardBodyStr !== null && cardBodyStr !== void 0 ? cardBodyStr : Breakscape.EMPTY_STRING;
742
+ const value = cardBodyStr !== null && cardBodyStr !== void 0 ? cardBodyStr : '';
689
743
  rowValues.push(value);
690
744
  }
691
745
  }
@@ -695,24 +749,29 @@ function parseCaptionDefinitionsList(_context, _bitType, cardSet) {
695
749
  }
696
750
  cardIdx++;
697
751
  }
698
- const captionDefinitionList = builder.captionDefinitionList({
699
- columns,
700
- definitions: rows.map((row) => {
701
- return builder.captionDefinition({
702
- term: row[0],
703
- description: row[1],
704
- });
705
- }),
706
- });
752
+ const captionDefinitionList = columns.length > 0
753
+ ? {
754
+ columns,
755
+ definitions: rows
756
+ .map((row) => {
757
+ const col = {
758
+ term: row[0],
759
+ definition: row[1],
760
+ };
761
+ return col;
762
+ })
763
+ .filter((d) => d != null),
764
+ }
765
+ : undefined;
707
766
  return { captionDefinitionList };
708
767
  }
709
- function parseCardBits(_context, _bitType, cardSet) {
768
+ function parseCardBits(_context, _bitType, _textFormat, cardSet) {
710
769
  const cardBits = [];
711
770
  for (const card of cardSet.cards) {
712
771
  for (const side of card.sides) {
713
772
  for (const content of side.variants) {
714
773
  const _a = content.data, { cardBody: body } = _a, rest = __rest(_a, ["cardBody"]);
715
- const cardBit = builder.cardBit(Object.assign({ body }, rest));
774
+ const cardBit = Object.assign({ body }, rest);
716
775
  if (cardBit)
717
776
  cardBits.push(cardBit);
718
777
  }
@@ -722,18 +781,5 @@ function parseCardBits(_context, _bitType, cardSet) {
722
781
  cardBits: cardBits.length > 0 ? cardBits : undefined,
723
782
  };
724
783
  }
725
- function cardBodyToBreakscapedString(cardBody) {
726
- let bodyStr = '';
727
- if (cardBody && cardBody.bodyParts) {
728
- for (const bodyPart of cardBody.bodyParts) {
729
- if (bodyPart.type === BodyBitType.text) {
730
- const asText = bodyPart;
731
- const bodyTextPart = asText.data.bodyText;
732
- bodyStr += bodyTextPart;
733
- }
734
- }
735
- }
736
- return bodyStr;
737
- }
738
784
  export { buildCards };
739
785
  //# sourceMappingURL=CardContentProcessor.js.map