@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
@@ -12,7 +12,6 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.buildCards = buildCards;
15
- const Builder_1 = require("../../../../ast/Builder");
16
15
  const Breakscape_1 = require("../../../../breakscaping/Breakscape");
17
16
  const Config_1 = require("../../../../config/Config");
18
17
  const CardSetConfigKey_1 = require("../../../../model/config/enum/CardSetConfigKey");
@@ -22,7 +21,6 @@ const ResourceTag_1 = require("../../../../model/enum/ResourceTag");
22
21
  const NumberUtils_1 = require("../../../../utils/NumberUtils");
23
22
  const BitmarkPegParserValidator_1 = require("../BitmarkPegParserValidator");
24
23
  const BitmarkPegParserTypes_1 = require("../BitmarkPegParserTypes");
25
- const builder = new Builder_1.Builder();
26
24
  function buildCards(context, bitType, textFormat, parsedCardSet, statementV1, statementsV1, choicesV1, responsesV1) {
27
25
  var _a;
28
26
  if (context.DEBUG_CARD_SET)
@@ -70,7 +68,7 @@ function buildCards(context, bitType, textFormat, parsedCardSet, statementV1, st
70
68
  break;
71
69
  case CardSetConfigKey_1.CardSetConfigKey._clozeList:
72
70
  case CardSetConfigKey_1.CardSetConfigKey._exampleBitList:
73
- result = parseCardBits(context, bitType, processedCardSet);
71
+ result = parseCardBits(context, bitType, textFormat, processedCardSet);
74
72
  break;
75
73
  case CardSetConfigKey_1.CardSetConfigKey._captionDefinitionsList:
76
74
  // ==> captionDefinitionsList
@@ -85,6 +83,7 @@ function buildCards(context, bitType, textFormat, parsedCardSet, statementV1, st
85
83
  return result;
86
84
  }
87
85
  function processCardSet(context, bitType, textFormat, parsedCardSet) {
86
+ var _a;
88
87
  const processedCardSet = {
89
88
  cards: [],
90
89
  internalComments: [],
@@ -122,7 +121,7 @@ function processCardSet(context, bitType, textFormat, parsedCardSet) {
122
121
  // Validate the cardBody
123
122
  tags.cardBody = BitmarkPegParserValidator_1.BitmarkPegParserValidator.checkCardBody(context, BitmarkPegParserTypes_1.BitContentLevel.Card, bitType, tags.cardBody, processedCard.no, processedSide.no, processedVariant.no);
124
123
  // Reduce the card body parts to a breakscaped string
125
- tags.cardBodyStr = cardBodyToBreakscapedString(tags.cardBody);
124
+ tags.cardBodyStr = (_a = tags.cardBody) === null || _a === void 0 ? void 0 : _a.bodyString;
126
125
  processedVariant.data = tags;
127
126
  // Add any internal comments
128
127
  if (tags.internalComments)
@@ -135,10 +134,12 @@ function processCardSet(context, bitType, textFormat, parsedCardSet) {
135
134
  return processedCardSet;
136
135
  }
137
136
  function parseFlashcardLike(context, bitType, cardSet) {
137
+ var _a;
138
138
  const flashcards = [];
139
139
  const definitions = [];
140
- let question = Breakscape_1.Breakscape.EMPTY_STRING;
141
- let answer;
140
+ let question = [];
141
+ let questionString = '';
142
+ let answer = [];
142
143
  let alternativeAnswers = [];
143
144
  let cardIndex = 0;
144
145
  let variantIndex = 0;
@@ -147,24 +148,25 @@ function parseFlashcardLike(context, bitType, cardSet) {
147
148
  const onlyOneCardAllowed = bitType === BitType_1.BitType.flashcard1;
148
149
  for (const card of cardSet.cards) {
149
150
  // Reset the question and answers
150
- question = Breakscape_1.Breakscape.EMPTY_STRING;
151
- answer = undefined;
151
+ question = [];
152
+ answer = [];
152
153
  alternativeAnswers = [];
153
154
  variantIndex = 0;
154
155
  extraTags = {};
155
156
  for (const side of card.sides) {
156
157
  for (const content of side.variants) {
157
- const _a = content.data, { cardBodyStr } = _a, tags = __rest(_a, ["cardBodyStr"]);
158
+ const _b = content.data, { cardBody } = _b, tags = __rest(_b, ["cardBody"]);
158
159
  extraTags = Object.assign(Object.assign({}, extraTags), tags);
159
160
  if (variantIndex === 0) {
160
161
  questionVariant = content;
161
- question = cardBodyStr !== null && cardBodyStr !== void 0 ? cardBodyStr : Breakscape_1.Breakscape.EMPTY_STRING;
162
+ question = cardBody === null || cardBody === void 0 ? void 0 : cardBody.body;
163
+ questionString = ((_a = cardBody === null || cardBody === void 0 ? void 0 : cardBody.bodyString) !== null && _a !== void 0 ? _a : '');
162
164
  }
163
165
  else if (variantIndex === 1) {
164
- answer = cardBodyStr !== null && cardBodyStr !== void 0 ? cardBodyStr : Breakscape_1.Breakscape.EMPTY_STRING;
166
+ answer = cardBody === null || cardBody === void 0 ? void 0 : cardBody.body;
165
167
  }
166
168
  else {
167
- alternativeAnswers.push(cardBodyStr !== null && cardBodyStr !== void 0 ? cardBodyStr : Breakscape_1.Breakscape.EMPTY_STRING);
169
+ alternativeAnswers.push(cardBody === null || cardBody === void 0 ? void 0 : cardBody.body);
168
170
  }
169
171
  variantIndex++;
170
172
  }
@@ -172,14 +174,19 @@ function parseFlashcardLike(context, bitType, cardSet) {
172
174
  // Add the flashcard
173
175
  if (cardIndex === 0 || !onlyOneCardAllowed) {
174
176
  if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.definitionList)) {
175
- // .definitions-list
176
- definitions.push(builder.definitionListItem(Object.assign({ term: question, description: answer, alternativeDefinitions: alternativeAnswers.length > 0 ? alternativeAnswers : undefined }, extraTags)));
177
+ // .definition-list
178
+ const dl = Object.assign({ term: question, definition: answer, alternativeDefinitions: alternativeAnswers }, extraTags);
179
+ if (dl)
180
+ definitions.push(dl);
177
181
  }
178
182
  else {
179
183
  // .flashcard
180
184
  // if (question) {
181
- flashcards.push(builder.flashcard(Object.assign({ question,
182
- answer, alternativeAnswers: alternativeAnswers.length > 0 ? alternativeAnswers : undefined }, extraTags)));
185
+ const fc = Object.assign({ question,
186
+ answer,
187
+ alternativeAnswers }, extraTags);
188
+ if (fc)
189
+ flashcards.push(fc);
183
190
  // } else {
184
191
  // context.addWarning('Ignoring card with empty question', questionVariant);
185
192
  // }
@@ -187,7 +194,7 @@ function parseFlashcardLike(context, bitType, cardSet) {
187
194
  }
188
195
  else {
189
196
  // Only one card allowed, add a warning and ignore the card
190
- context.addWarning(`Bit '${bitType}' should only contain one card. Ignore subsequent card: '${question}'`, questionVariant);
197
+ context.addWarning(`Bit '${bitType}' should only contain one card. Ignore subsequent card: '${questionString}'`, questionVariant);
191
198
  break;
192
199
  }
193
200
  cardIndex++;
@@ -205,7 +212,7 @@ function parseElements(_context, _bitType, cardSet) {
205
212
  for (const content of side.variants) {
206
213
  const tags = content.data;
207
214
  // if (tags.cardBody) {
208
- elements.push((_a = tags.cardBodyStr) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING);
215
+ elements.push((_a = tags.cardBodyStr) !== null && _a !== void 0 ? _a : '');
209
216
  // } else {
210
217
  // context.addWarning('Ignoring card with empty element', content);
211
218
  // }
@@ -217,19 +224,23 @@ function parseElements(_context, _bitType, cardSet) {
217
224
  };
218
225
  }
219
226
  function parseStatements(_context, _bitType, cardSet, statementV1, statementsV1) {
227
+ var _a;
220
228
  const statements = [];
221
229
  for (const card of cardSet.cards) {
222
230
  for (const side of card.sides) {
223
231
  for (const content of side.variants) {
224
- const _a = content.data, { statements: chainedStatements } = _a, tags = __rest(_a, ["statements"]);
232
+ const _b = content.data, { statements: chainedStatements, statement: _ignore } = _b, tags = __rest(_b, ["statements", "statement"]);
233
+ // Remove statement from rest, tags
234
+ _ignore;
225
235
  // Re-build the statement, adding any tags that were not in the True/False chain
226
236
  // These tags are actually not in the correct place, but we can still interpret them and fix the data.
227
237
  // As .true-false only has one statement per card, we can just add the extra tags to the statement.
228
238
  if (Array.isArray(chainedStatements)) {
229
239
  for (const s of chainedStatements) {
230
240
  // if (s.text) {
231
- const statement = builder.statement(Object.assign(Object.assign(Object.assign({}, s), s.itemLead), tags));
232
- statements.push(statement);
241
+ 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);
242
+ if (statement)
243
+ statements.push(statement);
233
244
  // } else {
234
245
  // context.addWarning('Ignoring card with empty statement', content);
235
246
  // }
@@ -260,24 +271,31 @@ function parseQuiz(_context, bitType, cardSet, choicesV1, responsesV1) {
260
271
  let exampleCard;
261
272
  for (const card of cardSet.cards) {
262
273
  isDefaultExampleCard = false;
263
- exampleCard = Breakscape_1.Breakscape.EMPTY_STRING;
274
+ exampleCard = undefined;
264
275
  for (const side of card.sides) {
265
276
  for (const content of side.variants) {
266
- const _a = content.data, { isDefaultExample, example } = _a, tags = __rest(_a, ["isDefaultExample", "example"]);
277
+ const _a = content.data, { __isDefaultExample, example } = _a, tags = __rest(_a, ["__isDefaultExample", "example"]);
267
278
  // Example
268
- isDefaultExampleCard = isDefaultExample === true ? true : isDefaultExampleCard;
279
+ isDefaultExampleCard = __isDefaultExample === true ? true : isDefaultExampleCard;
269
280
  exampleCard = example ? example : exampleCard;
270
281
  // Insert choices / responses
271
282
  if (tags.trueFalse && tags.trueFalse.length > 0) {
272
283
  const responsesOrChoices = [];
273
- const builderFunc = insertResponses ? builder.response : builder.choice;
274
284
  for (const tf of tags.trueFalse) {
275
- const { isDefaultExample: isDefaultExampleTf, example: exampleTf } = tf, tfTags = __rest(tf, ["isDefaultExample", "example"]);
276
- const isDefaultExample = isDefaultExampleTf || isDefaultExampleCard;
285
+ const { __isDefaultExample: isDefaultExampleTf, example: exampleTf } = tf, tfTags = __rest(tf, ["__isDefaultExample", "example"]);
286
+ const __isDefaultExample = isDefaultExampleTf || isDefaultExampleCard;
277
287
  const example = exampleTf || exampleCard;
278
- const response = builderFunc(Object.assign(Object.assign({}, tfTags), { isDefaultExample,
279
- example }));
280
- responsesOrChoices.push(response);
288
+ const response = {
289
+ isCorrect: tfTags.isCorrect,
290
+ __isDefaultExample,
291
+ example,
292
+ };
293
+ if (insertResponses)
294
+ response.response = tfTags.text;
295
+ else
296
+ response.choice = tfTags.text;
297
+ if (response)
298
+ responsesOrChoices.push(response);
281
299
  }
282
300
  if (insertResponses)
283
301
  tags.responses = responsesOrChoices;
@@ -285,8 +303,9 @@ function parseQuiz(_context, bitType, cardSet, choicesV1, responsesV1) {
285
303
  tags.choices = responsesOrChoices;
286
304
  }
287
305
  // if (tags.choices || tags.responses) {
288
- const quiz = builder.quiz(Object.assign(Object.assign({}, tags), { isDefaultExample: isDefaultExampleCard, example: exampleCard }));
289
- quizzes.push(quiz);
306
+ const quiz = Object.assign(Object.assign({}, tags), { choices: tags.choices, responses: tags.responses, __isDefaultExample: isDefaultExampleCard, __defaultExample: exampleCard });
307
+ if (quiz)
308
+ quizzes.push(quiz);
290
309
  // } else {
291
310
  // context.addWarning('Ignoring card with empty quiz', content);
292
311
  // }
@@ -295,16 +314,18 @@ function parseQuiz(_context, bitType, cardSet, choicesV1, responsesV1) {
295
314
  }
296
315
  // Add a quiz for the V1 choices / responses
297
316
  if (insertChoices && Array.isArray(choicesV1) && choicesV1.length > 0) {
298
- const quiz = builder.quiz({
317
+ const quiz = {
299
318
  choices: choicesV1,
300
- });
301
- quizzes.push(quiz);
319
+ };
320
+ if (quiz)
321
+ quizzes.push(quiz);
302
322
  }
303
323
  if (insertResponses && Array.isArray(responsesV1) && responsesV1.length > 0) {
304
- const quiz = builder.quiz({
324
+ const quiz = {
305
325
  responses: responsesV1,
306
- });
307
- quizzes.push(quiz);
326
+ };
327
+ if (quiz)
328
+ quizzes.push(quiz);
308
329
  }
309
330
  return {
310
331
  quizzes: quizzes.length > 0 ? quizzes : undefined,
@@ -318,8 +339,9 @@ function parseQuestions(_context, _bitType, cardSet) {
318
339
  for (const content of side.variants) {
319
340
  const tags = content.data;
320
341
  // if (tags.cardBody) {
321
- const q = builder.question(Object.assign({ question: (_a = tags.cardBodyStr) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING }, tags));
322
- questions.push(q);
342
+ const q = Object.assign({ question: (_a = tags.cardBodyStr) !== null && _a !== void 0 ? _a : '' }, tags);
343
+ if (q)
344
+ questions.push(q);
323
345
  // }
324
346
  // else {
325
347
  // context.addWarning('Ignoring card with empty body text', content);
@@ -331,7 +353,7 @@ function parseQuestions(_context, _bitType, cardSet) {
331
353
  questions: questions.length > 0 ? questions : undefined,
332
354
  };
333
355
  }
334
- function parseMatchPairs(_context, _bitType, cardSet) {
356
+ function parseMatchPairs(_context, bitType, cardSet) {
335
357
  let sideIdx = 0;
336
358
  let isHeading = false;
337
359
  let heading;
@@ -340,6 +362,7 @@ function parseMatchPairs(_context, _bitType, cardSet) {
340
362
  let forValues = [];
341
363
  let pairKey = undefined;
342
364
  let pairValues = [];
365
+ let _pairValuesAst = [];
343
366
  let keyAudio = undefined;
344
367
  let keyImage = undefined;
345
368
  let extraTags = {};
@@ -354,28 +377,29 @@ function parseMatchPairs(_context, _bitType, cardSet) {
354
377
  forValues = [];
355
378
  pairKey = undefined;
356
379
  pairValues = [];
380
+ _pairValuesAst = [];
357
381
  keyAudio = undefined;
358
382
  keyImage = undefined;
359
383
  sideIdx = 0;
360
384
  extraTags = {};
361
385
  isDefaultExampleCard = false;
362
- exampleCard = Breakscape_1.Breakscape.EMPTY_STRING;
386
+ exampleCard = undefined;
363
387
  for (const side of card.sides) {
364
388
  for (const content of side.variants) {
365
389
  // variant = content;
366
- const _a = content.data, { cardBodyStr, title, resources, isDefaultExample, example } = _a, tags = __rest(_a, ["cardBodyStr", "title", "resources", "isDefaultExample", "example"]);
390
+ const _a = content.data, { cardBody, cardBodyStr, title, resources, __isDefaultExample, example } = _a, tags = __rest(_a, ["cardBody", "cardBodyStr", "title", "resources", "__isDefaultExample", "example"]);
367
391
  // Example
368
- isDefaultExampleCard = isDefaultExample === true ? true : isDefaultExampleCard;
392
+ isDefaultExampleCard = __isDefaultExample === true ? true : isDefaultExampleCard;
369
393
  exampleCard = example ? example : exampleCard;
370
394
  // Get the 'heading' which is the [#title] at level 1
371
- const heading = title && title[1];
395
+ const heading = title && title[1].titleString;
372
396
  if (heading != null)
373
397
  isHeading = true;
374
398
  if (sideIdx === 0) {
375
399
  // First side
376
400
  forKeys = heading;
377
401
  if (heading != null) {
378
- isDefaultExampleCardSet = isDefaultExample === true ? true : isDefaultExampleCardSet;
402
+ isDefaultExampleCardSet = __isDefaultExample === true ? true : isDefaultExampleCardSet;
379
403
  exampleCardSet = example ? example : exampleCardSet;
380
404
  }
381
405
  else if (Array.isArray(resources) && resources.length > 0) {
@@ -383,10 +407,10 @@ function parseMatchPairs(_context, _bitType, cardSet) {
383
407
  const resource = resources[0];
384
408
  // console.log('WARNING: Match card has resource on first side', tags.resource);
385
409
  if (resource.type === ResourceTag_1.ResourceTag.audio) {
386
- keyAudio = resource;
410
+ keyAudio = resource.audio;
387
411
  }
388
412
  else if (resource.type === ResourceTag_1.ResourceTag.image) {
389
- keyImage = resource;
413
+ keyImage = resource.image;
390
414
  }
391
415
  }
392
416
  else {
@@ -396,17 +420,19 @@ function parseMatchPairs(_context, _bitType, cardSet) {
396
420
  }
397
421
  else {
398
422
  // Subsequent sides
399
- forValues.push(heading !== null && heading !== void 0 ? heading : Breakscape_1.Breakscape.EMPTY_STRING);
423
+ forValues.push(heading !== null && heading !== void 0 ? heading : '');
400
424
  if (heading != null) {
401
- isDefaultExampleCardSet = isDefaultExample === true ? true : isDefaultExampleCardSet;
425
+ isDefaultExampleCardSet = __isDefaultExample === true ? true : isDefaultExampleCardSet;
402
426
  exampleCardSet = example ? example : exampleCardSet;
403
427
  }
404
428
  else if (title == null) {
405
429
  // If not a heading, it is a pair
406
- const value = cardBodyStr !== null && cardBodyStr !== void 0 ? cardBodyStr : Breakscape_1.Breakscape.EMPTY_STRING;
430
+ const value = cardBodyStr !== null && cardBodyStr !== void 0 ? cardBodyStr : '';
431
+ const valueAst = cardBody === null || cardBody === void 0 ? void 0 : cardBody.body;
407
432
  pairValues.push(value);
433
+ _pairValuesAst.push(valueAst);
408
434
  if ((isDefaultExampleCardSet || isDefaultExampleCard) && !exampleCard)
409
- exampleCard = value;
435
+ exampleCard = valueAst;
410
436
  }
411
437
  // Fix: https://github.com/getMoreBrain/cosmic/issues/5454
412
438
  delete tags.item;
@@ -418,22 +444,37 @@ function parseMatchPairs(_context, _bitType, cardSet) {
418
444
  sideIdx++;
419
445
  }
420
446
  if (isHeading) {
421
- heading = builder.heading({
422
- forKeys: forKeys !== null && forKeys !== void 0 ? forKeys : Breakscape_1.Breakscape.EMPTY_STRING,
423
- forValues,
424
- });
447
+ let forValuesFinal = forValues;
448
+ if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.matchMatrix)) {
449
+ // forValues is an array of values
450
+ forValuesFinal = forValues;
451
+ }
452
+ else {
453
+ // Standard match, forValues is a single value
454
+ if (forValues.length >= 1) {
455
+ forValuesFinal = forValues[forValues.length - 1];
456
+ }
457
+ else {
458
+ forValuesFinal = '';
459
+ }
460
+ }
461
+ heading = {
462
+ forKeys: forKeys !== null && forKeys !== void 0 ? forKeys : '',
463
+ forValues: forValuesFinal,
464
+ };
425
465
  }
426
466
  else {
427
467
  // if (pairKey || keyAudio || keyImage) {
428
- // Calculate final example and isDefaultExample
468
+ // Calculate final example and __isDefaultExample
429
469
  if (isDefaultExampleCard)
430
470
  exampleCardSet = undefined;
431
- const isDefaultExample = isDefaultExampleCard || isDefaultExampleCardSet;
471
+ const __isDefaultExample = isDefaultExampleCard || isDefaultExampleCardSet;
432
472
  const example = exampleCard || exampleCardSet;
433
- const pair = builder.pair(Object.assign(Object.assign({ key: pairKey !== null && pairKey !== void 0 ? pairKey : Breakscape_1.Breakscape.EMPTY_STRING, keyAudio,
434
- keyImage, values: pairValues }, extraTags), { isDefaultExample,
435
- example }));
436
- pairs.push(pair);
473
+ const pair = Object.assign(Object.assign({ key: pairKey !== null && pairKey !== void 0 ? pairKey : '', keyAudio,
474
+ keyImage, values: pairValues, __valuesAst: _pairValuesAst }, extraTags), { __isDefaultExample,
475
+ example });
476
+ if (pair)
477
+ pairs.push(pair);
437
478
  // } else {
438
479
  // context.addWarning('Ignoring card with empty body text', variant);
439
480
  // }
@@ -455,6 +496,7 @@ function parseMatchMatrix(_context, _bitType, cardSet) {
455
496
  const matrix = [];
456
497
  let matrixCells = [];
457
498
  let matrixCellValues = [];
499
+ let _matrixCellValuesAst = [];
458
500
  let matrixCellTags = {};
459
501
  let isDefaultExampleCardSet = false;
460
502
  let exampleCardSet;
@@ -477,27 +519,29 @@ function parseMatchMatrix(_context, _bitType, cardSet) {
477
519
  // keyImage = undefined;
478
520
  matrixCells = [];
479
521
  matrixCellValues = [];
522
+ _matrixCellValuesAst = [];
480
523
  sideIdx = 0;
481
524
  isDefaultExampleCard = false;
482
- exampleCard = Breakscape_1.Breakscape.EMPTY_STRING;
525
+ exampleCard = undefined;
483
526
  isCaseSensitiveMatrix = undefined;
484
527
  for (const side of card.sides) {
485
528
  matrixCellValues = [];
529
+ _matrixCellValuesAst = [];
486
530
  matrixCellTags = {};
487
531
  isDefaultExampleSide = false;
488
- exampleSide = Breakscape_1.Breakscape.EMPTY_STRING;
532
+ exampleSide = undefined;
489
533
  isCaseSensitiveCell = undefined;
490
534
  for (const content of side.variants) {
491
535
  // variant = content;
492
536
  const tags = content.data;
493
- const { title, cardBodyStr, isDefaultExample, example, isCaseSensitive } = tags, restTags = __rest(tags, ["title", "cardBodyStr", "isDefaultExample", "example", "isCaseSensitive"]);
537
+ const { title, cardBody, cardBodyStr, __isDefaultExample, example, isCaseSensitive } = tags, restTags = __rest(tags, ["title", "cardBody", "cardBodyStr", "__isDefaultExample", "example", "isCaseSensitive"]);
494
538
  // Example
495
- isDefaultExampleSide = isDefaultExample === true ? true : isDefaultExampleSide;
539
+ isDefaultExampleSide = __isDefaultExample === true ? true : isDefaultExampleSide;
496
540
  exampleSide = example ? example : exampleSide;
497
541
  // Merge the tags into the matrix cell tags
498
542
  Object.assign(matrixCellTags, restTags);
499
543
  // Get the 'heading' which is the [#title] at level 1
500
- const heading = title && title[1];
544
+ const heading = title && title[1].titleString;
501
545
  if (heading != null)
502
546
  isHeading = true;
503
547
  if (sideIdx === 0) {
@@ -511,14 +555,14 @@ function parseMatchMatrix(_context, _bitType, cardSet) {
511
555
  // } else if (tags.resource.type === ResourceTag.image) {
512
556
  // keyImage = tags.resource as ImageResource;
513
557
  // }
514
- isDefaultExampleCardSet = isDefaultExample === true ? true : isDefaultExampleCardSet;
558
+ isDefaultExampleCardSet = __isDefaultExample === true ? true : isDefaultExampleCardSet;
515
559
  exampleCardSet = example ? example : exampleCardSet;
516
560
  }
517
561
  else {
518
562
  // If not a heading or resource, it is a matrix
519
563
  matrixKey = cardBodyStr;
520
564
  matrixKeyTags = restTags;
521
- isDefaultExampleCard = isDefaultExample === true ? true : isDefaultExampleCard;
565
+ isDefaultExampleCard = __isDefaultExample === true ? true : isDefaultExampleCard;
522
566
  exampleCard = example ? example : exampleCard;
523
567
  isCaseSensitiveMatrix = isCaseSensitive != null ? isCaseSensitive : isCaseSensitiveMatrix;
524
568
  }
@@ -527,48 +571,51 @@ function parseMatchMatrix(_context, _bitType, cardSet) {
527
571
  // Subsequent sides
528
572
  forValues.push(heading !== null && heading !== void 0 ? heading : Breakscape_1.Breakscape.EMPTY_STRING);
529
573
  if (heading != null) {
530
- isDefaultExampleCardSet = isDefaultExample === true ? true : isDefaultExampleCardSet;
574
+ isDefaultExampleCardSet = __isDefaultExample === true ? true : isDefaultExampleCardSet;
531
575
  exampleCardSet = example ? example : exampleCardSet;
532
576
  }
533
577
  else if (tags.title == null) {
534
578
  // If not a heading, it is a matrix cell value
535
579
  const value = cardBodyStr !== null && cardBodyStr !== void 0 ? cardBodyStr : Breakscape_1.Breakscape.EMPTY_STRING;
580
+ const valueAst = cardBody === null || cardBody === void 0 ? void 0 : cardBody.body;
536
581
  matrixCellValues.push(value);
582
+ _matrixCellValuesAst.push(valueAst);
537
583
  if ((isDefaultExampleCardSet || isDefaultExampleSide) && !exampleSide)
538
- exampleSide = value;
584
+ exampleSide = valueAst;
539
585
  isCaseSensitiveCell = isCaseSensitive != null ? isCaseSensitive : isCaseSensitiveMatrix;
540
586
  }
541
587
  }
542
588
  }
543
589
  // Finished looping variants, create matrix cell
544
590
  if (sideIdx > 0) {
545
- // Calculate final example and isDefaultExample
591
+ // Calculate final example and __isDefaultExample
546
592
  if (isDefaultExampleSide)
547
593
  exampleCard = exampleCardSet = undefined;
548
594
  if (isDefaultExampleCard)
549
595
  exampleCardSet = undefined;
550
- const isDefaultExample = isDefaultExampleSide || isDefaultExampleCard || isDefaultExampleCardSet;
596
+ const __isDefaultExample = isDefaultExampleSide || isDefaultExampleCard || isDefaultExampleCardSet;
551
597
  const example = exampleSide || exampleCard || exampleCardSet;
552
- const matrixCell = builder.matrixCell(Object.assign(Object.assign({ values: matrixCellValues }, matrixCellTags), { isDefaultExample,
553
- example, isCaseSensitive: isCaseSensitiveCell }));
554
- matrixCells.push(matrixCell);
598
+ const matrixCell = Object.assign(Object.assign({ values: matrixCellValues, __valuesAst: _matrixCellValuesAst }, matrixCellTags), { __isDefaultExample: __isDefaultExample, example, isCaseSensitive: isCaseSensitiveCell });
599
+ if (matrixCell)
600
+ matrixCells.push(matrixCell);
555
601
  }
556
602
  sideIdx++;
557
603
  }
558
604
  if (isHeading) {
559
- heading = builder.heading({
605
+ heading = {
560
606
  forKeys: forKeys !== null && forKeys !== void 0 ? forKeys : Breakscape_1.Breakscape.EMPTY_STRING,
561
607
  forValues,
562
- });
608
+ };
563
609
  }
564
610
  else {
565
611
  // if (matrixKey) {
566
- const m = builder.matrix(Object.assign({ key: matrixKey !== null && matrixKey !== void 0 ? matrixKey : Breakscape_1.Breakscape.EMPTY_STRING,
612
+ const m = Object.assign({ key: matrixKey !== null && matrixKey !== void 0 ? matrixKey : Breakscape_1.Breakscape.EMPTY_STRING,
567
613
  // item: matrixItem ?? Breakscape.EMPTY_STRING,
568
614
  // keyAudio,
569
615
  // keyImage,
570
- cells: matrixCells }, matrixKeyTags));
571
- matrix.push(m);
616
+ cells: matrixCells }, matrixKeyTags);
617
+ if (m)
618
+ matrix.push(m);
572
619
  // } else {
573
620
  // context.addWarning('Ignoring card with empty body text', variant);
574
621
  // }
@@ -594,15 +641,15 @@ function parseTable(_context, _bitType, cardSet) {
594
641
  const tags = content.data;
595
642
  const { title, cardBodyStr } = tags;
596
643
  // Get the 'heading' which is the [#title] at level 1
597
- const heading = title && title[1];
644
+ const heading = title && title[1].titleString;
598
645
  if (cardIdx === 0 && heading != null)
599
646
  isHeading = true;
600
647
  if (isHeading) {
601
- columns.push(heading !== null && heading !== void 0 ? heading : Breakscape_1.Breakscape.EMPTY_STRING);
648
+ columns.push(heading !== null && heading !== void 0 ? heading : '');
602
649
  }
603
650
  else {
604
651
  // If not a heading, it is a row cell value
605
- const value = cardBodyStr !== null && cardBodyStr !== void 0 ? cardBodyStr : Breakscape_1.Breakscape.EMPTY_STRING;
652
+ const value = cardBodyStr !== null && cardBodyStr !== void 0 ? cardBodyStr : '';
606
653
  rowValues.push(value);
607
654
  }
608
655
  }
@@ -612,10 +659,10 @@ function parseTable(_context, _bitType, cardSet) {
612
659
  }
613
660
  cardIdx++;
614
661
  }
615
- const table = builder.table({
662
+ const table = {
616
663
  columns,
617
- rows,
618
- });
664
+ data: rows,
665
+ };
619
666
  return { table };
620
667
  }
621
668
  function parseBotActionResponses(_context, _bitType, cardSet) {
@@ -623,9 +670,10 @@ function parseBotActionResponses(_context, _bitType, cardSet) {
623
670
  for (const card of cardSet.cards) {
624
671
  for (const side of card.sides) {
625
672
  for (const content of side.variants) {
626
- const _a = content.data, { instruction, reaction, cardBodyStr: feedback } = _a, tags = __rest(_a, ["instruction", "reaction", "cardBodyStr"]);
627
- const botResponse = builder.botResponse(Object.assign({ response: instruction !== null && instruction !== void 0 ? instruction : Breakscape_1.Breakscape.EMPTY_STRING, reaction: reaction !== null && reaction !== void 0 ? reaction : Breakscape_1.Breakscape.EMPTY_STRING, feedback: feedback !== null && feedback !== void 0 ? feedback : Breakscape_1.Breakscape.EMPTY_STRING }, tags));
628
- botResponses.push(botResponse);
673
+ const _a = content.data, { __instructionString, reaction, cardBodyStr: feedback } = _a, tags = __rest(_a, ["__instructionString", "reaction", "cardBodyStr"]);
674
+ const botResponse = Object.assign({ response: __instructionString !== null && __instructionString !== void 0 ? __instructionString : Breakscape_1.Breakscape.EMPTY_STRING, reaction: reaction !== null && reaction !== void 0 ? reaction : Breakscape_1.Breakscape.EMPTY_STRING, feedback: feedback !== null && feedback !== void 0 ? feedback : Breakscape_1.Breakscape.EMPTY_STRING }, tags);
675
+ if (botResponse)
676
+ botResponses.push(botResponse);
629
677
  }
630
678
  }
631
679
  }
@@ -638,26 +686,32 @@ function parseIngredients(_context, _bitType, cardSet) {
638
686
  for (const card of cardSet.cards) {
639
687
  for (const side of card.sides) {
640
688
  for (const content of side.variants) {
641
- 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"]);
689
+ 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"]);
642
690
  // Extract 'title' from title array (if present)
643
691
  // Extract 'quantity' from either then unchained instruction, or from the select (otherwise use 0)
644
692
  // Extract checked from the select options (if present, otherwise checked is false))
645
- const title = Array.isArray(titleArray) && titleArray.length > 0 ? titleArray[titleArray.length - 1] : undefined;
693
+ const title = Array.isArray(titleArray) && titleArray.length > 0
694
+ ? titleArray[titleArray.length - 1].titleString
695
+ : undefined;
646
696
  let checked = false;
647
- let quantity = NumberUtils_1.NumberUtils.asNumber(instruction);
648
- if (cardBody && cardBody.bodyParts) {
649
- const select = cardBody.bodyParts.find((part) => part.type === BodyBitType_1.BodyBitType.select);
697
+ let quantity = NumberUtils_1.NumberUtils.asNumber(__instructionString);
698
+ if (cardBody && cardBody.bodyBits) {
699
+ const select = cardBody.bodyBits.find((c) => c.type === BodyBitType_1.BodyBitType.select);
650
700
  if (select) {
651
- quantity = select.data.instruction ? NumberUtils_1.NumberUtils.asNumber(select.data.instruction) : quantity;
652
- if (select.data.options && select.data.options.length > 0) {
653
- checked = select.data.options[0].isCorrect;
701
+ quantity = select.__instructionString ? NumberUtils_1.NumberUtils.asNumber(select.__instructionString) : quantity;
702
+ if (select.options && select.options.length > 0) {
703
+ checked = select.options[0].isCorrect;
654
704
  }
655
705
  }
656
706
  }
657
- const trimmedItem = item ? item.trim() : Breakscape_1.Breakscape.EMPTY_STRING;
658
- const ingredient = builder.ingredient(Object.assign({ title,
659
- checked, item: trimmedItem, quantity, unit: unit !== null && unit !== void 0 ? unit : Breakscape_1.Breakscape.EMPTY_STRING, unitAbbr: unitAbbr !== null && unitAbbr !== void 0 ? unitAbbr : Breakscape_1.Breakscape.EMPTY_STRING, decimalPlaces: decimalPlaces !== null && decimalPlaces !== void 0 ? decimalPlaces : 1, disableCalculation: disableCalculation }, tags));
660
- ingredients.push(ingredient);
707
+ const ingredient = Object.assign({ title,
708
+ checked,
709
+ // TS compiler very weird. It doesn't recognize that cardBodyStr is a string|undefined, even if cast!
710
+ // Casting to 'any' to avoid the error
711
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
712
+ item: cardBodyStr, quantity, unit: unit !== null && unit !== void 0 ? unit : Breakscape_1.Breakscape.EMPTY_STRING, unitAbbr: unitAbbr !== null && unitAbbr !== void 0 ? unitAbbr : Breakscape_1.Breakscape.EMPTY_STRING, decimalPlaces: decimalPlaces !== null && decimalPlaces !== void 0 ? decimalPlaces : 1, disableCalculation: disableCalculation }, tags);
713
+ if (ingredient)
714
+ ingredients.push(ingredient);
661
715
  }
662
716
  }
663
717
  }
@@ -680,15 +734,15 @@ function parseCaptionDefinitionsList(_context, _bitType, cardSet) {
680
734
  const tags = content.data;
681
735
  const { title, cardBodyStr } = tags;
682
736
  // Get the 'heading' which is the [#title] at level 1
683
- const heading = title && title[1];
737
+ const heading = title && title[1].titleString;
684
738
  if (cardIdx === 0 && heading != null)
685
739
  isHeading = true;
686
740
  if (isHeading) {
687
- columns.push(heading !== null && heading !== void 0 ? heading : Breakscape_1.Breakscape.EMPTY_STRING);
741
+ columns.push(heading !== null && heading !== void 0 ? heading : '');
688
742
  }
689
743
  else {
690
744
  // If not a heading, it is a row cell value
691
- const value = cardBodyStr !== null && cardBodyStr !== void 0 ? cardBodyStr : Breakscape_1.Breakscape.EMPTY_STRING;
745
+ const value = cardBodyStr !== null && cardBodyStr !== void 0 ? cardBodyStr : '';
692
746
  rowValues.push(value);
693
747
  }
694
748
  }
@@ -698,24 +752,29 @@ function parseCaptionDefinitionsList(_context, _bitType, cardSet) {
698
752
  }
699
753
  cardIdx++;
700
754
  }
701
- const captionDefinitionList = builder.captionDefinitionList({
702
- columns,
703
- definitions: rows.map((row) => {
704
- return builder.captionDefinition({
705
- term: row[0],
706
- description: row[1],
707
- });
708
- }),
709
- });
755
+ const captionDefinitionList = columns.length > 0
756
+ ? {
757
+ columns,
758
+ definitions: rows
759
+ .map((row) => {
760
+ const col = {
761
+ term: row[0],
762
+ definition: row[1],
763
+ };
764
+ return col;
765
+ })
766
+ .filter((d) => d != null),
767
+ }
768
+ : undefined;
710
769
  return { captionDefinitionList };
711
770
  }
712
- function parseCardBits(_context, _bitType, cardSet) {
771
+ function parseCardBits(_context, _bitType, _textFormat, cardSet) {
713
772
  const cardBits = [];
714
773
  for (const card of cardSet.cards) {
715
774
  for (const side of card.sides) {
716
775
  for (const content of side.variants) {
717
776
  const _a = content.data, { cardBody: body } = _a, rest = __rest(_a, ["cardBody"]);
718
- const cardBit = builder.cardBit(Object.assign({ body }, rest));
777
+ const cardBit = Object.assign({ body }, rest);
719
778
  if (cardBit)
720
779
  cardBits.push(cardBit);
721
780
  }
@@ -725,17 +784,4 @@ function parseCardBits(_context, _bitType, cardSet) {
725
784
  cardBits: cardBits.length > 0 ? cardBits : undefined,
726
785
  };
727
786
  }
728
- function cardBodyToBreakscapedString(cardBody) {
729
- let bodyStr = '';
730
- if (cardBody && cardBody.bodyParts) {
731
- for (const bodyPart of cardBody.bodyParts) {
732
- if (bodyPart.type === BodyBitType_1.BodyBitType.text) {
733
- const asText = bodyPart;
734
- const bodyTextPart = asText.data.bodyText;
735
- bodyStr += bodyTextPart;
736
- }
737
- }
738
- }
739
- return bodyStr;
740
- }
741
787
  //# sourceMappingURL=CardContentProcessor.js.map