@gmb/bitmark-parser-generator 1.35.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +776 -389
- 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/breakscaping/Breakscape.js +96 -71
- package/dist/cjs/breakscaping/Breakscape.js.map +1 -1
- package/dist/cjs/config/raw/bits.js +14 -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 +1 -0
- 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 +959 -338
- package/dist/cjs/generator/bitmark/BitmarkGenerator.js.map +1 -1
- package/dist/cjs/generator/json/JsonGenerator.js +308 -1982
- 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 +27 -8
- 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 +1 -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 -1
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserHelper.js +9 -3
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserHelper.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserProcessor.js +49 -131
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserTypes.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserValidator.js +7 -31
- 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 -765
- package/dist/cjs/parser/json/JsonParser.js.map +1 -1
- package/dist/cjs/parser/text/TextParser.js +61 -2
- 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/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 +776 -389
- 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/breakscaping/Breakscape.js +96 -71
- package/dist/esm/breakscaping/Breakscape.js.map +1 -1
- package/dist/esm/config/raw/bits.js +14 -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 +1 -0
- 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 +959 -338
- package/dist/esm/generator/bitmark/BitmarkGenerator.js.map +1 -1
- package/dist/esm/generator/json/JsonGenerator.js +308 -1982
- 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 +27 -8
- 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 +1 -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 -1
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserHelper.js +9 -3
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserHelper.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserProcessor.js +49 -131
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserTypes.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserValidator.js +7 -31
- 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 -765
- package/dist/esm/parser/json/JsonParser.js.map +1 -1
- package/dist/esm/parser/text/TextParser.js +61 -2
- 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/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 +279 -441
- 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/breakscaping/Breakscape.d.ts +6 -5
- 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 +89 -55
- package/dist/types/generator/bitmark/BitmarkGenerator.d.ts.map +1 -1
- package/dist/types/generator/json/JsonGenerator.d.ts +88 -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 +48 -16
- package/dist/types/model/ast/NodeType.d.ts.map +1 -1
- package/dist/types/model/ast/Nodes.d.ts +64 -440
- package/dist/types/model/ast/Nodes.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 +2 -4
- package/dist/types/model/enum/BitType.d.ts.map +1 -1
- 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/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 +3 -2
- package/dist/types/parser/bitmark/peg/BitmarkPegParserHelper.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/BitmarkPegParserProcessor.d.ts +2 -15
- package/dist/types/parser/bitmark/peg/BitmarkPegParserProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/BitmarkPegParserTypes.d.ts +83 -71
- 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/package.json +1 -1
|
@@ -8,19 +8,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { Ast } from '../../ast/Ast';
|
|
11
|
+
import { Breakscape } from '../../breakscaping/Breakscape';
|
|
11
12
|
import { Config } from '../../config/Config';
|
|
12
13
|
import { NodeType } from '../../model/ast/NodeType';
|
|
13
14
|
import { BitType } from '../../model/enum/BitType';
|
|
14
15
|
import { BitmarkVersion, DEFAULT_BITMARK_VERSION } from '../../model/enum/BitmarkVersion';
|
|
15
16
|
import { BodyBitType } from '../../model/enum/BodyBitType';
|
|
16
17
|
import { CardSetVersion } from '../../model/enum/CardSetVersion';
|
|
17
|
-
import {
|
|
18
|
+
import { PropertyFormat } from '../../model/enum/PropertyFormat';
|
|
18
19
|
import { PropertyTag } from '../../model/enum/PropertyTag';
|
|
19
20
|
import { ResourceTag } from '../../model/enum/ResourceTag';
|
|
20
21
|
import { TextFormat } from '../../model/enum/TextFormat';
|
|
21
22
|
import { BooleanUtils } from '../../utils/BooleanUtils';
|
|
22
23
|
import { ObjectUtils } from '../../utils/ObjectUtils';
|
|
24
|
+
import { StringUtils } from '../../utils/StringUtils';
|
|
23
25
|
import { AstWalkerGenerator } from '../AstWalkerGenerator';
|
|
26
|
+
import { TextGenerator } from '../text/TextGenerator';
|
|
24
27
|
const DEFAULT_OPTIONS = {
|
|
25
28
|
debugGenerationInline: false,
|
|
26
29
|
};
|
|
@@ -50,6 +53,17 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
50
53
|
// State
|
|
51
54
|
this.skipNLBetweenBitsValue = false;
|
|
52
55
|
this.wroteSomething = false;
|
|
56
|
+
this.inTag = true;
|
|
57
|
+
// Keep TS happy
|
|
58
|
+
this.inTag;
|
|
59
|
+
// Bind callbacks
|
|
60
|
+
this.enter = this.enter.bind(this);
|
|
61
|
+
this.between = this.between.bind(this);
|
|
62
|
+
this.exit = this.exit.bind(this);
|
|
63
|
+
this.leaf = this.leaf.bind(this);
|
|
64
|
+
this.write = this.write.bind(this);
|
|
65
|
+
this.bodyBitCallback = this.bodyBitCallback.bind(this);
|
|
66
|
+
// Set options
|
|
53
67
|
this.bitmarkVersion = (_a = BitmarkVersion.fromValue(options === null || options === void 0 ? void 0 : options.bitmarkVersion)) !== null && _a !== void 0 ? _a : DEFAULT_BITMARK_VERSION;
|
|
54
68
|
this.options = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options === null || options === void 0 ? void 0 : options.bitmarkOptions);
|
|
55
69
|
this.debugGenerationInline = (_b = this.options.debugGenerationInline) !== null && _b !== void 0 ? _b : false;
|
|
@@ -66,11 +80,14 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
66
80
|
}
|
|
67
81
|
// Calculate the prettify space
|
|
68
82
|
this.prettifySpace = this.options.prettifyJson === true ? 2 : this.options.prettifyJson || undefined;
|
|
83
|
+
// Create the text generator
|
|
84
|
+
this.textGenerator = new TextGenerator(this.bitmarkVersion, {
|
|
85
|
+
writeCallback: this.write,
|
|
86
|
+
bodyBitCallback: this.bodyBitCallback,
|
|
87
|
+
debugGenerationInline: this.debugGenerationInline,
|
|
88
|
+
});
|
|
69
89
|
this.writer = writer;
|
|
70
|
-
this.
|
|
71
|
-
this.between = this.between.bind(this);
|
|
72
|
-
this.exit = this.exit.bind(this);
|
|
73
|
-
this.leaf = this.leaf.bind(this);
|
|
90
|
+
this.generateResourceHandlers();
|
|
74
91
|
this.generatePropertyHandlers();
|
|
75
92
|
}
|
|
76
93
|
/**
|
|
@@ -110,6 +127,7 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
110
127
|
resetState() {
|
|
111
128
|
this.skipNLBetweenBitsValue = false;
|
|
112
129
|
this.wroteSomething = false;
|
|
130
|
+
this.inTag = true;
|
|
113
131
|
this.printed = false;
|
|
114
132
|
}
|
|
115
133
|
walkAndWrite(ast) {
|
|
@@ -140,12 +158,12 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
140
158
|
this.writeOPD(bit.bitLevel);
|
|
141
159
|
if (bit.isCommented)
|
|
142
160
|
this.writeString('|');
|
|
143
|
-
this.
|
|
161
|
+
this.writeBreakscapedTagString(bit.bitType);
|
|
144
162
|
if (bit.textFormat) {
|
|
145
163
|
const write = this.isWriteTextFormat(bit.textFormat, bitConfig.textFormatDefault);
|
|
146
164
|
if (write) {
|
|
147
165
|
this.writeColon();
|
|
148
|
-
this.
|
|
166
|
+
this.writeBreakscapedTagString(bit.textFormat);
|
|
149
167
|
}
|
|
150
168
|
}
|
|
151
169
|
// Use the bitConfig to see if we need to write the resourceType attachment
|
|
@@ -168,10 +186,12 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
168
186
|
}
|
|
169
187
|
if (resourceType) {
|
|
170
188
|
this.writeAmpersand();
|
|
171
|
-
this.
|
|
189
|
+
this.writeBreakscapedTagString(resourceType);
|
|
172
190
|
}
|
|
173
191
|
this.writeCL();
|
|
174
192
|
this.writeNL();
|
|
193
|
+
// Continue traversal
|
|
194
|
+
return true;
|
|
175
195
|
}
|
|
176
196
|
between_bitsValue(node, left, right, route) {
|
|
177
197
|
// The following keys are combined with other keys so don't need newlines
|
|
@@ -192,14 +212,20 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
192
212
|
// Ignore values that are not at the bit level as they might be handled elsewhere
|
|
193
213
|
const parent = this.getParentNode(route);
|
|
194
214
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.bitsValue)
|
|
195
|
-
return;
|
|
215
|
+
return true;
|
|
196
216
|
for (let i = 0; i < internalComment.length; i++) {
|
|
197
217
|
const comment = internalComment[i];
|
|
198
218
|
const last = i === internalComment.length - 1;
|
|
199
|
-
this.writeProperty('internalComment', comment
|
|
219
|
+
this.writeProperty('internalComment', comment, {
|
|
220
|
+
format: PropertyFormat.trimmedString,
|
|
221
|
+
single: false,
|
|
222
|
+
ignoreEmpty: true,
|
|
223
|
+
});
|
|
200
224
|
if (!last)
|
|
201
225
|
this.writeNL();
|
|
202
226
|
}
|
|
227
|
+
// Stop traversal of this branch
|
|
228
|
+
return false;
|
|
203
229
|
}
|
|
204
230
|
// bitmarkAst -> bits -> bitsValue -> labelTrue / labelFalse
|
|
205
231
|
enter_labelTrue(node, route) {
|
|
@@ -207,14 +233,24 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
207
233
|
// Ignore example that is not at the bit level as it are handled elsewhere
|
|
208
234
|
const parent = this.getParentNode(route);
|
|
209
235
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.bitsValue)
|
|
210
|
-
return;
|
|
236
|
+
return true;
|
|
211
237
|
const bit = parent === null || parent === void 0 ? void 0 : parent.value;
|
|
212
238
|
if (bit) {
|
|
213
239
|
if (value != '')
|
|
214
|
-
this.writeProperty(PropertyTag.labelTrue, value,
|
|
240
|
+
this.writeProperty(PropertyTag.labelTrue, value, {
|
|
241
|
+
format: PropertyFormat.trimmedString,
|
|
242
|
+
single: true,
|
|
243
|
+
ignoreEmpty: true,
|
|
244
|
+
});
|
|
215
245
|
if (bit.labelFalse && bit.labelFalse[0] != '')
|
|
216
|
-
this.writeProperty(PropertyTag.labelFalse, bit.labelFalse,
|
|
246
|
+
this.writeProperty(PropertyTag.labelFalse, bit.labelFalse, {
|
|
247
|
+
format: PropertyFormat.trimmedString,
|
|
248
|
+
single: true,
|
|
249
|
+
ignoreEmpty: true,
|
|
250
|
+
});
|
|
217
251
|
}
|
|
252
|
+
// Stop traversal of this branch
|
|
253
|
+
return false;
|
|
218
254
|
}
|
|
219
255
|
// bitmarkAst -> bits -> bitsValue -> imageSource
|
|
220
256
|
enter_imageSource(node, route) {
|
|
@@ -222,19 +258,41 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
222
258
|
// Ignore values that are not at the bit level as they might be handled elsewhere
|
|
223
259
|
const parent = this.getParentNode(route);
|
|
224
260
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.bitsValue)
|
|
225
|
-
return;
|
|
261
|
+
return true;
|
|
226
262
|
const { url, mockupId, size, format, trim } = imageSource;
|
|
227
|
-
this.writeProperty('imageSource', url,
|
|
263
|
+
this.writeProperty('imageSource', url, {
|
|
264
|
+
format: PropertyFormat.trimmedString,
|
|
265
|
+
single: true,
|
|
266
|
+
ignoreEmpty: true,
|
|
267
|
+
});
|
|
228
268
|
if (url) {
|
|
229
269
|
if (mockupId)
|
|
230
|
-
this.writeProperty('mockupId', mockupId,
|
|
270
|
+
this.writeProperty('mockupId', mockupId, {
|
|
271
|
+
format: PropertyFormat.trimmedString,
|
|
272
|
+
single: true,
|
|
273
|
+
ignoreEmpty: true,
|
|
274
|
+
});
|
|
231
275
|
if (size)
|
|
232
|
-
this.writeProperty('size', size,
|
|
276
|
+
this.writeProperty('size', size, {
|
|
277
|
+
format: PropertyFormat.trimmedString,
|
|
278
|
+
single: true,
|
|
279
|
+
ignoreEmpty: true,
|
|
280
|
+
});
|
|
233
281
|
if (format)
|
|
234
|
-
this.writeProperty('format', format,
|
|
282
|
+
this.writeProperty('format', format, {
|
|
283
|
+
format: PropertyFormat.trimmedString,
|
|
284
|
+
single: true,
|
|
285
|
+
ignoreEmpty: true,
|
|
286
|
+
});
|
|
235
287
|
if (BooleanUtils.isBoolean(trim))
|
|
236
|
-
this.writeProperty('trim', trim,
|
|
288
|
+
this.writeProperty('trim', trim, {
|
|
289
|
+
format: PropertyFormat.trimmedString,
|
|
290
|
+
single: true,
|
|
291
|
+
ignoreEmpty: true,
|
|
292
|
+
});
|
|
237
293
|
}
|
|
294
|
+
// Stop traversal of this branch
|
|
295
|
+
return false;
|
|
238
296
|
}
|
|
239
297
|
// bitmarkAst -> bits -> bitsValue -> technicalTerm
|
|
240
298
|
enter_technicalTerm(node, route) {
|
|
@@ -242,11 +300,22 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
242
300
|
// Ignore values that are not at the bit level as they might be handled elsewhere
|
|
243
301
|
const parent = this.getParentNode(route);
|
|
244
302
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.bitsValue)
|
|
245
|
-
return;
|
|
303
|
+
return true;
|
|
246
304
|
const { technicalTerm, lang } = nodeValue;
|
|
247
|
-
this.writeProperty('technicalTerm', technicalTerm,
|
|
248
|
-
|
|
249
|
-
|
|
305
|
+
this.writeProperty('technicalTerm', technicalTerm, {
|
|
306
|
+
format: PropertyFormat.trimmedString,
|
|
307
|
+
single: true,
|
|
308
|
+
ignoreEmpty: true,
|
|
309
|
+
});
|
|
310
|
+
if (lang != null) {
|
|
311
|
+
this.writeProperty('lang', lang, {
|
|
312
|
+
format: PropertyFormat.trimmedString,
|
|
313
|
+
single: true,
|
|
314
|
+
ignoreEmpty: true,
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
// Stop traversal of this branch
|
|
318
|
+
return false;
|
|
250
319
|
}
|
|
251
320
|
// bitmarkAst -> bits -> bitsValue -> servings
|
|
252
321
|
enter_servings(node, route) {
|
|
@@ -254,17 +323,52 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
254
323
|
// Ignore values that are not at the bit level as they might be handled elsewhere
|
|
255
324
|
const parent = this.getParentNode(route);
|
|
256
325
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.bitsValue)
|
|
257
|
-
return;
|
|
258
|
-
const { servings, unit, unitAbbr, decimalPlaces, disableCalculation } = nodeValue;
|
|
259
|
-
this.writeProperty('servings', servings,
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
if (
|
|
265
|
-
this.writeProperty('
|
|
266
|
-
|
|
267
|
-
|
|
326
|
+
return true;
|
|
327
|
+
const { servings, unit, unitAbbr, decimalPlaces, disableCalculation, hint } = nodeValue;
|
|
328
|
+
this.writeProperty('servings', servings, {
|
|
329
|
+
format: PropertyFormat.trimmedString,
|
|
330
|
+
single: true,
|
|
331
|
+
ignoreEmpty: true,
|
|
332
|
+
});
|
|
333
|
+
if (unit != null) {
|
|
334
|
+
this.writeProperty('unit', unit, {
|
|
335
|
+
format: PropertyFormat.trimmedString,
|
|
336
|
+
single: true,
|
|
337
|
+
ignoreEmpty: true,
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
if (unitAbbr != null) {
|
|
341
|
+
this.writeProperty('unitAbbr', unitAbbr, {
|
|
342
|
+
format: PropertyFormat.trimmedString,
|
|
343
|
+
single: true,
|
|
344
|
+
ignoreEmpty: true,
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
if (decimalPlaces != null) {
|
|
348
|
+
this.writeProperty('decimalPlaces', decimalPlaces, {
|
|
349
|
+
format: PropertyFormat.trimmedString,
|
|
350
|
+
single: true,
|
|
351
|
+
ignoreEmpty: true,
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
if (disableCalculation != null) {
|
|
355
|
+
this.writeProperty('disableCalculation', disableCalculation, {
|
|
356
|
+
format: PropertyFormat.trimmedString,
|
|
357
|
+
single: true,
|
|
358
|
+
ignoreEmpty: true,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
if (hint != null) {
|
|
362
|
+
this.writeOPQ();
|
|
363
|
+
this.writeBreakscapedTagString(hint);
|
|
364
|
+
this.writeCL();
|
|
365
|
+
// this.writeProperty('hint', hint, {
|
|
366
|
+
// format: PropertyFormat.trimmedString,
|
|
367
|
+
// single: true,
|
|
368
|
+
// ignoreEmpty: true,
|
|
369
|
+
// });
|
|
370
|
+
}
|
|
371
|
+
return false;
|
|
268
372
|
}
|
|
269
373
|
// bitmarkAst -> bits -> bitsValue -> person
|
|
270
374
|
enter_person(node, route) {
|
|
@@ -272,15 +376,25 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
272
376
|
// Ignore values that are not at the bit level as they might be handled elsewhere
|
|
273
377
|
const parent = this.getParentNode(route);
|
|
274
378
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.bitsValue)
|
|
275
|
-
return;
|
|
379
|
+
return true;
|
|
276
380
|
const { name, title, avatarImage } = person;
|
|
277
|
-
this.writeProperty('person', name,
|
|
381
|
+
this.writeProperty('person', name, {
|
|
382
|
+
format: PropertyFormat.trimmedString,
|
|
383
|
+
single: true,
|
|
384
|
+
ignoreEmpty: true,
|
|
385
|
+
});
|
|
278
386
|
if (title) {
|
|
279
|
-
this.writeProperty('title', title,
|
|
387
|
+
this.writeProperty('title', title, {
|
|
388
|
+
format: PropertyFormat.trimmedString,
|
|
389
|
+
single: true,
|
|
390
|
+
ignoreEmpty: true,
|
|
391
|
+
});
|
|
280
392
|
}
|
|
281
393
|
if (avatarImage) {
|
|
282
|
-
this.writeResource(avatarImage);
|
|
394
|
+
this.writeResource(ResourceTag.image, avatarImage.src);
|
|
283
395
|
}
|
|
396
|
+
// Stop traversal of this branch
|
|
397
|
+
return false;
|
|
284
398
|
}
|
|
285
399
|
// bitmarkAst -> bits -> bitsValue -> ratingLevelStart
|
|
286
400
|
enter_ratingLevelStart(node, route) {
|
|
@@ -300,45 +414,110 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
300
414
|
// Ignore values that are not at the bit level as they might be handled elsewhere
|
|
301
415
|
const parent = this.getParentNode(route);
|
|
302
416
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.bitsValue)
|
|
303
|
-
return;
|
|
417
|
+
return true;
|
|
304
418
|
const { level, label } = n;
|
|
305
419
|
const levelKey = node.key === NodeType.ratingLevelStart ? PropertyTag.ratingLevelStart : PropertyTag.ratingLevelEnd;
|
|
306
|
-
this.writeProperty(levelKey, level,
|
|
420
|
+
this.writeProperty(levelKey, level, {
|
|
421
|
+
format: PropertyFormat.trimmedString,
|
|
422
|
+
single: true,
|
|
423
|
+
ignoreEmpty: true,
|
|
424
|
+
});
|
|
307
425
|
if (label) {
|
|
308
|
-
this.writeProperty('label', label,
|
|
426
|
+
this.writeProperty('label', label, {
|
|
427
|
+
format: PropertyFormat.bitmarkMinusMinus,
|
|
428
|
+
single: true,
|
|
429
|
+
ignoreEmpty: true,
|
|
430
|
+
});
|
|
309
431
|
}
|
|
432
|
+
return false;
|
|
310
433
|
}
|
|
311
|
-
// bitmarkAst -> bits -> bitsValue ->
|
|
434
|
+
// bitmarkAst -> bits -> bitsValue -> markConfig
|
|
435
|
+
enter_markConfig(_node, _route) {
|
|
436
|
+
// Handler so markConfig is not processed by the default property handler
|
|
437
|
+
// Continue traversal
|
|
438
|
+
return true;
|
|
439
|
+
}
|
|
440
|
+
// bitmarkAst -> bits -> bitsValue -> markConfig -> markConfigValue
|
|
312
441
|
enter_markConfigValue(node, route) {
|
|
313
442
|
const markConfig = node.value;
|
|
314
443
|
// Ignore values that are not at the correct level as they might be handled elsewhere
|
|
315
444
|
const parent = this.getParentNode(route);
|
|
316
445
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.markConfig)
|
|
317
|
-
return;
|
|
446
|
+
return true;
|
|
318
447
|
const { mark, color, emphasis } = markConfig;
|
|
319
448
|
if (mark) {
|
|
320
|
-
this.writeProperty('mark', mark,
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
449
|
+
this.writeProperty('mark', mark, {
|
|
450
|
+
format: PropertyFormat.trimmedString,
|
|
451
|
+
single: true,
|
|
452
|
+
ignoreEmpty: true,
|
|
453
|
+
});
|
|
454
|
+
if (color) {
|
|
455
|
+
this.writeProperty('color', color, {
|
|
456
|
+
format: PropertyFormat.trimmedString,
|
|
457
|
+
single: true,
|
|
458
|
+
ignoreEmpty: true,
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
if (emphasis) {
|
|
462
|
+
this.writeProperty('emphasis', emphasis, {
|
|
463
|
+
format: PropertyFormat.trimmedString,
|
|
464
|
+
single: true,
|
|
465
|
+
ignoreEmpty: true,
|
|
466
|
+
});
|
|
467
|
+
}
|
|
325
468
|
this.writeNL();
|
|
326
469
|
}
|
|
470
|
+
// Stop traversal of this branch
|
|
471
|
+
return false;
|
|
327
472
|
}
|
|
328
473
|
// bitmarkAst -> bits -> bitsValue -> partialAnswer
|
|
474
|
+
enter_partialAnswer(node, _route) {
|
|
475
|
+
this.writeProperty('partialAnswer', node.value, {
|
|
476
|
+
format: PropertyFormat.trimmedString,
|
|
477
|
+
single: true,
|
|
478
|
+
ignoreEmpty: true,
|
|
479
|
+
});
|
|
480
|
+
// Stop traversal of this branch
|
|
481
|
+
return false;
|
|
482
|
+
}
|
|
329
483
|
// bitmarkAst -> bits -> bitsValue -> questions -> questionsValue -> partialAnswer
|
|
330
484
|
leaf_partialAnswer(node, _route) {
|
|
331
|
-
this.writeProperty('partialAnswer', node.value
|
|
485
|
+
this.writeProperty('partialAnswer', node.value, {
|
|
486
|
+
format: PropertyFormat.trimmedString,
|
|
487
|
+
single: true,
|
|
488
|
+
ignoreEmpty: true,
|
|
489
|
+
});
|
|
490
|
+
// Stop traversal of this branch
|
|
491
|
+
return false;
|
|
332
492
|
}
|
|
333
493
|
// bitmarkAst -> bits -> bitsValue -> sampleSolution
|
|
334
494
|
// bitmarkAst -> bits -> bitsValue -> questions -> questionsValue -> sampleSolution
|
|
495
|
+
enter_sampleSolution(node, _route) {
|
|
496
|
+
this.writeProperty('sampleSolution', node.value, {
|
|
497
|
+
format: PropertyFormat.trimmedString,
|
|
498
|
+
single: true,
|
|
499
|
+
ignoreEmpty: true,
|
|
500
|
+
});
|
|
501
|
+
// Stop traversal of this branch
|
|
502
|
+
return false;
|
|
503
|
+
}
|
|
335
504
|
leaf_sampleSolution(node, _route) {
|
|
336
|
-
this.writeProperty('sampleSolution', node.value
|
|
505
|
+
this.writeProperty('sampleSolution', node.value, {
|
|
506
|
+
format: PropertyFormat.trimmedString,
|
|
507
|
+
single: true,
|
|
508
|
+
ignoreEmpty: true,
|
|
509
|
+
});
|
|
510
|
+
// Stop traversal of this branch
|
|
511
|
+
return false;
|
|
337
512
|
}
|
|
338
513
|
// bitmarkAst -> bits -> bitsValue -> reasonableNumOfChars
|
|
339
514
|
// bitmarkAst -> bits -> bitsValue -> questions -> questionsValue -> reasonableNumOfChars
|
|
340
515
|
leaf_reasonableNumOfChars(node, _route) {
|
|
341
|
-
this.writeProperty('reasonableNumOfChars', node.value
|
|
516
|
+
this.writeProperty('reasonableNumOfChars', node.value, {
|
|
517
|
+
format: PropertyFormat.trimmedString,
|
|
518
|
+
single: true,
|
|
519
|
+
ignoreEmpty: true,
|
|
520
|
+
});
|
|
342
521
|
}
|
|
343
522
|
// bitmarkAst -> bits -> bitsValue -> questions -> questionsValue -> additionalSolutions
|
|
344
523
|
between_additionalSolutions(_node, _left, _right, route) {
|
|
@@ -354,60 +533,244 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
354
533
|
const parent = this.getParentNode(route, 2);
|
|
355
534
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.questionsValue)
|
|
356
535
|
return;
|
|
357
|
-
this.writeProperty('additionalSolutions', node.value
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
536
|
+
this.writeProperty('additionalSolutions', node.value, {
|
|
537
|
+
format: PropertyFormat.trimmedString,
|
|
538
|
+
single: false,
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
// bitmarkAst -> bits -> bitsValue -> item
|
|
542
|
+
enter_item(node, route) {
|
|
543
|
+
var _a, _b, _c;
|
|
544
|
+
const item = node.value;
|
|
545
|
+
const parent = this.getParentNode(route);
|
|
546
|
+
if (this.isEmptyText(item))
|
|
547
|
+
return false; // Ignore empty
|
|
548
|
+
if (!this.isEmptyText((_a = parent === null || parent === void 0 ? void 0 : parent.value) === null || _a === void 0 ? void 0 : _a.lead))
|
|
549
|
+
return true; // Will be handled by lead
|
|
550
|
+
if (!this.isEmptyText((_b = parent === null || parent === void 0 ? void 0 : parent.value) === null || _b === void 0 ? void 0 : _b.pageNumber))
|
|
551
|
+
return true; // Will be handled by pageNumber
|
|
552
|
+
if (!this.isEmptyText((_c = parent === null || parent === void 0 ? void 0 : parent.value) === null || _c === void 0 ? void 0 : _c.marginNumber))
|
|
553
|
+
return true; // Will be handled by marginNumber
|
|
554
|
+
this.writeOPC();
|
|
555
|
+
this.textGenerator.generateSync(item, TextFormat.bitmarkMinusMinus);
|
|
556
|
+
this.writeCL();
|
|
557
|
+
return true;
|
|
558
|
+
}
|
|
559
|
+
// bitmarkAst -> bits -> bitsValue -> lead
|
|
560
|
+
enter_lead(node, route) {
|
|
561
|
+
var _a, _b, _c, _d;
|
|
562
|
+
const lead = node.value;
|
|
563
|
+
const parent = this.getParentNode(route);
|
|
564
|
+
if (this.isEmptyText(lead))
|
|
565
|
+
return false; // Ignore empty
|
|
566
|
+
if (!this.isEmptyText((_a = parent === null || parent === void 0 ? void 0 : parent.value) === null || _a === void 0 ? void 0 : _a.pageNumber))
|
|
567
|
+
return true; // Will be handled by pageNumber
|
|
568
|
+
if (!this.isEmptyText((_b = parent === null || parent === void 0 ? void 0 : parent.value) === null || _b === void 0 ? void 0 : _b.marginNumber))
|
|
569
|
+
return true; // Will be handled by marginNumber
|
|
570
|
+
this.writeOPC();
|
|
571
|
+
this.textGenerator.generateSync((_d = (_c = parent === null || parent === void 0 ? void 0 : parent.value) === null || _c === void 0 ? void 0 : _c.item) !== null && _d !== void 0 ? _d : '', TextFormat.bitmarkMinusMinus);
|
|
572
|
+
this.writeCL();
|
|
573
|
+
this.writeOPC();
|
|
574
|
+
this.textGenerator.generateSync(lead, TextFormat.bitmarkMinusMinus);
|
|
575
|
+
this.writeCL();
|
|
576
|
+
return true;
|
|
577
|
+
}
|
|
578
|
+
// bitmarkAst -> bits -> bitsValue -> pageNumber
|
|
579
|
+
enter_pageNumber(node, route) {
|
|
580
|
+
var _a, _b, _c, _d, _e;
|
|
581
|
+
const pageNumber = node.value;
|
|
582
|
+
const parent = this.getParentNode(route);
|
|
583
|
+
if (this.isEmptyText(pageNumber))
|
|
584
|
+
return false; // Ignore empty
|
|
585
|
+
if (!this.isEmptyText((_a = parent === null || parent === void 0 ? void 0 : parent.value) === null || _a === void 0 ? void 0 : _a.marginNumber))
|
|
586
|
+
return true; // Will be handled by marginNumber
|
|
587
|
+
this.writeOPC();
|
|
588
|
+
this.textGenerator.generateSync((_c = (_b = parent === null || parent === void 0 ? void 0 : parent.value) === null || _b === void 0 ? void 0 : _b.item) !== null && _c !== void 0 ? _c : '', TextFormat.bitmarkMinusMinus);
|
|
589
|
+
this.writeCL();
|
|
590
|
+
this.writeOPC();
|
|
591
|
+
this.textGenerator.generateSync((_e = (_d = parent === null || parent === void 0 ? void 0 : parent.value) === null || _d === void 0 ? void 0 : _d.lead) !== null && _e !== void 0 ? _e : '', TextFormat.bitmarkMinusMinus);
|
|
592
|
+
this.writeCL();
|
|
593
|
+
this.writeOPC();
|
|
594
|
+
this.textGenerator.generateSync(pageNumber !== null && pageNumber !== void 0 ? pageNumber : '', TextFormat.bitmarkMinusMinus);
|
|
595
|
+
this.writeCL();
|
|
596
|
+
return true;
|
|
597
|
+
}
|
|
598
|
+
// bitmarkAst -> bits -> bitsValue -> marginNumber
|
|
599
|
+
enter_marginNumber(node, route) {
|
|
600
|
+
var _a, _b, _c, _d, _e, _f;
|
|
601
|
+
const marginNumber = node.value;
|
|
602
|
+
const parent = this.getParentNode(route);
|
|
603
|
+
if (this.isEmptyText(marginNumber))
|
|
604
|
+
return false; // Ignore empty
|
|
605
|
+
this.writeOPC();
|
|
606
|
+
this.textGenerator.generateSync((_b = (_a = parent === null || parent === void 0 ? void 0 : parent.value) === null || _a === void 0 ? void 0 : _a.item) !== null && _b !== void 0 ? _b : '', TextFormat.bitmarkMinusMinus);
|
|
607
|
+
this.writeCL();
|
|
608
|
+
this.writeOPC();
|
|
609
|
+
this.textGenerator.generateSync((_d = (_c = parent === null || parent === void 0 ? void 0 : parent.value) === null || _c === void 0 ? void 0 : _c.lead) !== null && _d !== void 0 ? _d : '', TextFormat.bitmarkMinusMinus);
|
|
610
|
+
this.writeCL();
|
|
611
|
+
this.writeOPC();
|
|
612
|
+
this.textGenerator.generateSync((_f = (_e = parent === null || parent === void 0 ? void 0 : parent.value) === null || _e === void 0 ? void 0 : _e.pageNumber) !== null && _f !== void 0 ? _f : '', TextFormat.bitmarkMinusMinus);
|
|
613
|
+
this.writeCL();
|
|
614
|
+
this.writeOPC();
|
|
615
|
+
this.textGenerator.generateSync(marginNumber, TextFormat.bitmarkMinusMinus);
|
|
616
|
+
this.writeCL();
|
|
617
|
+
return true;
|
|
383
618
|
}
|
|
384
619
|
// bitmarkAst -> bits -> bitsValue -> body
|
|
385
620
|
enter_body(node, route) {
|
|
621
|
+
var _a;
|
|
622
|
+
// Ignore values that are not at the bit level as they might be handled elsewhere
|
|
623
|
+
const parent = this.getParentNode(route);
|
|
624
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.bitsValue && (parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.cardBitsValue)
|
|
625
|
+
return true;
|
|
626
|
+
this.inTag = false;
|
|
386
627
|
// always write a NL before the body content if there is any?
|
|
387
628
|
const body = node.value;
|
|
388
|
-
|
|
629
|
+
const textFormat = this.getTextFormat(route);
|
|
630
|
+
const isBitmarkText = textFormat === TextFormat.bitmarkPlusPlus || textFormat === TextFormat.bitmarkMinusMinus;
|
|
631
|
+
// Handle body
|
|
632
|
+
if (textFormat === TextFormat.json) {
|
|
633
|
+
const json = (_a = body.body) !== null && _a !== void 0 ? _a : null;
|
|
634
|
+
if (Array.isArray(json) || ObjectUtils.isObject(json)) {
|
|
635
|
+
const text = JSON.stringify(json, null, this.prettifySpace);
|
|
636
|
+
if (text) {
|
|
637
|
+
this.writeNL();
|
|
638
|
+
this.writePlainTextDivider();
|
|
639
|
+
this.writeNL();
|
|
640
|
+
this.write(Breakscape.breakscape(text, {
|
|
641
|
+
textFormat: TextFormat.text,
|
|
642
|
+
}));
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
else if (isBitmarkText) {
|
|
647
|
+
// handle bitmark text
|
|
648
|
+
this.writeNL();
|
|
649
|
+
// The text generator will write to the writer
|
|
650
|
+
const b = (Array.isArray(body.body) ? body.body : []);
|
|
651
|
+
this.textGenerator.generateSync(b, textFormat);
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
// handle plain text
|
|
655
|
+
this.writeNL();
|
|
656
|
+
this.writePlainTextDivider();
|
|
389
657
|
this.writeNL();
|
|
390
|
-
|
|
391
|
-
|
|
658
|
+
const s = (StringUtils.isString(body.body) ? body.body : '');
|
|
659
|
+
this.write(Breakscape.breakscape(`${s}`, {
|
|
660
|
+
textFormat: TextFormat.text,
|
|
661
|
+
}));
|
|
662
|
+
this.writeNL();
|
|
663
|
+
}
|
|
664
|
+
// Stop traversal of this branch
|
|
665
|
+
return false;
|
|
666
|
+
// if ((body.body && body.body.length > 0) || body.bodyJson) {
|
|
667
|
+
// this.writeNL();
|
|
668
|
+
// // Write the plain text divider if not bitmark++/-- format
|
|
669
|
+
// const textFormat = this.getTextFormat(route);
|
|
670
|
+
// const isBitmarkText = textFormat === TextFormat.bitmarkPlusPlus || textFormat === TextFormat.bitmarkMinusMinus;
|
|
671
|
+
// if (!isBitmarkText) {
|
|
672
|
+
// this.writePlainTextDivider();
|
|
673
|
+
// this.writeNL();
|
|
674
|
+
// }
|
|
675
|
+
// }
|
|
676
|
+
}
|
|
677
|
+
exit_body(_node, _route) {
|
|
678
|
+
this.inTag = true;
|
|
679
|
+
}
|
|
680
|
+
bodyBitCallback(bodyBit, _index, _route) {
|
|
681
|
+
// console.log('bodyBitCallback', bodyBit, index, route);
|
|
682
|
+
var _a;
|
|
683
|
+
// Walk the body bit AST
|
|
684
|
+
const nodeType = (_a = NodeType.fromValue(bodyBit.type)) !== null && _a !== void 0 ? _a : NodeType.bodyBit;
|
|
685
|
+
this.ast.walk(bodyBit, nodeType, this, undefined);
|
|
686
|
+
return ''; // Return empty string as we are writing to the writer
|
|
687
|
+
}
|
|
688
|
+
// bodyBit -> gap
|
|
689
|
+
enter_gap(node, _route) {
|
|
690
|
+
const gap = node.value;
|
|
691
|
+
if (gap.solutions && gap.solutions.length === 0) {
|
|
692
|
+
// If there are no solutions, we need to write the special cloze gap [_] to indicate this
|
|
693
|
+
this.writeOPU();
|
|
694
|
+
this.writeCL();
|
|
695
|
+
}
|
|
696
|
+
else {
|
|
697
|
+
for (const solution of gap.solutions) {
|
|
698
|
+
this.writeOPU();
|
|
699
|
+
this.writeBreakscapedTagString(solution);
|
|
700
|
+
this.writeCL();
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
// Continue traversal
|
|
704
|
+
return true;
|
|
705
|
+
}
|
|
706
|
+
// bodyBit -> mark
|
|
707
|
+
enter_mark(node, _route) {
|
|
708
|
+
const mark = node.value;
|
|
709
|
+
this.writeOPE();
|
|
710
|
+
this.writeBreakscapedTagString(mark.solution);
|
|
711
|
+
this.writeCL();
|
|
712
|
+
// Continue traversal
|
|
713
|
+
return true;
|
|
714
|
+
}
|
|
715
|
+
// bodyBit -> select
|
|
716
|
+
enter_select(_node, _route) {
|
|
717
|
+
// Continue traversal
|
|
718
|
+
return true;
|
|
719
|
+
}
|
|
720
|
+
// bodyBit -> highlight
|
|
721
|
+
enter_highlight(_node, _route) {
|
|
722
|
+
// Continue traversal
|
|
723
|
+
return true;
|
|
724
|
+
}
|
|
725
|
+
// bitmarkAst -> bits -> footer
|
|
726
|
+
enter_footer(node, route) {
|
|
727
|
+
const parent = this.getParentNode(route);
|
|
728
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.bitsValue)
|
|
729
|
+
return true;
|
|
730
|
+
const footer = node.value;
|
|
731
|
+
const textFormat = this.getTextFormat(route);
|
|
732
|
+
// Handle footer
|
|
733
|
+
if (textFormat === TextFormat.json) {
|
|
734
|
+
// Json footer?!
|
|
735
|
+
// Not valid, ignore
|
|
736
|
+
}
|
|
737
|
+
else if (footer.footer && footer.footer.length > 0) {
|
|
392
738
|
const isBitmarkText = textFormat === TextFormat.bitmarkPlusPlus || textFormat === TextFormat.bitmarkMinusMinus;
|
|
393
|
-
if (
|
|
394
|
-
|
|
739
|
+
if (isBitmarkText) {
|
|
740
|
+
// handle bitmark text
|
|
741
|
+
this.write('~~~~');
|
|
395
742
|
this.writeNL();
|
|
743
|
+
// The text generator will write to the writer
|
|
744
|
+
this.textGenerator.generateSync(footer.footer, TextFormat.text);
|
|
745
|
+
}
|
|
746
|
+
else {
|
|
747
|
+
// Plain text footer?!
|
|
748
|
+
// Not valid, ignore (plain text cannot have a card set / footer marker, so cannot have a footer!
|
|
396
749
|
}
|
|
397
750
|
}
|
|
751
|
+
// Stop traversal of this branch
|
|
752
|
+
return false;
|
|
398
753
|
}
|
|
399
754
|
// bitmarkAst -> bits -> bitsValue -> body -> bodyParts -> bodyPartsValue -> data -> solutions
|
|
400
|
-
enter_solutions(node,
|
|
755
|
+
enter_solutions(node, route) {
|
|
756
|
+
const parent = this.getParentNode(route);
|
|
757
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.bitsValue)
|
|
758
|
+
return true;
|
|
401
759
|
const solutions = node.value;
|
|
402
760
|
if (solutions && solutions.length === 0) {
|
|
403
761
|
// If there are no solutions, we need to write the special cloze gap [_] to indicate this
|
|
404
762
|
this.writeOPU();
|
|
405
763
|
this.writeCL();
|
|
406
764
|
}
|
|
765
|
+
// Continue traversal
|
|
766
|
+
return true;
|
|
407
767
|
}
|
|
408
768
|
// bitmarkAst -> bits -> bitsValue -> body -> bodyParts -> bodyPartsValue -> data -> solution
|
|
409
769
|
leaf_solution(node, route) {
|
|
410
770
|
var _a;
|
|
771
|
+
const parent = this.getParentNode(route);
|
|
772
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.bitsValue)
|
|
773
|
+
return;
|
|
411
774
|
const solution = node.value;
|
|
412
775
|
// Ignore values that are not at the correct level as they might be handled elsewhere
|
|
413
776
|
const bodyPartsValue = (_a = this.getParentNode(route, 2)) === null || _a === void 0 ? void 0 : _a.value;
|
|
@@ -415,20 +778,22 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
415
778
|
return;
|
|
416
779
|
if (solution) {
|
|
417
780
|
this.writeOPE();
|
|
418
|
-
this.
|
|
781
|
+
this.writeBreakscapedTagString(solution);
|
|
419
782
|
this.writeCL();
|
|
420
783
|
}
|
|
421
784
|
}
|
|
422
|
-
// bitmarkAst -> bits -> bitsValue -> body ->
|
|
785
|
+
// bitmarkAst -> bits -> bitsValue -> body -> bodyBit -> mark -> mark
|
|
423
786
|
leaf_mark(node, route) {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
// Ignore values that are not at the correct level as they might be handled elsewhere
|
|
427
|
-
const bodyPartsValue = (_a = this.getParentNode(route, 2)) === null || _a === void 0 ? void 0 : _a.value;
|
|
428
|
-
if ((bodyPartsValue === null || bodyPartsValue === void 0 ? void 0 : bodyPartsValue.type) !== BodyBitType.mark)
|
|
787
|
+
const root = route[0];
|
|
788
|
+
if ((root === null || root === void 0 ? void 0 : root.key) !== NodeType.mark)
|
|
429
789
|
return;
|
|
790
|
+
const mark = node.value;
|
|
430
791
|
if (mark) {
|
|
431
|
-
this.writeProperty('mark', mark,
|
|
792
|
+
this.writeProperty('mark', mark, {
|
|
793
|
+
format: PropertyFormat.trimmedString,
|
|
794
|
+
single: true,
|
|
795
|
+
ignoreEmpty: true,
|
|
796
|
+
});
|
|
432
797
|
}
|
|
433
798
|
}
|
|
434
799
|
// bitmarkAst -> bits -> bitsValue -> body -> bodyParts -> bodyPartsValue -> data -> options -> optionsValue
|
|
@@ -442,6 +807,8 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
442
807
|
}
|
|
443
808
|
this.write(selectOption.text);
|
|
444
809
|
this.writeCL();
|
|
810
|
+
// Continue traversal
|
|
811
|
+
return true;
|
|
445
812
|
}
|
|
446
813
|
// bitmarkAst -> bits -> bitsValue -> body -> bodyParts -> bodyPartsValue -> data -> texts -> textsValue
|
|
447
814
|
enter_textsValue(node, _route) {
|
|
@@ -454,15 +821,19 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
454
821
|
}
|
|
455
822
|
this.write(highlightText.text);
|
|
456
823
|
this.writeCL();
|
|
824
|
+
// Continue traversal
|
|
825
|
+
return true;
|
|
457
826
|
}
|
|
458
827
|
// bitmarkAst -> bits -> bitsValue -> cardNode
|
|
459
828
|
enter_cardNode(_node, route) {
|
|
460
829
|
// Ignore cards for xxx-1
|
|
461
830
|
const isBitType1 = this.isOfBitType1(route);
|
|
462
831
|
if (isBitType1)
|
|
463
|
-
return;
|
|
832
|
+
return true;
|
|
464
833
|
this.writeCardSetStart();
|
|
465
834
|
this.writeNL();
|
|
835
|
+
// Continue traversal
|
|
836
|
+
return true;
|
|
466
837
|
}
|
|
467
838
|
between_cardNode(_node, _left, _right, route) {
|
|
468
839
|
// Ignore cards for xxx-1
|
|
@@ -504,26 +875,29 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
504
875
|
}
|
|
505
876
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> flashcards -> flashcardsValue
|
|
506
877
|
between_flashcardsValue(_node, _left, right, _route) {
|
|
878
|
+
var _a;
|
|
507
879
|
if (right.key === NodeType.answer) {
|
|
508
880
|
this.writeNL();
|
|
509
881
|
this.writeCardSetSideDivider();
|
|
510
882
|
this.writeNL();
|
|
511
883
|
}
|
|
512
|
-
else if (right.key === NodeType.alternativeAnswers) {
|
|
884
|
+
else if (right.key === NodeType.alternativeAnswers && ((_a = right.value) === null || _a === void 0 ? void 0 : _a.length) !== 0) {
|
|
513
885
|
this.writeNL();
|
|
514
886
|
this.writeCardSetVariantDivider();
|
|
515
887
|
this.writeNL();
|
|
516
888
|
}
|
|
517
889
|
}
|
|
518
890
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> flashcards -> flashcardsValue -> answer
|
|
519
|
-
|
|
891
|
+
enter_answer(node, route) {
|
|
520
892
|
// Ignore responses that are not at the flashcardsValue level as they are handled elsewhere
|
|
521
893
|
const parent = this.getParentNode(route);
|
|
522
894
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.flashcardsValue)
|
|
523
|
-
return;
|
|
895
|
+
return true;
|
|
524
896
|
if (node.value) {
|
|
525
|
-
this.
|
|
897
|
+
this.textGenerator.generateSync(node.value, TextFormat.bitmarkMinusMinus);
|
|
526
898
|
}
|
|
899
|
+
// Stop traversal of this branch
|
|
900
|
+
return false;
|
|
527
901
|
}
|
|
528
902
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> flashcards -> flashcardsValue -> alternativeAnswers
|
|
529
903
|
between_alternativeAnswers(_node, _route) {
|
|
@@ -532,30 +906,38 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
532
906
|
this.writeNL();
|
|
533
907
|
}
|
|
534
908
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> flashcards -> flashcardsValue -> alternativeAnswers -> alternativeAnswersValue
|
|
535
|
-
|
|
909
|
+
enter_alternativeAnswersValue(node, route) {
|
|
536
910
|
// Ignore responses that are not at the alternativeAnswers level as they are handled elsewhere
|
|
537
911
|
const parent = this.getParentNode(route);
|
|
538
912
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.alternativeAnswers)
|
|
539
|
-
return;
|
|
913
|
+
return true;
|
|
540
914
|
if (node.value) {
|
|
541
|
-
this.
|
|
915
|
+
// this.writeBreakscapedTagString(node.value);
|
|
916
|
+
this.textGenerator.generateSync(node.value, TextFormat.bitmarkMinusMinus);
|
|
542
917
|
}
|
|
918
|
+
// Stop traversal of this branch
|
|
919
|
+
return false;
|
|
543
920
|
}
|
|
544
|
-
// bitmarkAst -> bits -> bitsValue -> cardNode -> definitions -> definitionsValue ->
|
|
921
|
+
// bitmarkAst -> bits -> bitsValue -> cardNode -> definitions -> definitionsValue -> alternativeDefintions
|
|
545
922
|
between_alternativeDefinitions(_node, _route) {
|
|
546
923
|
this.writeNL();
|
|
547
924
|
this.writeCardSetVariantDivider();
|
|
548
925
|
this.writeNL();
|
|
549
926
|
}
|
|
550
927
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> definitions -> definitionsValue -> alternativeDefinitions -> alternativeDefinitionsValue
|
|
551
|
-
|
|
552
|
-
// Ignore responses that are not at the
|
|
928
|
+
enter_alternativeDefinitionsValue(node, route) {
|
|
929
|
+
// Ignore responses that are not at the alternativeAnswers level as they are handled elsewhere
|
|
553
930
|
const parent = this.getParentNode(route);
|
|
554
931
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.alternativeDefinitions)
|
|
555
|
-
return;
|
|
932
|
+
return true;
|
|
556
933
|
if (node.value) {
|
|
557
|
-
this.
|
|
934
|
+
// this.writeNL();
|
|
935
|
+
// this.writeCardSetVariantDivider();
|
|
936
|
+
// this.writeNL();
|
|
937
|
+
this.textGenerator.generateSync(node.value, TextFormat.bitmarkMinusMinus);
|
|
558
938
|
}
|
|
939
|
+
// Stop traversal of this branch
|
|
940
|
+
return false;
|
|
559
941
|
}
|
|
560
942
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> statements
|
|
561
943
|
enter_statements(_node, _route) {
|
|
@@ -581,8 +963,10 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
581
963
|
else {
|
|
582
964
|
this.writeOPM();
|
|
583
965
|
}
|
|
584
|
-
this.write(statement.
|
|
966
|
+
this.write(statement.statement);
|
|
585
967
|
this.writeCL();
|
|
968
|
+
// Continue traversal
|
|
969
|
+
return true;
|
|
586
970
|
}
|
|
587
971
|
// bitmarkAst -> bits -> bitsValue -> choices
|
|
588
972
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> quizzes -> quizzesValue -> choices
|
|
@@ -602,8 +986,10 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
602
986
|
else {
|
|
603
987
|
this.writeOPM();
|
|
604
988
|
}
|
|
605
|
-
this.write(choice.
|
|
989
|
+
this.write(choice.choice);
|
|
606
990
|
this.writeCL();
|
|
991
|
+
// Continue traversal
|
|
992
|
+
return true;
|
|
607
993
|
}
|
|
608
994
|
// bitmarkAst -> bits -> bitsValue -> responses
|
|
609
995
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> quizzes -> quizzesValue -> responses
|
|
@@ -623,8 +1009,10 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
623
1009
|
else {
|
|
624
1010
|
this.writeOPM();
|
|
625
1011
|
}
|
|
626
|
-
this.write(response.
|
|
1012
|
+
this.write(response.response);
|
|
627
1013
|
this.writeCL();
|
|
1014
|
+
// Continue traversal
|
|
1015
|
+
return true;
|
|
628
1016
|
}
|
|
629
1017
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> quizzes
|
|
630
1018
|
enter_quizzes(_node, _route) {
|
|
@@ -688,13 +1076,17 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
688
1076
|
enter_keyAudio(node, _route) {
|
|
689
1077
|
const resource = node.value;
|
|
690
1078
|
// This is a resource, so handle it with the common code
|
|
691
|
-
this.writeResource(resource);
|
|
1079
|
+
this.writeResource(ResourceTag.audio, resource.src);
|
|
1080
|
+
// Stop traversal of this branch
|
|
1081
|
+
return false;
|
|
692
1082
|
}
|
|
693
1083
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> pairs -> pairsValue -> keyImage
|
|
694
1084
|
enter_keyImage(node, _route) {
|
|
695
1085
|
const resource = node.value;
|
|
696
1086
|
// This is a resource, so handle it with the common code
|
|
697
|
-
this.writeResource(resource);
|
|
1087
|
+
this.writeResource(ResourceTag.image, resource.src);
|
|
1088
|
+
// Stop traversal of this branch
|
|
1089
|
+
return false;
|
|
698
1090
|
}
|
|
699
1091
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> matrix
|
|
700
1092
|
enter_matrix(_node, _route) {
|
|
@@ -733,8 +1125,8 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
733
1125
|
this.writeCardSetCardDivider();
|
|
734
1126
|
this.writeNL();
|
|
735
1127
|
}
|
|
736
|
-
// bitmarkAst -> bits -> bitsValue -> cardNode -> table ->
|
|
737
|
-
|
|
1128
|
+
// bitmarkAst -> bits -> bitsValue -> cardNode -> table -> data
|
|
1129
|
+
between_data(_node, _left, _right, route) {
|
|
738
1130
|
const parent = this.getParentNode(route);
|
|
739
1131
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.table)
|
|
740
1132
|
return;
|
|
@@ -758,20 +1150,23 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
758
1150
|
leaf_columnsValue(node, _route) {
|
|
759
1151
|
this.writeOPHASH();
|
|
760
1152
|
if (node.value)
|
|
761
|
-
this.
|
|
1153
|
+
this.writeBreakscapedTagString(node.value);
|
|
762
1154
|
this.writeCL();
|
|
763
1155
|
}
|
|
764
|
-
// bitmarkAst -> bits -> bitsValue -> cardNode -> table ->
|
|
765
|
-
|
|
766
|
-
const parent = this.getParentNode(route);
|
|
767
|
-
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.
|
|
1156
|
+
// bitmarkAst -> bits -> bitsValue -> cardNode -> table -> data -> dataValue
|
|
1157
|
+
between_dataValue(_node, _left, _right, route) {
|
|
1158
|
+
const parent = this.getParentNode(route, 2);
|
|
1159
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.table)
|
|
768
1160
|
return;
|
|
769
1161
|
this.writeNL();
|
|
770
1162
|
this.writeCardSetSideDivider();
|
|
771
1163
|
this.writeNL();
|
|
772
1164
|
}
|
|
773
|
-
// bitmarkAst -> bits -> bitsValue -> cardNode -> table ->
|
|
774
|
-
|
|
1165
|
+
// bitmarkAst -> bits -> bitsValue -> cardNode -> table -> data -> dataValue -> dataValueValue
|
|
1166
|
+
leaf_dataValueValue(node, route) {
|
|
1167
|
+
const parent = this.getParentNode(route, 3);
|
|
1168
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.table)
|
|
1169
|
+
return;
|
|
775
1170
|
if (node.value)
|
|
776
1171
|
this.write(node.value);
|
|
777
1172
|
}
|
|
@@ -800,23 +1195,49 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
800
1195
|
// this.writeCardSetSideDivider();
|
|
801
1196
|
// this.writeNL();
|
|
802
1197
|
// }
|
|
803
|
-
// bitmarkAst -> bits -> bitsValue -> cardNode -> captionDefinitionList -> definitions -> definitionsValue -> term
|
|
804
1198
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> definitions -> definitionsValue -> term
|
|
1199
|
+
enter_term(node, route) {
|
|
1200
|
+
const parent = this.getParentNode(route);
|
|
1201
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.definitionsValue)
|
|
1202
|
+
return true;
|
|
1203
|
+
if (node.value) {
|
|
1204
|
+
this.textGenerator.generateSync(node.value, TextFormat.bitmarkMinusMinus);
|
|
1205
|
+
}
|
|
1206
|
+
// Stop traversal of this branch
|
|
1207
|
+
return false;
|
|
1208
|
+
}
|
|
1209
|
+
// bitmarkAst -> bits -> bitsValue -> cardNode -> captionDefinitionList -> definitions -> definitionsValue -> term
|
|
805
1210
|
leaf_term(node, route) {
|
|
806
1211
|
const parent = this.getParentNode(route);
|
|
807
1212
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.definitionsValue)
|
|
808
|
-
return;
|
|
809
|
-
if (node.value)
|
|
1213
|
+
return true;
|
|
1214
|
+
if (node.value) {
|
|
810
1215
|
this.write(node.value);
|
|
1216
|
+
}
|
|
1217
|
+
// Stop traversal of this branch
|
|
1218
|
+
return false;
|
|
811
1219
|
}
|
|
812
|
-
// bitmarkAst -> bits -> bitsValue -> cardNode ->
|
|
813
|
-
|
|
814
|
-
leaf_description(node, route) {
|
|
1220
|
+
// bitmarkAst -> bits -> bitsValue -> cardNode -> definitions -> definitionsValue -> definition
|
|
1221
|
+
enter_definition(node, route) {
|
|
815
1222
|
const parent = this.getParentNode(route);
|
|
816
1223
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.definitionsValue)
|
|
817
|
-
return;
|
|
818
|
-
if (node.value)
|
|
1224
|
+
return true;
|
|
1225
|
+
if (node.value) {
|
|
1226
|
+
this.textGenerator.generateSync(node.value, TextFormat.bitmarkMinusMinus);
|
|
1227
|
+
}
|
|
1228
|
+
// Stop traversal of this branch
|
|
1229
|
+
return false;
|
|
1230
|
+
}
|
|
1231
|
+
// bitmarkAst -> bits -> bitsValue -> cardNode -> captionDefinitionList -> definitions -> definitionsValue -> definition
|
|
1232
|
+
leaf_definition(node, route) {
|
|
1233
|
+
const parent = this.getParentNode(route);
|
|
1234
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.definitionsValue)
|
|
1235
|
+
return true;
|
|
1236
|
+
if (node.value) {
|
|
819
1237
|
this.write(node.value);
|
|
1238
|
+
}
|
|
1239
|
+
// Stop traversal of this branch
|
|
1240
|
+
return false;
|
|
820
1241
|
}
|
|
821
1242
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> captionDefinitionList -> definitions
|
|
822
1243
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> definitions
|
|
@@ -828,23 +1249,37 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
828
1249
|
this.writeCardSetCardDivider();
|
|
829
1250
|
this.writeNL();
|
|
830
1251
|
}
|
|
831
|
-
// bitmarkAst -> bits -> bitsValue -> cardNode -> captionDefinitionList -> definitions -> definitionsValue
|
|
832
1252
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> definitions -> definitionsValue
|
|
833
1253
|
between_definitionsValue(_node, _left, right, route) {
|
|
1254
|
+
var _a;
|
|
834
1255
|
const parent = this.getParentNode(route);
|
|
835
1256
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.definitions)
|
|
836
1257
|
return;
|
|
837
|
-
if (right.key === NodeType.
|
|
1258
|
+
if (right.key === NodeType.definition) {
|
|
838
1259
|
this.writeNL();
|
|
839
1260
|
this.writeCardSetSideDivider();
|
|
840
1261
|
this.writeNL();
|
|
841
1262
|
}
|
|
842
|
-
else if (right.key === NodeType.alternativeDefinitions) {
|
|
1263
|
+
else if (right.key === NodeType.alternativeDefinitions && ((_a = right.value) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
843
1264
|
this.writeNL();
|
|
844
1265
|
this.writeCardSetVariantDivider();
|
|
845
1266
|
this.writeNL();
|
|
846
1267
|
}
|
|
847
1268
|
}
|
|
1269
|
+
// bitmarkAst -> bits -> bitsValue -> cardNode -> captionDefinitionList -> definitions -> definitionsValue
|
|
1270
|
+
// protected between_definitionsValue(_node: NodeInfo, _left: NodeInfo, right: NodeInfo, route: NodeInfo[]): void {
|
|
1271
|
+
// const parent = this.getParentNode(route);
|
|
1272
|
+
// if (parent?.key !== NodeType.definitions) return;
|
|
1273
|
+
// if (right.key === NodeType.definition) {
|
|
1274
|
+
// this.writeNL();
|
|
1275
|
+
// this.writeCardSetSideDivider();
|
|
1276
|
+
// this.writeNL();
|
|
1277
|
+
// } else if (right.key === NodeType.alternativeDefinitions && right.value?.length > 0) {
|
|
1278
|
+
// this.writeNL();
|
|
1279
|
+
// this.writeCardSetVariantDivider();
|
|
1280
|
+
// this.writeNL();
|
|
1281
|
+
// }
|
|
1282
|
+
// }
|
|
848
1283
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> questions
|
|
849
1284
|
enter_questions(_node, _route) {
|
|
850
1285
|
//
|
|
@@ -884,7 +1319,7 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
884
1319
|
const ingredient = node.value;
|
|
885
1320
|
if (ingredient.title != null) {
|
|
886
1321
|
this.writeOPHASH();
|
|
887
|
-
this.
|
|
1322
|
+
this.writeBreakscapedTagString(ingredient.title);
|
|
888
1323
|
this.writeCL();
|
|
889
1324
|
this.writeNL();
|
|
890
1325
|
}
|
|
@@ -899,24 +1334,42 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
899
1334
|
// [!43]
|
|
900
1335
|
if (ingredient.quantity != null) {
|
|
901
1336
|
this.writeOPB();
|
|
902
|
-
this.
|
|
1337
|
+
this.writeBreakscapedTagString(`${ingredient.quantity}`);
|
|
903
1338
|
this.writeCL();
|
|
904
1339
|
}
|
|
905
1340
|
// [@unit:kilograms]
|
|
906
1341
|
if (ingredient.unit != null)
|
|
907
|
-
this.writeProperty('unit', ingredient.unit,
|
|
1342
|
+
this.writeProperty('unit', ingredient.unit, {
|
|
1343
|
+
format: PropertyFormat.trimmedString,
|
|
1344
|
+
single: true,
|
|
1345
|
+
ignoreEmpty: true,
|
|
1346
|
+
});
|
|
908
1347
|
// [@unitAbbr:kg]
|
|
909
1348
|
if (ingredient.unitAbbr != null)
|
|
910
|
-
this.writeProperty('unitAbbr', ingredient.unitAbbr,
|
|
1349
|
+
this.writeProperty('unitAbbr', ingredient.unitAbbr, {
|
|
1350
|
+
format: PropertyFormat.trimmedString,
|
|
1351
|
+
single: true,
|
|
1352
|
+
ignoreEmpty: true,
|
|
1353
|
+
});
|
|
911
1354
|
// [@decimalPlaces:1]
|
|
912
1355
|
if (ingredient.decimalPlaces != null)
|
|
913
|
-
this.writeProperty('decimalPlaces', ingredient.decimalPlaces,
|
|
1356
|
+
this.writeProperty('decimalPlaces', ingredient.decimalPlaces, {
|
|
1357
|
+
format: PropertyFormat.trimmedString,
|
|
1358
|
+
single: true,
|
|
1359
|
+
ignoreEmpty: true,
|
|
1360
|
+
});
|
|
914
1361
|
// [@disableCalculation]
|
|
915
1362
|
if (ingredient.disableCalculation)
|
|
916
|
-
this.writeProperty('disableCalculation', true,
|
|
1363
|
+
this.writeProperty('disableCalculation', true, {
|
|
1364
|
+
format: PropertyFormat.trimmedString,
|
|
1365
|
+
single: true,
|
|
1366
|
+
ignoreEmpty: true,
|
|
1367
|
+
});
|
|
917
1368
|
// item
|
|
918
1369
|
if (ingredient.item != null)
|
|
919
1370
|
this.write(ingredient.item);
|
|
1371
|
+
// Stop traversal of this branch
|
|
1372
|
+
return false;
|
|
920
1373
|
}
|
|
921
1374
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> botResponses
|
|
922
1375
|
enter_botResponses(_node, _route) {
|
|
@@ -949,37 +1402,42 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
949
1402
|
//
|
|
950
1403
|
}
|
|
951
1404
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> botResponses -> botResponsesValue -> response
|
|
952
|
-
leaf_response(node,
|
|
1405
|
+
leaf_response(node, route) {
|
|
1406
|
+
const parent = this.getParentNode(route);
|
|
1407
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.botResponsesValue)
|
|
1408
|
+
return;
|
|
953
1409
|
this.writeOPB();
|
|
954
|
-
this.
|
|
1410
|
+
this.writeBreakscapedTagString(node.value);
|
|
955
1411
|
this.writeCL();
|
|
956
1412
|
}
|
|
957
1413
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> botResponses -> botResponsesValue -> reaction
|
|
958
|
-
leaf_reaction(node,
|
|
959
|
-
this.
|
|
1414
|
+
leaf_reaction(node, route) {
|
|
1415
|
+
const parent = this.getParentNode(route);
|
|
1416
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.botResponsesValue)
|
|
1417
|
+
return;
|
|
1418
|
+
this.writeProperty('reaction', node.value, {
|
|
1419
|
+
format: PropertyFormat.trimmedString,
|
|
1420
|
+
single: true,
|
|
1421
|
+
ignoreEmpty: true,
|
|
1422
|
+
});
|
|
960
1423
|
}
|
|
961
1424
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> botResponses -> botResponsesValue -> feedback
|
|
962
|
-
leaf_feedback(node,
|
|
1425
|
+
leaf_feedback(node, route) {
|
|
1426
|
+
const parent = this.getParentNode(route);
|
|
1427
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.botResponsesValue)
|
|
1428
|
+
return;
|
|
963
1429
|
const feeback = node.value;
|
|
964
1430
|
if (feeback) {
|
|
965
1431
|
this.write(feeback);
|
|
966
1432
|
}
|
|
967
1433
|
}
|
|
968
|
-
// bitmarkAst -> bits -> bitsValue -> resources
|
|
969
|
-
between_resources(_node, _left, _right, _route) {
|
|
970
|
-
this.writeNL();
|
|
971
|
-
}
|
|
972
|
-
// bitmarkAst -> bits -> bitsValue -> resourcesValue
|
|
973
|
-
enter_resourcesValue(node, _route) {
|
|
974
|
-
const resource = node.value;
|
|
975
|
-
// This is a resource, so handle it with the common code
|
|
976
|
-
this.writeResource(resource);
|
|
977
|
-
}
|
|
978
1434
|
// bitmarkAst -> bits -> bitsValue -> imagePlaceholder
|
|
979
1435
|
enter_imagePlaceholder(node, _route) {
|
|
980
1436
|
const resource = node.value;
|
|
981
1437
|
// This is a resource, so handle it with the common code
|
|
982
1438
|
this.writePropertyStyleResource(node.key, resource);
|
|
1439
|
+
// Continue traversal
|
|
1440
|
+
return true;
|
|
983
1441
|
}
|
|
984
1442
|
exit_imagePlaceholder(_node, _route) {
|
|
985
1443
|
this.writeNL();
|
|
@@ -992,16 +1450,26 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
992
1450
|
// Bit poster image
|
|
993
1451
|
const posterImage = node.value;
|
|
994
1452
|
if (posterImage) {
|
|
995
|
-
this.writeProperty('posterImage', posterImage
|
|
1453
|
+
this.writeProperty('posterImage', posterImage, {
|
|
1454
|
+
format: PropertyFormat.trimmedString,
|
|
1455
|
+
single: true,
|
|
1456
|
+
ignoreEmpty: true,
|
|
1457
|
+
});
|
|
996
1458
|
}
|
|
997
1459
|
}
|
|
998
1460
|
else {
|
|
999
1461
|
// Resource poster image
|
|
1000
1462
|
const posterImage = node.value;
|
|
1001
|
-
if (posterImage && posterImage.
|
|
1002
|
-
this.writeProperty('posterImage', posterImage.
|
|
1463
|
+
if (posterImage && posterImage.src) {
|
|
1464
|
+
this.writeProperty('posterImage', posterImage.src, {
|
|
1465
|
+
format: PropertyFormat.trimmedString,
|
|
1466
|
+
single: true,
|
|
1467
|
+
ignoreEmpty: true,
|
|
1468
|
+
});
|
|
1003
1469
|
}
|
|
1004
1470
|
}
|
|
1471
|
+
// Continue traversal
|
|
1472
|
+
return true;
|
|
1005
1473
|
}
|
|
1006
1474
|
// bitmarkAst -> bits -> bitsValue -> resource -> thumbnails
|
|
1007
1475
|
// [src1x,src2x,src3x,src4x,width,height,alt,zoomDisabled,caption]
|
|
@@ -1015,21 +1483,24 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
1015
1483
|
break;
|
|
1016
1484
|
const thumbnail = thumbnails[i];
|
|
1017
1485
|
const key = thumbnailKeys[i];
|
|
1018
|
-
this.writeProperty(key, thumbnail.
|
|
1486
|
+
this.writeProperty(key, thumbnail.src, {
|
|
1487
|
+
format: PropertyFormat.trimmedString,
|
|
1488
|
+
single: true,
|
|
1489
|
+
ignoreEmpty: true,
|
|
1490
|
+
});
|
|
1019
1491
|
}
|
|
1020
1492
|
}
|
|
1493
|
+
// Stop traversal of this branch
|
|
1494
|
+
return false;
|
|
1021
1495
|
}
|
|
1022
|
-
//
|
|
1023
|
-
// Terminal nodes (leaves)
|
|
1024
|
-
//
|
|
1025
1496
|
// bitmarkAst -> bits -> bitsValue -> bitType
|
|
1026
1497
|
// bitmarkAst -> bits -> bitsValue -> textFormat
|
|
1027
1498
|
// bitmarkAst -> bits -> title
|
|
1028
|
-
|
|
1029
|
-
const parent = this.getParentNode(route);
|
|
1499
|
+
enter_title(node, route) {
|
|
1030
1500
|
// Ensure this is at the bit level
|
|
1501
|
+
const parent = this.getParentNode(route);
|
|
1031
1502
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.bitsValue)
|
|
1032
|
-
return;
|
|
1503
|
+
return true;
|
|
1033
1504
|
const value = node.value;
|
|
1034
1505
|
const title = value;
|
|
1035
1506
|
const bit = parent === null || parent === void 0 ? void 0 : parent.value;
|
|
@@ -1038,12 +1509,18 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
1038
1509
|
this.writeOP();
|
|
1039
1510
|
for (let i = 0; i < +level; i++)
|
|
1040
1511
|
this.writeHash();
|
|
1041
|
-
this.
|
|
1512
|
+
this.textGenerator.generateSync(title, TextFormat.bitmarkMinusMinus);
|
|
1042
1513
|
this.writeCL();
|
|
1043
1514
|
}
|
|
1515
|
+
// Stop traversal of this branch
|
|
1516
|
+
return false;
|
|
1044
1517
|
}
|
|
1045
1518
|
// bitmarkAst -> bits -> subtitle
|
|
1046
|
-
|
|
1519
|
+
enter_subtitle(node, route) {
|
|
1520
|
+
// Ensure this is at the bit level
|
|
1521
|
+
const parent = this.getParentNode(route);
|
|
1522
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.bitsValue)
|
|
1523
|
+
return true;
|
|
1047
1524
|
const value = node.value;
|
|
1048
1525
|
const subtitle = value;
|
|
1049
1526
|
const level = 2;
|
|
@@ -1051,23 +1528,29 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
1051
1528
|
this.writeOP();
|
|
1052
1529
|
for (let i = 0; i < level; i++)
|
|
1053
1530
|
this.writeHash();
|
|
1054
|
-
this.
|
|
1531
|
+
this.textGenerator.generateSync(subtitle, TextFormat.bitmarkMinusMinus);
|
|
1055
1532
|
this.writeCL();
|
|
1056
1533
|
}
|
|
1534
|
+
// Stop traversal of this branch
|
|
1535
|
+
return false;
|
|
1057
1536
|
}
|
|
1058
1537
|
// bitmarkAst -> bits -> bitsValue -> book
|
|
1059
1538
|
leaf_book(node, route) {
|
|
1060
1539
|
const parent = this.getParentNode(route);
|
|
1061
1540
|
const bit = parent === null || parent === void 0 ? void 0 : parent.value;
|
|
1062
1541
|
if (bit && node.value) {
|
|
1063
|
-
this.writeProperty('book', node.value
|
|
1542
|
+
this.writeProperty('book', node.value, {
|
|
1543
|
+
format: PropertyFormat.trimmedString,
|
|
1544
|
+
single: true,
|
|
1545
|
+
ignoreEmpty: false,
|
|
1546
|
+
});
|
|
1064
1547
|
if (bit.reference) {
|
|
1065
1548
|
this.writeOPRANGLE();
|
|
1066
|
-
this.
|
|
1549
|
+
this.writeBreakscapedTagString(bit.reference);
|
|
1067
1550
|
this.writeCL();
|
|
1068
1551
|
if (bit.referenceEnd) {
|
|
1069
1552
|
this.writeOPRANGLE();
|
|
1070
|
-
this.
|
|
1553
|
+
this.writeBreakscapedTagString(bit.referenceEnd);
|
|
1071
1554
|
this.writeCL();
|
|
1072
1555
|
}
|
|
1073
1556
|
}
|
|
@@ -1077,7 +1560,7 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
1077
1560
|
leaf_anchor(node, _route) {
|
|
1078
1561
|
if (node.value) {
|
|
1079
1562
|
this.writeOPDANGLE();
|
|
1080
|
-
this.
|
|
1563
|
+
this.writeBreakscapedTagString(node.value);
|
|
1081
1564
|
this.writeCL();
|
|
1082
1565
|
}
|
|
1083
1566
|
}
|
|
@@ -1089,7 +1572,7 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
1089
1572
|
// Only write reference if it is not chained to 'book'
|
|
1090
1573
|
if (!bit.book) {
|
|
1091
1574
|
this.writeOPRANGLE();
|
|
1092
|
-
this.
|
|
1575
|
+
this.writeBreakscapedTagString(node.value);
|
|
1093
1576
|
this.writeCL();
|
|
1094
1577
|
}
|
|
1095
1578
|
}
|
|
@@ -1097,101 +1580,80 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
1097
1580
|
// * -> itemLead --> item
|
|
1098
1581
|
// * -> itemLead --> lead
|
|
1099
1582
|
// * -> hint
|
|
1100
|
-
|
|
1583
|
+
enter_hint(node, _route) {
|
|
1101
1584
|
const value = node.value;
|
|
1102
1585
|
const text = value;
|
|
1103
|
-
if (text) {
|
|
1586
|
+
if (!this.isEmptyText(text)) {
|
|
1104
1587
|
this.writeOPQ();
|
|
1105
|
-
this.
|
|
1588
|
+
this.textGenerator.generateSync(text, TextFormat.bitmarkMinusMinus);
|
|
1106
1589
|
this.writeCL();
|
|
1107
1590
|
}
|
|
1591
|
+
// Stop traversal of this branch
|
|
1592
|
+
return false;
|
|
1108
1593
|
}
|
|
1109
1594
|
// bitmarkAst -> bits -> bitsValue -> * -> instruction
|
|
1110
|
-
|
|
1595
|
+
enter_instruction(node, _route) {
|
|
1111
1596
|
const value = node.value;
|
|
1112
1597
|
const text = value;
|
|
1113
|
-
if (text) {
|
|
1598
|
+
if (!this.isEmptyText(text)) {
|
|
1114
1599
|
this.writeOPB();
|
|
1115
|
-
this.
|
|
1600
|
+
this.textGenerator.generateSync(text, TextFormat.bitmarkMinusMinus);
|
|
1116
1601
|
this.writeCL();
|
|
1117
1602
|
}
|
|
1603
|
+
// Stop traversal of this branch
|
|
1604
|
+
return false;
|
|
1118
1605
|
}
|
|
1119
|
-
// bitmarkAst -> bits -> bitsValue -> * -> example
|
|
1120
|
-
|
|
1121
|
-
var _a
|
|
1122
|
-
const
|
|
1123
|
-
const parent = this.getParentNode(route);
|
|
1124
|
-
const isExample = (_a = parent === null || parent === void 0 ? void 0 : parent.value.isExample) !== null && _a !== void 0 ? _a : false;
|
|
1125
|
-
const isDefaultExample = (_b = parent === null || parent === void 0 ? void 0 : parent.value.isDefaultExample) !== null && _b !== void 0 ? _b : false;
|
|
1606
|
+
// bitmarkAst -> bits -> bitsValue -> * -> isExample / example
|
|
1607
|
+
leaf_isExample(node, route) {
|
|
1608
|
+
var _a;
|
|
1609
|
+
const isExample = node.value;
|
|
1126
1610
|
if (!isExample)
|
|
1127
1611
|
return;
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
}
|
|
1133
|
-
else if (value != null) {
|
|
1612
|
+
const parent = this.getParentNode(route);
|
|
1613
|
+
const example = (_a = parent === null || parent === void 0 ? void 0 : parent.value.example) !== null && _a !== void 0 ? _a : null;
|
|
1614
|
+
// const __isDefaultExample = parent?.value.__isDefaultExample ?? false;
|
|
1615
|
+
if (example != null && example !== '') {
|
|
1134
1616
|
this.writeOPA();
|
|
1135
1617
|
this.writeString('example');
|
|
1136
1618
|
this.writeColon();
|
|
1137
|
-
if (
|
|
1619
|
+
if (example === true) {
|
|
1138
1620
|
this.writeString('true');
|
|
1139
1621
|
}
|
|
1140
|
-
else if (
|
|
1622
|
+
else if (example === false) {
|
|
1141
1623
|
this.writeString('false');
|
|
1142
1624
|
}
|
|
1625
|
+
else if (Array.isArray(example)) {
|
|
1626
|
+
// TextAst
|
|
1627
|
+
this.textGenerator.generateSync(example, TextFormat.bitmarkMinusMinus);
|
|
1628
|
+
}
|
|
1143
1629
|
else {
|
|
1144
1630
|
// String
|
|
1145
|
-
this.
|
|
1631
|
+
this.writeBreakscapedTagString(example);
|
|
1146
1632
|
}
|
|
1147
1633
|
this.writeCL();
|
|
1148
1634
|
}
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
if (text) {
|
|
1155
|
-
this.writeString(text);
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
// bitmarkAst -> bits -> body -> bodyValue -> bodyJson
|
|
1159
|
-
enter_bodyJson(node, _route) {
|
|
1160
|
-
const value = node.value;
|
|
1161
|
-
if (Array.isArray(value) || ObjectUtils.isObject(value)) {
|
|
1162
|
-
const text = JSON.stringify(value, null, this.prettifySpace);
|
|
1163
|
-
if (text) {
|
|
1164
|
-
this.writeString(text);
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
// Stop traversal of this branch to avoid processing the bodyJson
|
|
1168
|
-
return false;
|
|
1169
|
-
}
|
|
1170
|
-
// bitmarkAst -> bits -> footer
|
|
1171
|
-
enter_footer(_node, _route) {
|
|
1172
|
-
this.write('~~~~');
|
|
1173
|
-
this.writeNL();
|
|
1174
|
-
}
|
|
1175
|
-
// bitmarkAst -> bits -> footer -> footerText
|
|
1176
|
-
leaf_footerText(node, _route) {
|
|
1177
|
-
const value = node.value;
|
|
1178
|
-
const text = value;
|
|
1179
|
-
if (text) {
|
|
1180
|
-
this.writeString(text);
|
|
1635
|
+
else {
|
|
1636
|
+
// Don't write example if it is null.
|
|
1637
|
+
// this.writeOPA();
|
|
1638
|
+
// this.writeString('example');
|
|
1639
|
+
// this.writeCL();
|
|
1181
1640
|
}
|
|
1182
1641
|
}
|
|
1183
1642
|
// bitmarkAst -> bits -> bitsValue -> elements -> elementsValue
|
|
1184
1643
|
leaf_elementsValue(node, _route) {
|
|
1185
1644
|
if (node.value) {
|
|
1186
|
-
this.
|
|
1645
|
+
this.writeBreakscapedTagString(node.value);
|
|
1187
1646
|
}
|
|
1188
1647
|
}
|
|
1189
1648
|
// bitmarkAst -> bits -> bitsValue -> body -> bodyValue -> gap -> solutions -> solution
|
|
1190
1649
|
// ? -> solutions -> solution
|
|
1191
|
-
leaf_solutionsValue(node,
|
|
1650
|
+
leaf_solutionsValue(node, route) {
|
|
1651
|
+
const parent = this.getParentNode(route, 2);
|
|
1652
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.bitsValue)
|
|
1653
|
+
return;
|
|
1192
1654
|
if (node.value != null) {
|
|
1193
1655
|
this.writeOPU();
|
|
1194
|
-
this.
|
|
1656
|
+
this.writeBreakscapedTagString(node.value);
|
|
1195
1657
|
this.writeCL();
|
|
1196
1658
|
}
|
|
1197
1659
|
}
|
|
@@ -1200,7 +1662,7 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
1200
1662
|
leaf_prefix(node, _route) {
|
|
1201
1663
|
if (node.value) {
|
|
1202
1664
|
this.writeOPPRE();
|
|
1203
|
-
this.
|
|
1665
|
+
this.writeBreakscapedTagString(node.value);
|
|
1204
1666
|
this.writeCL();
|
|
1205
1667
|
}
|
|
1206
1668
|
}
|
|
@@ -1209,39 +1671,50 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
1209
1671
|
leaf_postfix(node, _route) {
|
|
1210
1672
|
if (node.value) {
|
|
1211
1673
|
this.writeOPPOST();
|
|
1212
|
-
this.
|
|
1674
|
+
this.writeBreakscapedTagString(node.value);
|
|
1213
1675
|
this.writeCL();
|
|
1214
1676
|
}
|
|
1215
1677
|
}
|
|
1216
1678
|
// bitmarkAst -> bits -> bitsValue -> * -> isCaseSensitive
|
|
1217
1679
|
leaf_isCaseSensitive(node, _route) {
|
|
1218
|
-
this.writeProperty('isCaseSensitive', node.value,
|
|
1680
|
+
this.writeProperty('isCaseSensitive', node.value, {
|
|
1681
|
+
format: PropertyFormat.boolean,
|
|
1682
|
+
single: true,
|
|
1683
|
+
ignoreFalse: false,
|
|
1684
|
+
ignoreTrue: true,
|
|
1685
|
+
});
|
|
1219
1686
|
}
|
|
1220
1687
|
// bitmarkAst -> bits -> bitsValue -> * -> isCorrect
|
|
1221
1688
|
// bitmarkAst -> bits -> bitsValue -> heading -> forKeys
|
|
1222
1689
|
leaf_forKeys(node, _route) {
|
|
1223
1690
|
this.writeOPHASH();
|
|
1224
|
-
this.
|
|
1691
|
+
this.writeBreakscapedTagString(node.value);
|
|
1692
|
+
this.writeCL();
|
|
1693
|
+
}
|
|
1694
|
+
// bitmarkAst -> bits -> bitsValue -> heading -> forValues
|
|
1695
|
+
leaf_forValues(node, _route) {
|
|
1696
|
+
this.writeOPHASH();
|
|
1697
|
+
this.writeBreakscapedTagString(node.value);
|
|
1225
1698
|
this.writeCL();
|
|
1226
1699
|
}
|
|
1227
1700
|
// bitmarkAst -> bits -> bitsValue -> heading -> forValuesValue
|
|
1228
1701
|
leaf_forValuesValue(node, _route) {
|
|
1229
1702
|
this.writeOPHASH();
|
|
1230
|
-
this.
|
|
1703
|
+
this.writeBreakscapedTagString(node.value);
|
|
1231
1704
|
this.writeCL();
|
|
1232
1705
|
}
|
|
1233
1706
|
// bitmarkAst -> bits -> bitsValue -> pairs -> pairsValue -> key
|
|
1234
1707
|
// bitmarkAst -> bits -> bitsValue -> matrix -> matrixValue -> key
|
|
1235
1708
|
leaf_key(node, _route) {
|
|
1236
1709
|
if (node.value) {
|
|
1237
|
-
this.
|
|
1710
|
+
this.writeBreakscapedTagString(node.value);
|
|
1238
1711
|
}
|
|
1239
1712
|
}
|
|
1240
1713
|
// bitmarkAst -> bits -> bitsValue -> pairs -> pairsValue -> values -> valuesValue
|
|
1241
1714
|
// bitmarkAst -> bits -> bitsValue -> matrix -> matrixValue -> cells -> cellsValue -> values -> valuesValue
|
|
1242
1715
|
leaf_valuesValue(node, _route) {
|
|
1243
1716
|
if (node.value) {
|
|
1244
|
-
this.
|
|
1717
|
+
this.writeBreakscapedTagString(node.value);
|
|
1245
1718
|
}
|
|
1246
1719
|
}
|
|
1247
1720
|
// bitmarkAst -> bits -> bitsValue -> questions -> questionsValue -> question
|
|
@@ -1252,9 +1725,22 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
1252
1725
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.questionsValue && (parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.flashcardsValue)
|
|
1253
1726
|
return;
|
|
1254
1727
|
if (node.value) {
|
|
1255
|
-
this.
|
|
1728
|
+
this.writeBreakscapedTagString(node.value);
|
|
1729
|
+
// this.writeNL();
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
enter_question(node, route) {
|
|
1733
|
+
// Ignore responses that are not at the questionsValue level as they are handled elsewhere
|
|
1734
|
+
const parent = this.getParentNode(route);
|
|
1735
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.questionsValue && (parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.flashcardsValue)
|
|
1736
|
+
return true;
|
|
1737
|
+
if (node.value) {
|
|
1738
|
+
this.textGenerator.generateSync(node.value, TextFormat.bitmarkMinusMinus);
|
|
1739
|
+
// this.writeString(node.value);
|
|
1256
1740
|
// this.writeNL();
|
|
1257
1741
|
}
|
|
1742
|
+
// Stop traversal of this branch
|
|
1743
|
+
return false;
|
|
1258
1744
|
}
|
|
1259
1745
|
// bitmarkAst -> bits -> bitsValue -> statements -> text
|
|
1260
1746
|
// bitmarkAst -> bits -> bitsValue -> resource -> ...
|
|
@@ -1262,25 +1748,53 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
1262
1748
|
// bitmarkAst -> bits -> bitsValue -> resource -> thumbnails -> thumbnailsValue -> ...
|
|
1263
1749
|
// [src1x,src2x,src3x,src4x,width,height,alt,zoomDisabled,caption]
|
|
1264
1750
|
leaf_src1x(node, _route) {
|
|
1265
|
-
this.writeProperty('src1x', node.value
|
|
1751
|
+
this.writeProperty('src1x', node.value, {
|
|
1752
|
+
format: PropertyFormat.trimmedString,
|
|
1753
|
+
single: true,
|
|
1754
|
+
ignoreEmpty: true,
|
|
1755
|
+
});
|
|
1266
1756
|
}
|
|
1267
1757
|
leaf_src2x(node, _route) {
|
|
1268
|
-
this.writeProperty('src2x', node.value
|
|
1758
|
+
this.writeProperty('src2x', node.value, {
|
|
1759
|
+
format: PropertyFormat.trimmedString,
|
|
1760
|
+
single: true,
|
|
1761
|
+
ignoreEmpty: true,
|
|
1762
|
+
});
|
|
1269
1763
|
}
|
|
1270
1764
|
leaf_src3x(node, _route) {
|
|
1271
|
-
this.writeProperty('src3x', node.value
|
|
1765
|
+
this.writeProperty('src3x', node.value, {
|
|
1766
|
+
format: PropertyFormat.trimmedString,
|
|
1767
|
+
single: true,
|
|
1768
|
+
ignoreEmpty: true,
|
|
1769
|
+
});
|
|
1272
1770
|
}
|
|
1273
1771
|
leaf_src4x(node, _route) {
|
|
1274
|
-
this.writeProperty('src4x', node.value
|
|
1772
|
+
this.writeProperty('src4x', node.value, {
|
|
1773
|
+
format: PropertyFormat.trimmedString,
|
|
1774
|
+
single: true,
|
|
1775
|
+
ignoreEmpty: true,
|
|
1776
|
+
});
|
|
1275
1777
|
}
|
|
1276
1778
|
leaf_width(node, _route) {
|
|
1277
|
-
this.writeProperty('width', node.value
|
|
1779
|
+
this.writeProperty('width', node.value, {
|
|
1780
|
+
format: PropertyFormat.trimmedString,
|
|
1781
|
+
single: true,
|
|
1782
|
+
ignoreEmpty: true,
|
|
1783
|
+
});
|
|
1278
1784
|
}
|
|
1279
1785
|
leaf_height(node, _route) {
|
|
1280
|
-
this.writeProperty('height', node.value
|
|
1786
|
+
this.writeProperty('height', node.value, {
|
|
1787
|
+
format: PropertyFormat.trimmedString,
|
|
1788
|
+
single: true,
|
|
1789
|
+
ignoreEmpty: true,
|
|
1790
|
+
});
|
|
1281
1791
|
}
|
|
1282
1792
|
leaf_alt(node, _route) {
|
|
1283
|
-
this.writeProperty('alt', node.value
|
|
1793
|
+
this.writeProperty('alt', node.value, {
|
|
1794
|
+
format: PropertyFormat.trimmedString,
|
|
1795
|
+
single: true,
|
|
1796
|
+
ignoreEmpty: true,
|
|
1797
|
+
});
|
|
1284
1798
|
}
|
|
1285
1799
|
leaf_zoomDisabled(node, route) {
|
|
1286
1800
|
const bitType = this.getBitType(route);
|
|
@@ -1290,32 +1804,65 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
1290
1804
|
BitType.imagesLogoGrave,
|
|
1291
1805
|
BitType.prototypeImages,
|
|
1292
1806
|
])) {
|
|
1293
|
-
this.writeProperty('zoomDisabled', node.value,
|
|
1807
|
+
this.writeProperty('zoomDisabled', node.value, {
|
|
1808
|
+
format: PropertyFormat.boolean,
|
|
1809
|
+
single: true,
|
|
1810
|
+
ignoreFalse: false,
|
|
1811
|
+
ignoreTrue: true,
|
|
1812
|
+
});
|
|
1294
1813
|
}
|
|
1295
1814
|
else {
|
|
1296
|
-
this.writeProperty('zoomDisabled', node.value,
|
|
1815
|
+
this.writeProperty('zoomDisabled', node.value, {
|
|
1816
|
+
format: PropertyFormat.boolean,
|
|
1817
|
+
single: true,
|
|
1818
|
+
ignoreFalse: true,
|
|
1819
|
+
ignoreTrue: false,
|
|
1820
|
+
});
|
|
1297
1821
|
}
|
|
1298
1822
|
}
|
|
1299
1823
|
leaf_license(node, _route) {
|
|
1300
|
-
this.writeProperty('license', node.value
|
|
1824
|
+
this.writeProperty('license', node.value, {
|
|
1825
|
+
format: PropertyFormat.trimmedString,
|
|
1826
|
+
single: true,
|
|
1827
|
+
ignoreEmpty: true,
|
|
1828
|
+
});
|
|
1301
1829
|
}
|
|
1302
1830
|
leaf_copyright(node, _route) {
|
|
1303
|
-
this.writeProperty('copyright', node.value
|
|
1831
|
+
this.writeProperty('copyright', node.value, {
|
|
1832
|
+
format: PropertyFormat.trimmedString,
|
|
1833
|
+
single: true,
|
|
1834
|
+
ignoreEmpty: true,
|
|
1835
|
+
});
|
|
1304
1836
|
}
|
|
1305
1837
|
leaf_provider(_node, _route) {
|
|
1306
1838
|
// provider is included in the url (it is the domain) and should not be written as a property
|
|
1307
1839
|
// this.writeProperty('provider', node.value);
|
|
1308
1840
|
}
|
|
1309
1841
|
leaf_showInIndex(node, _route) {
|
|
1310
|
-
this.writeProperty('showInIndex', node.value
|
|
1842
|
+
this.writeProperty('showInIndex', node.value, {
|
|
1843
|
+
format: PropertyFormat.boolean,
|
|
1844
|
+
single: true,
|
|
1845
|
+
ignoreEmpty: true,
|
|
1846
|
+
ignoreFalse: true,
|
|
1847
|
+
});
|
|
1311
1848
|
}
|
|
1312
|
-
|
|
1849
|
+
enter_caption(node, _route) {
|
|
1313
1850
|
const value = node.value;
|
|
1314
|
-
this.writeProperty('caption', value
|
|
1851
|
+
this.writeProperty('caption', value, {
|
|
1852
|
+
format: PropertyFormat.bitmarkMinusMinus,
|
|
1853
|
+
single: true, // ??
|
|
1854
|
+
ignoreEmpty: true,
|
|
1855
|
+
});
|
|
1856
|
+
// Stop traversal of this branch
|
|
1857
|
+
return false;
|
|
1315
1858
|
}
|
|
1316
1859
|
leaf_search(node, _route) {
|
|
1317
1860
|
const value = node.value;
|
|
1318
|
-
this.writeProperty('search', value
|
|
1861
|
+
this.writeProperty('search', value, {
|
|
1862
|
+
format: PropertyFormat.trimmedString,
|
|
1863
|
+
single: true,
|
|
1864
|
+
ignoreEmpty: true,
|
|
1865
|
+
});
|
|
1319
1866
|
}
|
|
1320
1867
|
// bitmarkAst -> bits -> bitsValue -> resource -> ...
|
|
1321
1868
|
// bitmarkAst -> bits -> bitsValue -> resource -> posterImage -> ...
|
|
@@ -1326,23 +1873,97 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
1326
1873
|
const parent = this.getParentNode(route);
|
|
1327
1874
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) === NodeType.bitsValue)
|
|
1328
1875
|
return;
|
|
1329
|
-
this.writeProperty('duration', node.value
|
|
1876
|
+
this.writeProperty('duration', node.value, {
|
|
1877
|
+
format: PropertyFormat.trimmedString,
|
|
1878
|
+
single: true,
|
|
1879
|
+
ignoreEmpty: true,
|
|
1880
|
+
});
|
|
1330
1881
|
}
|
|
1331
1882
|
leaf_mute(node, _route) {
|
|
1332
|
-
this.writeProperty('mute', node.value
|
|
1883
|
+
this.writeProperty('mute', node.value, {
|
|
1884
|
+
format: PropertyFormat.boolean,
|
|
1885
|
+
single: true,
|
|
1886
|
+
ignoreEmpty: true,
|
|
1887
|
+
});
|
|
1333
1888
|
}
|
|
1334
1889
|
leaf_autoplay(node, _route) {
|
|
1335
|
-
this.writeProperty('autoplay', node.value
|
|
1890
|
+
this.writeProperty('autoplay', node.value, {
|
|
1891
|
+
format: PropertyFormat.boolean,
|
|
1892
|
+
single: true,
|
|
1893
|
+
ignoreEmpty: true,
|
|
1894
|
+
});
|
|
1336
1895
|
}
|
|
1337
1896
|
leaf_allowSubtitles(node, _route) {
|
|
1338
|
-
this.writeProperty('allowSubtitles', node.value
|
|
1897
|
+
this.writeProperty('allowSubtitles', node.value, {
|
|
1898
|
+
format: PropertyFormat.boolean,
|
|
1899
|
+
single: true,
|
|
1900
|
+
ignoreEmpty: true,
|
|
1901
|
+
});
|
|
1339
1902
|
}
|
|
1340
1903
|
leaf_showSubtitles(node, _route) {
|
|
1341
|
-
this.writeProperty('showSubtitles', node.value
|
|
1904
|
+
this.writeProperty('showSubtitles', node.value, {
|
|
1905
|
+
format: PropertyFormat.boolean,
|
|
1906
|
+
single: true,
|
|
1907
|
+
ignoreEmpty: true,
|
|
1908
|
+
});
|
|
1909
|
+
}
|
|
1910
|
+
//
|
|
1911
|
+
// Resources
|
|
1912
|
+
//
|
|
1913
|
+
// bitmarkAst -> bits -> bitsValue -> resources
|
|
1914
|
+
between_resources(_node, _left, _right, _route) {
|
|
1915
|
+
this.writeNL();
|
|
1916
|
+
}
|
|
1917
|
+
exit_resources(_node, _left, _right, _route) {
|
|
1918
|
+
this.writeNL();
|
|
1919
|
+
}
|
|
1920
|
+
// bitmarkAst -> bits -> bitsValue -> resourcesValue
|
|
1921
|
+
between_resourcesValue(_node, _left, _right, _route) {
|
|
1922
|
+
this.writeNL();
|
|
1342
1923
|
}
|
|
1343
1924
|
//
|
|
1344
1925
|
// Generated Node Handlers
|
|
1345
1926
|
//
|
|
1927
|
+
/**
|
|
1928
|
+
* Generate the handlers for resources, as they are mostly the same, but not quite
|
|
1929
|
+
*/
|
|
1930
|
+
generateResourceHandlers() {
|
|
1931
|
+
for (const tag of ResourceTag.keys()) {
|
|
1932
|
+
// skip unknown
|
|
1933
|
+
if (tag === ResourceTag.keyFromValue(ResourceTag.unknown))
|
|
1934
|
+
continue;
|
|
1935
|
+
const enterFuncName = `enter_${tag}`;
|
|
1936
|
+
// Skip if the function already exists, allows for custom handlers
|
|
1937
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1938
|
+
if (typeof this[enterFuncName] === 'function') {
|
|
1939
|
+
continue;
|
|
1940
|
+
}
|
|
1941
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1942
|
+
this[enterFuncName] = (node, route) => {
|
|
1943
|
+
const resource = node.value;
|
|
1944
|
+
if (resource == null)
|
|
1945
|
+
return false;
|
|
1946
|
+
// Ignore any property that is not at the bit level as that will be handled by a different handler
|
|
1947
|
+
const parent = this.getParentNode(route);
|
|
1948
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.resourcesValue)
|
|
1949
|
+
return true;
|
|
1950
|
+
// Get the resource alias
|
|
1951
|
+
const alias = ResourceTag.fromValue(parent.value.__typeAlias);
|
|
1952
|
+
const type = alias !== null && alias !== void 0 ? alias : ResourceTag.fromValue(parent.value.type);
|
|
1953
|
+
if (!type)
|
|
1954
|
+
return false;
|
|
1955
|
+
// url / src / href / app
|
|
1956
|
+
const url = resource.url || resource.src || resource.body || '';
|
|
1957
|
+
// Write the resource
|
|
1958
|
+
this.writeResource(type, url);
|
|
1959
|
+
// Continue traversal
|
|
1960
|
+
return true;
|
|
1961
|
+
};
|
|
1962
|
+
// Bind this
|
|
1963
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1964
|
+
this[enterFuncName] = this[enterFuncName].bind(this);
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1346
1967
|
/**
|
|
1347
1968
|
* Generate the handlers for properties, as they are mostly the same, but not quite
|
|
1348
1969
|
*/
|
|
@@ -1359,36 +1980,15 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
1359
1980
|
const propertiesConfig = Config.getRawPropertiesConfig();
|
|
1360
1981
|
for (const propertyConfig of Object.values(propertiesConfig)) {
|
|
1361
1982
|
const astKey = (_a = propertyConfig.astKey) !== null && _a !== void 0 ? _a : propertyConfig.tag;
|
|
1362
|
-
// Special cases (handled outside of the automatically generated handlers)
|
|
1363
|
-
if (astKey === PropertyTag.internalComment)
|
|
1364
|
-
continue;
|
|
1365
|
-
if (astKey === PropertyTag.example)
|
|
1366
|
-
continue;
|
|
1367
|
-
if (astKey === PropertyTag.labelTrue)
|
|
1368
|
-
continue;
|
|
1369
|
-
if (astKey === PropertyTag.labelFalse)
|
|
1370
|
-
continue;
|
|
1371
|
-
if (astKey === PropertyTag.posterImage)
|
|
1372
|
-
continue;
|
|
1373
|
-
if (astKey === PropertyTag.imageSource)
|
|
1374
|
-
continue;
|
|
1375
|
-
if (astKey === PropertyTag.imagePlaceholder)
|
|
1376
|
-
continue;
|
|
1377
|
-
if (astKey === PropertyTag.technicalTerm)
|
|
1378
|
-
continue;
|
|
1379
|
-
if (astKey === PropertyTag.servings)
|
|
1380
|
-
continue;
|
|
1381
|
-
if (astKey === PropertyTag.person)
|
|
1382
|
-
continue;
|
|
1383
|
-
if (astKey === PropertyAstKey.ast_markConfig)
|
|
1384
|
-
continue;
|
|
1385
|
-
if (astKey === PropertyTag.ratingLevelStart)
|
|
1386
|
-
continue;
|
|
1387
|
-
if (astKey === PropertyTag.ratingLevelEnd)
|
|
1388
|
-
continue;
|
|
1389
1983
|
const enterFuncName = `enter_${astKey}`;
|
|
1984
|
+
// Skip if the function already exists, allows for custom handlers
|
|
1985
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1986
|
+
if (typeof this[enterFuncName] === 'function') {
|
|
1987
|
+
continue;
|
|
1988
|
+
}
|
|
1390
1989
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1391
1990
|
this[enterFuncName] = (node, route) => {
|
|
1991
|
+
var _a, _b;
|
|
1392
1992
|
const value = node.value;
|
|
1393
1993
|
if (value == null)
|
|
1394
1994
|
return;
|
|
@@ -1398,7 +1998,12 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
1398
1998
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType.bitsValue)
|
|
1399
1999
|
return;
|
|
1400
2000
|
// Write the property
|
|
1401
|
-
this.writeProperty(propertyConfig.tag, node.value,
|
|
2001
|
+
this.writeProperty(propertyConfig.tag, node.value, {
|
|
2002
|
+
format: (_a = propertyConfig.format) !== null && _a !== void 0 ? _a : PropertyFormat.trimmedString,
|
|
2003
|
+
single: (_b = propertyConfig.single) !== null && _b !== void 0 ? _b : false,
|
|
2004
|
+
ignoreFalse: propertyConfig.defaultValue === 'false',
|
|
2005
|
+
ignoreTrue: propertyConfig.defaultValue === 'true',
|
|
2006
|
+
});
|
|
1402
2007
|
};
|
|
1403
2008
|
// Bind this
|
|
1404
2009
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1434,6 +2039,13 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
1434
2039
|
//
|
|
1435
2040
|
// WRITE FUNCTIONS
|
|
1436
2041
|
//
|
|
2042
|
+
writeBreakscapedTagString(s) {
|
|
2043
|
+
if (s != null) {
|
|
2044
|
+
this.write(Breakscape.breakscape(`${s}`, {
|
|
2045
|
+
textFormat: TextFormat.bitmarkMinusMinus,
|
|
2046
|
+
}));
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
1437
2049
|
writeString(s) {
|
|
1438
2050
|
if (s != null)
|
|
1439
2051
|
this.write(`${s}`);
|
|
@@ -1568,84 +2180,86 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
1568
2180
|
this.write('\n');
|
|
1569
2181
|
}
|
|
1570
2182
|
writePropertyStyleResource(key, resource) {
|
|
1571
|
-
|
|
2183
|
+
var _a;
|
|
1572
2184
|
if (key && resource) {
|
|
2185
|
+
const resourceTag = (_a = ResourceTag.keyFromValue(resource.type)) !== null && _a !== void 0 ? _a : '';
|
|
2186
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2187
|
+
const resourceData = resource[resourceTag];
|
|
2188
|
+
const src = resourceData ? resourceData.src || resourceData.url || resourceData.body || '' : '';
|
|
1573
2189
|
this.writeOPA();
|
|
1574
|
-
this.
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
this.writeString(resourceAsArticle.value);
|
|
2190
|
+
this.writeBreakscapedTagString(key);
|
|
2191
|
+
this.writeColon();
|
|
2192
|
+
this.writeBreakscapedTagString(src);
|
|
2193
|
+
if (resource.type === ResourceTag.article) {
|
|
1579
2194
|
this.writeNL();
|
|
1580
2195
|
}
|
|
1581
|
-
else if (resource.value) {
|
|
1582
|
-
this.writeColon();
|
|
1583
|
-
this.writeString(resource.value);
|
|
1584
|
-
}
|
|
1585
2196
|
this.writeCL();
|
|
1586
2197
|
}
|
|
1587
2198
|
}
|
|
1588
|
-
writeResource(
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
if (resource) {
|
|
1592
|
-
// All resources should now be valid as they are validated in the AST
|
|
1593
|
-
// TODO: remove code below
|
|
1594
|
-
// // Check if a resource has a value, if not, we should not write it (or any of its chained properties)
|
|
1595
|
-
// let valid = false;
|
|
1596
|
-
// if (resource.value) {
|
|
1597
|
-
// valid = true;
|
|
1598
|
-
// }
|
|
1599
|
-
// // Resource is not valid, cancel walking it's tree.
|
|
1600
|
-
// if (!valid) return false;
|
|
2199
|
+
writeResource(type, value) {
|
|
2200
|
+
// const resourceAsArticle = resource as ArticleResource;
|
|
2201
|
+
if (type) {
|
|
1601
2202
|
// Standard case
|
|
1602
2203
|
this.writeOPAMP();
|
|
1603
|
-
this.
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
this.writeString(resourceAsArticle.value);
|
|
2204
|
+
this.writeBreakscapedTagString(type);
|
|
2205
|
+
this.writeColon();
|
|
2206
|
+
this.writeBreakscapedTagString(value);
|
|
2207
|
+
if (type === ResourceTag.article) {
|
|
1608
2208
|
this.writeNL();
|
|
1609
2209
|
}
|
|
1610
|
-
else if (resource.value) {
|
|
1611
|
-
this.writeColon();
|
|
1612
|
-
this.writeString(resource.value);
|
|
1613
|
-
}
|
|
1614
2210
|
this.writeCL();
|
|
1615
2211
|
}
|
|
1616
2212
|
}
|
|
1617
|
-
writeProperty(name, values,
|
|
2213
|
+
writeProperty(name, values, options) {
|
|
2214
|
+
var _a;
|
|
1618
2215
|
let valuesArray;
|
|
1619
2216
|
let wroteSomething = false;
|
|
1620
2217
|
if (values !== undefined) {
|
|
1621
|
-
|
|
1622
|
-
|
|
2218
|
+
const isBitmarkText = options.format === PropertyFormat.bitmarkMinusMinus || options.format === PropertyFormat.bitmarkPlusPlus;
|
|
2219
|
+
if (isBitmarkText) {
|
|
2220
|
+
// Write bitmark text
|
|
2221
|
+
if (options.ignoreEmpty && isBitmarkText && this.isEmptyText(values))
|
|
2222
|
+
return;
|
|
2223
|
+
this.writeOPA();
|
|
2224
|
+
this.writeBreakscapedTagString(name);
|
|
2225
|
+
this.writeColon();
|
|
2226
|
+
this.textGenerator.generateSync(values, (_a = TextFormat.fromValue(options.format)) !== null && _a !== void 0 ? _a : TextFormat.bitmarkMinusMinus);
|
|
2227
|
+
this.writeCL();
|
|
2228
|
+
wroteSomething = true;
|
|
1623
2229
|
}
|
|
1624
2230
|
else {
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
if (
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
2231
|
+
// Write any other property type
|
|
2232
|
+
if (!Array.isArray(values)) {
|
|
2233
|
+
valuesArray = [values];
|
|
2234
|
+
}
|
|
2235
|
+
else {
|
|
2236
|
+
valuesArray = values;
|
|
2237
|
+
}
|
|
2238
|
+
if (valuesArray.length > 0) {
|
|
2239
|
+
if (options.single)
|
|
2240
|
+
valuesArray = valuesArray.slice(valuesArray.length - 1);
|
|
2241
|
+
let propertyIndex = 0;
|
|
2242
|
+
for (const val of valuesArray) {
|
|
2243
|
+
if (val !== undefined) {
|
|
2244
|
+
if (options.ignoreFalse && val === false)
|
|
2245
|
+
continue;
|
|
2246
|
+
if (options.ignoreTrue && val === true)
|
|
2247
|
+
continue;
|
|
2248
|
+
if (options.ignoreEmpty && val === '')
|
|
2249
|
+
continue;
|
|
2250
|
+
if (propertyIndex > 0)
|
|
2251
|
+
this.writeNL();
|
|
2252
|
+
this.writeOPA();
|
|
2253
|
+
this.writeBreakscapedTagString(name);
|
|
2254
|
+
this.writeColon();
|
|
2255
|
+
this.writeBreakscapedTagString(`${val}`);
|
|
2256
|
+
this.writeCL();
|
|
2257
|
+
wroteSomething = true;
|
|
2258
|
+
propertyIndex++;
|
|
2259
|
+
}
|
|
1646
2260
|
}
|
|
1647
2261
|
}
|
|
1648
|
-
}
|
|
2262
|
+
} // isBitmarkText
|
|
1649
2263
|
}
|
|
1650
2264
|
if (!wroteSomething) {
|
|
1651
2265
|
this.skipNLBetweenBitsValue = true;
|
|
@@ -1667,6 +2281,13 @@ class BitmarkGenerator extends AstWalkerGenerator {
|
|
|
1667
2281
|
//
|
|
1668
2282
|
// Helper functions
|
|
1669
2283
|
//
|
|
2284
|
+
isEmptyText(text) {
|
|
2285
|
+
if (!text)
|
|
2286
|
+
return true;
|
|
2287
|
+
if (Array.isArray(text))
|
|
2288
|
+
return text.length === 0;
|
|
2289
|
+
return true; // true as not valid TextAst?
|
|
2290
|
+
}
|
|
1670
2291
|
isWriteTextFormat(bitsValue, textFormatDefault) {
|
|
1671
2292
|
const isDefault = TextFormat.fromValue(bitsValue) === textFormatDefault;
|
|
1672
2293
|
const writeFormat = !isDefault || this.options.explicitTextFormat;
|