@gmb/bitmark-parser-generator 1.34.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.
- package/dist/browser/bitmark-parser-generator.min.js +1 -1
- package/dist/browser/bundle-report.html +2 -2
- package/dist/cjs/BitmarkParserGenerator.js +8 -3
- package/dist/cjs/BitmarkParserGenerator.js.map +1 -1
- package/dist/cjs/ast/Ast.js +1 -0
- package/dist/cjs/ast/Ast.js.map +1 -1
- package/dist/cjs/ast/BaseBuilder.js +91 -54
- package/dist/cjs/ast/BaseBuilder.js.map +1 -1
- package/dist/cjs/ast/Builder.js +780 -377
- package/dist/cjs/ast/Builder.js.map +1 -1
- package/dist/cjs/ast/ResourceBuilder.js +516 -252
- package/dist/cjs/ast/ResourceBuilder.js.map +1 -1
- package/dist/cjs/ast/rules/NodeValidator.js +61 -22
- package/dist/cjs/ast/rules/NodeValidator.js.map +1 -1
- package/dist/cjs/ast/writer/StreamWriter.js +13 -0
- package/dist/cjs/ast/writer/StreamWriter.js.map +1 -1
- package/dist/cjs/ast/writer/StringWriter.js +13 -0
- package/dist/cjs/ast/writer/StringWriter.js.map +1 -1
- package/dist/cjs/breakscaping/Breakscape.js +122 -95
- package/dist/cjs/breakscaping/Breakscape.js.map +1 -1
- package/dist/cjs/config/raw/bits.js +24 -5
- package/dist/cjs/config/raw/bits.js.map +1 -1
- package/dist/cjs/config/raw/properties.js +7 -2
- package/dist/cjs/config/raw/properties.js.map +1 -1
- package/dist/cjs/generated/build-info.js +1 -1
- package/dist/cjs/generated/build-info.js.map +1 -1
- package/dist/cjs/generated/parser/bitmark/bitmark-peggy-parser.js +312 -262
- package/dist/cjs/generated/parser/bitmark/bitmark-peggy-parser.js.map +1 -1
- package/dist/cjs/generator/AstWalkerGenerator.js +4 -1
- package/dist/cjs/generator/AstWalkerGenerator.js.map +1 -1
- package/dist/cjs/generator/bitmark/BitmarkGenerator.js +977 -336
- package/dist/cjs/generator/bitmark/BitmarkGenerator.js.map +1 -1
- package/dist/cjs/generator/json/JsonGenerator.js +361 -1964
- package/dist/cjs/generator/json/JsonGenerator.js.map +1 -1
- package/dist/cjs/generator/text/TextGenerator.js +26 -8
- package/dist/cjs/generator/text/TextGenerator.js.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/model/ast/NodeType.js +64 -42
- package/dist/cjs/model/ast/NodeType.js.map +1 -1
- package/dist/cjs/model/config/enum/PropertyConfigKey.js +1 -0
- package/dist/cjs/model/config/enum/PropertyConfigKey.js.map +1 -1
- package/dist/cjs/model/enum/BitType.js +2 -2
- package/dist/cjs/model/enum/BitType.js.map +1 -1
- package/dist/cjs/model/enum/PropertyFormat.js +3 -1
- package/dist/cjs/model/enum/PropertyFormat.js.map +1 -1
- package/dist/cjs/model/enum/TextFormat.js +1 -0
- package/dist/cjs/model/enum/TextFormat.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserHelper.js +22 -4
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserHelper.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserProcessor.js +93 -88
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserTypes.js +3 -1
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserTypes.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserValidator.js +10 -32
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserValidator.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/BodyContentProcessor.js +255 -0
- package/dist/cjs/parser/bitmark/peg/contentProcessors/BodyContentProcessor.js.map +1 -0
- package/dist/cjs/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.js +2 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/CardContentProcessor.js +175 -129
- package/dist/cjs/parser/bitmark/peg/contentProcessors/CardContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.js +8 -2
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ContentProcessorUtils.js +61 -0
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ContentProcessorUtils.js.map +1 -0
- package/dist/cjs/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.js +11 -5
- package/dist/cjs/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js +21 -17
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/FooterContentProcessor.js +50 -0
- package/dist/cjs/parser/bitmark/peg/contentProcessors/FooterContentProcessor.js.map +1 -0
- package/dist/cjs/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.js +2 -15
- package/dist/cjs/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.js +2 -4
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.js +4 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.js +2 -4
- package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.js +5 -5
- package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/PersonChainContentProcessor.js +5 -6
- package/dist/cjs/parser/bitmark/peg/contentProcessors/PersonChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js +23 -7
- package/dist/cjs/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/RatingLevelChainContentProcessor.js +5 -5
- package/dist/cjs/parser/bitmark/peg/contentProcessors/RatingLevelChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.js +3 -2
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.js +19 -8
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ServingsChainContentProcessor.js +4 -6
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ServingsChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TechnicalTermChainContentProcessor.js +4 -5
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TechnicalTermChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.js +14 -5
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.js +37 -21
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js +3 -2
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js.map +1 -1
- package/dist/cjs/parser/json/JsonParser.js +73 -759
- package/dist/cjs/parser/json/JsonParser.js.map +1 -1
- package/dist/cjs/parser/text/TextParser.js +75 -1
- package/dist/cjs/parser/text/TextParser.js.map +1 -1
- package/dist/cjs/utils/BitUtils.js +15 -13
- package/dist/cjs/utils/BitUtils.js.map +1 -1
- package/dist/cjs/utils/StringUtils.js +40 -0
- package/dist/cjs/utils/StringUtils.js.map +1 -1
- package/dist/esm/BitmarkParserGenerator.js +8 -3
- package/dist/esm/BitmarkParserGenerator.js.map +1 -1
- package/dist/esm/ast/Ast.js +1 -0
- package/dist/esm/ast/Ast.js.map +1 -1
- package/dist/esm/ast/BaseBuilder.js +91 -54
- package/dist/esm/ast/BaseBuilder.js.map +1 -1
- package/dist/esm/ast/Builder.js +780 -377
- package/dist/esm/ast/Builder.js.map +1 -1
- package/dist/esm/ast/ResourceBuilder.js +516 -252
- package/dist/esm/ast/ResourceBuilder.js.map +1 -1
- package/dist/esm/ast/rules/NodeValidator.js +61 -22
- package/dist/esm/ast/rules/NodeValidator.js.map +1 -1
- package/dist/esm/ast/writer/StreamWriter.js +13 -0
- package/dist/esm/ast/writer/StreamWriter.js.map +1 -1
- package/dist/esm/ast/writer/StringWriter.js +13 -0
- package/dist/esm/ast/writer/StringWriter.js.map +1 -1
- package/dist/esm/breakscaping/Breakscape.js +122 -95
- package/dist/esm/breakscaping/Breakscape.js.map +1 -1
- package/dist/esm/config/raw/bits.js +24 -5
- package/dist/esm/config/raw/bits.js.map +1 -1
- package/dist/esm/config/raw/properties.js +7 -2
- package/dist/esm/config/raw/properties.js.map +1 -1
- package/dist/esm/generated/build-info.js +1 -1
- package/dist/esm/generated/build-info.js.map +1 -1
- package/dist/esm/generated/parser/bitmark/bitmark-peggy-parser.js +312 -262
- package/dist/esm/generated/parser/bitmark/bitmark-peggy-parser.js.map +1 -1
- package/dist/esm/generator/AstWalkerGenerator.js +4 -1
- package/dist/esm/generator/AstWalkerGenerator.js.map +1 -1
- package/dist/esm/generator/bitmark/BitmarkGenerator.js +977 -336
- package/dist/esm/generator/bitmark/BitmarkGenerator.js.map +1 -1
- package/dist/esm/generator/json/JsonGenerator.js +361 -1964
- package/dist/esm/generator/json/JsonGenerator.js.map +1 -1
- package/dist/esm/generator/text/TextGenerator.js +26 -8
- package/dist/esm/generator/text/TextGenerator.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/model/ast/NodeType.js +64 -42
- package/dist/esm/model/ast/NodeType.js.map +1 -1
- package/dist/esm/model/config/enum/PropertyConfigKey.js +1 -0
- package/dist/esm/model/config/enum/PropertyConfigKey.js.map +1 -1
- package/dist/esm/model/enum/BitType.js +2 -2
- package/dist/esm/model/enum/BitType.js.map +1 -1
- package/dist/esm/model/enum/PropertyFormat.js +3 -1
- package/dist/esm/model/enum/PropertyFormat.js.map +1 -1
- package/dist/esm/model/enum/TextFormat.js +1 -0
- package/dist/esm/model/enum/TextFormat.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserHelper.js +22 -4
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserHelper.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserProcessor.js +93 -88
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserTypes.js +3 -1
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserTypes.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserValidator.js +10 -32
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserValidator.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/BodyContentProcessor.js +252 -0
- package/dist/esm/parser/bitmark/peg/contentProcessors/BodyContentProcessor.js.map +1 -0
- package/dist/esm/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.js +2 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/CardContentProcessor.js +175 -129
- package/dist/esm/parser/bitmark/peg/contentProcessors/CardContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.js +8 -2
- package/dist/esm/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ContentProcessorUtils.js +58 -0
- package/dist/esm/parser/bitmark/peg/contentProcessors/ContentProcessorUtils.js.map +1 -0
- package/dist/esm/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.js +11 -5
- package/dist/esm/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js +21 -17
- package/dist/esm/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/FooterContentProcessor.js +47 -0
- package/dist/esm/parser/bitmark/peg/contentProcessors/FooterContentProcessor.js.map +1 -0
- package/dist/esm/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.js +2 -15
- package/dist/esm/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.js +2 -4
- package/dist/esm/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.js +4 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.js +2 -4
- package/dist/esm/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.js +5 -5
- package/dist/esm/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/PersonChainContentProcessor.js +5 -6
- package/dist/esm/parser/bitmark/peg/contentProcessors/PersonChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js +23 -7
- package/dist/esm/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/RatingLevelChainContentProcessor.js +5 -5
- package/dist/esm/parser/bitmark/peg/contentProcessors/RatingLevelChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.js +3 -2
- package/dist/esm/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.js +19 -8
- package/dist/esm/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ServingsChainContentProcessor.js +4 -6
- package/dist/esm/parser/bitmark/peg/contentProcessors/ServingsChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/TechnicalTermChainContentProcessor.js +4 -5
- package/dist/esm/parser/bitmark/peg/contentProcessors/TechnicalTermChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.js +14 -5
- package/dist/esm/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.js +37 -21
- package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js +3 -2
- package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js.map +1 -1
- package/dist/esm/parser/json/JsonParser.js +73 -759
- package/dist/esm/parser/json/JsonParser.js.map +1 -1
- package/dist/esm/parser/text/TextParser.js +75 -1
- package/dist/esm/parser/text/TextParser.js.map +1 -1
- package/dist/esm/utils/BitUtils.js +15 -13
- package/dist/esm/utils/BitUtils.js.map +1 -1
- package/dist/esm/utils/StringUtils.js +40 -0
- package/dist/esm/utils/StringUtils.js.map +1 -1
- package/dist/types/BitmarkParserGenerator.d.ts +8 -0
- package/dist/types/BitmarkParserGenerator.d.ts.map +1 -1
- package/dist/types/ast/Ast.d.ts.map +1 -1
- package/dist/types/ast/BaseBuilder.d.ts +31 -21
- package/dist/types/ast/BaseBuilder.d.ts.map +1 -1
- package/dist/types/ast/Builder.d.ts +283 -435
- package/dist/types/ast/Builder.d.ts.map +1 -1
- package/dist/types/ast/ResourceBuilder.d.ts +177 -164
- package/dist/types/ast/ResourceBuilder.d.ts.map +1 -1
- package/dist/types/ast/rules/NodeValidator.d.ts +3 -2
- package/dist/types/ast/rules/NodeValidator.d.ts.map +1 -1
- package/dist/types/ast/writer/StreamWriter.d.ts +2 -0
- package/dist/types/ast/writer/StreamWriter.d.ts.map +1 -1
- package/dist/types/ast/writer/StringWriter.d.ts +2 -0
- package/dist/types/ast/writer/StringWriter.d.ts.map +1 -1
- package/dist/types/ast/writer/Writer.d.ts +6 -0
- package/dist/types/ast/writer/Writer.d.ts.map +1 -1
- package/dist/types/breakscaping/Breakscape.d.ts +6 -1
- package/dist/types/breakscaping/Breakscape.d.ts.map +1 -1
- package/dist/types/config/raw/bits.d.ts.map +1 -1
- package/dist/types/config/raw/properties.d.ts.map +1 -1
- package/dist/types/generated/parser/bitmark/bitmark-peggy-parser.d.ts.map +1 -1
- package/dist/types/generator/AstWalkerGenerator.d.ts.map +1 -1
- package/dist/types/generator/bitmark/BitmarkGenerator.d.ts +91 -55
- package/dist/types/generator/bitmark/BitmarkGenerator.d.ts.map +1 -1
- package/dist/types/generator/json/JsonGenerator.d.ts +96 -108
- package/dist/types/generator/json/JsonGenerator.d.ts.map +1 -1
- package/dist/types/generator/text/TextGenerator.d.ts +14 -2
- package/dist/types/generator/text/TextGenerator.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/model/ast/NodeType.d.ts +122 -84
- package/dist/types/model/ast/NodeType.d.ts.map +1 -1
- package/dist/types/model/ast/Nodes.d.ts +66 -436
- package/dist/types/model/ast/Nodes.d.ts.map +1 -1
- package/dist/types/model/ast/TextNodes.d.ts +1 -1
- package/dist/types/model/ast/TextNodes.d.ts.map +1 -1
- package/dist/types/model/config/enum/ConfigKey.d.ts +2 -0
- package/dist/types/model/config/enum/ConfigKey.d.ts.map +1 -1
- package/dist/types/model/config/enum/PropertyConfigKey.d.ts +3 -0
- package/dist/types/model/config/enum/PropertyConfigKey.d.ts.map +1 -1
- package/dist/types/model/enum/BitType.d.ts +4 -4
- package/dist/types/model/enum/PropertyFormat.d.ts +4 -2
- package/dist/types/model/enum/PropertyFormat.d.ts.map +1 -1
- package/dist/types/model/enum/PropertyTag.d.ts +2 -0
- package/dist/types/model/enum/PropertyTag.d.ts.map +1 -1
- package/dist/types/model/enum/TextFormat.d.ts +2 -0
- package/dist/types/model/enum/TextFormat.d.ts.map +1 -1
- package/dist/types/model/json/BitJson.d.ts +32 -20
- package/dist/types/model/json/BitJson.d.ts.map +1 -1
- package/dist/types/model/json/BodyBitJson.d.ts +16 -12
- package/dist/types/model/json/BodyBitJson.d.ts.map +1 -1
- package/dist/types/model/json/ResourceJson.d.ts +2 -22
- package/dist/types/model/json/ResourceJson.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/BitmarkPegParserHelper.d.ts +4 -2
- package/dist/types/parser/bitmark/peg/BitmarkPegParserHelper.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/BitmarkPegParserProcessor.d.ts +3 -9
- package/dist/types/parser/bitmark/peg/BitmarkPegParserProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/BitmarkPegParserTypes.d.ts +90 -74
- package/dist/types/parser/bitmark/peg/BitmarkPegParserTypes.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/BitmarkPegParserValidator.d.ts +2 -2
- package/dist/types/parser/bitmark/peg/BitmarkPegParserValidator.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/BodyContentProcessor.d.ts +37 -0
- package/dist/types/parser/bitmark/peg/contentProcessors/BodyContentProcessor.d.ts.map +1 -0
- package/dist/types/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/CardContentProcessor.d.ts +2 -2
- package/dist/types/parser/bitmark/peg/contentProcessors/CardContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/ContentProcessorUtils.d.ts +15 -0
- package/dist/types/parser/bitmark/peg/contentProcessors/ContentProcessorUtils.d.ts.map +1 -0
- package/dist/types/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/FooterContentProcessor.d.ts +16 -0
- package/dist/types/parser/bitmark/peg/contentProcessors/FooterContentProcessor.d.ts.map +1 -0
- package/dist/types/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/PersonChainContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/RatingLevelChainContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.d.ts +2 -2
- package/dist/types/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/ServingsChainContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/TechnicalTermChainContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.d.ts +5 -2
- package/dist/types/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.d.ts +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/json/JsonParser.d.ts +9 -72
- package/dist/types/parser/json/JsonParser.d.ts.map +1 -1
- package/dist/types/parser/text/TextParser.d.ts +16 -1
- package/dist/types/parser/text/TextParser.d.ts.map +1 -1
- package/dist/types/utils/BitUtils.d.ts +8 -8
- package/dist/types/utils/BitUtils.d.ts.map +1 -1
- package/dist/types/utils/StringUtils.d.ts +24 -0
- package/dist/types/utils/StringUtils.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -27,19 +27,16 @@ const Config_1 = require("../../config/Config");
|
|
|
27
27
|
const NodeType_1 = require("../../model/ast/NodeType");
|
|
28
28
|
const BitType_1 = require("../../model/enum/BitType");
|
|
29
29
|
const BitmarkVersion_1 = require("../../model/enum/BitmarkVersion");
|
|
30
|
-
const BodyBitType_1 = require("../../model/enum/BodyBitType");
|
|
31
30
|
const ExampleType_1 = require("../../model/enum/ExampleType");
|
|
32
|
-
const PropertyAstKey_1 = require("../../model/enum/PropertyAstKey");
|
|
33
|
-
const PropertyTag_1 = require("../../model/enum/PropertyTag");
|
|
34
31
|
const ResourceTag_1 = require("../../model/enum/ResourceTag");
|
|
35
32
|
const TextFormat_1 = require("../../model/enum/TextFormat");
|
|
33
|
+
const TextNodeType_1 = require("../../model/enum/TextNodeType");
|
|
36
34
|
const TextParser_1 = require("../../parser/text/TextParser");
|
|
37
35
|
const ArrayUtils_1 = require("../../utils/ArrayUtils");
|
|
38
36
|
const BooleanUtils_1 = require("../../utils/BooleanUtils");
|
|
39
37
|
const NumberUtils_1 = require("../../utils/NumberUtils");
|
|
40
|
-
const StringUtils_1 = require("../../utils/StringUtils");
|
|
41
|
-
const UrlUtils_1 = require("../../utils/UrlUtils");
|
|
42
38
|
const AstWalkerGenerator_1 = require("../AstWalkerGenerator");
|
|
39
|
+
const TextGenerator_1 = require("../text/TextGenerator");
|
|
43
40
|
const DEFAULT_OPTIONS = {
|
|
44
41
|
// debugGenerationInline: true,
|
|
45
42
|
};
|
|
@@ -67,7 +64,13 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
67
64
|
this.textDefault = Breakscape_1.Breakscape.EMPTY_STRING;
|
|
68
65
|
this.bodyDefault = Breakscape_1.Breakscape.EMPTY_STRING;
|
|
69
66
|
this.bodyJson = this.bodyDefault;
|
|
70
|
-
this.
|
|
67
|
+
this.placeholderIndex = 0;
|
|
68
|
+
// Bind callbacks
|
|
69
|
+
this.enter = this.enter.bind(this);
|
|
70
|
+
this.between = this.between.bind(this);
|
|
71
|
+
this.exit = this.exit.bind(this);
|
|
72
|
+
this.leaf = this.leaf.bind(this);
|
|
73
|
+
this.bodyBitCallback = this.bodyBitCallback.bind(this);
|
|
71
74
|
this.bitmarkVersion = (_a = BitmarkVersion_1.BitmarkVersion.fromValue(options === null || options === void 0 ? void 0 : options.bitmarkVersion)) !== null && _a !== void 0 ? _a : BitmarkVersion_1.DEFAULT_BITMARK_VERSION;
|
|
72
75
|
this.textParserVersion = this.textParser.version();
|
|
73
76
|
this.options = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options === null || options === void 0 ? void 0 : options.jsonOptions);
|
|
@@ -84,11 +87,13 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
84
87
|
this.options.textAsPlainText = false;
|
|
85
88
|
}
|
|
86
89
|
}
|
|
90
|
+
// Create the text generator for generating v2 texts
|
|
91
|
+
this.textGenerator = new TextGenerator_1.TextGenerator(this.bitmarkVersion, {
|
|
92
|
+
// writeCallback: this.write,
|
|
93
|
+
bodyBitCallback: this.bodyBitCallback,
|
|
94
|
+
debugGenerationInline: this.debugGenerationInline,
|
|
95
|
+
});
|
|
87
96
|
this.writer = writer;
|
|
88
|
-
this.enter = this.enter.bind(this);
|
|
89
|
-
this.between = this.between.bind(this);
|
|
90
|
-
this.exit = this.exit.bind(this);
|
|
91
|
-
this.leaf = this.leaf.bind(this);
|
|
92
97
|
this.generatePropertyHandlers();
|
|
93
98
|
}
|
|
94
99
|
/**
|
|
@@ -132,7 +137,8 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
132
137
|
this.textDefault = this.options.textAsPlainText ? Breakscape_1.Breakscape.EMPTY_STRING : [];
|
|
133
138
|
this.bodyDefault = this.options.textAsPlainText ? Breakscape_1.Breakscape.EMPTY_STRING : [];
|
|
134
139
|
this.bodyJson = this.bodyDefault;
|
|
135
|
-
this.
|
|
140
|
+
this.listItem = undefined;
|
|
141
|
+
this.placeholderIndex = 0;
|
|
136
142
|
this.printed = false;
|
|
137
143
|
}
|
|
138
144
|
walkAndWrite(ast) {
|
|
@@ -150,6 +156,16 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
150
156
|
// Reset the JSON
|
|
151
157
|
this.json = [];
|
|
152
158
|
}
|
|
159
|
+
exit_bitmarkAst(_node, _route) {
|
|
160
|
+
// Convert all bitmark text to plain text if required
|
|
161
|
+
if (this.options.textAsPlainText) {
|
|
162
|
+
// Convert all bitmark text to plain text
|
|
163
|
+
this.convertAllBitmarkTextsToStringsForPlainText(this.json);
|
|
164
|
+
}
|
|
165
|
+
// Walk the entire json object and remove all' '_xxx' properties
|
|
166
|
+
// (which are used to store temporary data during the generation process)
|
|
167
|
+
this.removeTemporaryProperties(this.json);
|
|
168
|
+
}
|
|
153
169
|
// bitmarkAst -> bits
|
|
154
170
|
// bitmarkAst -> bits -> bitsValue
|
|
155
171
|
enter_bitsValue(node, _route) {
|
|
@@ -183,7 +199,7 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
183
199
|
}
|
|
184
200
|
else {
|
|
185
201
|
// String example
|
|
186
|
-
defaultExample = (_c =
|
|
202
|
+
defaultExample = (_c = ArrayUtils_1.ArrayUtils.asSingle(bit.sampleSolution)) !== null && _c !== void 0 ? _c : '';
|
|
187
203
|
}
|
|
188
204
|
const exampleRes = this.toExample(bit, {
|
|
189
205
|
defaultExample,
|
|
@@ -195,87 +211,34 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
195
211
|
else if (bit.isExample) {
|
|
196
212
|
this.bitJson.isExample = true;
|
|
197
213
|
}
|
|
214
|
+
// Reset the placeholder index
|
|
215
|
+
this.placeholderIndex = 0;
|
|
198
216
|
}
|
|
199
217
|
exit_bitsValue(_node, _route) {
|
|
200
218
|
// Clean up the bit JSON, removing any unwanted values
|
|
201
|
-
this.
|
|
219
|
+
this.cleanBitJson(this.bitJson);
|
|
202
220
|
}
|
|
203
221
|
// bitmarkAst -> bits -> bitsValue -> imageSource
|
|
204
222
|
enter_imageSource(node, route) {
|
|
205
|
-
|
|
206
|
-
// Ignore values that are not at the bit level as they might be handled elsewhere
|
|
207
|
-
const parent = this.getParentNode(route);
|
|
208
|
-
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.bitsValue)
|
|
209
|
-
return;
|
|
210
|
-
const { url, mockupId, size, format, trim } = imageSource;
|
|
211
|
-
const imageSourceJson = {};
|
|
212
|
-
this.addProperty(imageSourceJson, 'url', url !== null && url !== void 0 ? url : '', true);
|
|
213
|
-
this.addProperty(imageSourceJson, 'mockupId', mockupId !== null && mockupId !== void 0 ? mockupId : '', true);
|
|
214
|
-
this.addProperty(imageSourceJson, 'size', size !== null && size !== void 0 ? size : null, true);
|
|
215
|
-
this.addProperty(imageSourceJson, 'format', format !== null && format !== void 0 ? format : null, true);
|
|
216
|
-
this.addProperty(imageSourceJson, 'trim', BooleanUtils_1.BooleanUtils.isBoolean(trim) ? trim : null, true);
|
|
217
|
-
this.bitJson.imageSource = imageSourceJson;
|
|
223
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.bitsValue, { array: false });
|
|
218
224
|
}
|
|
219
225
|
// bitmarkAst -> bits -> bitsValue -> person
|
|
220
226
|
enter_person(node, route) {
|
|
221
|
-
const person = node.value;
|
|
222
227
|
const bitType = this.getBitType(route);
|
|
223
|
-
|
|
224
|
-
const parent = this.getParentNode(route);
|
|
225
|
-
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.bitsValue || !bitType)
|
|
226
|
-
return;
|
|
227
|
-
const { name, title, avatarImage } = person;
|
|
228
|
-
const personJson = {};
|
|
229
|
-
this.addProperty(personJson, 'name', name !== null && name !== void 0 ? name : '', true);
|
|
230
|
-
if (title) {
|
|
231
|
-
this.addProperty(personJson, 'title', title, true);
|
|
232
|
-
}
|
|
233
|
-
if (avatarImage) {
|
|
234
|
-
const res = this.parseResourceToJson(bitType, avatarImage);
|
|
235
|
-
if (res && res.type === ResourceTag_1.ResourceTag.image) {
|
|
236
|
-
personJson.avatarImage = res.image;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
228
|
+
let keyOverride = 'person';
|
|
239
229
|
if (Config_1.Config.isOfBitType(bitType, BitType_1.BitType.conversationLeft1)) {
|
|
240
230
|
// Use the legacy partner property in the JSON for conversation bits, so change to person is backwards compatible
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
this.bitJson.person = personJson;
|
|
231
|
+
keyOverride = 'partner';
|
|
245
232
|
}
|
|
233
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.bitsValue, { array: false, keyOverride });
|
|
246
234
|
}
|
|
247
235
|
// bitmarkAst -> bits -> bitsValue -> ratingLevelStart
|
|
248
236
|
enter_ratingLevelStart(node, route) {
|
|
249
|
-
|
|
250
|
-
if (json)
|
|
251
|
-
this.bitJson.ratingLevelStart = json;
|
|
252
|
-
// Stop traversal of this branch
|
|
253
|
-
return false;
|
|
237
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.bitsValue, { array: false });
|
|
254
238
|
}
|
|
255
239
|
// bitmarkAst -> bits -> bitsValue -> ratingLevelEnd
|
|
256
240
|
enter_ratingLevelEnd(node, route) {
|
|
257
|
-
|
|
258
|
-
if (json)
|
|
259
|
-
this.bitJson.ratingLevelEnd = json;
|
|
260
|
-
// Stop traversal of this branch
|
|
261
|
-
return false;
|
|
262
|
-
}
|
|
263
|
-
// Common code for ratingLevelStart and ratingLevelEnd
|
|
264
|
-
enterRatingLevelStartEndCommon(node, route) {
|
|
265
|
-
const n = node.value;
|
|
266
|
-
// Ignore statements that are not at the bit level
|
|
267
|
-
const parent = this.getParentNode(route);
|
|
268
|
-
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.bitsValue)
|
|
269
|
-
return;
|
|
270
|
-
const json = {};
|
|
271
|
-
this.addProperty(json, 'level', n.level, true);
|
|
272
|
-
if (n.label) {
|
|
273
|
-
json.label = this.convertBreakscapedStringToJsonText(n.label, TextFormat_1.TextFormat.bitmarkMinusMinus);
|
|
274
|
-
}
|
|
275
|
-
// Delete unwanted properties
|
|
276
|
-
if ((json === null || json === void 0 ? void 0 : json.label) == null)
|
|
277
|
-
delete json.label;
|
|
278
|
-
return json;
|
|
241
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.bitsValue, { array: false });
|
|
279
242
|
}
|
|
280
243
|
// bitmarkAst -> bits -> bitsValue -> productId
|
|
281
244
|
enter_productId(node, route) {
|
|
@@ -283,53 +246,76 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
283
246
|
// Ignore item that is not at the correct level
|
|
284
247
|
const parent = this.getParentNode(route);
|
|
285
248
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.bitsValue)
|
|
286
|
-
return;
|
|
249
|
+
return true;
|
|
287
250
|
const bitType = this.getBitType(route);
|
|
288
251
|
if (bitType === BitType_1.BitType.module) {
|
|
289
|
-
this.addProperty(this.bitJson, 'productId', productIds);
|
|
252
|
+
this.addProperty(this.bitJson, 'productId', productIds, { array: true });
|
|
290
253
|
}
|
|
291
254
|
else if (productIds.length > 0) {
|
|
292
|
-
this.addProperty(this.bitJson, 'productId', productIds[productIds.length - 1],
|
|
255
|
+
this.addProperty(this.bitJson, 'productId', productIds[productIds.length - 1], { array: false });
|
|
293
256
|
}
|
|
257
|
+
// Stop traversal of this branch
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
// bitmarkAst -> bits -> bitsValue -> markConfig
|
|
261
|
+
enter_markConfig(_node, _route) {
|
|
262
|
+
// Handler so markConfig is not processed by the default property handler
|
|
263
|
+
// Continue traversal
|
|
264
|
+
return true;
|
|
294
265
|
}
|
|
295
266
|
// bitmarkAst -> bits -> bitsValue -> markConfig -> markConfigValue
|
|
296
267
|
enter_markConfigValue(node, route) {
|
|
297
|
-
const
|
|
268
|
+
const markJson = node.value;
|
|
298
269
|
// Ignore item that is not at the correct level
|
|
299
270
|
const parent = this.getParentNode(route);
|
|
300
271
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.markConfig)
|
|
301
|
-
return;
|
|
302
|
-
const { mark, color, emphasis } = markConfig;
|
|
303
|
-
const markJson = {};
|
|
304
|
-
this.addProperty(markJson, 'mark', mark !== null && mark !== void 0 ? mark : 'unknown', true);
|
|
305
|
-
if (color)
|
|
306
|
-
this.addProperty(markJson, 'color', color !== null && color !== void 0 ? color : '', true);
|
|
307
|
-
if (emphasis)
|
|
308
|
-
this.addProperty(markJson, 'emphasis', emphasis !== null && emphasis !== void 0 ? emphasis : '', true);
|
|
272
|
+
return true;
|
|
309
273
|
if (!this.bitJson.marks)
|
|
310
274
|
this.bitJson.marks = [];
|
|
311
275
|
this.bitJson.marks.push(markJson);
|
|
276
|
+
// Stop traversal of this branch
|
|
277
|
+
return false;
|
|
312
278
|
}
|
|
313
|
-
// bitmarkAst -> bits -> bitsValue ->
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
279
|
+
// bitmarkAst -> bits -> bitsValue -> item
|
|
280
|
+
enter_item(node, route) {
|
|
281
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.bitsValue, { array: true });
|
|
282
|
+
}
|
|
283
|
+
// bitmarkAst -> bits -> bitsValue -> lead
|
|
284
|
+
enter_lead(node, route) {
|
|
285
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.bitsValue, { array: true });
|
|
286
|
+
}
|
|
287
|
+
// bitmarkAst -> bits -> bitsValue -> pageNumber
|
|
288
|
+
enter_pageNumber(node, route) {
|
|
289
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.bitsValue, { array: true });
|
|
290
|
+
}
|
|
291
|
+
// bitmarkAst -> bits -> bitsValue -> marginNumber
|
|
292
|
+
enter_marginNumber(node, route) {
|
|
293
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.bitsValue, { array: true });
|
|
294
|
+
}
|
|
295
|
+
// bitmarkAst -> bits -> bitsValue -> hint
|
|
296
|
+
enter_hint(node, route) {
|
|
297
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.bitsValue, { array: true });
|
|
298
|
+
}
|
|
299
|
+
// bitmarkAst -> bits -> bitsValue -> instruction
|
|
300
|
+
enter_instruction(node, route) {
|
|
301
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.bitsValue, { array: true });
|
|
302
|
+
}
|
|
303
|
+
// bitmarkAst -> bits -> bitsValue -> title
|
|
304
|
+
enter_title(node, route) {
|
|
305
|
+
// // Ignore title that are not at the bit or card node level as they are handled elsewhere
|
|
306
|
+
// const parent = this.getParentNode(route);
|
|
307
|
+
// if (parent?.key !== NodeType.bitsValue && parent?.key !== NodeType.cardNode) return;
|
|
308
|
+
// this.bitJson.title = node.value;
|
|
309
|
+
return this.standardHandler(node, route, [NodeType_1.NodeType.bitsValue, NodeType_1.NodeType.cardNode], { array: true });
|
|
310
|
+
}
|
|
311
|
+
// bitmarkAst -> bits -> bitsValue -> subtitle
|
|
312
|
+
enter_subtitle(node, route) {
|
|
313
|
+
// this.bitJson.subtitle = node.value;
|
|
314
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.bitsValue, { array: true });
|
|
315
|
+
}
|
|
316
|
+
// bitmarkAst -> bits -> bitsValue -> caption
|
|
317
|
+
enter_caption(node, route) {
|
|
318
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.bitsValue, { array: true });
|
|
333
319
|
}
|
|
334
320
|
// bitmarkAst -> bits -> bitsValue -> width
|
|
335
321
|
enter_width(node, route) {
|
|
@@ -341,8 +327,7 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
341
327
|
value = (_a = NumberUtils_1.NumberUtils.asNumber(value, 0)) !== null && _a !== void 0 ? _a : 0;
|
|
342
328
|
}
|
|
343
329
|
// Add the property
|
|
344
|
-
this.
|
|
345
|
-
return false;
|
|
330
|
+
return this.standardHandler(node, route, undefined, { array: false, valueOverride: value });
|
|
346
331
|
}
|
|
347
332
|
// bitmarkAst -> bits -> bitsValue -> height
|
|
348
333
|
enter_height(node, route) {
|
|
@@ -354,8 +339,7 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
354
339
|
value = (_a = NumberUtils_1.NumberUtils.asNumber(value, 0)) !== null && _a !== void 0 ? _a : 0;
|
|
355
340
|
}
|
|
356
341
|
// Add the property
|
|
357
|
-
this.
|
|
358
|
-
return false;
|
|
342
|
+
return this.standardHandler(node, route, undefined, { array: false, valueOverride: value });
|
|
359
343
|
}
|
|
360
344
|
// bitmarkAst -> bits -> bitsValue -> extraProperties
|
|
361
345
|
enter_extraProperties(node, _route) {
|
|
@@ -366,12 +350,14 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
366
350
|
if (Object.prototype.hasOwnProperty.call(this.bitJson, key)) {
|
|
367
351
|
k = `_${key}`;
|
|
368
352
|
}
|
|
369
|
-
this.addProperty(this.bitJson, k, values);
|
|
353
|
+
this.addProperty(this.bitJson, k, values, { array: true });
|
|
370
354
|
}
|
|
371
355
|
}
|
|
372
356
|
}
|
|
373
357
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> cardBits -> cardBitsValue
|
|
374
358
|
enter_cardBitsValue(node, route) {
|
|
359
|
+
var _a, _b, _c, _d;
|
|
360
|
+
const cardBit = node.value;
|
|
375
361
|
// How cardBits are handled depends on the bit type
|
|
376
362
|
const bitType = this.getBitType(route);
|
|
377
363
|
if (!bitType)
|
|
@@ -389,7 +375,14 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
389
375
|
listItems = this.bitJson.listItems;
|
|
390
376
|
}
|
|
391
377
|
// Create this list item
|
|
392
|
-
this.listItem =
|
|
378
|
+
this.listItem = {
|
|
379
|
+
item: ((_a = cardBit.item) !== null && _a !== void 0 ? _a : []),
|
|
380
|
+
lead: ((_b = cardBit.lead) !== null && _b !== void 0 ? _b : []),
|
|
381
|
+
hint: ((_c = cardBit.hint) !== null && _c !== void 0 ? _c : []),
|
|
382
|
+
instruction: ((_d = cardBit.instruction) !== null && _d !== void 0 ? _d : []),
|
|
383
|
+
// ...this.toItemLeadHintInstruction(node.value),
|
|
384
|
+
body: this.bodyDefault,
|
|
385
|
+
};
|
|
393
386
|
// Delete unwanted properties
|
|
394
387
|
// const nv = node.value;
|
|
395
388
|
// const li: Partial<ListItemJson> = this.listItem;
|
|
@@ -399,208 +392,58 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
399
392
|
this.listItem = undefined;
|
|
400
393
|
}
|
|
401
394
|
// bitmarkAst -> bits -> bitsValue -> body
|
|
402
|
-
enter_body(
|
|
403
|
-
|
|
404
|
-
const textFormat = this.getTextFormat(_route);
|
|
405
|
-
if (textFormat === TextFormat_1.TextFormat.json)
|
|
406
|
-
this.bodyDefault = null;
|
|
407
|
-
this.bodyJson = this.bodyDefault;
|
|
408
|
-
}
|
|
409
|
-
exit_body(_node, route) {
|
|
395
|
+
enter_body(node, route) {
|
|
396
|
+
const value = node.value;
|
|
410
397
|
const parent = this.getParentNode(route);
|
|
411
398
|
if (!parent)
|
|
412
|
-
return;
|
|
399
|
+
return false;
|
|
400
|
+
const textFormat = this.getTextFormat(route);
|
|
401
|
+
const isBitmarkText = textFormat === TextFormat_1.TextFormat.bitmarkMinusMinus || textFormat === TextFormat_1.TextFormat.bitmarkPlusPlus;
|
|
402
|
+
this.bodyJson = value.body;
|
|
403
|
+
// Set the correct body property
|
|
413
404
|
if (parent.key === NodeType_1.NodeType.bitsValue) {
|
|
414
405
|
// Body is at the bit level
|
|
415
406
|
this.bitJson.body = this.bodyJson;
|
|
407
|
+
// Convert the body to plain text if required
|
|
408
|
+
if (this.options.textAsPlainText && isBitmarkText && this.isBitmarkText(this.bodyJson)) {
|
|
409
|
+
const textBody = this.textGenerator.generateSync(this.bodyJson, textFormat);
|
|
410
|
+
this.bitJson.body = (Breakscape_1.Breakscape.unbreakscape(textBody, {
|
|
411
|
+
textFormat: TextFormat_1.TextFormat.bitmarkMinusMinus,
|
|
412
|
+
}) || '').trim();
|
|
413
|
+
}
|
|
416
414
|
}
|
|
417
415
|
else if (parent.key === NodeType_1.NodeType.cardBitsValue) {
|
|
418
416
|
// Body is at the list item (card bit) level
|
|
419
417
|
if (this.listItem)
|
|
420
418
|
this.listItem.body = this.bodyJson;
|
|
421
419
|
}
|
|
422
|
-
|
|
423
|
-
// bitmarkAst -> bits -> bitsValue -> * -> bodyParts (body, cardBody (e.g. cloze-list, page-footer))
|
|
424
|
-
enter_bodyParts(node, route) {
|
|
425
|
-
const bodyParts = node.value;
|
|
426
|
-
const plainText = this.options.textAsPlainText;
|
|
427
|
-
const textFormat = this.getTextFormat(route);
|
|
428
|
-
let fullBodyTextStr = '';
|
|
429
|
-
let placeholderIndex = this.startPlaceholderIndex;
|
|
430
|
-
// Function for creating the placeholder keys
|
|
431
|
-
const createPlaceholderKeys = (i) => {
|
|
432
|
-
return {
|
|
433
|
-
// Old placeholder style (for backwards compatibility) = {0}
|
|
434
|
-
legacyPlaceholderKey: `{${i}}`,
|
|
435
|
-
// New placeholder style (cannot clash as bitmark parser would have removed it) = [!0]
|
|
436
|
-
placeholderKey: `[!${i}]`,
|
|
437
|
-
};
|
|
438
|
-
};
|
|
439
|
-
// Loop the text bodyParts creating full body text with the correct placeholders
|
|
440
|
-
//
|
|
441
|
-
// For text output 'fullBodyTextStr:
|
|
442
|
-
// - is created and written to the JSON
|
|
443
|
-
// - has placeholders inserted into 'fullBodyTextStr' in the format {0}
|
|
444
|
-
//
|
|
445
|
-
// For JSON output 'fullBodyTextStr:
|
|
446
|
-
// - is created and passed into the text parser to create the body text AST
|
|
447
|
-
// - has placeholders inserted into 'fullBodyTextStr' in the format [!0] to allow the text parser to identify
|
|
448
|
-
// where the body bits should be inserted
|
|
449
|
-
//
|
|
450
|
-
for (let i = 0; i < bodyParts.length; i++) {
|
|
451
|
-
const bodyPart = bodyParts[i];
|
|
452
|
-
const isText = bodyPart.type === BodyBitType_1.BodyBitType.text;
|
|
453
|
-
if (isText) {
|
|
454
|
-
const asText = bodyPart;
|
|
455
|
-
const bodyTextPart = asText.data.bodyText;
|
|
456
|
-
// Append the text part to the full text body
|
|
457
|
-
fullBodyTextStr = Breakscape_1.Breakscape.concatenate(fullBodyTextStr, bodyTextPart);
|
|
458
|
-
}
|
|
459
|
-
else {
|
|
460
|
-
const { legacyPlaceholderKey, placeholderKey } = createPlaceholderKeys(placeholderIndex);
|
|
461
|
-
// Append the placeholder to the full text body
|
|
462
|
-
fullBodyTextStr = Breakscape_1.Breakscape.concatenate(fullBodyTextStr, plainText ? legacyPlaceholderKey : placeholderKey);
|
|
463
|
-
placeholderIndex++;
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
// Add string or AST to the body
|
|
467
|
-
this.bodyJson = this.convertBreakscapedStringToJsonText(fullBodyTextStr, textFormat);
|
|
468
|
-
const bodyAst = this.bodyJson;
|
|
469
|
-
// Loop the body parts again to create the body bits:
|
|
470
|
-
// - For text output the body bits are inserted into the 'placeholders' object
|
|
471
|
-
// - For JSON output the body bits are inserted into body AST, replacing the placeholders created by the text parser
|
|
472
|
-
placeholderIndex = this.startPlaceholderIndex;
|
|
473
|
-
for (let i = 0; i < bodyParts.length; i++) {
|
|
474
|
-
const bodyPart = bodyParts[i];
|
|
475
|
-
// Skip text body parts as they are handled above
|
|
476
|
-
const isText = bodyPart.type === BodyBitType_1.BodyBitType.text;
|
|
477
|
-
if (isText)
|
|
478
|
-
continue;
|
|
479
|
-
const bodyBit = bodyPart;
|
|
480
|
-
let bodyBitJson;
|
|
481
|
-
const { legacyPlaceholderKey } = createPlaceholderKeys(placeholderIndex);
|
|
482
|
-
switch (bodyPart.type) {
|
|
483
|
-
case BodyBitType_1.BodyBitType.gap: {
|
|
484
|
-
const gap = bodyBit;
|
|
485
|
-
bodyBitJson = this.createGapJson(gap);
|
|
486
|
-
break;
|
|
487
|
-
}
|
|
488
|
-
case BodyBitType_1.BodyBitType.mark: {
|
|
489
|
-
const mark = bodyBit;
|
|
490
|
-
bodyBitJson = this.createMarkJson(mark);
|
|
491
|
-
break;
|
|
492
|
-
}
|
|
493
|
-
case BodyBitType_1.BodyBitType.select: {
|
|
494
|
-
const select = bodyBit;
|
|
495
|
-
bodyBitJson = this.createSelectJson(select);
|
|
496
|
-
break;
|
|
497
|
-
}
|
|
498
|
-
case BodyBitType_1.BodyBitType.highlight: {
|
|
499
|
-
const highlight = bodyBit;
|
|
500
|
-
bodyBitJson = this.createHighlightJson(highlight);
|
|
501
|
-
break;
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
// Add the gap to the placeholders
|
|
505
|
-
if (bodyBitJson) {
|
|
506
|
-
if (plainText) {
|
|
507
|
-
// Ensure placeholders exists
|
|
508
|
-
if (!this.bitJson.placeholders)
|
|
509
|
-
this.bitJson.placeholders = {};
|
|
510
|
-
// Add the body bit to the placeholders
|
|
511
|
-
this.bitJson.placeholders[legacyPlaceholderKey] = bodyBitJson;
|
|
512
|
-
}
|
|
513
|
-
else {
|
|
514
|
-
// Insert the body bit into the body AST
|
|
515
|
-
this.replacePlaceholderWithBodyBit(bodyAst, bodyBitJson, placeholderIndex);
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
placeholderIndex++;
|
|
519
|
-
}
|
|
520
|
-
// Save the current placeholder index for the next body (body, card bodies)
|
|
521
|
-
this.startPlaceholderIndex = placeholderIndex;
|
|
522
|
-
// Stop traversal of this branch for efficiency
|
|
420
|
+
// Stop traversal of this branch
|
|
523
421
|
return false;
|
|
524
422
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
this.
|
|
531
|
-
|
|
532
|
-
return
|
|
423
|
+
bodyBitCallback(bodyBit, _index, _route) {
|
|
424
|
+
// console.log('bodyBitCallback', bodyBit, index, route);
|
|
425
|
+
var _a;
|
|
426
|
+
const placeholder = `{${this.placeholderIndex}}`;
|
|
427
|
+
this.placeholderIndex++;
|
|
428
|
+
this.bitJson.placeholders = (_a = this.bitJson.placeholders) !== null && _a !== void 0 ? _a : {};
|
|
429
|
+
this.bitJson.placeholders[placeholder] = bodyBit;
|
|
430
|
+
return placeholder;
|
|
431
|
+
}
|
|
432
|
+
// bitmarkAst -> bits -> bitsValue -> footer
|
|
433
|
+
enter_footer(node, route) {
|
|
434
|
+
return this.standardHandler(node, route, undefined, { array: true, valueOverride: node.value.footer });
|
|
533
435
|
}
|
|
534
436
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> elements
|
|
535
|
-
enter_elements(node,
|
|
536
|
-
|
|
537
|
-
// Ignore elements that are not at the bit level as they are handled elsewhere as quizzes
|
|
538
|
-
// if (parent?.key !== NodeType.bitsValue) return;
|
|
539
|
-
if (elements && elements.length > 0) {
|
|
540
|
-
this.bitJson.elements = Breakscape_1.Breakscape.unbreakscape(elements);
|
|
541
|
-
}
|
|
437
|
+
enter_elements(node, route) {
|
|
438
|
+
return this.standardHandler(node, route, undefined, { array: true });
|
|
542
439
|
}
|
|
543
440
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> flashcards
|
|
544
441
|
enter_flashcards(node, route) {
|
|
545
|
-
|
|
546
|
-
const flashcards = node.value;
|
|
547
|
-
// Ignore responses that are not at the correct level as they are potentially handled elsewhere
|
|
548
|
-
const parent = this.getParentNode(route);
|
|
549
|
-
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.cardNode)
|
|
550
|
-
return;
|
|
551
|
-
const flashcardsJson = [];
|
|
552
|
-
if (flashcards) {
|
|
553
|
-
for (const c of flashcards) {
|
|
554
|
-
// Create the flashcard
|
|
555
|
-
const flashcardJson = Object.assign(Object.assign({ question: this.convertBreakscapedStringToJsonText((_a = c.question) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING, TextFormat_1.TextFormat.bitmarkMinusMinus), answer: this.convertBreakscapedStringToJsonText((_b = c.answer) !== null && _b !== void 0 ? _b : Breakscape_1.Breakscape.EMPTY_STRING, TextFormat_1.TextFormat.bitmarkMinusMinus), alternativeAnswers: ((_c = c.alternativeAnswers) !== null && _c !== void 0 ? _c : []).map((a) => this.convertBreakscapedStringToJsonText(a !== null && a !== void 0 ? a : Breakscape_1.Breakscape.EMPTY_STRING, TextFormat_1.TextFormat.bitmarkMinusMinus)) }, this.toItemLeadHintInstruction(c)), this.toExample(c, {
|
|
556
|
-
defaultExample: c.isDefaultExample,
|
|
557
|
-
isBoolean: true,
|
|
558
|
-
}));
|
|
559
|
-
// Delete unwanted properties
|
|
560
|
-
if (((_d = c.itemLead) === null || _d === void 0 ? void 0 : _d.lead) == null)
|
|
561
|
-
delete flashcardJson.lead;
|
|
562
|
-
flashcardsJson.push(flashcardJson);
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
if (flashcardsJson.length > 0) {
|
|
566
|
-
this.bitJson.cards = flashcardsJson;
|
|
567
|
-
}
|
|
442
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.cardNode, { array: true, keyOverride: 'cards' });
|
|
568
443
|
}
|
|
569
444
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> definitions
|
|
570
445
|
enter_definitions(node, route) {
|
|
571
|
-
|
|
572
|
-
const definitionListItem = node.value;
|
|
573
|
-
// Ignore responses that are not at the correct level as they are potentially handled elsewhere
|
|
574
|
-
const parent = this.getParentNode(route);
|
|
575
|
-
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.cardNode)
|
|
576
|
-
return;
|
|
577
|
-
const definitionsJson = [];
|
|
578
|
-
if (definitionListItem) {
|
|
579
|
-
for (const c of definitionListItem) {
|
|
580
|
-
// Create the flashcard
|
|
581
|
-
const definitionListItemJson = Object.assign(Object.assign({ term: this.convertBreakscapedStringToJsonText((_a = c.term) !== null && _a !== void 0 ? _a : Breakscape_1.Breakscape.EMPTY_STRING, TextFormat_1.TextFormat.bitmarkMinusMinus), description: this.convertBreakscapedStringToJsonText((_b = c.description) !== null && _b !== void 0 ? _b : Breakscape_1.Breakscape.EMPTY_STRING, TextFormat_1.TextFormat.bitmarkMinusMinus), alternativeDefinitions: ((_c = c.alternativeDefinitions) !== null && _c !== void 0 ? _c : []).map((a) => this.convertBreakscapedStringToJsonText(a !== null && a !== void 0 ? a : Breakscape_1.Breakscape.EMPTY_STRING, TextFormat_1.TextFormat.bitmarkMinusMinus)) }, this.toItemLeadHintInstruction(c)), this.toExample(c, {
|
|
582
|
-
defaultExample: c.isDefaultExample,
|
|
583
|
-
isBoolean: true,
|
|
584
|
-
}));
|
|
585
|
-
// Delete unwanted properties
|
|
586
|
-
if (((_d = c.itemLead) === null || _d === void 0 ? void 0 : _d.lead) == null)
|
|
587
|
-
delete definitionListItemJson.lead;
|
|
588
|
-
// description-list is an alias of definition-list. Just rename the properties
|
|
589
|
-
if (Config_1.Config.isOfBitType(this.getBitType(route), BitType_1.BitType.descriptionList)) {
|
|
590
|
-
definitionListItemJson.alternativeDescriptions = definitionListItemJson.alternativeDefinitions;
|
|
591
|
-
delete definitionListItemJson.alternativeDefinitions;
|
|
592
|
-
}
|
|
593
|
-
definitionsJson.push(definitionListItemJson);
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
if (definitionsJson.length > 0) {
|
|
597
|
-
if (Config_1.Config.isOfBitType(this.getBitType(route), BitType_1.BitType.descriptionList)) {
|
|
598
|
-
this.bitJson.descriptions = definitionsJson;
|
|
599
|
-
}
|
|
600
|
-
else {
|
|
601
|
-
this.bitJson.definitions = definitionsJson;
|
|
602
|
-
}
|
|
603
|
-
}
|
|
446
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.cardNode, { array: true });
|
|
604
447
|
}
|
|
605
448
|
// bitmarkAst -> bits -> bitsValue -> statement
|
|
606
449
|
enter_statement(node, route) {
|
|
@@ -611,405 +454,74 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
611
454
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.cardNode)
|
|
612
455
|
return;
|
|
613
456
|
if (statement) {
|
|
614
|
-
this.bitJson.statement = (_a =
|
|
457
|
+
this.bitJson.statement = (_a = statement.statement) !== null && _a !== void 0 ? _a : '';
|
|
615
458
|
this.bitJson.isCorrect = (_b = statement.isCorrect) !== null && _b !== void 0 ? _b : false;
|
|
459
|
+
this.bitJson.example = statement.example;
|
|
460
|
+
this.bitJson.isExample = statement.isExample;
|
|
616
461
|
}
|
|
617
462
|
}
|
|
618
463
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> statements -> statementsValue
|
|
619
464
|
enter_statements(node, route) {
|
|
620
|
-
|
|
621
|
-
const statements = node.value;
|
|
622
|
-
// Ignore statements that are not at the card node level as they are handled elsewhere
|
|
623
|
-
const parent = this.getParentNode(route);
|
|
624
|
-
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.cardNode)
|
|
625
|
-
return;
|
|
626
|
-
const statementsJson = [];
|
|
627
|
-
if (statements) {
|
|
628
|
-
for (const s of statements) {
|
|
629
|
-
// Create the statement
|
|
630
|
-
const statementJson = Object.assign(Object.assign({ statement: (_a = Breakscape_1.Breakscape.unbreakscape(s.text)) !== null && _a !== void 0 ? _a : '', isCorrect: !!s.isCorrect }, this.toItemLeadHintInstruction(s)), this.toExample(s, {
|
|
631
|
-
defaultExample: !!s.isCorrect,
|
|
632
|
-
isBoolean: true,
|
|
633
|
-
}));
|
|
634
|
-
// Delete unwanted properties
|
|
635
|
-
if (((_b = s.itemLead) === null || _b === void 0 ? void 0 : _b.item) == null)
|
|
636
|
-
delete statementJson.item;
|
|
637
|
-
if (((_c = s.itemLead) === null || _c === void 0 ? void 0 : _c.lead) == null)
|
|
638
|
-
delete statementJson.lead;
|
|
639
|
-
if ((s === null || s === void 0 ? void 0 : s.hint) == null)
|
|
640
|
-
delete statementJson.hint;
|
|
641
|
-
if ((s === null || s === void 0 ? void 0 : s.instruction) == null)
|
|
642
|
-
delete statementJson.instruction;
|
|
643
|
-
statementsJson.push(statementJson);
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
if (statementsJson.length > 0) {
|
|
647
|
-
this.bitJson.statements = statementsJson;
|
|
648
|
-
}
|
|
465
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.cardNode, { array: true });
|
|
649
466
|
}
|
|
650
467
|
// bitmarkAst -> bits -> bitsValue -> choices
|
|
651
468
|
// X bitmarkAst -> bits -> bitsValue -> cardNode -> quizzes -> quizzesValue -> choices
|
|
652
469
|
enter_choices(node, route) {
|
|
653
|
-
|
|
654
|
-
const choices = node.value;
|
|
655
|
-
// Ignore choices that are not at the bit level as they are handled elsewhere as quizzes
|
|
656
|
-
const parent = this.getParentNode(route);
|
|
657
|
-
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.cardNode)
|
|
658
|
-
return;
|
|
659
|
-
const choicesJson = [];
|
|
660
|
-
if (choices) {
|
|
661
|
-
for (const c of choices) {
|
|
662
|
-
// Create the choice
|
|
663
|
-
const choiceJson = Object.assign(Object.assign({ choice: (_a = Breakscape_1.Breakscape.unbreakscape(c.text)) !== null && _a !== void 0 ? _a : '', isCorrect: (_b = c.isCorrect) !== null && _b !== void 0 ? _b : false }, this.toItemLeadHintInstruction(c)), this.toExample(c, {
|
|
664
|
-
defaultExample: !!c.isCorrect,
|
|
665
|
-
isBoolean: true,
|
|
666
|
-
}));
|
|
667
|
-
// Delete unwanted properties
|
|
668
|
-
if (((_c = c.itemLead) === null || _c === void 0 ? void 0 : _c.lead) == null)
|
|
669
|
-
delete choiceJson.lead;
|
|
670
|
-
choicesJson.push(choiceJson);
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
if (choicesJson.length > 0) {
|
|
674
|
-
this.bitJson.choices = choicesJson;
|
|
675
|
-
}
|
|
470
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.cardNode, { array: true });
|
|
676
471
|
}
|
|
677
472
|
// bitmarkAst -> bits -> bitsValue -> responses
|
|
678
473
|
// X bitmarkAst -> bits -> bitsValue -> cardNode -> quizzes -> quizzesValue -> responses
|
|
679
474
|
enter_responses(node, route) {
|
|
680
|
-
|
|
681
|
-
const responses = node.value;
|
|
682
|
-
// Ignore responses that are not at the correct level as they are handled elsewhere as quizzes
|
|
683
|
-
const parent = this.getParentNode(route);
|
|
684
|
-
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.cardNode)
|
|
685
|
-
return;
|
|
686
|
-
const responsesJson = [];
|
|
687
|
-
if (responses) {
|
|
688
|
-
for (const r of responses) {
|
|
689
|
-
// Create the response
|
|
690
|
-
const responseJson = Object.assign(Object.assign({ response: (_a = Breakscape_1.Breakscape.unbreakscape(r.text)) !== null && _a !== void 0 ? _a : '', isCorrect: (_b = r.isCorrect) !== null && _b !== void 0 ? _b : false }, this.toItemLeadHintInstruction(r)), this.toExample(r, {
|
|
691
|
-
defaultExample: !!r.isCorrect,
|
|
692
|
-
isBoolean: true,
|
|
693
|
-
}));
|
|
694
|
-
// Delete unwanted properties
|
|
695
|
-
if (((_c = r.itemLead) === null || _c === void 0 ? void 0 : _c.lead) == null)
|
|
696
|
-
delete responseJson.lead;
|
|
697
|
-
responsesJson.push(responseJson);
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
if (responsesJson.length > 0) {
|
|
701
|
-
this.bitJson.responses = responsesJson;
|
|
702
|
-
}
|
|
475
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.cardNode, { array: true });
|
|
703
476
|
}
|
|
704
477
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> quizzes
|
|
705
|
-
enter_quizzes(node,
|
|
706
|
-
|
|
707
|
-
const quizzes = node.value;
|
|
708
|
-
const quizzesJson = [];
|
|
709
|
-
if (quizzes) {
|
|
710
|
-
for (const q of quizzes) {
|
|
711
|
-
// Choices
|
|
712
|
-
const choicesJson = [];
|
|
713
|
-
if (q.choices) {
|
|
714
|
-
for (const c of q.choices) {
|
|
715
|
-
// Create the choice
|
|
716
|
-
const choiceJson = Object.assign(Object.assign({ choice: (_a = Breakscape_1.Breakscape.unbreakscape(c.text)) !== null && _a !== void 0 ? _a : '', isCorrect: (_b = c.isCorrect) !== null && _b !== void 0 ? _b : false }, this.toItemLeadHintInstruction(c)), this.toExample(c, {
|
|
717
|
-
defaultExample: !!c.isCorrect,
|
|
718
|
-
isBoolean: true,
|
|
719
|
-
}));
|
|
720
|
-
// Delete unwanted properties
|
|
721
|
-
if (((_c = q.itemLead) === null || _c === void 0 ? void 0 : _c.lead) == null)
|
|
722
|
-
delete choiceJson.lead;
|
|
723
|
-
choicesJson.push(choiceJson);
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
// Responses
|
|
727
|
-
const responsesJson = [];
|
|
728
|
-
if (q.responses) {
|
|
729
|
-
for (const r of q.responses) {
|
|
730
|
-
// Create the choice
|
|
731
|
-
const responseJson = Object.assign(Object.assign({ response: (_d = Breakscape_1.Breakscape.unbreakscape(r.text)) !== null && _d !== void 0 ? _d : '', isCorrect: (_e = r.isCorrect) !== null && _e !== void 0 ? _e : false }, this.toItemLeadHintInstruction(r)), this.toExample(r, {
|
|
732
|
-
defaultExample: !!r.isCorrect,
|
|
733
|
-
isBoolean: true,
|
|
734
|
-
}));
|
|
735
|
-
// Delete unwanted properties
|
|
736
|
-
if (((_f = q.itemLead) === null || _f === void 0 ? void 0 : _f.lead) == null)
|
|
737
|
-
delete responseJson.lead;
|
|
738
|
-
responsesJson.push(responseJson);
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
// Create the quiz
|
|
742
|
-
const quizJson = Object.assign(Object.assign({}, this.toItemLeadHintInstruction(q)), { isExample: (_g = q.isExample) !== null && _g !== void 0 ? _g : false, choices: q.choices ? choicesJson : undefined, responses: q.responses ? responsesJson : undefined });
|
|
743
|
-
// Delete unwanted properties
|
|
744
|
-
if (((_h = q.itemLead) === null || _h === void 0 ? void 0 : _h.lead) == null)
|
|
745
|
-
delete quizJson.lead;
|
|
746
|
-
quizzesJson.push(quizJson);
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
if (quizzesJson.length > 0) {
|
|
750
|
-
this.bitJson.quizzes = quizzesJson;
|
|
751
|
-
}
|
|
478
|
+
enter_quizzes(node, route) {
|
|
479
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.cardNode, { array: true });
|
|
752
480
|
}
|
|
753
481
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> heading
|
|
754
|
-
enter_heading(node,
|
|
755
|
-
|
|
756
|
-
const heading = node.value;
|
|
757
|
-
// Check if the heading is for a match or a match matrix
|
|
758
|
-
const bitType = this.getBitType(_route);
|
|
759
|
-
const isMatrix = Config_1.Config.isOfBitType(bitType, BitType_1.BitType.matchMatrix);
|
|
760
|
-
// Create the heading
|
|
761
|
-
const headingJson = {
|
|
762
|
-
forKeys: (_a = Breakscape_1.Breakscape.unbreakscape(heading.forKeys)) !== null && _a !== void 0 ? _a : '',
|
|
763
|
-
};
|
|
764
|
-
if (isMatrix) {
|
|
765
|
-
// Matrix match, forValues is an array
|
|
766
|
-
headingJson.forValues = [];
|
|
767
|
-
if (Array.isArray(heading.forValues)) {
|
|
768
|
-
if (heading.forValues.length >= 1) {
|
|
769
|
-
headingJson.forValues = Breakscape_1.Breakscape.unbreakscape(heading.forValues);
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
else {
|
|
774
|
-
// Standard match, forValues is a string
|
|
775
|
-
headingJson.forValues = '';
|
|
776
|
-
if (Array.isArray(heading.forValues)) {
|
|
777
|
-
if (heading.forValues.length >= 1) {
|
|
778
|
-
headingJson.forValues = Breakscape_1.Breakscape.unbreakscape(heading.forValues[heading.forValues.length - 1]);
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
this.bitJson.heading = headingJson;
|
|
482
|
+
enter_heading(node, route) {
|
|
483
|
+
return this.standardHandler(node, route, undefined, { array: false });
|
|
783
484
|
}
|
|
784
485
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> pairs
|
|
785
486
|
enter_pairs(node, route) {
|
|
786
|
-
|
|
787
|
-
const pairs = node.value;
|
|
788
|
-
const pairsJson = [];
|
|
789
|
-
const bitType = this.getBitType(route);
|
|
790
|
-
if (pairs && bitType) {
|
|
791
|
-
for (const p of pairs) {
|
|
792
|
-
// Get default example
|
|
793
|
-
const defaultExample = Array.isArray(p.values) && p.values.length > 0 && p.values[0];
|
|
794
|
-
// Create the question
|
|
795
|
-
const pairJson = Object.assign(Object.assign(Object.assign({ key: (_a = Breakscape_1.Breakscape.unbreakscape(p.key)) !== null && _a !== void 0 ? _a : '', keyAudio: p.keyAudio ? this.addAudioResource(bitType, p.keyAudio) : undefined, keyImage: p.keyImage ? this.addImageResource(bitType, p.keyImage) : undefined, values: (_b = Breakscape_1.Breakscape.unbreakscape(p.values)) !== null && _b !== void 0 ? _b : [] }, this.toItemLeadHintInstruction(p)), { isCaseSensitive: (_c = p.isCaseSensitive) !== null && _c !== void 0 ? _c : true }), this.toExample(p, {
|
|
796
|
-
defaultExample,
|
|
797
|
-
isBoolean: false,
|
|
798
|
-
}));
|
|
799
|
-
// Delete unwanted properties
|
|
800
|
-
if (((_d = p.itemLead) === null || _d === void 0 ? void 0 : _d.lead) == null)
|
|
801
|
-
delete pairJson.lead;
|
|
802
|
-
if (pairJson.key) {
|
|
803
|
-
delete pairJson.keyAudio;
|
|
804
|
-
delete pairJson.keyImage;
|
|
805
|
-
}
|
|
806
|
-
if (pairJson.keyAudio != null) {
|
|
807
|
-
delete pairJson.key;
|
|
808
|
-
delete pairJson.keyImage;
|
|
809
|
-
}
|
|
810
|
-
if (pairJson.keyImage != null) {
|
|
811
|
-
delete pairJson.key;
|
|
812
|
-
delete pairJson.keyAudio;
|
|
813
|
-
}
|
|
814
|
-
pairsJson.push(pairJson);
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
if (pairsJson.length > 0) {
|
|
818
|
-
this.bitJson.pairs = pairsJson;
|
|
819
|
-
}
|
|
487
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.cardNode, { array: true });
|
|
820
488
|
}
|
|
821
489
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> matrix
|
|
822
|
-
enter_matrix(node,
|
|
823
|
-
|
|
824
|
-
const matrix = node.value;
|
|
825
|
-
const matrixJsonArray = [];
|
|
826
|
-
if (matrix) {
|
|
827
|
-
for (const m of matrix) {
|
|
828
|
-
// Choices
|
|
829
|
-
const matrixCellsJson = [];
|
|
830
|
-
if (m.cells) {
|
|
831
|
-
for (const c of m.cells) {
|
|
832
|
-
// Get default example
|
|
833
|
-
const defaultExample = Array.isArray(c.values) && c.values.length > 0 && c.values[0];
|
|
834
|
-
// Create the choice
|
|
835
|
-
const matrixCellJson = Object.assign(Object.assign(Object.assign({ values: (_a = Breakscape_1.Breakscape.unbreakscape(c.values)) !== null && _a !== void 0 ? _a : [] }, this.toItemLeadHintInstruction(c)), { isCaseSensitive: (_b = c.isCaseSensitive) !== null && _b !== void 0 ? _b : true }), this.toExample(c, {
|
|
836
|
-
defaultExample,
|
|
837
|
-
isBoolean: false,
|
|
838
|
-
}));
|
|
839
|
-
// Delete unwanted properties
|
|
840
|
-
if (((_c = c.itemLead) === null || _c === void 0 ? void 0 : _c.lead) == null)
|
|
841
|
-
delete matrixCellJson.lead;
|
|
842
|
-
if (c.hint == null)
|
|
843
|
-
delete matrixCellJson.hint;
|
|
844
|
-
matrixCellsJson.push(matrixCellJson);
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
// Create the matrix
|
|
848
|
-
const matrixJson = Object.assign(Object.assign({ key: (_d = Breakscape_1.Breakscape.unbreakscape(m.key)) !== null && _d !== void 0 ? _d : '', cells: matrixCellsJson !== null && matrixCellsJson !== void 0 ? matrixCellsJson : [] }, this.toItemLeadHintInstruction(m)), {
|
|
849
|
-
// ...this.toExample(m.example, m.isExample),
|
|
850
|
-
isExample: (_e = m.isExample) !== null && _e !== void 0 ? _e : false });
|
|
851
|
-
// Delete unwanted properties
|
|
852
|
-
if (((_f = m.itemLead) === null || _f === void 0 ? void 0 : _f.lead) == null)
|
|
853
|
-
delete matrixJson.lead;
|
|
854
|
-
if (m.instruction == null)
|
|
855
|
-
delete matrixJson.instruction;
|
|
856
|
-
matrixJsonArray.push(matrixJson);
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
if (matrixJsonArray.length > 0) {
|
|
860
|
-
this.bitJson.matrix = matrixJsonArray;
|
|
861
|
-
}
|
|
490
|
+
enter_matrix(node, route) {
|
|
491
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.cardNode, { array: true });
|
|
862
492
|
}
|
|
863
493
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> table
|
|
864
|
-
enter_table(node,
|
|
865
|
-
|
|
866
|
-
// const bitType = this.getBitType(route);
|
|
867
|
-
if (table) {
|
|
868
|
-
const tableJson = {
|
|
869
|
-
columns: Breakscape_1.Breakscape.unbreakscape(table.columns),
|
|
870
|
-
data: table.rows.map((row) => Breakscape_1.Breakscape.unbreakscape(row)),
|
|
871
|
-
};
|
|
872
|
-
// const isEmpty = !table.columns || table.columns.length === 0 || !table.rows || table.rows.length === 0;
|
|
873
|
-
this.bitJson.table = tableJson;
|
|
874
|
-
}
|
|
875
|
-
// Stop traversal of this branch to avoid unnecessary processing
|
|
876
|
-
return false;
|
|
494
|
+
enter_table(node, route) {
|
|
495
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.cardNode, { array: false });
|
|
877
496
|
}
|
|
878
497
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> questions
|
|
879
|
-
enter_questions(node,
|
|
880
|
-
|
|
881
|
-
const questions = node.value;
|
|
882
|
-
const questionsJson = [];
|
|
883
|
-
if (questions) {
|
|
884
|
-
for (const q of questions) {
|
|
885
|
-
// Create the question
|
|
886
|
-
const questionJson = Object.assign(Object.assign(Object.assign({ question: (_a = Breakscape_1.Breakscape.unbreakscape(q.question)) !== null && _a !== void 0 ? _a : '', partialAnswer: (_b = Breakscape_1.Breakscape.unbreakscape(ArrayUtils_1.ArrayUtils.asSingle(q.partialAnswer))) !== null && _b !== void 0 ? _b : '', sampleSolution: (_c = Breakscape_1.Breakscape.unbreakscape(ArrayUtils_1.ArrayUtils.asSingle(q.sampleSolution))) !== null && _c !== void 0 ? _c : '', additionalSolutions: (_d = Breakscape_1.Breakscape.unbreakscape(q.additionalSolutions)) !== null && _d !== void 0 ? _d : [] }, this.toItemLeadHintInstruction(q)), { reasonableNumOfChars: q.reasonableNumOfChars }), this.toExample(q, {
|
|
887
|
-
defaultExample: q.sampleSolution || '',
|
|
888
|
-
isBoolean: false,
|
|
889
|
-
}));
|
|
890
|
-
// Delete unwanted properties
|
|
891
|
-
if (((_e = q.itemLead) === null || _e === void 0 ? void 0 : _e.lead) == null)
|
|
892
|
-
delete questionJson.lead;
|
|
893
|
-
if (q.additionalSolutions == null || q.additionalSolutions.length === 0) {
|
|
894
|
-
delete questionJson.additionalSolutions;
|
|
895
|
-
}
|
|
896
|
-
questionsJson.push(questionJson);
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
if (questionsJson.length > 0) {
|
|
900
|
-
this.bitJson.questions = questionsJson;
|
|
901
|
-
}
|
|
498
|
+
enter_questions(node, route) {
|
|
499
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.cardNode, { array: true });
|
|
902
500
|
}
|
|
903
501
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> botResponses
|
|
904
502
|
enter_botResponses(node, route) {
|
|
905
|
-
|
|
906
|
-
const botResponses = node.value;
|
|
907
|
-
// Ignore responses that are not at the cardNode level as they are handled elsewhere
|
|
908
|
-
const parent = this.getParentNode(route);
|
|
909
|
-
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.cardNode)
|
|
910
|
-
return;
|
|
911
|
-
const responsesJson = [];
|
|
912
|
-
if (botResponses) {
|
|
913
|
-
for (const r of botResponses) {
|
|
914
|
-
// Create the response
|
|
915
|
-
const responseJson = Object.assign({ response: (_a = Breakscape_1.Breakscape.unbreakscape(r.response)) !== null && _a !== void 0 ? _a : '', reaction: (_b = Breakscape_1.Breakscape.unbreakscape(r.reaction)) !== null && _b !== void 0 ? _b : '', feedback: (_c = Breakscape_1.Breakscape.unbreakscape(r.feedback)) !== null && _c !== void 0 ? _c : '' }, this.toItemLeadHintInstruction(r));
|
|
916
|
-
// Delete unwanted properties
|
|
917
|
-
if (((_d = r.itemLead) === null || _d === void 0 ? void 0 : _d.lead) == null)
|
|
918
|
-
delete responseJson.lead;
|
|
919
|
-
if (r.hint == null)
|
|
920
|
-
delete responseJson.hint;
|
|
921
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
922
|
-
delete responseJson.instruction;
|
|
923
|
-
responsesJson.push(responseJson);
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
if (responsesJson.length > 0) {
|
|
927
|
-
this.bitJson.responses = responsesJson;
|
|
928
|
-
}
|
|
503
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.cardNode, { array: true, keyOverride: 'responses' });
|
|
929
504
|
}
|
|
930
505
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> ingredients -> ingredientsValue
|
|
931
506
|
enter_ingredients(node, route) {
|
|
932
|
-
|
|
933
|
-
const ingredients = node.value;
|
|
934
|
-
// Ignore statements that are not at the card node level as they are handled elsewhere
|
|
935
|
-
const parent = this.getParentNode(route);
|
|
936
|
-
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.cardNode)
|
|
937
|
-
return;
|
|
938
|
-
const ingredientsJson = [];
|
|
939
|
-
if (ingredients) {
|
|
940
|
-
for (const i of ingredients) {
|
|
941
|
-
// Create the ingredient
|
|
942
|
-
const ingredientJson = {
|
|
943
|
-
title: (_a = Breakscape_1.Breakscape.unbreakscape(i.title)) !== null && _a !== void 0 ? _a : '',
|
|
944
|
-
checked: (_b = i.checked) !== null && _b !== void 0 ? _b : false,
|
|
945
|
-
item: (_c = Breakscape_1.Breakscape.unbreakscape(i.item)) !== null && _c !== void 0 ? _c : '',
|
|
946
|
-
quantity: (_d = i.quantity) !== null && _d !== void 0 ? _d : 0,
|
|
947
|
-
unit: (_e = Breakscape_1.Breakscape.unbreakscape(i.unit)) !== null && _e !== void 0 ? _e : '',
|
|
948
|
-
unitAbbr: (_f = Breakscape_1.Breakscape.unbreakscape(i.unitAbbr)) !== null && _f !== void 0 ? _f : '',
|
|
949
|
-
decimalPlaces: (_g = i.decimalPlaces) !== null && _g !== void 0 ? _g : 1,
|
|
950
|
-
disableCalculation: (_h = i.disableCalculation) !== null && _h !== void 0 ? _h : false,
|
|
951
|
-
};
|
|
952
|
-
// Delete unwanted properties
|
|
953
|
-
if ((i === null || i === void 0 ? void 0 : i.title) == null)
|
|
954
|
-
delete ingredientJson.title;
|
|
955
|
-
// if (i?.unit == null) delete ingredientJson.unit;
|
|
956
|
-
if ((i === null || i === void 0 ? void 0 : i.unitAbbr) == null)
|
|
957
|
-
delete ingredientJson.unitAbbr;
|
|
958
|
-
// if (i?.instruction == null) delete ingredientJson.instruction;
|
|
959
|
-
ingredientsJson.push(ingredientJson);
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
if (ingredientsJson.length > 0) {
|
|
963
|
-
this.bitJson.ingredients = ingredientsJson;
|
|
964
|
-
}
|
|
507
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.cardNode, { array: true });
|
|
965
508
|
}
|
|
966
509
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> captionDefinitionList
|
|
967
|
-
enter_captionDefinitionList(node,
|
|
968
|
-
|
|
969
|
-
const list = node.value;
|
|
970
|
-
// const bitType = this.getBitType(route);
|
|
971
|
-
if (list) {
|
|
972
|
-
const columns = (_a = list.columns) !== null && _a !== void 0 ? _a : [];
|
|
973
|
-
const definitions = (_b = list.definitions) !== null && _b !== void 0 ? _b : [];
|
|
974
|
-
const captionDefinitionListJson = {
|
|
975
|
-
columns: Breakscape_1.Breakscape.unbreakscape(columns),
|
|
976
|
-
definitions: definitions.map((d) => {
|
|
977
|
-
var _a, _b;
|
|
978
|
-
return {
|
|
979
|
-
term: (_a = Breakscape_1.Breakscape.unbreakscape(d.term)) !== null && _a !== void 0 ? _a : '',
|
|
980
|
-
description: (_b = Breakscape_1.Breakscape.unbreakscape(d.description)) !== null && _b !== void 0 ? _b : '',
|
|
981
|
-
};
|
|
982
|
-
}),
|
|
983
|
-
};
|
|
984
|
-
// const isEmpty = !table.columns || table.columns.length === 0 || !table.rows || table.rows.length === 0;
|
|
985
|
-
this.bitJson.captionDefinitionList = captionDefinitionListJson;
|
|
986
|
-
}
|
|
987
|
-
// Stop traversal of this branch to avoid unnecessary processing
|
|
988
|
-
return false;
|
|
510
|
+
enter_captionDefinitionList(node, route) {
|
|
511
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.cardNode, { array: false });
|
|
989
512
|
}
|
|
990
513
|
// bitmarkAst -> bits -> bitsValue -> imagePlaceholder
|
|
991
514
|
enter_imagePlaceholder(node, route) {
|
|
992
|
-
|
|
993
|
-
const parent = this.getParentNode(route);
|
|
994
|
-
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.bitsValue)
|
|
995
|
-
return;
|
|
996
|
-
const resource = node.value;
|
|
997
|
-
const bitType = this.getBitType(route);
|
|
998
|
-
if (!resource || !bitType)
|
|
999
|
-
return;
|
|
1000
|
-
const res = this.parseResourceToJson(bitType, resource);
|
|
1001
|
-
if (res && res.type === ResourceTag_1.ResourceTag.image) {
|
|
1002
|
-
this.bitJson.imagePlaceholder = res;
|
|
1003
|
-
}
|
|
515
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.bitsValue, { array: false });
|
|
1004
516
|
}
|
|
1005
517
|
// bitmarkAst -> bits -> bitsValue -> resources
|
|
1006
518
|
enter_resources(node, route) {
|
|
1007
|
-
var _a;
|
|
519
|
+
var _a, _b;
|
|
1008
520
|
const resources = node.value;
|
|
1009
521
|
const bitType = this.getBitType(route);
|
|
1010
522
|
const resourceType = this.getResourceType(route);
|
|
1011
523
|
if (!resources || !bitType)
|
|
1012
|
-
return;
|
|
524
|
+
return true;
|
|
1013
525
|
let resourceJson;
|
|
1014
526
|
const bitConfig = Config_1.Config.getBitConfig(bitType);
|
|
1015
527
|
const bitResourcesConfig = Config_1.Config.getBitResourcesConfig(bitType, resourceType);
|
|
@@ -1023,15 +535,17 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1023
535
|
// Create the combo resource wrapper
|
|
1024
536
|
const wrapper = {
|
|
1025
537
|
type: comboTagType,
|
|
538
|
+
__typeAlias: comboTagType,
|
|
1026
539
|
};
|
|
1027
540
|
// For each of the resources in this combo resource, find the actual resource and add it to the JSON
|
|
1028
541
|
for (const rt of resourceTags) {
|
|
1029
|
-
const r = resources.find((r) => r.
|
|
542
|
+
const r = resources.find((r) => r.__typeAlias === rt);
|
|
1030
543
|
// Extract everything except the type from the resource
|
|
1031
544
|
if (r) {
|
|
1032
|
-
const tagConfig = Config_1.Config.getTagConfigForTag(bitConfig.tags, r.
|
|
1033
|
-
const key = (_a = tagConfig === null || tagConfig === void 0 ? void 0 : tagConfig.jsonKey) !== null && _a !== void 0 ? _a : r.
|
|
1034
|
-
const
|
|
545
|
+
const tagConfig = Config_1.Config.getTagConfigForTag(bitConfig.tags, r.__typeAlias);
|
|
546
|
+
const key = (_a = tagConfig === null || tagConfig === void 0 ? void 0 : tagConfig.jsonKey) !== null && _a !== void 0 ? _a : r.__typeAlias;
|
|
547
|
+
const tag = (_b = tagConfig === null || tagConfig === void 0 ? void 0 : tagConfig.tag) !== null && _b !== void 0 ? _b : r.__typeAlias;
|
|
548
|
+
const json = r.__typeAlias === tag ? r : undefined;
|
|
1035
549
|
if (json) {
|
|
1036
550
|
for (const [k, v] of Object.entries(json)) {
|
|
1037
551
|
if (k !== 'type') {
|
|
@@ -1049,9 +563,8 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1049
563
|
// The resource is a logo-grave / prototpye-images resource
|
|
1050
564
|
const images = [];
|
|
1051
565
|
for (const r of resources) {
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
images.push(json);
|
|
566
|
+
if (r.type === ResourceTag_1.ResourceTag.image) {
|
|
567
|
+
images.push(r);
|
|
1055
568
|
}
|
|
1056
569
|
}
|
|
1057
570
|
if (bitType === BitType_1.BitType.imagesLogoGrave) {
|
|
@@ -1065,93 +578,49 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1065
578
|
// This is a standard resource. If there is more than one resource, use the first one.
|
|
1066
579
|
// There should not be more than one because of validation
|
|
1067
580
|
if (resources.length >= 1) {
|
|
1068
|
-
resourceJson = this.parseResourceToJson(bitType, resources[0]);
|
|
581
|
+
resourceJson = resources[0]; // this.parseResourceToJson(bitType, resources[0]);
|
|
1069
582
|
}
|
|
1070
583
|
}
|
|
1071
584
|
this.bitJson.resource = resourceJson;
|
|
585
|
+
return false;
|
|
1072
586
|
}
|
|
1073
587
|
//
|
|
1074
588
|
// Terminal nodes (leaves)
|
|
1075
589
|
//
|
|
1076
|
-
//
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
const parent = this.getParentNode(route);
|
|
1080
|
-
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.bitsValue && (parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.cardNode)
|
|
1081
|
-
return;
|
|
1082
|
-
this.bitJson.title = this.convertBreakscapedStringToJsonText(node.value, TextFormat_1.TextFormat.bitmarkMinusMinus);
|
|
1083
|
-
}
|
|
1084
|
-
// bitmarkAst -> bits -> bitsValue -> subtitle
|
|
1085
|
-
leaf_subtitle(node, _route) {
|
|
1086
|
-
this.bitJson.subtitle = this.convertBreakscapedStringToJsonText(node.value, TextFormat_1.TextFormat.bitmarkMinusMinus);
|
|
1087
|
-
}
|
|
1088
|
-
// // bitmarkAst -> bits -> bitsValue -> level
|
|
1089
|
-
leaf_level(node, _route) {
|
|
1090
|
-
var _a;
|
|
1091
|
-
if (node.value != null)
|
|
1092
|
-
this.addProperty(this.bitJson, 'level', (_a = node.value) !== null && _a !== void 0 ? _a : 1, true);
|
|
590
|
+
// bitmarkAst -> bits -> bitsValue -> level
|
|
591
|
+
leaf_level(node, route) {
|
|
592
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.bitsValue, { array: false });
|
|
1093
593
|
}
|
|
1094
594
|
// bitmarkAst -> bits -> bitsValue -> book
|
|
1095
|
-
leaf_book(node,
|
|
1096
|
-
|
|
1097
|
-
this.addProperty(this.bitJson, 'book', node.value, true);
|
|
595
|
+
leaf_book(node, route) {
|
|
596
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.bitsValue, { array: false });
|
|
1098
597
|
}
|
|
1099
598
|
// bitmarkAst -> bits -> bitsValue -> anchor
|
|
1100
|
-
leaf_anchor(node,
|
|
1101
|
-
|
|
1102
|
-
this.addProperty(this.bitJson, 'anchor', node.value, true);
|
|
599
|
+
leaf_anchor(node, route) {
|
|
600
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.bitsValue, { array: false });
|
|
1103
601
|
}
|
|
1104
602
|
// bitmarkAst -> bits -> bitsValue -> reference
|
|
1105
|
-
leaf_reference(node,
|
|
1106
|
-
|
|
1107
|
-
this.addProperty(this.bitJson, 'reference', node.value, true);
|
|
603
|
+
leaf_reference(node, route) {
|
|
604
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.bitsValue, { array: false });
|
|
1108
605
|
}
|
|
1109
606
|
// bitmarkAst -> bits -> bitsValue -> referenceEnd
|
|
1110
|
-
leaf_referenceEnd(node,
|
|
1111
|
-
|
|
1112
|
-
this.addProperty(this.bitJson, 'referenceEnd', node.value, true);
|
|
1113
|
-
}
|
|
1114
|
-
// bitmarkAst -> bits -> bitsValue -> caption
|
|
1115
|
-
leaf_caption(node, route) {
|
|
1116
|
-
const caption = node.value;
|
|
1117
|
-
// Ignore caption that is not at the bit level as it are handled elsewhere
|
|
1118
|
-
const parent = this.getParentNode(route);
|
|
1119
|
-
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.bitsValue)
|
|
1120
|
-
return;
|
|
1121
|
-
this.bitJson.caption = this.convertBreakscapedStringToJsonText(caption, TextFormat_1.TextFormat.bitmarkMinusMinus);
|
|
1122
|
-
}
|
|
1123
|
-
// bitmarkAst -> bits -> bitsValue -> * -> hint
|
|
1124
|
-
leaf_hint(node, route) {
|
|
1125
|
-
const hint = node.value;
|
|
1126
|
-
// Ignore hint that is not at the bit level as it are handled elsewhere
|
|
1127
|
-
const parent = this.getParentNode(route);
|
|
1128
|
-
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.bitsValue)
|
|
1129
|
-
return;
|
|
1130
|
-
this.bitJson.hint = this.convertBreakscapedStringToJsonText(hint, TextFormat_1.TextFormat.bitmarkMinusMinus);
|
|
1131
|
-
}
|
|
1132
|
-
// bitmarkAst -> bits -> bitsValue -> * -> instruction
|
|
1133
|
-
leaf_instruction(node, route) {
|
|
1134
|
-
const instruction = node.value;
|
|
1135
|
-
// Ignore instruction that is not at the bit level as it are handled elsewhere
|
|
1136
|
-
const parent = this.getParentNode(route);
|
|
1137
|
-
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.bitsValue)
|
|
1138
|
-
return;
|
|
1139
|
-
this.bitJson.instruction = this.convertBreakscapedStringToJsonText(instruction, TextFormat_1.TextFormat.bitmarkMinusMinus);
|
|
1140
|
-
}
|
|
1141
|
-
// bitmarkAst -> bits -> footer -> footerText
|
|
1142
|
-
leaf_footerText(node, route) {
|
|
1143
|
-
const footer = node.value;
|
|
1144
|
-
const textFormat = this.getTextFormat(route);
|
|
1145
|
-
this.bitJson.footer = this.convertBreakscapedStringToJsonText(footer, textFormat);
|
|
607
|
+
leaf_referenceEnd(node, route) {
|
|
608
|
+
return this.standardHandler(node, route, NodeType_1.NodeType.bitsValue, { array: false });
|
|
1146
609
|
}
|
|
1147
610
|
// bitmarkAst -> bits -> bitsValue -> markup
|
|
1148
611
|
leaf_markup(node, _route) {
|
|
1149
612
|
const bitmark = node.value;
|
|
1150
613
|
if (bitmark)
|
|
1151
614
|
this.bitWrapperJson.bitmark = bitmark;
|
|
615
|
+
// Stop traversal of this branch
|
|
616
|
+
return false;
|
|
1152
617
|
}
|
|
1153
|
-
// bitmarkAst -> bits -> bitsValue -> parser
|
|
1154
618
|
// bitmarkAst -> bits -> bitsValue -> * -> internalComment
|
|
619
|
+
enter_internalComment(_node, _route) {
|
|
620
|
+
// Stop traversal of this branch, handled in enter_parser()
|
|
621
|
+
return false;
|
|
622
|
+
}
|
|
623
|
+
// bitmarkAst -> bits -> bitsValue -> parser
|
|
1155
624
|
enter_parser(node, route) {
|
|
1156
625
|
const parser = node.value;
|
|
1157
626
|
const bitType = this.getBitType(route);
|
|
@@ -1165,13 +634,11 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1165
634
|
if (Array.isArray(parserExcessResources) && parserExcessResources.length > 0) {
|
|
1166
635
|
excessResources = [];
|
|
1167
636
|
for (const r of parserExcessResources) {
|
|
1168
|
-
|
|
1169
|
-
if (rJson)
|
|
1170
|
-
excessResources.push(rJson);
|
|
637
|
+
excessResources.push(r);
|
|
1171
638
|
}
|
|
1172
639
|
}
|
|
1173
640
|
// Extract internal comments from the AST and add to the parser
|
|
1174
|
-
const internalComments =
|
|
641
|
+
const internalComments = this.getInternalComments(route);
|
|
1175
642
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) === NodeType_1.NodeType.bitsValue) {
|
|
1176
643
|
// Bit level parser information
|
|
1177
644
|
this.bitWrapperJson.parser = Object.assign(Object.assign({ version,
|
|
@@ -1217,32 +684,12 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1217
684
|
const propertiesConfig = Config_1.Config.getRawPropertiesConfig();
|
|
1218
685
|
for (const propertyConfig of Object.values(propertiesConfig)) {
|
|
1219
686
|
const astKey = (_a = propertyConfig.astKey) !== null && _a !== void 0 ? _a : propertyConfig.tag;
|
|
1220
|
-
// Special cases (handled outside of the automatically generated handlers)
|
|
1221
|
-
if (astKey === PropertyTag_1.PropertyTag.internalComment)
|
|
1222
|
-
continue;
|
|
1223
|
-
if (astKey === PropertyTag_1.PropertyTag.caption)
|
|
1224
|
-
continue;
|
|
1225
|
-
if (astKey === PropertyTag_1.PropertyTag.example)
|
|
1226
|
-
continue;
|
|
1227
|
-
if (astKey === PropertyTag_1.PropertyTag.imageSource)
|
|
1228
|
-
continue;
|
|
1229
|
-
if (astKey === PropertyTag_1.PropertyTag.person)
|
|
1230
|
-
continue;
|
|
1231
|
-
if (astKey === PropertyTag_1.PropertyTag.imagePlaceholder)
|
|
1232
|
-
continue;
|
|
1233
|
-
if (astKey === PropertyTag_1.PropertyTag.width)
|
|
1234
|
-
continue;
|
|
1235
|
-
if (astKey === PropertyTag_1.PropertyTag.height)
|
|
1236
|
-
continue;
|
|
1237
|
-
if (astKey === PropertyAstKey_1.PropertyAstKey.ast_markConfig)
|
|
1238
|
-
continue;
|
|
1239
|
-
if (astKey === PropertyTag_1.PropertyTag.ratingLevelStart)
|
|
1240
|
-
continue;
|
|
1241
|
-
if (astKey === PropertyTag_1.PropertyTag.ratingLevelEnd)
|
|
1242
|
-
continue;
|
|
1243
|
-
if (astKey === PropertyTag_1.PropertyTag.productId)
|
|
1244
|
-
continue;
|
|
1245
687
|
const funcName = `enter_${astKey}`;
|
|
688
|
+
// Skip if the function already exists, allows for custom handlers
|
|
689
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
690
|
+
if (typeof this[funcName] === 'function') {
|
|
691
|
+
continue;
|
|
692
|
+
}
|
|
1246
693
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1247
694
|
this[funcName] = (node, route) => {
|
|
1248
695
|
var _a;
|
|
@@ -1257,7 +704,7 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1257
704
|
// Convert key as needed
|
|
1258
705
|
const jsonKey = (_a = propertyConfig.jsonKey) !== null && _a !== void 0 ? _a : propertyConfig.tag;
|
|
1259
706
|
// Add the property
|
|
1260
|
-
this.addProperty(this.bitJson, jsonKey, value, propertyConfig.single);
|
|
707
|
+
this.addProperty(this.bitJson, jsonKey, value, { array: !propertyConfig.single });
|
|
1261
708
|
};
|
|
1262
709
|
// Bind this
|
|
1263
710
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1268,605 +715,51 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1268
715
|
//
|
|
1269
716
|
// HELPER FUNCTIONS
|
|
1270
717
|
//
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
// Remove unwanted properties
|
|
1281
|
-
// if (!data.itemLead?.lead) delete gapJson.lead;
|
|
1282
|
-
return gapJson;
|
|
1283
|
-
}
|
|
1284
|
-
createMarkJson(mark) {
|
|
1285
|
-
const data = mark.data;
|
|
1286
|
-
// Create the mark
|
|
1287
|
-
const markJson = Object.assign(Object.assign({ type: 'mark', solution: Breakscape_1.Breakscape.unbreakscape(data.solution), mark: Breakscape_1.Breakscape.unbreakscape(data.mark) }, this.toItemLeadHintInstruction(data)), this.toExample(data, {
|
|
1288
|
-
defaultExample: true,
|
|
1289
|
-
isBoolean: true,
|
|
1290
|
-
}));
|
|
1291
|
-
// Remove unwanted properties
|
|
1292
|
-
// if (!data.itemLead?.lead) delete markJson.lead;
|
|
1293
|
-
return markJson;
|
|
1294
|
-
}
|
|
1295
|
-
createSelectJson(select) {
|
|
1296
|
-
var _a, _b, _c, _d;
|
|
1297
|
-
const data = select.data;
|
|
1298
|
-
// Create the select options
|
|
1299
|
-
const options = [];
|
|
1300
|
-
for (const option of data.options) {
|
|
1301
|
-
const optionJson = Object.assign(Object.assign({ text: Breakscape_1.Breakscape.unbreakscape(option.text), isCorrect: (_a = option.isCorrect) !== null && _a !== void 0 ? _a : false }, this.toItemLeadHintInstruction(option)), this.toExample(option, {
|
|
1302
|
-
defaultExample: !!option.isCorrect,
|
|
1303
|
-
isBoolean: true,
|
|
1304
|
-
}));
|
|
1305
|
-
// Remove unwanted properties
|
|
1306
|
-
// if (!option.itemLead?.item) delete optionJson.item;
|
|
1307
|
-
// if (!option.itemLead?.lead) delete optionJson.lead;
|
|
1308
|
-
// if (!option.instruction) delete optionJson.instruction;
|
|
1309
|
-
options.push(optionJson);
|
|
1310
|
-
}
|
|
1311
|
-
// Create the select
|
|
1312
|
-
const selectJson = Object.assign(Object.assign({ type: 'select', prefix: (_b = Breakscape_1.Breakscape.unbreakscape(data.prefix)) !== null && _b !== void 0 ? _b : '', postfix: (_c = Breakscape_1.Breakscape.unbreakscape(data.postfix)) !== null && _c !== void 0 ? _c : '' }, this.toItemLeadHintInstruction(data)), { isExample: (_d = data.isExample) !== null && _d !== void 0 ? _d : false, options });
|
|
1313
|
-
// Remove unwanted properties
|
|
1314
|
-
// if (!data.itemLead?.lead) delete selectJson.lead;
|
|
1315
|
-
return selectJson;
|
|
1316
|
-
}
|
|
1317
|
-
createHighlightJson(highlight) {
|
|
1318
|
-
var _a, _b, _c, _d, _e;
|
|
1319
|
-
const data = highlight.data;
|
|
1320
|
-
// Create the highlight options
|
|
1321
|
-
const texts = [];
|
|
1322
|
-
for (const text of data.texts) {
|
|
1323
|
-
const textJson = Object.assign(Object.assign({ text: Breakscape_1.Breakscape.unbreakscape(text.text), isCorrect: (_a = text.isCorrect) !== null && _a !== void 0 ? _a : false, isHighlighted: (_b = text.isHighlighted) !== null && _b !== void 0 ? _b : false }, this.toItemLeadHintInstruction(text)), this.toExample(text, {
|
|
1324
|
-
defaultExample: !!text.isCorrect,
|
|
1325
|
-
isBoolean: true,
|
|
1326
|
-
}));
|
|
1327
|
-
// Remove unwanted properties
|
|
1328
|
-
// if (!text.itemLead?.item) delete textJson.item;
|
|
1329
|
-
// if (!text.itemLead?.lead) delete textJson.lead;
|
|
1330
|
-
// if (!text.hint) delete textJson.hint;
|
|
1331
|
-
texts.push(textJson);
|
|
1332
|
-
}
|
|
1333
|
-
// Create the select
|
|
1334
|
-
const highlightJson = Object.assign(Object.assign({ type: 'highlight', prefix: (_c = Breakscape_1.Breakscape.unbreakscape(data.prefix)) !== null && _c !== void 0 ? _c : '', postfix: (_d = Breakscape_1.Breakscape.unbreakscape(data.postfix)) !== null && _d !== void 0 ? _d : '' }, this.toItemLeadHintInstruction(data)), { isExample: (_e = data.isExample) !== null && _e !== void 0 ? _e : false, texts });
|
|
1335
|
-
// Remove unwanted properties
|
|
1336
|
-
// if (!data.itemLead?.lead) delete highlightJson.lead;
|
|
1337
|
-
return highlightJson;
|
|
1338
|
-
}
|
|
1339
|
-
parseResourceToJson(bitType, resource) {
|
|
1340
|
-
if (!resource)
|
|
1341
|
-
return undefined;
|
|
1342
|
-
// All resources should now be valid as they are validated in the AST
|
|
1343
|
-
// TODO: remove code below
|
|
1344
|
-
// // Check if a resource has a value, if not, we should not write it (or any of its chained properties)
|
|
1345
|
-
// let valid = false;
|
|
1346
|
-
// if (resource.value) {
|
|
1347
|
-
// valid = true;
|
|
1348
|
-
// }
|
|
1349
|
-
// // Resource is not valid, return undefined
|
|
1350
|
-
// if (!valid) return undefined;
|
|
1351
|
-
// // Resource is valid, write it.
|
|
1352
|
-
let resourceJson;
|
|
1353
|
-
switch (resource.type) {
|
|
1354
|
-
case ResourceTag_1.ResourceTag.image:
|
|
1355
|
-
resourceJson = {
|
|
1356
|
-
type: ResourceTag_1.ResourceTag.image,
|
|
1357
|
-
image: this.addImageResource(bitType, resource),
|
|
1358
|
-
};
|
|
1359
|
-
break;
|
|
1360
|
-
case ResourceTag_1.ResourceTag.imageLink:
|
|
1361
|
-
resourceJson = {
|
|
1362
|
-
type: ResourceTag_1.ResourceTag.imageLink,
|
|
1363
|
-
imageLink: this.addImageLinkResource(bitType, resource),
|
|
1364
|
-
};
|
|
1365
|
-
break;
|
|
1366
|
-
case ResourceTag_1.ResourceTag.audio:
|
|
1367
|
-
resourceJson = {
|
|
1368
|
-
type: ResourceTag_1.ResourceTag.audio,
|
|
1369
|
-
audio: this.addAudioResource(bitType, resource),
|
|
1370
|
-
};
|
|
1371
|
-
break;
|
|
1372
|
-
case ResourceTag_1.ResourceTag.audioEmbed:
|
|
1373
|
-
resourceJson = {
|
|
1374
|
-
type: ResourceTag_1.ResourceTag.audioEmbed,
|
|
1375
|
-
audioEmbed: this.addAudioEmbedResource(bitType, resource),
|
|
1376
|
-
};
|
|
1377
|
-
break;
|
|
1378
|
-
case ResourceTag_1.ResourceTag.audioLink:
|
|
1379
|
-
resourceJson = {
|
|
1380
|
-
type: ResourceTag_1.ResourceTag.audioLink,
|
|
1381
|
-
audioLink: this.addAudioLinkResource(bitType, resource),
|
|
1382
|
-
};
|
|
1383
|
-
break;
|
|
1384
|
-
case ResourceTag_1.ResourceTag.video:
|
|
1385
|
-
resourceJson = {
|
|
1386
|
-
type: ResourceTag_1.ResourceTag.video,
|
|
1387
|
-
video: this.addVideoResource(bitType, resource),
|
|
1388
|
-
};
|
|
1389
|
-
break;
|
|
1390
|
-
case ResourceTag_1.ResourceTag.videoEmbed:
|
|
1391
|
-
resourceJson = {
|
|
1392
|
-
type: ResourceTag_1.ResourceTag.videoEmbed,
|
|
1393
|
-
videoEmbed: this.addVideoEmbedResource(bitType, resource),
|
|
1394
|
-
};
|
|
1395
|
-
resourceJson.videoEmbed = this.addVideoLinkResource(bitType, resource);
|
|
1396
|
-
break;
|
|
1397
|
-
case ResourceTag_1.ResourceTag.videoLink:
|
|
1398
|
-
resourceJson = {
|
|
1399
|
-
type: ResourceTag_1.ResourceTag.videoLink,
|
|
1400
|
-
videoLink: this.addVideoLinkResource(bitType, resource),
|
|
1401
|
-
};
|
|
1402
|
-
break;
|
|
1403
|
-
case ResourceTag_1.ResourceTag.stillImageFilmEmbed:
|
|
1404
|
-
resourceJson = {
|
|
1405
|
-
type: ResourceTag_1.ResourceTag.stillImageFilmEmbed,
|
|
1406
|
-
stillImageFilmEmbed: this.addStillImageFilmEmbedResource(bitType, resource),
|
|
1407
|
-
};
|
|
1408
|
-
break;
|
|
1409
|
-
case ResourceTag_1.ResourceTag.stillImageFilmLink:
|
|
1410
|
-
resourceJson = {
|
|
1411
|
-
type: ResourceTag_1.ResourceTag.stillImageFilmLink,
|
|
1412
|
-
stillImageFilmLink: this.addStillImageFilmLinkResource(bitType, resource),
|
|
1413
|
-
};
|
|
1414
|
-
break;
|
|
1415
|
-
case ResourceTag_1.ResourceTag.article:
|
|
1416
|
-
resourceJson = {
|
|
1417
|
-
type: ResourceTag_1.ResourceTag.article,
|
|
1418
|
-
article: this.addArticleResource(bitType, resource),
|
|
1419
|
-
};
|
|
1420
|
-
break;
|
|
1421
|
-
case ResourceTag_1.ResourceTag.document:
|
|
1422
|
-
resourceJson = {
|
|
1423
|
-
type: ResourceTag_1.ResourceTag.document,
|
|
1424
|
-
document: this.addDocumentResource(bitType, resource),
|
|
1425
|
-
};
|
|
1426
|
-
break;
|
|
1427
|
-
case ResourceTag_1.ResourceTag.documentEmbed:
|
|
1428
|
-
resourceJson = {
|
|
1429
|
-
type: ResourceTag_1.ResourceTag.documentEmbed,
|
|
1430
|
-
documentEmbed: this.addDocumentEmbedResource(bitType, resource),
|
|
1431
|
-
};
|
|
1432
|
-
break;
|
|
1433
|
-
case ResourceTag_1.ResourceTag.documentLink:
|
|
1434
|
-
resourceJson = {
|
|
1435
|
-
type: ResourceTag_1.ResourceTag.documentLink,
|
|
1436
|
-
documentLink: this.addDocumentLinkResource(bitType, resource),
|
|
1437
|
-
};
|
|
1438
|
-
break;
|
|
1439
|
-
case ResourceTag_1.ResourceTag.documentDownload:
|
|
1440
|
-
resourceJson = {
|
|
1441
|
-
type: ResourceTag_1.ResourceTag.documentDownload,
|
|
1442
|
-
documentDownload: this.addDocumentDownloadResource(bitType, resource),
|
|
1443
|
-
};
|
|
1444
|
-
break;
|
|
1445
|
-
case ResourceTag_1.ResourceTag.appLink:
|
|
1446
|
-
resourceJson = {
|
|
1447
|
-
type: ResourceTag_1.ResourceTag.appLink,
|
|
1448
|
-
appLink: this.addAppLinkResource(bitType, resource),
|
|
1449
|
-
};
|
|
1450
|
-
break;
|
|
1451
|
-
case ResourceTag_1.ResourceTag.websiteLink:
|
|
1452
|
-
resourceJson = {
|
|
1453
|
-
type: ResourceTag_1.ResourceTag.websiteLink,
|
|
1454
|
-
websiteLink: this.addWebsiteLinkResource(bitType, resource),
|
|
1455
|
-
};
|
|
1456
|
-
break;
|
|
1457
|
-
default:
|
|
1458
|
-
}
|
|
1459
|
-
return resourceJson;
|
|
1460
|
-
}
|
|
1461
|
-
addImageResource(bitType, resource) {
|
|
1462
|
-
var _a, _b, _c;
|
|
1463
|
-
const resourceJson = {};
|
|
1464
|
-
if (StringUtils_1.StringUtils.isString(resource)) {
|
|
1465
|
-
const value = resource;
|
|
1466
|
-
resource = {
|
|
1467
|
-
type: ResourceTag_1.ResourceTag.image,
|
|
1468
|
-
typeAlias: ResourceTag_1.ResourceTag.image,
|
|
1469
|
-
value: value,
|
|
1470
|
-
format: UrlUtils_1.UrlUtils.fileExtensionFromUrl(value),
|
|
1471
|
-
provider: UrlUtils_1.UrlUtils.domainFromUrl(value),
|
|
1472
|
-
};
|
|
1473
|
-
}
|
|
1474
|
-
resource = resource; // Keep TS compiler happy
|
|
1475
|
-
if (resource.format != null)
|
|
1476
|
-
resourceJson.format = Breakscape_1.Breakscape.unbreakscape(resource.format);
|
|
1477
|
-
if (resource.provider != null)
|
|
1478
|
-
resourceJson.provider = Breakscape_1.Breakscape.unbreakscape(resource.provider);
|
|
1479
|
-
if (resource.value != null)
|
|
1480
|
-
resourceJson.src = Breakscape_1.Breakscape.unbreakscape(resource.value);
|
|
1481
|
-
if (resource.src1x != null)
|
|
1482
|
-
resourceJson.src1x = Breakscape_1.Breakscape.unbreakscape(resource.src1x);
|
|
1483
|
-
if (resource.src2x != null)
|
|
1484
|
-
resourceJson.src2x = Breakscape_1.Breakscape.unbreakscape(resource.src2x);
|
|
1485
|
-
if (resource.src3x != null)
|
|
1486
|
-
resourceJson.src3x = Breakscape_1.Breakscape.unbreakscape(resource.src3x);
|
|
1487
|
-
if (resource.src4x != null)
|
|
1488
|
-
resourceJson.src4x = Breakscape_1.Breakscape.unbreakscape(resource.src4x);
|
|
1489
|
-
resourceJson.width = (_a = resource.width) !== null && _a !== void 0 ? _a : null;
|
|
1490
|
-
resourceJson.height = (_b = resource.height) !== null && _b !== void 0 ? _b : null;
|
|
1491
|
-
resourceJson.alt = (_c = Breakscape_1.Breakscape.unbreakscape(resource.alt)) !== null && _c !== void 0 ? _c : '';
|
|
1492
|
-
resourceJson.zoomDisabled = this.getZoomDisabled(bitType, resource.zoomDisabled);
|
|
1493
|
-
this.addGenericResourceProperties(bitType, resource, resourceJson);
|
|
1494
|
-
return resourceJson;
|
|
1495
|
-
}
|
|
1496
|
-
addImageLinkResource(bitType, resource) {
|
|
1497
|
-
var _a, _b, _c;
|
|
1498
|
-
const resourceJson = {};
|
|
1499
|
-
if (StringUtils_1.StringUtils.isString(resource)) {
|
|
1500
|
-
const value = resource;
|
|
1501
|
-
resource = {
|
|
1502
|
-
type: ResourceTag_1.ResourceTag.imageLink,
|
|
1503
|
-
typeAlias: ResourceTag_1.ResourceTag.imageLink,
|
|
1504
|
-
value,
|
|
1505
|
-
format: UrlUtils_1.UrlUtils.fileExtensionFromUrl(value),
|
|
1506
|
-
provider: UrlUtils_1.UrlUtils.domainFromUrl(value),
|
|
1507
|
-
};
|
|
1508
|
-
}
|
|
1509
|
-
resource = resource; // Keep TS compiler happy
|
|
1510
|
-
if (resource.format != null)
|
|
1511
|
-
resourceJson.format = Breakscape_1.Breakscape.unbreakscape(resource.format);
|
|
1512
|
-
if (resource.provider != null)
|
|
1513
|
-
resourceJson.provider = Breakscape_1.Breakscape.unbreakscape(resource.provider);
|
|
1514
|
-
if (resource.value != null)
|
|
1515
|
-
resourceJson.url = Breakscape_1.Breakscape.unbreakscape(resource.value);
|
|
1516
|
-
if (resource.src1x != null)
|
|
1517
|
-
resourceJson.src1x = Breakscape_1.Breakscape.unbreakscape(resource.src1x);
|
|
1518
|
-
if (resource.src2x != null)
|
|
1519
|
-
resourceJson.src2x = Breakscape_1.Breakscape.unbreakscape(resource.src2x);
|
|
1520
|
-
if (resource.src3x != null)
|
|
1521
|
-
resourceJson.src3x = Breakscape_1.Breakscape.unbreakscape(resource.src3x);
|
|
1522
|
-
if (resource.src4x != null)
|
|
1523
|
-
resourceJson.src4x = Breakscape_1.Breakscape.unbreakscape(resource.src4x);
|
|
1524
|
-
resourceJson.width = (_a = resource.width) !== null && _a !== void 0 ? _a : null;
|
|
1525
|
-
resourceJson.height = (_b = resource.height) !== null && _b !== void 0 ? _b : null;
|
|
1526
|
-
resourceJson.alt = (_c = Breakscape_1.Breakscape.unbreakscape(resource.alt)) !== null && _c !== void 0 ? _c : '';
|
|
1527
|
-
resourceJson.zoomDisabled = this.getZoomDisabled(bitType, resource.zoomDisabled);
|
|
1528
|
-
this.addGenericResourceProperties(bitType, resource, resourceJson);
|
|
1529
|
-
return resourceJson;
|
|
1530
|
-
}
|
|
1531
|
-
addAudioResource(bitType, resource) {
|
|
1532
|
-
const resourceJson = {};
|
|
1533
|
-
if (resource.format != null)
|
|
1534
|
-
resourceJson.format = Breakscape_1.Breakscape.unbreakscape(resource.format);
|
|
1535
|
-
if (resource.provider != null)
|
|
1536
|
-
resourceJson.provider = Breakscape_1.Breakscape.unbreakscape(resource.provider);
|
|
1537
|
-
if (resource.value != null)
|
|
1538
|
-
resourceJson.src = Breakscape_1.Breakscape.unbreakscape(resource.value);
|
|
1539
|
-
if (resource.duration != null)
|
|
1540
|
-
resourceJson.duration = resource.duration;
|
|
1541
|
-
if (resource.mute != null)
|
|
1542
|
-
resourceJson.mute = resource.mute;
|
|
1543
|
-
if (resource.autoplay != null)
|
|
1544
|
-
resourceJson.autoplay = resource.autoplay;
|
|
1545
|
-
this.addGenericResourceProperties(bitType, resource, resourceJson);
|
|
1546
|
-
return resourceJson;
|
|
1547
|
-
}
|
|
1548
|
-
addAudioEmbedResource(bitType, resource) {
|
|
1549
|
-
const resourceJson = {};
|
|
1550
|
-
if (resource.format != null)
|
|
1551
|
-
resourceJson.format = Breakscape_1.Breakscape.unbreakscape(resource.format);
|
|
1552
|
-
if (resource.provider != null)
|
|
1553
|
-
resourceJson.provider = Breakscape_1.Breakscape.unbreakscape(resource.provider);
|
|
1554
|
-
if (resource.value != null)
|
|
1555
|
-
resourceJson.src = Breakscape_1.Breakscape.unbreakscape(resource.value);
|
|
1556
|
-
if (resource.duration != null)
|
|
1557
|
-
resourceJson.duration = resource.duration;
|
|
1558
|
-
if (resource.mute != null)
|
|
1559
|
-
resourceJson.mute = resource.mute;
|
|
1560
|
-
if (resource.autoplay != null)
|
|
1561
|
-
resourceJson.autoplay = resource.autoplay;
|
|
1562
|
-
this.addGenericResourceProperties(bitType, resource, resourceJson);
|
|
1563
|
-
return resourceJson;
|
|
1564
|
-
}
|
|
1565
|
-
addAudioLinkResource(bitType, resource) {
|
|
1566
|
-
const resourceJson = {};
|
|
1567
|
-
if (resource.format != null)
|
|
1568
|
-
resourceJson.format = Breakscape_1.Breakscape.unbreakscape(resource.format);
|
|
1569
|
-
if (resource.provider != null)
|
|
1570
|
-
resourceJson.provider = Breakscape_1.Breakscape.unbreakscape(resource.provider);
|
|
1571
|
-
if (resource.value != null)
|
|
1572
|
-
resourceJson.url = Breakscape_1.Breakscape.unbreakscape(resource.value);
|
|
1573
|
-
if (resource.duration != null)
|
|
1574
|
-
resourceJson.duration = resource.duration;
|
|
1575
|
-
if (resource.mute != null)
|
|
1576
|
-
resourceJson.mute = resource.mute;
|
|
1577
|
-
if (resource.autoplay != null)
|
|
1578
|
-
resourceJson.autoplay = resource.autoplay;
|
|
1579
|
-
this.addGenericResourceProperties(bitType, resource, resourceJson, true);
|
|
1580
|
-
return resourceJson;
|
|
1581
|
-
}
|
|
1582
|
-
addVideoResource(bitType, resource) {
|
|
1583
|
-
var _a, _b;
|
|
1584
|
-
const resourceJson = {};
|
|
1585
|
-
if (resource.format != null)
|
|
1586
|
-
resourceJson.format = Breakscape_1.Breakscape.unbreakscape(resource.format);
|
|
1587
|
-
if (resource.provider != null)
|
|
1588
|
-
resourceJson.provider = Breakscape_1.Breakscape.unbreakscape(resource.provider);
|
|
1589
|
-
if (resource.value != null)
|
|
1590
|
-
resourceJson.src = Breakscape_1.Breakscape.unbreakscape(resource.value);
|
|
1591
|
-
resourceJson.width = (_a = resource.width) !== null && _a !== void 0 ? _a : null;
|
|
1592
|
-
resourceJson.height = (_b = resource.height) !== null && _b !== void 0 ? _b : null;
|
|
1593
|
-
if (resource.duration != null)
|
|
1594
|
-
resourceJson.duration = resource.duration;
|
|
1595
|
-
if (resource.mute != null)
|
|
1596
|
-
resourceJson.mute = resource.mute;
|
|
1597
|
-
if (resource.autoplay != null)
|
|
1598
|
-
resourceJson.autoplay = resource.autoplay;
|
|
1599
|
-
if (resource.allowSubtitles != null)
|
|
1600
|
-
resourceJson.allowSubtitles = resource.allowSubtitles;
|
|
1601
|
-
if (resource.showSubtitles != null)
|
|
1602
|
-
resourceJson.showSubtitles = resource.showSubtitles;
|
|
1603
|
-
if (resource.alt != null)
|
|
1604
|
-
resourceJson.alt = Breakscape_1.Breakscape.unbreakscape(resource.alt);
|
|
1605
|
-
if (resource.posterImage != null)
|
|
1606
|
-
resourceJson.posterImage = this.addImageResource(bitType, resource.posterImage);
|
|
1607
|
-
if (resource.thumbnails != null && resource.thumbnails.length > 0) {
|
|
1608
|
-
resourceJson.thumbnails = [];
|
|
1609
|
-
for (const thumbnail of resource.thumbnails) {
|
|
1610
|
-
resourceJson.thumbnails.push(this.addImageResource(bitType, thumbnail));
|
|
1611
|
-
}
|
|
1612
|
-
}
|
|
1613
|
-
this.addGenericResourceProperties(bitType, resource, resourceJson);
|
|
1614
|
-
return resourceJson;
|
|
1615
|
-
}
|
|
1616
|
-
addVideoEmbedResource(bitType, resource) {
|
|
1617
|
-
var _a, _b;
|
|
1618
|
-
const resourceJson = {};
|
|
1619
|
-
if (resource.format != null)
|
|
1620
|
-
resourceJson.format = Breakscape_1.Breakscape.unbreakscape(resource.format);
|
|
1621
|
-
if (resource.provider != null)
|
|
1622
|
-
resourceJson.provider = Breakscape_1.Breakscape.unbreakscape(resource.provider);
|
|
1623
|
-
if (resource.value != null)
|
|
1624
|
-
resourceJson.src = Breakscape_1.Breakscape.unbreakscape(resource.value);
|
|
1625
|
-
resourceJson.width = (_a = resource.width) !== null && _a !== void 0 ? _a : null;
|
|
1626
|
-
resourceJson.height = (_b = resource.height) !== null && _b !== void 0 ? _b : null;
|
|
1627
|
-
if (resource.duration != null)
|
|
1628
|
-
resourceJson.duration = resource.duration;
|
|
1629
|
-
if (resource.mute != null)
|
|
1630
|
-
resourceJson.mute = resource.mute;
|
|
1631
|
-
if (resource.autoplay != null)
|
|
1632
|
-
resourceJson.autoplay = resource.autoplay;
|
|
1633
|
-
if (resource.allowSubtitles != null)
|
|
1634
|
-
resourceJson.allowSubtitles = resource.allowSubtitles;
|
|
1635
|
-
if (resource.showSubtitles != null)
|
|
1636
|
-
resourceJson.showSubtitles = resource.showSubtitles;
|
|
1637
|
-
if (resource.alt != null)
|
|
1638
|
-
resourceJson.alt = Breakscape_1.Breakscape.unbreakscape(resource.alt);
|
|
1639
|
-
if (resource.posterImage != null)
|
|
1640
|
-
resourceJson.posterImage = this.addImageResource(bitType, resource.posterImage);
|
|
1641
|
-
if (resource.thumbnails != null && resource.thumbnails.length > 0) {
|
|
1642
|
-
resourceJson.thumbnails = [];
|
|
1643
|
-
for (const thumbnail of resource.thumbnails) {
|
|
1644
|
-
resourceJson.thumbnails.push(this.addImageResource(bitType, thumbnail));
|
|
1645
|
-
}
|
|
1646
|
-
}
|
|
1647
|
-
this.addGenericResourceProperties(bitType, resource, resourceJson);
|
|
1648
|
-
return resourceJson;
|
|
1649
|
-
}
|
|
1650
|
-
addVideoLinkResource(bitType, resource) {
|
|
718
|
+
/**
|
|
719
|
+
* Default handler for properties.
|
|
720
|
+
*
|
|
721
|
+
* @param node the node
|
|
722
|
+
* @param route the route to the node
|
|
723
|
+
* @param parentNodeTypes the parent node types for which to handle the node
|
|
724
|
+
* @returns
|
|
725
|
+
*/
|
|
726
|
+
standardHandler(node, route, parentNodeTypes, options) {
|
|
1651
727
|
var _a, _b;
|
|
1652
|
-
|
|
1653
|
-
if (
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
resourceJson.url = Breakscape_1.Breakscape.unbreakscape(resource.value);
|
|
1659
|
-
resourceJson.width = (_a = resource.width) !== null && _a !== void 0 ? _a : null;
|
|
1660
|
-
resourceJson.height = (_b = resource.height) !== null && _b !== void 0 ? _b : null;
|
|
1661
|
-
if (resource.duration != null)
|
|
1662
|
-
resourceJson.duration = resource.duration;
|
|
1663
|
-
if (resource.mute != null)
|
|
1664
|
-
resourceJson.mute = resource.mute;
|
|
1665
|
-
if (resource.autoplay != null)
|
|
1666
|
-
resourceJson.autoplay = resource.autoplay;
|
|
1667
|
-
if (resource.allowSubtitles != null)
|
|
1668
|
-
resourceJson.allowSubtitles = resource.allowSubtitles;
|
|
1669
|
-
if (resource.showSubtitles != null)
|
|
1670
|
-
resourceJson.showSubtitles = resource.showSubtitles;
|
|
1671
|
-
if (resource.alt != null)
|
|
1672
|
-
resourceJson.alt = Breakscape_1.Breakscape.unbreakscape(resource.alt);
|
|
1673
|
-
if (resource.posterImage != null)
|
|
1674
|
-
resourceJson.posterImage = this.addImageResource(bitType, resource.posterImage);
|
|
1675
|
-
if (resource.thumbnails != null && resource.thumbnails.length > 0) {
|
|
1676
|
-
resourceJson.thumbnails = [];
|
|
1677
|
-
for (const thumbnail of resource.thumbnails) {
|
|
1678
|
-
resourceJson.thumbnails.push(this.addImageResource(bitType, thumbnail));
|
|
1679
|
-
}
|
|
728
|
+
// Ignore items not at the nodeType level
|
|
729
|
+
if (parentNodeTypes) {
|
|
730
|
+
const nodeTypeArray = Array.isArray(parentNodeTypes) ? parentNodeTypes : [parentNodeTypes];
|
|
731
|
+
const parent = this.getParentNode(route);
|
|
732
|
+
if (!(parent === null || parent === void 0 ? void 0 : parent.key) || !nodeTypeArray.includes(parent === null || parent === void 0 ? void 0 : parent.key))
|
|
733
|
+
return true;
|
|
1680
734
|
}
|
|
1681
|
-
|
|
1682
|
-
|
|
735
|
+
// Add the property
|
|
736
|
+
this.addProperty(this.bitJson, (_a = options.keyOverride) !== null && _a !== void 0 ? _a : node.key, (_b = options.valueOverride) !== null && _b !== void 0 ? _b : node.value, options);
|
|
737
|
+
// Stop traversal of this branch
|
|
738
|
+
return false;
|
|
1683
739
|
}
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
if (
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
if (resource.duration != null)
|
|
1696
|
-
resourceJson.duration = resource.duration;
|
|
1697
|
-
if (resource.mute != null)
|
|
1698
|
-
resourceJson.mute = resource.mute;
|
|
1699
|
-
if (resource.autoplay != null)
|
|
1700
|
-
resourceJson.autoplay = resource.autoplay;
|
|
1701
|
-
if (resource.allowSubtitles != null)
|
|
1702
|
-
resourceJson.allowSubtitles = resource.allowSubtitles;
|
|
1703
|
-
if (resource.showSubtitles != null)
|
|
1704
|
-
resourceJson.showSubtitles = resource.showSubtitles;
|
|
1705
|
-
if (resource.alt != null)
|
|
1706
|
-
resourceJson.alt = Breakscape_1.Breakscape.unbreakscape(resource.alt);
|
|
1707
|
-
if (resource.posterImage != null)
|
|
1708
|
-
resourceJson.posterImage = this.addImageResource(bitType, resource.posterImage);
|
|
1709
|
-
if (resource.thumbnails != null && resource.thumbnails.length > 0) {
|
|
1710
|
-
resourceJson.thumbnails = [];
|
|
1711
|
-
for (const thumbnail of resource.thumbnails) {
|
|
1712
|
-
resourceJson.thumbnails.push(this.addImageResource(bitType, thumbnail));
|
|
740
|
+
addProperty(
|
|
741
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
742
|
+
target, name, values, options) {
|
|
743
|
+
if (values !== undefined) {
|
|
744
|
+
let finalValue;
|
|
745
|
+
if (!Array.isArray(values))
|
|
746
|
+
values = [values];
|
|
747
|
+
const valuesArr = values;
|
|
748
|
+
// if (valuesArr.length > 0) {
|
|
749
|
+
if (!options.array && valuesArr.length >= 1) {
|
|
750
|
+
finalValue = valuesArr[valuesArr.length - 1];
|
|
1713
751
|
}
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
return resourceJson;
|
|
1717
|
-
}
|
|
1718
|
-
addStillImageFilmLinkResource(bitType, resource) {
|
|
1719
|
-
var _a, _b;
|
|
1720
|
-
const resourceJson = {};
|
|
1721
|
-
if (resource.format != null)
|
|
1722
|
-
resourceJson.format = Breakscape_1.Breakscape.unbreakscape(resource.format);
|
|
1723
|
-
if (resource.provider != null)
|
|
1724
|
-
resourceJson.provider = Breakscape_1.Breakscape.unbreakscape(resource.provider);
|
|
1725
|
-
if (resource.value != null)
|
|
1726
|
-
resourceJson.url = Breakscape_1.Breakscape.unbreakscape(resource.value);
|
|
1727
|
-
resourceJson.width = (_a = resource.width) !== null && _a !== void 0 ? _a : null;
|
|
1728
|
-
resourceJson.height = (_b = resource.height) !== null && _b !== void 0 ? _b : null;
|
|
1729
|
-
if (resource.duration != null)
|
|
1730
|
-
resourceJson.duration = resource.duration;
|
|
1731
|
-
if (resource.mute != null)
|
|
1732
|
-
resourceJson.mute = resource.mute;
|
|
1733
|
-
if (resource.autoplay != null)
|
|
1734
|
-
resourceJson.autoplay = resource.autoplay;
|
|
1735
|
-
if (resource.allowSubtitles != null)
|
|
1736
|
-
resourceJson.allowSubtitles = resource.allowSubtitles;
|
|
1737
|
-
if (resource.showSubtitles != null)
|
|
1738
|
-
resourceJson.showSubtitles = resource.showSubtitles;
|
|
1739
|
-
if (resource.alt != null)
|
|
1740
|
-
resourceJson.alt = Breakscape_1.Breakscape.unbreakscape(resource.alt);
|
|
1741
|
-
if (resource.posterImage != null)
|
|
1742
|
-
resourceJson.posterImage = this.addImageResource(bitType, resource.posterImage);
|
|
1743
|
-
if (resource.thumbnails != null && resource.thumbnails.length > 0) {
|
|
1744
|
-
resourceJson.thumbnails = [];
|
|
1745
|
-
for (const thumbnail of resource.thumbnails) {
|
|
1746
|
-
resourceJson.thumbnails.push(this.addImageResource(bitType, thumbnail));
|
|
752
|
+
else {
|
|
753
|
+
finalValue = valuesArr;
|
|
1747
754
|
}
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
}
|
|
1752
|
-
addArticleResource(bitType, resource) {
|
|
1753
|
-
const resourceJson = {};
|
|
1754
|
-
if (resource.format != null)
|
|
1755
|
-
resourceJson.format = Breakscape_1.Breakscape.unbreakscape(resource.format);
|
|
1756
|
-
if (resource.provider != null)
|
|
1757
|
-
resourceJson.provider = Breakscape_1.Breakscape.unbreakscape(resource.provider);
|
|
1758
|
-
if (resource.value != null)
|
|
1759
|
-
resourceJson.body = Breakscape_1.Breakscape.unbreakscape(resource.value);
|
|
1760
|
-
// if (resource.href != null) resourceJson.href = BreakscapeUtils.unbreakscape(resource.href); // It is never used (and doesn't exist in the AST model)
|
|
1761
|
-
this.addGenericResourceProperties(bitType, resource, resourceJson);
|
|
1762
|
-
return resourceJson;
|
|
1763
|
-
}
|
|
1764
|
-
addDocumentResource(bitType, resource) {
|
|
1765
|
-
const resourceJson = {};
|
|
1766
|
-
if (resource.format != null)
|
|
1767
|
-
resourceJson.format = Breakscape_1.Breakscape.unbreakscape(resource.format);
|
|
1768
|
-
if (resource.provider != null)
|
|
1769
|
-
resourceJson.provider = Breakscape_1.Breakscape.unbreakscape(resource.provider);
|
|
1770
|
-
if (resource.value != null)
|
|
1771
|
-
resourceJson.url = Breakscape_1.Breakscape.unbreakscape(resource.value);
|
|
1772
|
-
// if (resource.href != null) resourceJson.href = BreakscapeUtils.unbreakscape(resource.href); // It is never used (and doesn't exist in the AST model)
|
|
1773
|
-
this.addGenericResourceProperties(bitType, resource, resourceJson);
|
|
1774
|
-
return resourceJson;
|
|
1775
|
-
}
|
|
1776
|
-
addDocumentEmbedResource(bitType, resource) {
|
|
1777
|
-
const resourceJson = {};
|
|
1778
|
-
if (resource.format != null)
|
|
1779
|
-
resourceJson.format = Breakscape_1.Breakscape.unbreakscape(resource.format);
|
|
1780
|
-
if (resource.provider != null)
|
|
1781
|
-
resourceJson.provider = Breakscape_1.Breakscape.unbreakscape(resource.provider);
|
|
1782
|
-
if (resource.value != null)
|
|
1783
|
-
resourceJson.url = Breakscape_1.Breakscape.unbreakscape(resource.value);
|
|
1784
|
-
// if (resource.href != null) resourceJson.href = BreakscapeUtils.unbreakscape(resource.href); // It is never used (and doesn't exist in the AST model)
|
|
1785
|
-
this.addGenericResourceProperties(bitType, resource, resourceJson);
|
|
1786
|
-
return resourceJson;
|
|
1787
|
-
}
|
|
1788
|
-
addDocumentLinkResource(bitType, resource) {
|
|
1789
|
-
const resourceJson = {};
|
|
1790
|
-
if (resource.format != null)
|
|
1791
|
-
resourceJson.format = Breakscape_1.Breakscape.unbreakscape(resource.format);
|
|
1792
|
-
if (resource.provider != null)
|
|
1793
|
-
resourceJson.provider = Breakscape_1.Breakscape.unbreakscape(resource.provider);
|
|
1794
|
-
if (resource.value != null)
|
|
1795
|
-
resourceJson.url = Breakscape_1.Breakscape.unbreakscape(resource.value);
|
|
1796
|
-
// if (resource.href != null) resourceJson.href = BreakscapeUtils.unbreakscape(resource.href); // It is never used (and doesn't exist in the AST model)
|
|
1797
|
-
this.addGenericResourceProperties(bitType, resource, resourceJson);
|
|
1798
|
-
return resourceJson;
|
|
1799
|
-
}
|
|
1800
|
-
addDocumentDownloadResource(bitType, resource) {
|
|
1801
|
-
const resourceJson = {};
|
|
1802
|
-
if (resource.format != null)
|
|
1803
|
-
resourceJson.format = Breakscape_1.Breakscape.unbreakscape(resource.format);
|
|
1804
|
-
if (resource.provider != null)
|
|
1805
|
-
resourceJson.provider = Breakscape_1.Breakscape.unbreakscape(resource.provider);
|
|
1806
|
-
if (resource.value != null)
|
|
1807
|
-
resourceJson.url = Breakscape_1.Breakscape.unbreakscape(resource.value);
|
|
1808
|
-
// if (resource.href != null) resourceJson.href = resource.href; // It is never used (and doesn't exist in the AST model)
|
|
1809
|
-
this.addGenericResourceProperties(bitType, resource, resourceJson);
|
|
1810
|
-
return resourceJson;
|
|
1811
|
-
}
|
|
1812
|
-
addAppLinkResource(bitType, resource) {
|
|
1813
|
-
const resourceJson = {};
|
|
1814
|
-
// if (resource.format != null) resourceJson.format = BreakscapeUtils.unbreakscape(resource.format);
|
|
1815
|
-
if (resource.value != null)
|
|
1816
|
-
resourceJson.url = Breakscape_1.Breakscape.unbreakscape(resource.value);
|
|
1817
|
-
this.addGenericResourceProperties(bitType, resource, resourceJson);
|
|
1818
|
-
return resourceJson;
|
|
1819
|
-
}
|
|
1820
|
-
addWebsiteLinkResource(bitType, resource) {
|
|
1821
|
-
const resourceJson = {};
|
|
1822
|
-
// if (resource.format != null) resourceJson.format = BreakscapeUtils.unbreakscape(resource.format);
|
|
1823
|
-
if (resource.value != null)
|
|
1824
|
-
resourceJson.url = Breakscape_1.Breakscape.unbreakscape(resource.value);
|
|
1825
|
-
if (resource.siteName != null)
|
|
1826
|
-
resourceJson.siteName = Breakscape_1.Breakscape.unbreakscape(resource.siteName);
|
|
1827
|
-
this.addGenericResourceProperties(bitType, resource, resourceJson);
|
|
1828
|
-
return resourceJson;
|
|
1829
|
-
}
|
|
1830
|
-
addGenericResourceProperties(_bitType, resource, resourceJson, noDefaults) {
|
|
1831
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1832
|
-
if (noDefaults) {
|
|
1833
|
-
if (resource.license != null)
|
|
1834
|
-
resourceJson.license = (_a = Breakscape_1.Breakscape.unbreakscape(resource.license)) !== null && _a !== void 0 ? _a : '';
|
|
1835
|
-
if (resource.copyright != null)
|
|
1836
|
-
resourceJson.copyright = (_b = Breakscape_1.Breakscape.unbreakscape(resource.copyright)) !== null && _b !== void 0 ? _b : '';
|
|
1837
|
-
if (resource.provider != null)
|
|
1838
|
-
resourceJson.provider = Breakscape_1.Breakscape.unbreakscape(resource.provider);
|
|
1839
|
-
if (resource.showInIndex != null)
|
|
1840
|
-
resourceJson.showInIndex = (_c = resource.showInIndex) !== null && _c !== void 0 ? _c : false;
|
|
1841
|
-
if (resource.caption != null) {
|
|
1842
|
-
resourceJson.caption = this.convertBreakscapedStringToJsonText((_d = resource.caption) !== null && _d !== void 0 ? _d : '', TextFormat_1.TextFormat.bitmarkMinusMinus);
|
|
755
|
+
// }
|
|
756
|
+
if (options.allowNull || finalValue != null) {
|
|
757
|
+
target[name] = finalValue;
|
|
1843
758
|
}
|
|
1844
|
-
if (resource.search != null)
|
|
1845
|
-
resourceJson.search = (_e = Breakscape_1.Breakscape.unbreakscape(resource.search)) !== null && _e !== void 0 ? _e : '';
|
|
1846
759
|
}
|
|
1847
|
-
else {
|
|
1848
|
-
resourceJson.license = (_f = Breakscape_1.Breakscape.unbreakscape(resource.license)) !== null && _f !== void 0 ? _f : '';
|
|
1849
|
-
resourceJson.copyright = (_g = Breakscape_1.Breakscape.unbreakscape(resource.copyright)) !== null && _g !== void 0 ? _g : '';
|
|
1850
|
-
if (resource.provider != null)
|
|
1851
|
-
resourceJson.provider = Breakscape_1.Breakscape.unbreakscape(resource.provider);
|
|
1852
|
-
resourceJson.showInIndex = (_h = resource.showInIndex) !== null && _h !== void 0 ? _h : false;
|
|
1853
|
-
resourceJson.caption = this.convertBreakscapedStringToJsonText((_j = resource.caption) !== null && _j !== void 0 ? _j : Breakscape_1.Breakscape.EMPTY_STRING, TextFormat_1.TextFormat.bitmarkMinusMinus);
|
|
1854
|
-
if (resource.search != null)
|
|
1855
|
-
resourceJson.search = (_k = Breakscape_1.Breakscape.unbreakscape(resource.search)) !== null && _k !== void 0 ? _k : '';
|
|
1856
|
-
}
|
|
1857
|
-
return resourceJson;
|
|
1858
|
-
}
|
|
1859
|
-
toItemLeadHintInstruction(item) {
|
|
1860
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1861
|
-
return {
|
|
1862
|
-
item: this.convertBreakscapedStringToJsonText((_b = (_a = item.itemLead) === null || _a === void 0 ? void 0 : _a.item) !== null && _b !== void 0 ? _b : Breakscape_1.Breakscape.EMPTY_STRING, TextFormat_1.TextFormat.bitmarkMinusMinus),
|
|
1863
|
-
lead: this.convertBreakscapedStringToJsonText((_d = (_c = item.itemLead) === null || _c === void 0 ? void 0 : _c.lead) !== null && _d !== void 0 ? _d : Breakscape_1.Breakscape.EMPTY_STRING, TextFormat_1.TextFormat.bitmarkMinusMinus),
|
|
1864
|
-
hint: this.convertBreakscapedStringToJsonText((_e = item.hint) !== null && _e !== void 0 ? _e : Breakscape_1.Breakscape.EMPTY_STRING, TextFormat_1.TextFormat.bitmarkMinusMinus),
|
|
1865
|
-
instruction: this.convertBreakscapedStringToJsonText((_f = item.instruction) !== null && _f !== void 0 ? _f : Breakscape_1.Breakscape.EMPTY_STRING, TextFormat_1.TextFormat.bitmarkMinusMinus),
|
|
1866
|
-
};
|
|
1867
760
|
}
|
|
1868
761
|
toExample(node, options) {
|
|
1869
|
-
const { isExample, example,
|
|
762
|
+
const { isExample, example, __isDefaultExample } = node;
|
|
1870
763
|
const { defaultExample, isBoolean } = options;
|
|
1871
764
|
if (!isExample) {
|
|
1872
765
|
return {
|
|
@@ -1875,7 +768,7 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1875
768
|
};
|
|
1876
769
|
}
|
|
1877
770
|
let exampleValue;
|
|
1878
|
-
if (
|
|
771
|
+
if (__isDefaultExample) {
|
|
1879
772
|
exampleValue = isBoolean
|
|
1880
773
|
? BooleanUtils_1.BooleanUtils.toBoolean(defaultExample)
|
|
1881
774
|
: this.convertBreakscapedStringToJsonText(defaultExample, TextFormat_1.TextFormat.bitmarkMinusMinus);
|
|
@@ -1890,53 +783,6 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1890
783
|
example: exampleValue,
|
|
1891
784
|
};
|
|
1892
785
|
}
|
|
1893
|
-
addProperty(
|
|
1894
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1895
|
-
target, name, values, singleWithoutArray) {
|
|
1896
|
-
if (values !== undefined) {
|
|
1897
|
-
let finalValue;
|
|
1898
|
-
if (!Array.isArray(values))
|
|
1899
|
-
values = [values];
|
|
1900
|
-
if (Array.isArray(values) && values.length > 0) {
|
|
1901
|
-
// Unbreakscape values that are strings
|
|
1902
|
-
values = Breakscape_1.Breakscape.unbreakscape(values);
|
|
1903
|
-
if (Array.isArray(values) && singleWithoutArray && values.length >= 1) {
|
|
1904
|
-
finalValue = values[values.length - 1];
|
|
1905
|
-
}
|
|
1906
|
-
else {
|
|
1907
|
-
finalValue = values;
|
|
1908
|
-
}
|
|
1909
|
-
}
|
|
1910
|
-
// if (finalValue != null) {
|
|
1911
|
-
target[name] = finalValue;
|
|
1912
|
-
// }
|
|
1913
|
-
}
|
|
1914
|
-
}
|
|
1915
|
-
//
|
|
1916
|
-
// Helper functions
|
|
1917
|
-
//
|
|
1918
|
-
/**
|
|
1919
|
-
* Get the value for the zoomDisabled property, setting the appropriate default value if no value is set.
|
|
1920
|
-
*
|
|
1921
|
-
* @param bitType
|
|
1922
|
-
* @param zoomDisabled
|
|
1923
|
-
* @returns
|
|
1924
|
-
*/
|
|
1925
|
-
getZoomDisabled(bitType, zoomDisabled) {
|
|
1926
|
-
if (zoomDisabled != null)
|
|
1927
|
-
return zoomDisabled;
|
|
1928
|
-
// The default value in the JSON is hardcoded, because there is currently no good way to set a different
|
|
1929
|
-
// default per bit in the BitConfig.
|
|
1930
|
-
if (Config_1.Config.isOfBitType(bitType, [
|
|
1931
|
-
BitType_1.BitType.imageSeparator,
|
|
1932
|
-
BitType_1.BitType.pageBanner,
|
|
1933
|
-
BitType_1.BitType.imagesLogoGrave,
|
|
1934
|
-
BitType_1.BitType.prototypeImages,
|
|
1935
|
-
])) {
|
|
1936
|
-
return true;
|
|
1937
|
-
}
|
|
1938
|
-
return false;
|
|
1939
|
-
}
|
|
1940
786
|
/**
|
|
1941
787
|
* Get the bit type from any node
|
|
1942
788
|
*
|
|
@@ -2023,9 +869,14 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
2023
869
|
convertBreakscapedStringToJsonText(text, format) {
|
|
2024
870
|
if (!text)
|
|
2025
871
|
undefined;
|
|
2026
|
-
const
|
|
872
|
+
const isBitmarkText = format === TextFormat_1.TextFormat.bitmarkMinusMinus || format === TextFormat_1.TextFormat.bitmarkPlusPlus;
|
|
873
|
+
if (!isBitmarkText) {
|
|
874
|
+
// Not bitmark text, so plain text, so unbreakscape only the start of bit tags
|
|
875
|
+
return text || '';
|
|
876
|
+
}
|
|
877
|
+
const asPlainText = this.options.textAsPlainText;
|
|
2027
878
|
if (asPlainText) {
|
|
2028
|
-
return
|
|
879
|
+
return text || '';
|
|
2029
880
|
}
|
|
2030
881
|
// Use the text parser to parse the text
|
|
2031
882
|
const textAst = this.textParser.toAst(text, {
|
|
@@ -2034,40 +885,73 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
2034
885
|
return textAst;
|
|
2035
886
|
}
|
|
2036
887
|
/**
|
|
2037
|
-
*
|
|
888
|
+
* Concatenates a plain JSON text with a JsonText that may be plain (v2) or BitmarkText (v3)
|
|
889
|
+
* Returns the combined text.
|
|
2038
890
|
*
|
|
2039
|
-
* @param
|
|
2040
|
-
* @param
|
|
2041
|
-
* @param index the index of the placeholder to replace
|
|
891
|
+
* @param text the text to concatenate
|
|
892
|
+
* @param textPlain the plain text to concatenate
|
|
2042
893
|
*/
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
894
|
+
concatenatePlainTextWithJsonTexts(text, extraBreaks, textPlain) {
|
|
895
|
+
var _a;
|
|
896
|
+
if (Array.isArray(text)) {
|
|
897
|
+
textPlain = textPlain.trim();
|
|
898
|
+
if (textPlain) {
|
|
899
|
+
const splitText = textPlain.split('\n');
|
|
900
|
+
const content = [];
|
|
901
|
+
for (let i = 0; i < extraBreaks; i++) {
|
|
902
|
+
content.push({
|
|
903
|
+
type: TextNodeType_1.TextNodeType.hardBreak,
|
|
904
|
+
});
|
|
2053
905
|
}
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
906
|
+
for (let i = 0; i < splitText.length; i++) {
|
|
907
|
+
const t = splitText[i];
|
|
908
|
+
if (t) {
|
|
909
|
+
content.push({
|
|
910
|
+
text: t,
|
|
911
|
+
type: TextNodeType_1.TextNodeType.text,
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
// Add a hard break after each paragraph, except the last one
|
|
915
|
+
if (i < splitText.length - 1) {
|
|
916
|
+
content.push({
|
|
917
|
+
type: TextNodeType_1.TextNodeType.hardBreak,
|
|
918
|
+
});
|
|
919
|
+
}
|
|
2060
920
|
}
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
921
|
+
// Add the content to the final paragraph, or create a new one if there none
|
|
922
|
+
const lastNode = text[text.length - 1];
|
|
923
|
+
if (lastNode && lastNode.type === TextNodeType_1.TextNodeType.paragraph) {
|
|
924
|
+
lastNode.content = [...((_a = lastNode.content) !== null && _a !== void 0 ? _a : []), ...content];
|
|
925
|
+
}
|
|
926
|
+
else {
|
|
927
|
+
text.push({
|
|
928
|
+
type: TextNodeType_1.TextNodeType.paragraph,
|
|
929
|
+
content,
|
|
930
|
+
attrs: {},
|
|
931
|
+
});
|
|
2066
932
|
}
|
|
2067
933
|
}
|
|
934
|
+
return text;
|
|
935
|
+
}
|
|
936
|
+
return `${text !== null && text !== void 0 ? text : ''}${'\n'.repeat(extraBreaks)}${textPlain !== null && textPlain !== void 0 ? textPlain : ''}`;
|
|
937
|
+
}
|
|
938
|
+
/**
|
|
939
|
+
* Check if an object is bitmark text
|
|
940
|
+
* The check looks for a special tag on the array (__tag: 'text')
|
|
941
|
+
*
|
|
942
|
+
* @param obj object that might be bitmark text
|
|
943
|
+
* @returns
|
|
944
|
+
*/
|
|
945
|
+
isBitmarkText(obj) {
|
|
946
|
+
if (obj == null)
|
|
2068
947
|
return false;
|
|
2069
|
-
|
|
2070
|
-
|
|
948
|
+
if (!Array.isArray(obj))
|
|
949
|
+
return false;
|
|
950
|
+
// Check for the hidden text tag
|
|
951
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
952
|
+
if (obj.__tag === 'text')
|
|
953
|
+
return true;
|
|
954
|
+
return false;
|
|
2071
955
|
}
|
|
2072
956
|
//
|
|
2073
957
|
// WRITE FUNCTIONS
|
|
@@ -2102,211 +986,23 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
2102
986
|
originalType: bit.isCommented ? bit.bitType : undefined,
|
|
2103
987
|
format: bit.textFormat,
|
|
2104
988
|
bitLevel: bit.bitLevel,
|
|
2105
|
-
// Properties
|
|
2106
|
-
id: undefined,
|
|
2107
|
-
internalComment: undefined,
|
|
2108
|
-
externalId: undefined,
|
|
2109
|
-
spaceId: undefined,
|
|
2110
|
-
padletId: undefined,
|
|
2111
|
-
jupyterId: undefined,
|
|
2112
|
-
jupyterExecutionCount: undefined,
|
|
2113
|
-
isPublic: undefined,
|
|
2114
|
-
aiGenerated: undefined,
|
|
2115
|
-
machineTranslated: undefined,
|
|
2116
|
-
analyticsTag: undefined,
|
|
2117
|
-
feedbackEngine: undefined,
|
|
2118
|
-
feedbackType: undefined,
|
|
2119
|
-
disableFeedback: undefined,
|
|
2120
|
-
releaseVersion: undefined,
|
|
2121
|
-
releaseKind: undefined,
|
|
2122
|
-
releaseDate: undefined,
|
|
2123
|
-
book: undefined,
|
|
2124
|
-
ageRange: undefined,
|
|
2125
|
-
lang: undefined,
|
|
2126
|
-
language: undefined,
|
|
2127
|
-
publisher: undefined,
|
|
2128
|
-
publisherName: undefined,
|
|
2129
|
-
theme: undefined,
|
|
2130
|
-
computerLanguage: undefined,
|
|
2131
|
-
target: undefined,
|
|
2132
|
-
slug: undefined,
|
|
2133
|
-
tag: undefined,
|
|
2134
|
-
reductionTag: undefined,
|
|
2135
|
-
bubbleTag: undefined,
|
|
2136
|
-
levelCEFRp: undefined,
|
|
2137
|
-
levelCEFR: undefined,
|
|
2138
|
-
levelILR: undefined,
|
|
2139
|
-
levelACTFL: undefined,
|
|
2140
|
-
icon: undefined,
|
|
2141
|
-
iconTag: undefined,
|
|
2142
|
-
colorTag: undefined,
|
|
2143
|
-
flashcardSet: undefined,
|
|
2144
|
-
subtype: undefined,
|
|
2145
|
-
bookAlias: undefined,
|
|
2146
|
-
coverImage: undefined,
|
|
2147
|
-
coverColor: undefined,
|
|
2148
|
-
publications: undefined,
|
|
2149
|
-
author: undefined,
|
|
2150
|
-
subject: undefined,
|
|
2151
|
-
date: undefined,
|
|
2152
|
-
dateEnd: undefined,
|
|
2153
|
-
location: undefined,
|
|
2154
|
-
kind: undefined,
|
|
2155
|
-
hasMarkAsDone: undefined,
|
|
2156
|
-
processHandIn: undefined,
|
|
2157
|
-
action: undefined,
|
|
2158
|
-
showInIndex: undefined,
|
|
2159
|
-
blockId: undefined,
|
|
2160
|
-
pageNo: undefined,
|
|
2161
|
-
x: undefined,
|
|
2162
|
-
y: undefined,
|
|
2163
|
-
width: undefined,
|
|
2164
|
-
height: undefined,
|
|
2165
|
-
index: undefined,
|
|
2166
|
-
classification: undefined,
|
|
2167
|
-
availableClassifications: undefined,
|
|
2168
|
-
allowedBit: undefined,
|
|
2169
|
-
tableFixedHeader: undefined,
|
|
2170
|
-
tableSearch: undefined,
|
|
2171
|
-
tableSort: undefined,
|
|
2172
|
-
tablePagination: undefined,
|
|
2173
|
-
tablePaginationLimit: undefined,
|
|
2174
|
-
tableHeight: undefined,
|
|
2175
|
-
tableWhitespaceNoWrap: undefined,
|
|
2176
|
-
tableAutoWidth: undefined,
|
|
2177
|
-
tableResizableColumns: undefined,
|
|
2178
|
-
quizCountItems: undefined,
|
|
2179
|
-
quizStrikethroughSolutions: undefined,
|
|
2180
|
-
codeLineNumbers: undefined,
|
|
2181
|
-
codeMinimap: undefined,
|
|
2182
|
-
stripePricingTableId: undefined,
|
|
2183
|
-
stripePublishableKey: undefined,
|
|
2184
|
-
thumbImage: undefined,
|
|
2185
|
-
scormSource: undefined,
|
|
2186
|
-
posterImage: undefined,
|
|
2187
|
-
focusX: undefined,
|
|
2188
|
-
focusY: undefined,
|
|
2189
|
-
pointerLeft: undefined,
|
|
2190
|
-
pointerTop: undefined,
|
|
2191
|
-
listItemIndent: undefined,
|
|
2192
|
-
backgroundWallpaper: undefined,
|
|
2193
|
-
hasBookNavigation: undefined,
|
|
2194
|
-
duration: undefined,
|
|
2195
|
-
deeplink: undefined,
|
|
2196
|
-
externalLink: undefined,
|
|
2197
|
-
externalLinkText: undefined,
|
|
2198
|
-
videoCallLink: undefined,
|
|
2199
|
-
vendorUrl: undefined,
|
|
2200
|
-
search: undefined,
|
|
2201
|
-
list: undefined,
|
|
2202
|
-
textReference: undefined,
|
|
2203
|
-
isTracked: undefined,
|
|
2204
|
-
isInfoOnly: undefined,
|
|
2205
|
-
imageFirst: undefined,
|
|
2206
|
-
activityType: undefined,
|
|
2207
|
-
labelTrue: undefined,
|
|
2208
|
-
labelFalse: undefined,
|
|
2209
|
-
content2Buy: undefined,
|
|
2210
|
-
mailingList: undefined,
|
|
2211
|
-
buttonCaption: undefined,
|
|
2212
|
-
callToActionUrl: undefined,
|
|
2213
|
-
caption: undefined,
|
|
2214
|
-
quotedPerson: undefined,
|
|
2215
|
-
reasonableNumOfChars: undefined,
|
|
2216
|
-
resolved: undefined,
|
|
2217
|
-
resolvedDate: undefined,
|
|
2218
|
-
resolvedBy: undefined,
|
|
2219
|
-
maxCreatedBits: undefined,
|
|
2220
|
-
maxDisplayLevel: undefined,
|
|
2221
|
-
page: undefined,
|
|
2222
|
-
productId: undefined,
|
|
2223
|
-
product: undefined,
|
|
2224
|
-
productVideo: undefined,
|
|
2225
|
-
productFolder: undefined,
|
|
2226
|
-
technicalTerm: undefined,
|
|
2227
|
-
servings: undefined,
|
|
2228
|
-
ratingLevelStart: undefined,
|
|
2229
|
-
ratingLevelEnd: undefined,
|
|
2230
|
-
ratingLevelSelected: undefined,
|
|
2231
|
-
// Book data
|
|
2232
|
-
title: undefined,
|
|
2233
|
-
subtitle: undefined,
|
|
2234
|
-
level: undefined,
|
|
2235
|
-
toc: undefined,
|
|
2236
|
-
progress: undefined,
|
|
2237
|
-
anchor: undefined,
|
|
2238
|
-
reference: undefined,
|
|
2239
|
-
referenceEnd: undefined,
|
|
2240
|
-
// Item, Lead, Hint, Instruction
|
|
2241
|
-
item: undefined,
|
|
2242
|
-
lead: undefined,
|
|
2243
|
-
pageNumber: undefined,
|
|
2244
|
-
marginNumber: undefined,
|
|
2245
|
-
hint: undefined,
|
|
2246
|
-
instruction: undefined,
|
|
2247
|
-
// Example
|
|
2248
|
-
isExample: undefined,
|
|
2249
|
-
example: undefined,
|
|
2250
|
-
// Person .conversion-xxx, page-person, etc
|
|
2251
|
-
person: undefined,
|
|
2252
|
-
// Marks (config)
|
|
2253
|
-
marks: undefined,
|
|
2254
|
-
// Extra Properties
|
|
2255
|
-
extraProperties: undefined,
|
|
2256
|
-
// Body
|
|
2257
|
-
body: undefined,
|
|
2258
|
-
// Resource
|
|
2259
|
-
imagePlaceholder: undefined,
|
|
2260
|
-
resource: undefined,
|
|
2261
|
-
logos: undefined,
|
|
2262
|
-
images: undefined,
|
|
2263
|
-
// Children
|
|
2264
|
-
statement: undefined,
|
|
2265
|
-
isCorrect: undefined,
|
|
2266
|
-
sampleSolution: undefined,
|
|
2267
|
-
additionalSolutions: undefined,
|
|
2268
|
-
partialAnswer: undefined,
|
|
2269
|
-
elements: undefined,
|
|
2270
|
-
cards: undefined,
|
|
2271
|
-
definitions: undefined,
|
|
2272
|
-
statements: undefined,
|
|
2273
|
-
responses: undefined,
|
|
2274
|
-
quizzes: undefined,
|
|
2275
|
-
heading: undefined,
|
|
2276
|
-
pairs: undefined,
|
|
2277
|
-
matrix: undefined,
|
|
2278
|
-
choices: undefined,
|
|
2279
|
-
questions: undefined,
|
|
2280
|
-
captionDefinitionList: undefined,
|
|
2281
|
-
listItems: undefined,
|
|
2282
|
-
sections: undefined,
|
|
2283
|
-
// Placeholders
|
|
2284
|
-
placeholders: undefined,
|
|
2285
|
-
// Footer
|
|
2286
|
-
footer: undefined,
|
|
2287
989
|
};
|
|
2288
|
-
// Add the resource template if there should be a resource (indicated by resourceType) but there is none defined.
|
|
2289
|
-
// if (bit.resourceType && !bitJson.resource) {
|
|
2290
|
-
// const jsonKey = ResourceTag.keyFromValue(bit.resourceType);
|
|
2291
|
-
// bitJson.resource = {
|
|
2292
|
-
// type: bit.resourceType,
|
|
2293
|
-
// } as ResourceJson;
|
|
2294
|
-
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2295
|
-
// if (jsonKey) (bitJson.resource as any)[jsonKey] = {};
|
|
2296
|
-
// }
|
|
2297
990
|
return bitJson;
|
|
2298
991
|
}
|
|
2299
992
|
/**
|
|
2300
993
|
* Remove wanted properties from bit json object.
|
|
2301
994
|
* - This function defines the defaults for properties in the json.
|
|
2302
995
|
*
|
|
996
|
+
* TODO: All these defaults should come from the config and be set in the Builder.
|
|
997
|
+
*
|
|
2303
998
|
* @param bit
|
|
2304
999
|
* @returns
|
|
2305
1000
|
*/
|
|
2306
|
-
|
|
1001
|
+
cleanBitJson(bitJson) {
|
|
1002
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2307
1003
|
const bitType = Config_1.Config.getBitType(bitJson.type);
|
|
2308
|
-
const textFormat = bitJson.format;
|
|
2309
|
-
const plainText = this.options.textAsPlainText;
|
|
1004
|
+
// const textFormat = bitJson.format;
|
|
1005
|
+
// const plainText = this.options.textAsPlainText;
|
|
2310
1006
|
// Clear 'originalType' if not set
|
|
2311
1007
|
if (bitJson.originalType == null)
|
|
2312
1008
|
bitJson.originalType = undefined;
|
|
@@ -2320,8 +1016,14 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
2320
1016
|
// The properties used are a bit random sometimes?
|
|
2321
1017
|
// It would be better if this functionality was generated from the bit config
|
|
2322
1018
|
if (Config_1.Config.isOfBitType(bitType, [BitType_1.BitType._error, BitType_1.BitType._comment])) {
|
|
2323
|
-
// Special
|
|
1019
|
+
// Special case for _error and _comment bits
|
|
2324
1020
|
delete bitJson.format;
|
|
1021
|
+
delete bitJson.item;
|
|
1022
|
+
delete bitJson.lead;
|
|
1023
|
+
delete bitJson.pageNumber;
|
|
1024
|
+
delete bitJson.marginNumber;
|
|
1025
|
+
delete bitJson.hint;
|
|
1026
|
+
delete bitJson.instruction;
|
|
2325
1027
|
//
|
|
2326
1028
|
}
|
|
2327
1029
|
else {
|
|
@@ -2330,6 +1032,18 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
2330
1032
|
// Most bits have these defaults, but there are special cases (not sure if that is by error or design)
|
|
2331
1033
|
if (Config_1.Config.isOfBitType(bitType, [BitType_1.BitType.page])) {
|
|
2332
1034
|
// Bits without item, lead, etc
|
|
1035
|
+
if (bitJson.item == null || ((_a = bitJson.item) === null || _a === void 0 ? void 0 : _a.length) === 0)
|
|
1036
|
+
delete bitJson.item;
|
|
1037
|
+
if (bitJson.lead == null || ((_b = bitJson.lead) === null || _b === void 0 ? void 0 : _b.length) === 0)
|
|
1038
|
+
delete bitJson.lead;
|
|
1039
|
+
if (bitJson.pageNumber == null || ((_c = bitJson.pageNumber) === null || _c === void 0 ? void 0 : _c.length) === 0)
|
|
1040
|
+
delete bitJson.pageNumber;
|
|
1041
|
+
if (bitJson.marginNumber == null || ((_d = bitJson.marginNumber) === null || _d === void 0 ? void 0 : _d.length) === 0)
|
|
1042
|
+
delete bitJson.marginNumber;
|
|
1043
|
+
if (bitJson.hint == null || ((_e = bitJson.hint) === null || _e === void 0 ? void 0 : _e.length) === 0)
|
|
1044
|
+
delete bitJson.hint;
|
|
1045
|
+
if (bitJson.instruction == null || ((_f = bitJson.instruction) === null || _f === void 0 ? void 0 : _f.length) === 0)
|
|
1046
|
+
delete bitJson.instruction;
|
|
2333
1047
|
}
|
|
2334
1048
|
else {
|
|
2335
1049
|
// Majority of bits
|
|
@@ -2497,6 +1211,8 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
2497
1211
|
bitJson.tableAutoWidth = true;
|
|
2498
1212
|
if (bitJson.tableResizableColumns == null)
|
|
2499
1213
|
bitJson.tableResizableColumns = false;
|
|
1214
|
+
if (bitJson.tableColumnMinWidth == null)
|
|
1215
|
+
bitJson.tableColumnMinWidth = 0;
|
|
2500
1216
|
//
|
|
2501
1217
|
}
|
|
2502
1218
|
if (Config_1.Config.isOfBitType(bitType, [
|
|
@@ -2637,361 +1353,42 @@ class JsonGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
2637
1353
|
delete bitJson.example;
|
|
2638
1354
|
}
|
|
2639
1355
|
}
|
|
2640
|
-
// Remove unwanted properties
|
|
2641
|
-
// Properties
|
|
2642
|
-
if (bitJson.id == null)
|
|
2643
|
-
delete bitJson.id;
|
|
2644
|
-
if (bitJson.internalComment == null)
|
|
2645
|
-
delete bitJson.internalComment;
|
|
2646
|
-
if (bitJson.externalId == null)
|
|
2647
|
-
delete bitJson.externalId;
|
|
2648
|
-
if (bitJson.spaceId == null)
|
|
2649
|
-
delete bitJson.spaceId;
|
|
2650
|
-
if (bitJson.padletId == null)
|
|
2651
|
-
delete bitJson.padletId;
|
|
2652
|
-
if (bitJson.jupyterId == null)
|
|
2653
|
-
delete bitJson.jupyterId;
|
|
2654
|
-
if (bitJson.jupyterExecutionCount == null)
|
|
2655
|
-
delete bitJson.jupyterExecutionCount;
|
|
2656
|
-
if (bitJson.isPublic == null)
|
|
2657
|
-
delete bitJson.isPublic;
|
|
2658
|
-
if (bitJson.aiGenerated == null)
|
|
2659
|
-
delete bitJson.aiGenerated;
|
|
2660
|
-
if (bitJson.machineTranslated == null)
|
|
2661
|
-
delete bitJson.machineTranslated;
|
|
2662
|
-
if (bitJson.analyticsTag == null)
|
|
2663
|
-
delete bitJson.analyticsTag;
|
|
2664
|
-
if (bitJson.feedbackEngine == null)
|
|
2665
|
-
delete bitJson.feedbackEngine;
|
|
2666
|
-
if (bitJson.feedbackType == null)
|
|
2667
|
-
delete bitJson.feedbackType;
|
|
2668
|
-
if (bitJson.disableFeedback == null)
|
|
2669
|
-
delete bitJson.disableFeedback;
|
|
2670
|
-
if (bitJson.releaseVersion == null)
|
|
2671
|
-
delete bitJson.releaseVersion;
|
|
2672
|
-
if (bitJson.releaseKind == null)
|
|
2673
|
-
delete bitJson.releaseKind;
|
|
2674
|
-
if (bitJson.releaseDate == null)
|
|
2675
|
-
delete bitJson.releaseDate;
|
|
2676
|
-
if (bitJson.book == null)
|
|
2677
|
-
delete bitJson.book;
|
|
2678
|
-
if (bitJson.ageRange == null)
|
|
2679
|
-
delete bitJson.ageRange;
|
|
2680
|
-
if (bitJson.lang == null)
|
|
2681
|
-
delete bitJson.lang;
|
|
2682
|
-
if (bitJson.language == null)
|
|
2683
|
-
delete bitJson.language;
|
|
2684
|
-
if (bitJson.publisher == null)
|
|
2685
|
-
delete bitJson.publisher;
|
|
2686
|
-
if (bitJson.publisherName == null)
|
|
2687
|
-
delete bitJson.publisherName;
|
|
2688
|
-
if (bitJson.theme == null)
|
|
2689
|
-
delete bitJson.theme;
|
|
2690
|
-
if (bitJson.computerLanguage == null)
|
|
2691
|
-
delete bitJson.computerLanguage;
|
|
2692
|
-
if (bitJson.target == null)
|
|
2693
|
-
delete bitJson.target;
|
|
2694
|
-
if (bitJson.slug == null)
|
|
2695
|
-
delete bitJson.slug;
|
|
2696
|
-
if (bitJson.tag == null)
|
|
2697
|
-
delete bitJson.tag;
|
|
2698
|
-
if (bitJson.reductionTag == null)
|
|
2699
|
-
delete bitJson.reductionTag;
|
|
2700
|
-
if (bitJson.bubbleTag == null)
|
|
2701
|
-
delete bitJson.bubbleTag;
|
|
2702
|
-
if (bitJson.levelCEFRp == null)
|
|
2703
|
-
delete bitJson.levelCEFRp;
|
|
2704
|
-
if (bitJson.levelCEFR == null)
|
|
2705
|
-
delete bitJson.levelCEFR;
|
|
2706
|
-
if (bitJson.levelILR == null)
|
|
2707
|
-
delete bitJson.levelILR;
|
|
2708
|
-
if (bitJson.levelACTFL == null)
|
|
2709
|
-
delete bitJson.levelACTFL;
|
|
2710
|
-
if (bitJson.icon == null)
|
|
2711
|
-
delete bitJson.icon;
|
|
2712
|
-
if (bitJson.iconTag == null)
|
|
2713
|
-
delete bitJson.iconTag;
|
|
2714
|
-
if (bitJson.colorTag == null)
|
|
2715
|
-
delete bitJson.colorTag;
|
|
2716
|
-
if (bitJson.flashcardSet == null)
|
|
2717
|
-
delete bitJson.flashcardSet;
|
|
2718
|
-
if (bitJson.subtype == null)
|
|
2719
|
-
delete bitJson.subtype;
|
|
2720
|
-
if (bitJson.bookAlias == null)
|
|
2721
|
-
delete bitJson.bookAlias;
|
|
2722
|
-
if (bitJson.coverImage == null)
|
|
2723
|
-
delete bitJson.coverImage;
|
|
2724
|
-
if (bitJson.coverColor == null)
|
|
2725
|
-
delete bitJson.coverColor;
|
|
2726
|
-
if (bitJson.publications == null)
|
|
2727
|
-
delete bitJson.publications;
|
|
2728
|
-
if (bitJson.author == null)
|
|
2729
|
-
delete bitJson.author;
|
|
2730
|
-
if (bitJson.subject == null)
|
|
2731
|
-
delete bitJson.subject;
|
|
2732
|
-
if (bitJson.date == null)
|
|
2733
|
-
delete bitJson.date;
|
|
2734
|
-
if (bitJson.dateEnd == null)
|
|
2735
|
-
delete bitJson.dateEnd;
|
|
2736
|
-
if (bitJson.location == null)
|
|
2737
|
-
delete bitJson.location;
|
|
2738
|
-
if (bitJson.kind == null)
|
|
2739
|
-
delete bitJson.kind;
|
|
2740
|
-
if (bitJson.hasMarkAsDone == null)
|
|
2741
|
-
delete bitJson.hasMarkAsDone;
|
|
2742
|
-
if (bitJson.processHandIn == null)
|
|
2743
|
-
delete bitJson.processHandIn;
|
|
2744
|
-
if (bitJson.action == null)
|
|
2745
|
-
delete bitJson.action;
|
|
2746
|
-
if (bitJson.showInIndex == null)
|
|
2747
|
-
delete bitJson.showInIndex;
|
|
2748
|
-
if (bitJson.blockId == null)
|
|
2749
|
-
delete bitJson.blockId;
|
|
2750
|
-
if (bitJson.pageNo == null)
|
|
2751
|
-
delete bitJson.pageNo;
|
|
2752
|
-
if (bitJson.x == null)
|
|
2753
|
-
delete bitJson.x;
|
|
2754
|
-
if (bitJson.y == null)
|
|
2755
|
-
delete bitJson.y;
|
|
2756
|
-
if (bitJson.width == null)
|
|
2757
|
-
delete bitJson.width;
|
|
2758
|
-
if (bitJson.height == null)
|
|
2759
|
-
delete bitJson.height;
|
|
2760
|
-
if (bitJson.index == null)
|
|
2761
|
-
delete bitJson.index;
|
|
2762
|
-
if (bitJson.classification == null)
|
|
2763
|
-
delete bitJson.classification;
|
|
2764
|
-
if (bitJson.availableClassifications == null)
|
|
2765
|
-
delete bitJson.availableClassifications;
|
|
2766
|
-
if (bitJson.allowedBit == null)
|
|
2767
|
-
delete bitJson.allowedBit;
|
|
2768
|
-
if (bitJson.tableFixedHeader == null)
|
|
2769
|
-
delete bitJson.tableFixedHeader;
|
|
2770
|
-
if (bitJson.tableSearch == null)
|
|
2771
|
-
delete bitJson.tableSearch;
|
|
2772
|
-
if (bitJson.tableSort == null)
|
|
2773
|
-
delete bitJson.tableSort;
|
|
2774
|
-
if (bitJson.tablePagination == null)
|
|
2775
|
-
delete bitJson.tablePagination;
|
|
2776
|
-
if (bitJson.tablePaginationLimit == null)
|
|
2777
|
-
delete bitJson.tablePaginationLimit;
|
|
2778
|
-
if (bitJson.tableHeight == null)
|
|
2779
|
-
delete bitJson.tableHeight;
|
|
2780
|
-
if (bitJson.tableWhitespaceNoWrap == null)
|
|
2781
|
-
delete bitJson.tableWhitespaceNoWrap;
|
|
2782
|
-
if (bitJson.tableAutoWidth == null)
|
|
2783
|
-
delete bitJson.tableAutoWidth;
|
|
2784
|
-
if (bitJson.tableResizableColumns == null)
|
|
2785
|
-
delete bitJson.tableResizableColumns;
|
|
2786
|
-
if (bitJson.quizCountItems == null)
|
|
2787
|
-
delete bitJson.quizCountItems;
|
|
2788
|
-
if (bitJson.quizStrikethroughSolutions == null)
|
|
2789
|
-
delete bitJson.quizStrikethroughSolutions;
|
|
2790
|
-
if (bitJson.codeLineNumbers == null)
|
|
2791
|
-
delete bitJson.codeLineNumbers;
|
|
2792
|
-
if (bitJson.codeMinimap == null)
|
|
2793
|
-
delete bitJson.codeMinimap;
|
|
2794
|
-
if (bitJson.stripePricingTableId == null)
|
|
2795
|
-
delete bitJson.stripePricingTableId;
|
|
2796
|
-
if (bitJson.stripePublishableKey == null)
|
|
2797
|
-
delete bitJson.stripePublishableKey;
|
|
2798
|
-
if (bitJson.thumbImage == null)
|
|
2799
|
-
delete bitJson.thumbImage;
|
|
2800
|
-
if (bitJson.scormSource == null)
|
|
2801
|
-
delete bitJson.scormSource;
|
|
2802
|
-
if (bitJson.posterImage == null)
|
|
2803
|
-
delete bitJson.posterImage;
|
|
2804
|
-
if (bitJson.focusX == null)
|
|
2805
|
-
delete bitJson.focusX;
|
|
2806
|
-
if (bitJson.focusY == null)
|
|
2807
|
-
delete bitJson.focusY;
|
|
2808
|
-
if (bitJson.pointerLeft == null)
|
|
2809
|
-
delete bitJson.pointerLeft;
|
|
2810
|
-
if (bitJson.pointerTop == null)
|
|
2811
|
-
delete bitJson.pointerTop;
|
|
2812
|
-
if (bitJson.listItemIndent == null)
|
|
2813
|
-
delete bitJson.listItemIndent;
|
|
2814
|
-
if (bitJson.backgroundWallpaper == null)
|
|
2815
|
-
delete bitJson.backgroundWallpaper;
|
|
2816
|
-
if (bitJson.hasBookNavigation == null)
|
|
2817
|
-
delete bitJson.hasBookNavigation;
|
|
2818
|
-
if (bitJson.duration == null)
|
|
2819
|
-
delete bitJson.duration;
|
|
2820
|
-
if (bitJson.deeplink == null)
|
|
2821
|
-
delete bitJson.deeplink;
|
|
2822
|
-
if (bitJson.externalLink == null)
|
|
2823
|
-
delete bitJson.externalLink;
|
|
2824
|
-
if (bitJson.externalLinkText == null)
|
|
2825
|
-
delete bitJson.externalLinkText;
|
|
2826
|
-
if (bitJson.videoCallLink == null)
|
|
2827
|
-
delete bitJson.videoCallLink;
|
|
2828
|
-
if (bitJson.vendorUrl == null)
|
|
2829
|
-
delete bitJson.vendorUrl;
|
|
2830
|
-
if (bitJson.search == null)
|
|
2831
|
-
delete bitJson.search;
|
|
2832
|
-
if (bitJson.list == null)
|
|
2833
|
-
delete bitJson.list;
|
|
2834
|
-
if (bitJson.textReference == null)
|
|
2835
|
-
delete bitJson.textReference;
|
|
2836
|
-
if (bitJson.isTracked == null)
|
|
2837
|
-
delete bitJson.isTracked;
|
|
2838
|
-
if (bitJson.isInfoOnly == null)
|
|
2839
|
-
delete bitJson.isInfoOnly;
|
|
2840
|
-
if (bitJson.imageFirst == null)
|
|
2841
|
-
delete bitJson.imageFirst;
|
|
2842
|
-
if (bitJson.activityType == null)
|
|
2843
|
-
delete bitJson.activityType;
|
|
2844
|
-
if (bitJson.labelTrue == null)
|
|
2845
|
-
delete bitJson.labelTrue;
|
|
2846
|
-
if (bitJson.labelFalse == null)
|
|
2847
|
-
delete bitJson.labelFalse;
|
|
2848
|
-
if (bitJson.content2Buy == null)
|
|
2849
|
-
delete bitJson.content2Buy;
|
|
2850
|
-
if (bitJson.mailingList == null)
|
|
2851
|
-
delete bitJson.mailingList;
|
|
2852
|
-
if (bitJson.buttonCaption == null)
|
|
2853
|
-
delete bitJson.buttonCaption;
|
|
2854
|
-
if (bitJson.callToActionUrl == null)
|
|
2855
|
-
delete bitJson.callToActionUrl;
|
|
2856
|
-
if (bitJson.caption == null)
|
|
2857
|
-
delete bitJson.caption;
|
|
2858
|
-
if (bitJson.quotedPerson == null)
|
|
2859
|
-
delete bitJson.quotedPerson;
|
|
2860
|
-
if (bitJson.resolved == null)
|
|
2861
|
-
delete bitJson.resolved;
|
|
2862
|
-
if (bitJson.resolvedDate == null)
|
|
2863
|
-
delete bitJson.resolvedDate;
|
|
2864
|
-
if (bitJson.resolvedBy == null)
|
|
2865
|
-
delete bitJson.resolvedBy;
|
|
2866
|
-
if (bitJson.maxCreatedBits == null)
|
|
2867
|
-
delete bitJson.maxCreatedBits;
|
|
2868
|
-
if (bitJson.maxDisplayLevel == null)
|
|
2869
|
-
delete bitJson.maxDisplayLevel;
|
|
2870
|
-
if (bitJson.page == null)
|
|
2871
|
-
delete bitJson.page;
|
|
2872
|
-
if (bitJson.productId == null)
|
|
2873
|
-
delete bitJson.productId;
|
|
2874
|
-
if (bitJson.product == null)
|
|
2875
|
-
delete bitJson.product;
|
|
2876
|
-
if (bitJson.productVideo == null)
|
|
2877
|
-
delete bitJson.productVideo;
|
|
2878
|
-
if (bitJson.productFolder == null)
|
|
2879
|
-
delete bitJson.productFolder;
|
|
2880
|
-
if (bitJson.technicalTerm == null)
|
|
2881
|
-
delete bitJson.technicalTerm;
|
|
2882
|
-
if (bitJson.servings == null)
|
|
2883
|
-
delete bitJson.servings;
|
|
2884
|
-
if (bitJson.ratingLevelStart == null)
|
|
2885
|
-
delete bitJson.ratingLevelStart;
|
|
2886
|
-
if (bitJson.ratingLevelEnd == null)
|
|
2887
|
-
delete bitJson.ratingLevelEnd;
|
|
2888
|
-
if (bitJson.ratingLevelSelected == null)
|
|
2889
|
-
delete bitJson.ratingLevelSelected;
|
|
2890
|
-
// Book data
|
|
2891
|
-
if (bitJson.title == null)
|
|
2892
|
-
delete bitJson.title;
|
|
2893
|
-
if (bitJson.subtitle == null)
|
|
2894
|
-
delete bitJson.subtitle;
|
|
2895
|
-
if (bitJson.level == null)
|
|
2896
|
-
delete bitJson.level;
|
|
2897
|
-
if (bitJson.toc == null)
|
|
2898
|
-
delete bitJson.toc;
|
|
2899
|
-
if (bitJson.progress == null)
|
|
2900
|
-
delete bitJson.progress;
|
|
2901
|
-
if (bitJson.anchor == null)
|
|
2902
|
-
delete bitJson.anchor;
|
|
2903
|
-
if (bitJson.reference == null)
|
|
2904
|
-
delete bitJson.reference;
|
|
2905
|
-
if (bitJson.referenceEnd == null)
|
|
2906
|
-
delete bitJson.referenceEnd;
|
|
2907
|
-
// Item, Lead, Hint, Instruction
|
|
2908
|
-
if (bitJson.item == null)
|
|
2909
|
-
delete bitJson.item;
|
|
2910
|
-
if (bitJson.lead == null)
|
|
2911
|
-
delete bitJson.lead;
|
|
2912
|
-
if (bitJson.pageNumber == null)
|
|
2913
|
-
delete bitJson.pageNumber;
|
|
2914
|
-
if (bitJson.marginNumber == null)
|
|
2915
|
-
delete bitJson.marginNumber;
|
|
2916
|
-
if (bitJson.hint == null)
|
|
2917
|
-
delete bitJson.hint;
|
|
2918
|
-
if (bitJson.instruction == null)
|
|
2919
|
-
delete bitJson.instruction;
|
|
2920
|
-
// Example
|
|
2921
|
-
if (bitJson.example === undefined)
|
|
2922
|
-
delete bitJson.example;
|
|
2923
|
-
if (bitJson.isExample == null)
|
|
2924
|
-
delete bitJson.isExample;
|
|
2925
|
-
// Mark
|
|
2926
|
-
if (bitJson.marks == null)
|
|
2927
|
-
delete bitJson.marks;
|
|
2928
|
-
// Extra Properties
|
|
2929
|
-
if (bitJson.extraProperties == null)
|
|
2930
|
-
delete bitJson.extraProperties;
|
|
2931
|
-
// Body
|
|
2932
|
-
if (bitJson.body == null && textFormat !== TextFormat_1.TextFormat.json)
|
|
2933
|
-
delete bitJson.body;
|
|
2934
|
-
// Placeholders
|
|
2935
|
-
if (bitJson.placeholders == null || Object.keys(bitJson.placeholders).length === 0)
|
|
2936
|
-
delete bitJson.placeholders;
|
|
2937
|
-
// Resource
|
|
2938
|
-
if (bitJson.imagePlaceholder == null)
|
|
2939
|
-
delete bitJson.imagePlaceholder;
|
|
2940
|
-
if (bitJson.resource == null)
|
|
2941
|
-
delete bitJson.resource;
|
|
2942
|
-
if (bitJson.logos == null)
|
|
2943
|
-
delete bitJson.logos;
|
|
2944
|
-
if (bitJson.images == null)
|
|
2945
|
-
delete bitJson.images;
|
|
2946
|
-
// Children
|
|
2947
|
-
if (bitJson.statement == null)
|
|
2948
|
-
delete bitJson.statement;
|
|
2949
|
-
if (bitJson.isCorrect == null)
|
|
2950
|
-
delete bitJson.isCorrect;
|
|
2951
|
-
if (bitJson.sampleSolution == null)
|
|
2952
|
-
delete bitJson.sampleSolution;
|
|
2953
|
-
if (bitJson.additionalSolutions == null)
|
|
2954
|
-
delete bitJson.additionalSolutions;
|
|
2955
|
-
if (bitJson.partialAnswer == null)
|
|
2956
|
-
delete bitJson.partialAnswer;
|
|
2957
|
-
if (bitJson.elements == null)
|
|
2958
|
-
delete bitJson.elements;
|
|
2959
|
-
if (bitJson.cards == null)
|
|
2960
|
-
delete bitJson.cards;
|
|
2961
|
-
if (bitJson.definitions == null)
|
|
2962
|
-
delete bitJson.definitions;
|
|
2963
|
-
if (bitJson.statements == null)
|
|
2964
|
-
delete bitJson.statements;
|
|
2965
|
-
if (bitJson.responses == null)
|
|
2966
|
-
delete bitJson.responses;
|
|
2967
|
-
if (bitJson.quizzes == null)
|
|
2968
|
-
delete bitJson.quizzes;
|
|
2969
|
-
if (bitJson.heading == null)
|
|
2970
|
-
delete bitJson.heading;
|
|
2971
|
-
if (bitJson.pairs == null)
|
|
2972
|
-
delete bitJson.pairs;
|
|
2973
|
-
if (bitJson.matrix == null)
|
|
2974
|
-
delete bitJson.matrix;
|
|
2975
|
-
if (bitJson.table == null)
|
|
2976
|
-
delete bitJson.table;
|
|
2977
|
-
if (bitJson.choices == null)
|
|
2978
|
-
delete bitJson.choices;
|
|
2979
|
-
if (bitJson.questions == null)
|
|
2980
|
-
delete bitJson.questions;
|
|
2981
|
-
if (bitJson.captionDefinitionList == null)
|
|
2982
|
-
delete bitJson.captionDefinitionList;
|
|
2983
|
-
if (bitJson.listItems == null)
|
|
2984
|
-
delete bitJson.listItems;
|
|
2985
|
-
if (bitJson.sections == null)
|
|
2986
|
-
delete bitJson.sections;
|
|
2987
|
-
// Placeholders
|
|
2988
|
-
if (!plainText || bitJson.placeholders == null)
|
|
2989
|
-
delete bitJson.placeholders;
|
|
2990
|
-
// Footer
|
|
2991
|
-
if (bitJson.footer == null)
|
|
2992
|
-
delete bitJson.footer;
|
|
2993
1356
|
return bitJson;
|
|
2994
1357
|
}
|
|
1358
|
+
/**
|
|
1359
|
+
* Convert any bitmark texts to strings.
|
|
1360
|
+
*/
|
|
1361
|
+
convertAllBitmarkTextsToStringsForPlainText(json) {
|
|
1362
|
+
if (!this.options.textAsPlainText)
|
|
1363
|
+
return;
|
|
1364
|
+
const obj = json;
|
|
1365
|
+
for (const key in obj) {
|
|
1366
|
+
const val = obj[key];
|
|
1367
|
+
if (this.isBitmarkText(val)) {
|
|
1368
|
+
const s = this.textGenerator.generateSync(val, TextFormat_1.TextFormat.bitmarkMinusMinus);
|
|
1369
|
+
obj[key] = (Breakscape_1.Breakscape.unbreakscape(s) || '').trim();
|
|
1370
|
+
}
|
|
1371
|
+
else if (typeof obj[key] === 'object') {
|
|
1372
|
+
this.convertAllBitmarkTextsToStringsForPlainText(obj[key]);
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
/**
|
|
1377
|
+
* Remove any property with a key starting with an double underscore.
|
|
1378
|
+
*
|
|
1379
|
+
* @param json
|
|
1380
|
+
*/
|
|
1381
|
+
removeTemporaryProperties(json) {
|
|
1382
|
+
const obj = json;
|
|
1383
|
+
for (const key in obj) {
|
|
1384
|
+
if (key.startsWith('__')) {
|
|
1385
|
+
delete obj[key];
|
|
1386
|
+
}
|
|
1387
|
+
else if (typeof obj[key] === 'object') {
|
|
1388
|
+
this.removeTemporaryProperties(obj[key]);
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
2995
1392
|
//
|
|
2996
1393
|
// Writer interface
|
|
2997
1394
|
//
|