@gmb/bitmark-parser-generator 3.23.0 → 3.25.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 +10 -2
- package/dist/cjs/BitmarkParserGenerator.js.map +1 -1
- package/dist/cjs/ast/BaseBuilder.js +4 -0
- package/dist/cjs/ast/BaseBuilder.js.map +1 -1
- package/dist/cjs/ast/Builder.js +11 -7
- package/dist/cjs/ast/Builder.js.map +1 -1
- package/dist/cjs/breakscaping/Breakscape.js +185 -128
- package/dist/cjs/breakscaping/Breakscape.js.map +1 -1
- package/dist/cjs/config/raw/bits.js +11 -0
- package/dist/cjs/config/raw/bits.js.map +1 -1
- package/dist/cjs/config/raw/groups.js +5 -0
- package/dist/cjs/config/raw/groups.js.map +1 -1
- package/dist/cjs/config/raw/properties.js +4 -0
- package/dist/cjs/config/raw/properties.js.map +1 -1
- package/dist/cjs/generated/build-info.js +1 -1
- package/dist/cjs/generated/parser/text/text-peggy-parser.js +317 -296
- package/dist/cjs/generated/parser/text/text-peggy-parser.js.map +1 -1
- package/dist/cjs/generator/bitmark/BitmarkGenerator.js +276 -166
- package/dist/cjs/generator/bitmark/BitmarkGenerator.js.map +1 -1
- package/dist/cjs/generator/json/JsonGenerator.js +10 -7
- package/dist/cjs/generator/json/JsonGenerator.js.map +1 -1
- package/dist/cjs/generator/text/TextGenerator.js +42 -12
- package/dist/cjs/generator/text/TextGenerator.js.map +1 -1
- package/dist/cjs/model/ast/NodeType.js +2 -0
- package/dist/cjs/model/ast/NodeType.js.map +1 -1
- package/dist/cjs/model/config/enum/PropertyConfigKey.js +1 -0
- package/dist/cjs/model/config/enum/PropertyConfigKey.js.map +1 -1
- package/dist/cjs/model/enum/BitType.js +2 -0
- package/dist/cjs/model/enum/BitType.js.map +1 -1
- package/dist/cjs/model/enum/TextFormat.js +16 -7
- package/dist/cjs/model/enum/TextFormat.js.map +1 -1
- package/dist/cjs/model/enum/TextLocation.js +15 -0
- package/dist/cjs/model/enum/TextLocation.js.map +1 -0
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserHelper.js +5 -2
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserHelper.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserProcessor.js +5 -2
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/BodyContentProcessor.js +4 -0
- package/dist/cjs/parser/bitmark/peg/contentProcessors/BodyContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.js +3 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/CardContentProcessor.js +1 -2
- package/dist/cjs/parser/bitmark/peg/contentProcessors/CardContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.js +3 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.js +17 -5
- package/dist/cjs/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js +8 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/FooterContentProcessor.js +3 -0
- package/dist/cjs/parser/bitmark/peg/contentProcessors/FooterContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.js +3 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.js +3 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkTagContentProcessor.js +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkTagContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/PersonChainContentProcessor.js +4 -2
- package/dist/cjs/parser/bitmark/peg/contentProcessors/PersonChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js +11 -5
- package/dist/cjs/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.js +5 -2
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.js +7 -2
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TechnicalTermChainContentProcessor.js +3 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TechnicalTermChainContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js +3 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js.map +1 -1
- package/dist/cjs/parser/text/TextParser.js +0 -15
- package/dist/cjs/parser/text/TextParser.js.map +1 -1
- package/dist/esm/BitmarkParserGenerator.js +10 -2
- package/dist/esm/BitmarkParserGenerator.js.map +1 -1
- package/dist/esm/ast/BaseBuilder.js +4 -0
- package/dist/esm/ast/BaseBuilder.js.map +1 -1
- package/dist/esm/ast/Builder.js +11 -7
- package/dist/esm/ast/Builder.js.map +1 -1
- package/dist/esm/breakscaping/Breakscape.js +185 -128
- package/dist/esm/breakscaping/Breakscape.js.map +1 -1
- package/dist/esm/config/raw/bits.js +11 -0
- package/dist/esm/config/raw/bits.js.map +1 -1
- package/dist/esm/config/raw/groups.js +5 -0
- package/dist/esm/config/raw/groups.js.map +1 -1
- package/dist/esm/config/raw/properties.js +4 -0
- package/dist/esm/config/raw/properties.js.map +1 -1
- package/dist/esm/generated/build-info.js +1 -1
- package/dist/esm/generated/parser/text/text-peggy-parser.js +317 -296
- package/dist/esm/generated/parser/text/text-peggy-parser.js.map +1 -1
- package/dist/esm/generator/bitmark/BitmarkGenerator.js +276 -166
- package/dist/esm/generator/bitmark/BitmarkGenerator.js.map +1 -1
- package/dist/esm/generator/json/JsonGenerator.js +10 -7
- package/dist/esm/generator/json/JsonGenerator.js.map +1 -1
- package/dist/esm/generator/text/TextGenerator.js +42 -12
- package/dist/esm/generator/text/TextGenerator.js.map +1 -1
- package/dist/esm/model/ast/NodeType.js +2 -0
- package/dist/esm/model/ast/NodeType.js.map +1 -1
- package/dist/esm/model/config/enum/PropertyConfigKey.js +1 -0
- package/dist/esm/model/config/enum/PropertyConfigKey.js.map +1 -1
- package/dist/esm/model/enum/BitType.js +2 -0
- package/dist/esm/model/enum/BitType.js.map +1 -1
- package/dist/esm/model/enum/TextFormat.js +16 -7
- package/dist/esm/model/enum/TextFormat.js.map +1 -1
- package/dist/esm/model/enum/TextLocation.js +12 -0
- package/dist/esm/model/enum/TextLocation.js.map +1 -0
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserHelper.js +5 -2
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserHelper.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserProcessor.js +5 -2
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/BodyContentProcessor.js +4 -0
- package/dist/esm/parser/bitmark/peg/contentProcessors/BodyContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.js +3 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/CardContentProcessor.js +1 -2
- package/dist/esm/parser/bitmark/peg/contentProcessors/CardContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.js +3 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.js +17 -5
- package/dist/esm/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js +8 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/FooterContentProcessor.js +3 -0
- package/dist/esm/parser/bitmark/peg/contentProcessors/FooterContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.js +3 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.js +3 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/MarkTagContentProcessor.js +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/MarkTagContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/PersonChainContentProcessor.js +4 -2
- package/dist/esm/parser/bitmark/peg/contentProcessors/PersonChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js +11 -5
- package/dist/esm/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.js +5 -2
- package/dist/esm/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.js +7 -2
- package/dist/esm/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/TechnicalTermChainContentProcessor.js +3 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/TechnicalTermChainContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js +3 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js.map +1 -1
- package/dist/esm/parser/text/TextParser.js +0 -15
- package/dist/esm/parser/text/TextParser.js.map +1 -1
- package/dist/types/BitmarkParserGenerator.d.ts +13 -0
- package/dist/types/BitmarkParserGenerator.d.ts.map +1 -1
- package/dist/types/ast/BaseBuilder.d.ts.map +1 -1
- package/dist/types/ast/Builder.d.ts +1 -0
- package/dist/types/ast/Builder.d.ts.map +1 -1
- package/dist/types/breakscaping/Breakscape.d.ts +23 -1
- package/dist/types/breakscaping/Breakscape.d.ts.map +1 -1
- package/dist/types/config/raw/bits.d.ts.map +1 -1
- package/dist/types/config/raw/groups.d.ts.map +1 -1
- package/dist/types/config/raw/properties.d.ts.map +1 -1
- package/dist/types/generated/parser/text/text-peggy-parser.d.ts.map +1 -1
- package/dist/types/generator/bitmark/BitmarkGenerator.d.ts +61 -18
- package/dist/types/generator/bitmark/BitmarkGenerator.d.ts.map +1 -1
- package/dist/types/generator/json/JsonGenerator.d.ts.map +1 -1
- package/dist/types/generator/text/TextGenerator.d.ts +9 -2
- package/dist/types/generator/text/TextGenerator.d.ts.map +1 -1
- package/dist/types/model/ast/NodeType.d.ts +4 -0
- package/dist/types/model/ast/NodeType.d.ts.map +1 -1
- package/dist/types/model/ast/Nodes.d.ts +1 -0
- 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 +4 -0
- package/dist/types/model/enum/BitType.d.ts.map +1 -1
- package/dist/types/model/enum/PropertyTag.d.ts +2 -0
- package/dist/types/model/enum/PropertyTag.d.ts.map +1 -1
- package/dist/types/model/enum/TextFormat.d.ts +0 -2
- package/dist/types/model/enum/TextFormat.d.ts.map +1 -1
- package/dist/types/model/enum/TextLocation.d.ts +16 -0
- package/dist/types/model/enum/TextLocation.d.ts.map +1 -0
- package/dist/types/model/json/BitJson.d.ts +4 -3
- package/dist/types/model/json/BitJson.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/BitmarkPegParserHelper.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/BitmarkPegParserProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/BodyContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.d.ts.map +1 -1
- 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/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.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.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/ReferenceTagContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.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/TrueFalseTagContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/text/TextParser.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.BitmarkGenerator = void 0;
|
|
13
13
|
const Ast_1 = require("../../ast/Ast");
|
|
14
|
+
const StringWriter_1 = require("../../ast/writer/StringWriter");
|
|
14
15
|
const Breakscape_1 = require("../../breakscaping/Breakscape");
|
|
15
16
|
const Config_1 = require("../../config/Config");
|
|
16
17
|
const NodeType_1 = require("../../model/ast/NodeType");
|
|
@@ -22,6 +23,7 @@ const PropertyFormat_1 = require("../../model/enum/PropertyFormat");
|
|
|
22
23
|
const PropertyTag_1 = require("../../model/enum/PropertyTag");
|
|
23
24
|
const ResourceTag_1 = require("../../model/enum/ResourceTag");
|
|
24
25
|
const TextFormat_1 = require("../../model/enum/TextFormat");
|
|
26
|
+
const TextLocation_1 = require("../../model/enum/TextLocation");
|
|
25
27
|
const BooleanUtils_1 = require("../../utils/BooleanUtils");
|
|
26
28
|
const ObjectUtils_1 = require("../../utils/ObjectUtils");
|
|
27
29
|
const StringUtils_1 = require("../../utils/StringUtils");
|
|
@@ -30,6 +32,8 @@ const TextGenerator_1 = require("../text/TextGenerator");
|
|
|
30
32
|
const DEFAULT_OPTIONS = {
|
|
31
33
|
debugGenerationInline: false,
|
|
32
34
|
};
|
|
35
|
+
const DEFAULT_SPACES_AROUND_VALUES = 1;
|
|
36
|
+
const MAX_SPACES_AROUND_VALUES = 10;
|
|
33
37
|
/**
|
|
34
38
|
* Generate bitmark markup from a bitmark AST
|
|
35
39
|
*
|
|
@@ -57,6 +61,11 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
57
61
|
super();
|
|
58
62
|
this.ast = new Ast_1.Ast();
|
|
59
63
|
// State
|
|
64
|
+
this.bitType = BitType_1.BitType._error;
|
|
65
|
+
this.textFormat = TextFormat_1.TextFormat.bitmarkMinusMinus;
|
|
66
|
+
this.tagTextFormat = TextFormat_1.TextFormat.bitmarkMinusMinus;
|
|
67
|
+
this.isBodyBitmarkText = false;
|
|
68
|
+
this.isCardAllowed = false;
|
|
60
69
|
this.firstBit = true;
|
|
61
70
|
this.hasCardSet = false;
|
|
62
71
|
this.hasFooter = false;
|
|
@@ -87,13 +96,18 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
87
96
|
}
|
|
88
97
|
// Calculate the prettify space
|
|
89
98
|
this.prettifySpace = this.options.prettifyJson === true ? 2 : this.options.prettifyJson || undefined;
|
|
99
|
+
// Calculate the spaces around values
|
|
100
|
+
this.spacesAroundValues = this.calcSpacesAroundValues();
|
|
101
|
+
this.spacesAroundValuesStr = ' '.repeat(this.spacesAroundValues);
|
|
90
102
|
// Create the text generator
|
|
91
103
|
this.textGenerator = new TextGenerator_1.TextGenerator(this.bitmarkVersion, {
|
|
92
104
|
writeCallback: this.write,
|
|
93
105
|
bodyBitCallback: this.bodyBitCallback,
|
|
94
106
|
debugGenerationInline: this.debugGenerationInline,
|
|
95
107
|
});
|
|
96
|
-
this.
|
|
108
|
+
this.mainWriter = writer;
|
|
109
|
+
this.partWriter = new StringWriter_1.StringWriter();
|
|
110
|
+
this.writer = this.mainWriter;
|
|
97
111
|
this.generateResourceHandlers();
|
|
98
112
|
this.generatePropertyHandlers();
|
|
99
113
|
}
|
|
@@ -132,6 +146,11 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
132
146
|
this.writer.closeSync();
|
|
133
147
|
}
|
|
134
148
|
resetState() {
|
|
149
|
+
this.bitType = BitType_1.BitType._error;
|
|
150
|
+
this.textFormat = TextFormat_1.TextFormat.bitmarkMinusMinus;
|
|
151
|
+
this.tagTextFormat = TextFormat_1.TextFormat.bitmarkMinusMinus;
|
|
152
|
+
this.isBodyBitmarkText = false;
|
|
153
|
+
this.isCardAllowed = false;
|
|
135
154
|
this.firstBit = true;
|
|
136
155
|
this.hasCardSet = false;
|
|
137
156
|
this.hasFooter = false;
|
|
@@ -153,9 +172,24 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
153
172
|
// bitmark
|
|
154
173
|
// bitmarkAst -> bits -> bitsValue
|
|
155
174
|
enter_bitsValue(node, _route) {
|
|
175
|
+
var _a;
|
|
156
176
|
const bit = node.value;
|
|
157
177
|
const bitConfig = Config_1.Config.getBitConfig(bit.bitType);
|
|
158
178
|
const bitResourcesConfig = Config_1.Config.getBitResourcesConfig(bit.bitType, bit.resourceType);
|
|
179
|
+
// Set state variables
|
|
180
|
+
this.bitType = bit.bitType;
|
|
181
|
+
this.textFormat = (_a = bit.textFormat) !== null && _a !== void 0 ? _a : bitConfig.textFormatDefault;
|
|
182
|
+
this.isBodyBitmarkText =
|
|
183
|
+
this.textFormat === TextFormat_1.TextFormat.bitmarkMinusMinus || this.textFormat === TextFormat_1.TextFormat.bitmarkPlusPlus;
|
|
184
|
+
this.isCardAllowed = this.calculateIsCardAllowed();
|
|
185
|
+
// NOTE:
|
|
186
|
+
// If the bit text format is bitmark++ then the tagTextFormat should be bitmark+, but that is not implemented yet.
|
|
187
|
+
// It works anyhow, and would require a lot of changes to implement.
|
|
188
|
+
// Since this may well change in the future, we will keep the code as is for now.
|
|
189
|
+
this.tagTextFormat =
|
|
190
|
+
this.textFormat === TextFormat_1.TextFormat.bitmarkPlusPlus
|
|
191
|
+
? TextFormat_1.TextFormat.bitmarkPlusPlus // NOTE: should be bitmarkPlus
|
|
192
|
+
: TextFormat_1.TextFormat.bitmarkMinusMinus;
|
|
159
193
|
this.hasCardSet = this.haveValidCardSet(bit);
|
|
160
194
|
this.hasFooter = this.haveValidFooter(bit);
|
|
161
195
|
// Separate the bits with 3 newlines
|
|
@@ -168,12 +202,12 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
168
202
|
this.writeOPD(bit.bitLevel);
|
|
169
203
|
if (bit.isCommented)
|
|
170
204
|
this.writeString('|');
|
|
171
|
-
this.
|
|
205
|
+
this.writeTagKey(bit.bitType);
|
|
172
206
|
if (bit.textFormat) {
|
|
173
207
|
const write = this.isWriteTextFormat(bit.textFormat, bitConfig.textFormatDefault);
|
|
174
208
|
if (write) {
|
|
175
209
|
this.writeColon();
|
|
176
|
-
this.
|
|
210
|
+
this.writeTagKey(bit.textFormat);
|
|
177
211
|
}
|
|
178
212
|
}
|
|
179
213
|
// Use the bitConfig to see if we need to write the resourceType attachment
|
|
@@ -196,7 +230,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
196
230
|
}
|
|
197
231
|
if (resourceType) {
|
|
198
232
|
this.writeAmpersand();
|
|
199
|
-
this.
|
|
233
|
+
this.writeTagKey(resourceType);
|
|
200
234
|
}
|
|
201
235
|
this.writeCL();
|
|
202
236
|
// this.writeNL();
|
|
@@ -370,13 +404,8 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
370
404
|
}
|
|
371
405
|
if (hint != null) {
|
|
372
406
|
this.writeOPQ();
|
|
373
|
-
this.
|
|
407
|
+
this.writeTextOrValue(hint, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
374
408
|
this.writeCL();
|
|
375
|
-
// this.writeProperty('hint', hint, {
|
|
376
|
-
// format: PropertyFormat.trimmedString,
|
|
377
|
-
// single: true,
|
|
378
|
-
// ignoreEmpty: true,
|
|
379
|
-
// });
|
|
380
409
|
}
|
|
381
410
|
return false;
|
|
382
411
|
}
|
|
@@ -402,7 +431,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
402
431
|
});
|
|
403
432
|
}
|
|
404
433
|
if (avatarImage) {
|
|
405
|
-
this.writeResource(ResourceTag_1.ResourceTag.image, avatarImage.src);
|
|
434
|
+
this.writeResource(ResourceTag_1.ResourceTag.image, avatarImage.image.src);
|
|
406
435
|
}
|
|
407
436
|
// Stop traversal of this branch
|
|
408
437
|
return false;
|
|
@@ -416,8 +445,6 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
416
445
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> flashcards -> flashcardsValue -> alternativeAnswers ->
|
|
417
446
|
// -> alternativeAnswersValue -> text
|
|
418
447
|
enter_text(node, route) {
|
|
419
|
-
var _a;
|
|
420
|
-
const textFormat = (_a = this.getTextFormat(route)) !== null && _a !== void 0 ? _a : TextFormat_1.TextFormat.bitmarkMinusMinus;
|
|
421
448
|
const parent = this.getParentNode(route);
|
|
422
449
|
if (!parent ||
|
|
423
450
|
(parent.key !== NodeType_1.NodeType.term &&
|
|
@@ -430,7 +457,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
430
457
|
}
|
|
431
458
|
if (node.value) {
|
|
432
459
|
this.writeNL();
|
|
433
|
-
this.
|
|
460
|
+
this.writeTextOrValue(node.value, this.textFormat, TextLocation_1.TextLocation.body);
|
|
434
461
|
}
|
|
435
462
|
// Stop traversal of this branch
|
|
436
463
|
return false;
|
|
@@ -448,11 +475,8 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
448
475
|
return true;
|
|
449
476
|
}
|
|
450
477
|
if (StringUtils_1.StringUtils.isString(node.value)) {
|
|
451
|
-
const str = node.value;
|
|
452
478
|
this.writeNL();
|
|
453
|
-
this.
|
|
454
|
-
textFormat: TextFormat_1.TextFormat.text,
|
|
455
|
-
}));
|
|
479
|
+
this.writeTextOrValue(node.value, this.textFormat, TextLocation_1.TextLocation.body);
|
|
456
480
|
}
|
|
457
481
|
// Stop traversal of this branch
|
|
458
482
|
return false;
|
|
@@ -656,7 +680,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
656
680
|
return true; // Will be handled by marginNumber
|
|
657
681
|
this.writeNL_IfNotChain(route);
|
|
658
682
|
this.writeOPC();
|
|
659
|
-
this.
|
|
683
|
+
this.writeTextOrValue(item, this.tagTextFormat, TextLocation_1.TextLocation.tag);
|
|
660
684
|
this.writeCL();
|
|
661
685
|
return true;
|
|
662
686
|
}
|
|
@@ -673,10 +697,10 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
673
697
|
return true; // Will be handled by marginNumber
|
|
674
698
|
this.writeNL_IfNotChain(route);
|
|
675
699
|
this.writeOPC();
|
|
676
|
-
this.
|
|
700
|
+
this.writeTextOrValue((_d = (_c = parent === null || parent === void 0 ? void 0 : parent.value) === null || _c === void 0 ? void 0 : _c.item) !== null && _d !== void 0 ? _d : '', this.tagTextFormat, TextLocation_1.TextLocation.tag);
|
|
677
701
|
this.writeCL();
|
|
678
702
|
this.writeOPC();
|
|
679
|
-
this.
|
|
703
|
+
this.writeTextOrValue(lead, this.tagTextFormat, TextLocation_1.TextLocation.tag);
|
|
680
704
|
this.writeCL();
|
|
681
705
|
return true;
|
|
682
706
|
}
|
|
@@ -691,13 +715,13 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
691
715
|
return true; // Will be handled by marginNumber
|
|
692
716
|
this.writeNL_IfNotChain(route);
|
|
693
717
|
this.writeOPC();
|
|
694
|
-
this.
|
|
718
|
+
this.writeTextOrValue((_c = (_b = parent === null || parent === void 0 ? void 0 : parent.value) === null || _b === void 0 ? void 0 : _b.item) !== null && _c !== void 0 ? _c : '', this.tagTextFormat, TextLocation_1.TextLocation.tag);
|
|
695
719
|
this.writeCL();
|
|
696
720
|
this.writeOPC();
|
|
697
|
-
this.
|
|
721
|
+
this.writeTextOrValue((_e = (_d = parent === null || parent === void 0 ? void 0 : parent.value) === null || _d === void 0 ? void 0 : _d.lead) !== null && _e !== void 0 ? _e : '', this.tagTextFormat, TextLocation_1.TextLocation.tag);
|
|
698
722
|
this.writeCL();
|
|
699
723
|
this.writeOPC();
|
|
700
|
-
this.
|
|
724
|
+
this.writeTextOrValue(pageNumber !== null && pageNumber !== void 0 ? pageNumber : '', this.tagTextFormat, TextLocation_1.TextLocation.tag);
|
|
701
725
|
this.writeCL();
|
|
702
726
|
return true;
|
|
703
727
|
}
|
|
@@ -710,16 +734,16 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
710
734
|
return false; // Ignore empty
|
|
711
735
|
this.writeNL_IfNotChain(route);
|
|
712
736
|
this.writeOPC();
|
|
713
|
-
this.
|
|
737
|
+
this.writeTextOrValue((_b = (_a = parent === null || parent === void 0 ? void 0 : parent.value) === null || _a === void 0 ? void 0 : _a.item) !== null && _b !== void 0 ? _b : '', this.tagTextFormat, TextLocation_1.TextLocation.tag);
|
|
714
738
|
this.writeCL();
|
|
715
739
|
this.writeOPC();
|
|
716
|
-
this.
|
|
740
|
+
this.writeTextOrValue((_d = (_c = parent === null || parent === void 0 ? void 0 : parent.value) === null || _c === void 0 ? void 0 : _c.lead) !== null && _d !== void 0 ? _d : '', this.tagTextFormat, TextLocation_1.TextLocation.tag);
|
|
717
741
|
this.writeCL();
|
|
718
742
|
this.writeOPC();
|
|
719
|
-
this.
|
|
743
|
+
this.writeTextOrValue((_f = (_e = parent === null || parent === void 0 ? void 0 : parent.value) === null || _e === void 0 ? void 0 : _e.pageNumber) !== null && _f !== void 0 ? _f : '', this.tagTextFormat, TextLocation_1.TextLocation.tag);
|
|
720
744
|
this.writeCL();
|
|
721
745
|
this.writeOPC();
|
|
722
|
-
this.
|
|
746
|
+
this.writeTextOrValue(marginNumber, this.tagTextFormat, TextLocation_1.TextLocation.tag);
|
|
723
747
|
this.writeCL();
|
|
724
748
|
return true;
|
|
725
749
|
}
|
|
@@ -733,29 +757,25 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
733
757
|
this.inTag = false;
|
|
734
758
|
// Always write a NL before the body content if there is any (see Handle body)
|
|
735
759
|
const body = node.value;
|
|
736
|
-
const textFormat = this.getTextFormat(route);
|
|
737
|
-
const isBitmarkText = textFormat === TextFormat_1.TextFormat.bitmarkPlusPlus || textFormat === TextFormat_1.TextFormat.bitmarkMinusMinus;
|
|
738
760
|
// Handle body
|
|
739
|
-
if (textFormat === TextFormat_1.TextFormat.json) {
|
|
761
|
+
if (this.textFormat === TextFormat_1.TextFormat.json) {
|
|
740
762
|
const json = (_a = body.body) !== null && _a !== void 0 ? _a : null;
|
|
741
763
|
if (Array.isArray(json) || ObjectUtils_1.ObjectUtils.isObject(json)) {
|
|
742
764
|
const text = JSON.stringify(json, null, this.prettifySpace);
|
|
743
765
|
if (text) {
|
|
744
766
|
this.writePlainTextDivider();
|
|
745
767
|
this.writeNL();
|
|
746
|
-
this.
|
|
747
|
-
textFormat: TextFormat_1.TextFormat.text,
|
|
748
|
-
}));
|
|
768
|
+
this.writeTextOrValue(text, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.body);
|
|
749
769
|
}
|
|
750
770
|
}
|
|
751
771
|
}
|
|
752
|
-
else if (
|
|
772
|
+
else if (this.isBodyBitmarkText) {
|
|
753
773
|
// handle bitmark text
|
|
754
774
|
const plainTextDividerAllowed = !(this.hasCardSet || this.hasFooter);
|
|
755
775
|
this.writeNL();
|
|
756
776
|
// The text generator will write to the writer
|
|
757
777
|
const b = (Array.isArray(body.body) ? body.body : []);
|
|
758
|
-
this.
|
|
778
|
+
this.writeTextOrValue(b, this.textFormat, TextLocation_1.TextLocation.body, {
|
|
759
779
|
plainTextDividerAllowed,
|
|
760
780
|
});
|
|
761
781
|
}
|
|
@@ -764,9 +784,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
764
784
|
this.writePlainTextDivider();
|
|
765
785
|
this.writeNL();
|
|
766
786
|
const s = (StringUtils_1.StringUtils.isString(body.body) ? body.body : '');
|
|
767
|
-
this.
|
|
768
|
-
textFormat: TextFormat_1.TextFormat.text,
|
|
769
|
-
}));
|
|
787
|
+
this.writeTextOrValue(`${s}`, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.body);
|
|
770
788
|
}
|
|
771
789
|
// Stop traversal of this branch
|
|
772
790
|
return false;
|
|
@@ -793,7 +811,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
793
811
|
else {
|
|
794
812
|
for (const solution of gap.solutions) {
|
|
795
813
|
this.writeOPU();
|
|
796
|
-
this.
|
|
814
|
+
this.writeTextOrValue(solution, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
797
815
|
this.writeCL();
|
|
798
816
|
}
|
|
799
817
|
}
|
|
@@ -804,7 +822,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
804
822
|
enter_mark(node, _route) {
|
|
805
823
|
const mark = node.value;
|
|
806
824
|
this.writeOPE();
|
|
807
|
-
this.
|
|
825
|
+
this.writeTextOrValue(mark.solution, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
808
826
|
this.writeCL();
|
|
809
827
|
// Continue traversal
|
|
810
828
|
return true;
|
|
@@ -825,21 +843,19 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
825
843
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.bitsValue)
|
|
826
844
|
return true;
|
|
827
845
|
const footer = node.value;
|
|
828
|
-
const textFormat = this.getTextFormat(route);
|
|
829
846
|
// Handle footer
|
|
830
|
-
if (textFormat === TextFormat_1.TextFormat.json) {
|
|
847
|
+
if (this.textFormat === TextFormat_1.TextFormat.json) {
|
|
831
848
|
// Json footer?!
|
|
832
849
|
// Not valid, ignore
|
|
833
850
|
}
|
|
834
851
|
else if (footer.footer && footer.footer.length > 0) {
|
|
835
|
-
|
|
836
|
-
if (isBitmarkText) {
|
|
852
|
+
if (this.isBodyBitmarkText) {
|
|
837
853
|
// handle bitmark text
|
|
838
854
|
this.writeNL();
|
|
839
|
-
this.
|
|
855
|
+
this.writeTextOrValue('==== footer ====', TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.body);
|
|
840
856
|
this.writeNL();
|
|
841
857
|
// The text generator will write to the writer
|
|
842
|
-
this.
|
|
858
|
+
this.writeTextOrValue(footer.footer, this.textFormat, TextLocation_1.TextLocation.body, {
|
|
843
859
|
plainTextDividerAllowed: true, // Always allowed for the footer.
|
|
844
860
|
});
|
|
845
861
|
}
|
|
@@ -878,7 +894,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
878
894
|
return;
|
|
879
895
|
if (solution) {
|
|
880
896
|
this.writeOPE();
|
|
881
|
-
this.
|
|
897
|
+
this.writeTextOrValue(solution, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
882
898
|
this.writeCL();
|
|
883
899
|
}
|
|
884
900
|
}
|
|
@@ -905,7 +921,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
905
921
|
else {
|
|
906
922
|
this.writeOPM();
|
|
907
923
|
}
|
|
908
|
-
this.
|
|
924
|
+
this.writeTextOrValue(selectOption.text, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
909
925
|
this.writeCL();
|
|
910
926
|
// Continue traversal
|
|
911
927
|
return true;
|
|
@@ -919,29 +935,29 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
919
935
|
else {
|
|
920
936
|
this.writeOPM();
|
|
921
937
|
}
|
|
922
|
-
this.
|
|
938
|
+
this.writeTextOrValue(highlightText.text, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
923
939
|
this.writeCL();
|
|
924
940
|
// Continue traversal
|
|
925
941
|
return true;
|
|
926
942
|
}
|
|
927
943
|
// bitmarkAst -> bits -> bitsValue -> cardNode
|
|
928
|
-
enter_cardNode(_node,
|
|
944
|
+
enter_cardNode(_node, _route) {
|
|
929
945
|
// Ignore cards if not allowed
|
|
930
|
-
if (!this.isCardAllowed
|
|
946
|
+
if (!this.isCardAllowed)
|
|
931
947
|
return true;
|
|
932
948
|
this.writeCardSetStart();
|
|
933
949
|
// Continue traversal
|
|
934
950
|
return true;
|
|
935
951
|
}
|
|
936
|
-
between_cardNode(_node, _left, _right,
|
|
952
|
+
between_cardNode(_node, _left, _right, _route) {
|
|
937
953
|
// Ignore cards if not allowed
|
|
938
|
-
if (!this.isCardAllowed
|
|
954
|
+
if (!this.isCardAllowed)
|
|
939
955
|
return;
|
|
940
956
|
this.writeCardSetCardDivider();
|
|
941
957
|
}
|
|
942
|
-
exit_cardNode(_node,
|
|
958
|
+
exit_cardNode(_node, _route) {
|
|
943
959
|
// Ignore cards if not allowed
|
|
944
|
-
if (!this.isCardAllowed
|
|
960
|
+
if (!this.isCardAllowed)
|
|
945
961
|
return;
|
|
946
962
|
this.writeCardSetEnd();
|
|
947
963
|
if (this.options.cardSetVersion === CardSetVersion_1.CardSetVersion.v1) {
|
|
@@ -960,10 +976,10 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
960
976
|
this.writeCardSetCardDivider();
|
|
961
977
|
}
|
|
962
978
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> flashcards -> flashcardsValue
|
|
963
|
-
between_flashcardsValue(_node, _left, right,
|
|
979
|
+
between_flashcardsValue(_node, _left, right, _route) {
|
|
964
980
|
var _a;
|
|
965
981
|
// Ignore cards if not allowed
|
|
966
|
-
if (!this.isCardAllowed
|
|
982
|
+
if (!this.isCardAllowed)
|
|
967
983
|
return;
|
|
968
984
|
if (right.key === NodeType_1.NodeType.answer) {
|
|
969
985
|
this.writeCardSetSideDivider();
|
|
@@ -984,8 +1000,8 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
984
1000
|
enter_statements(_node, _route) {
|
|
985
1001
|
//
|
|
986
1002
|
}
|
|
987
|
-
between_statements(_node, _left, _right,
|
|
988
|
-
const isTrueFalse1 = this.isOfBitType(
|
|
1003
|
+
between_statements(_node, _left, _right, _route) {
|
|
1004
|
+
const isTrueFalse1 = this.isOfBitType(BitType_1.BitType.trueFalse1);
|
|
989
1005
|
if (!isTrueFalse1) {
|
|
990
1006
|
this.writeCardSetCardDivider();
|
|
991
1007
|
}
|
|
@@ -1000,7 +1016,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1000
1016
|
else {
|
|
1001
1017
|
this.writeOPM();
|
|
1002
1018
|
}
|
|
1003
|
-
this.
|
|
1019
|
+
this.writeTextOrValue(statement.statement, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
1004
1020
|
this.writeCL();
|
|
1005
1021
|
// Continue traversal
|
|
1006
1022
|
return true;
|
|
@@ -1017,7 +1033,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1017
1033
|
else {
|
|
1018
1034
|
this.writeOPM();
|
|
1019
1035
|
}
|
|
1020
|
-
this.
|
|
1036
|
+
this.writeTextOrValue(choice.choice, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
1021
1037
|
this.writeCL();
|
|
1022
1038
|
// Continue traversal
|
|
1023
1039
|
return true;
|
|
@@ -1033,7 +1049,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1033
1049
|
else {
|
|
1034
1050
|
this.writeOPM();
|
|
1035
1051
|
}
|
|
1036
|
-
this.
|
|
1052
|
+
this.writeTextOrValue(response.response, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
1037
1053
|
this.writeCL();
|
|
1038
1054
|
// Continue traversal
|
|
1039
1055
|
return true;
|
|
@@ -1059,9 +1075,9 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1059
1075
|
enter_heading(_node, _route) {
|
|
1060
1076
|
//
|
|
1061
1077
|
}
|
|
1062
|
-
between_heading(_node, _left, _right,
|
|
1078
|
+
between_heading(_node, _left, _right, _route) {
|
|
1063
1079
|
// Ignore cards if not allowed
|
|
1064
|
-
if (!this.isCardAllowed
|
|
1080
|
+
if (!this.isCardAllowed)
|
|
1065
1081
|
return;
|
|
1066
1082
|
this.writeCardSetSideDivider();
|
|
1067
1083
|
}
|
|
@@ -1069,9 +1085,9 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1069
1085
|
enter_forValues(_node, _route) {
|
|
1070
1086
|
//
|
|
1071
1087
|
}
|
|
1072
|
-
between_forValues(_node, _left, _right,
|
|
1088
|
+
between_forValues(_node, _left, _right, _route) {
|
|
1073
1089
|
// Ignore cards if not allowed
|
|
1074
|
-
if (!this.isCardAllowed
|
|
1090
|
+
if (!this.isCardAllowed)
|
|
1075
1091
|
return;
|
|
1076
1092
|
this.writeCardSetSideDivider();
|
|
1077
1093
|
}
|
|
@@ -1109,15 +1125,15 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1109
1125
|
}
|
|
1110
1126
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> pairs -> pairsValue -> values
|
|
1111
1127
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> matrix -> matrixValue -> cells -> cellsValue -> values
|
|
1112
|
-
enter_values(_node,
|
|
1128
|
+
enter_values(_node, _route) {
|
|
1113
1129
|
// Ignore cards if not allowed
|
|
1114
|
-
if (!this.isCardAllowed
|
|
1130
|
+
if (!this.isCardAllowed)
|
|
1115
1131
|
return;
|
|
1116
1132
|
this.writeCardSetSideDivider();
|
|
1117
1133
|
}
|
|
1118
|
-
between_values(_node, _left, _right,
|
|
1134
|
+
between_values(_node, _left, _right, _route) {
|
|
1119
1135
|
// Ignore cards if not allowed
|
|
1120
|
-
if (!this.isCardAllowed
|
|
1136
|
+
if (!this.isCardAllowed)
|
|
1121
1137
|
return;
|
|
1122
1138
|
this.writeCardSetVariantDivider();
|
|
1123
1139
|
}
|
|
@@ -1127,7 +1143,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1127
1143
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.cardNode)
|
|
1128
1144
|
return;
|
|
1129
1145
|
// Ignore cards if not allowed
|
|
1130
|
-
if (!this.isCardAllowed
|
|
1146
|
+
if (!this.isCardAllowed)
|
|
1131
1147
|
return;
|
|
1132
1148
|
this.writeCardSetCardDivider();
|
|
1133
1149
|
}
|
|
@@ -1137,7 +1153,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1137
1153
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.cardNode)
|
|
1138
1154
|
return;
|
|
1139
1155
|
// Ignore cards if not allowed
|
|
1140
|
-
if (!this.isCardAllowed
|
|
1156
|
+
if (!this.isCardAllowed)
|
|
1141
1157
|
return;
|
|
1142
1158
|
this.writeCardSetCardDivider();
|
|
1143
1159
|
}
|
|
@@ -1157,7 +1173,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1157
1173
|
if (parentKey !== NodeType_1.NodeType.table && parentKey !== NodeType_1.NodeType.captionDefinitionList)
|
|
1158
1174
|
return;
|
|
1159
1175
|
// Ignore cards if not allowed
|
|
1160
|
-
if (!this.isCardAllowed
|
|
1176
|
+
if (!this.isCardAllowed)
|
|
1161
1177
|
return;
|
|
1162
1178
|
this.writeCardSetSideDivider();
|
|
1163
1179
|
}
|
|
@@ -1166,16 +1182,13 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1166
1182
|
leaf_columnsValue(node, _route) {
|
|
1167
1183
|
this.writeNL();
|
|
1168
1184
|
this.writeOPHASH();
|
|
1169
|
-
|
|
1170
|
-
this.writeBreakscapedTagString(node.value);
|
|
1185
|
+
this.writeTextOrValue(node.value, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
1171
1186
|
this.writeCL();
|
|
1172
1187
|
}
|
|
1173
1188
|
enter_columnsValue(node, _route) {
|
|
1174
1189
|
this.writeNL();
|
|
1175
1190
|
this.writeOPHASH();
|
|
1176
|
-
|
|
1177
|
-
this.textGenerator.generateSync(node.value, TextFormat_1.TextFormat.bitmarkMinusMinus);
|
|
1178
|
-
}
|
|
1191
|
+
this.writeTextOrValue(node.value, this.tagTextFormat, TextLocation_1.TextLocation.tag);
|
|
1179
1192
|
this.writeCL();
|
|
1180
1193
|
}
|
|
1181
1194
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> table -> data -> dataValue
|
|
@@ -1185,7 +1198,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1185
1198
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.table && (parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.pronunciationTable)
|
|
1186
1199
|
return;
|
|
1187
1200
|
// Ignore cards if not allowed
|
|
1188
|
-
if (!this.isCardAllowed
|
|
1201
|
+
if (!this.isCardAllowed)
|
|
1189
1202
|
return;
|
|
1190
1203
|
this.writeCardSetSideDivider();
|
|
1191
1204
|
}
|
|
@@ -1195,16 +1208,14 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1195
1208
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.table)
|
|
1196
1209
|
return;
|
|
1197
1210
|
this.writeNL();
|
|
1198
|
-
this.
|
|
1211
|
+
this.writeTextOrValue(node.value, this.textFormat, TextLocation_1.TextLocation.body);
|
|
1199
1212
|
}
|
|
1200
1213
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> table -> data -> dataValue -> dataValueValue
|
|
1201
1214
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> pronunciationTable -> data -> dataValue -> dataValueValue
|
|
1202
1215
|
enter_dataValueValue(node, route) {
|
|
1203
|
-
var _a;
|
|
1204
1216
|
const parent = this.getParentNode(route, 3);
|
|
1205
1217
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.table && (parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.pronunciationTable)
|
|
1206
1218
|
return;
|
|
1207
|
-
const textFormat = (_a = this.getTextFormat(route)) !== null && _a !== void 0 ? _a : TextFormat_1.TextFormat.bitmarkMinusMinus;
|
|
1208
1219
|
if (node.value) {
|
|
1209
1220
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) === NodeType_1.NodeType.pronunciationTable) {
|
|
1210
1221
|
// Pronunciation Table
|
|
@@ -1213,16 +1224,16 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1213
1224
|
this.writeNL();
|
|
1214
1225
|
this.writeOP();
|
|
1215
1226
|
this.writeHash();
|
|
1216
|
-
this.
|
|
1227
|
+
this.writeTextOrValue(cell.title, this.tagTextFormat, TextLocation_1.TextLocation.tag);
|
|
1217
1228
|
this.writeCL();
|
|
1218
1229
|
}
|
|
1219
1230
|
if (cell.audio) {
|
|
1220
1231
|
this.writeNL();
|
|
1221
|
-
this.writeResource(ResourceTag_1.ResourceTag.audio, cell.audio.src);
|
|
1232
|
+
this.writeResource(ResourceTag_1.ResourceTag.audio, cell.audio.audio.src);
|
|
1222
1233
|
}
|
|
1223
1234
|
if (cell.body) {
|
|
1224
1235
|
this.writeNL();
|
|
1225
|
-
this.
|
|
1236
|
+
this.writeTextOrValue(cell.body, this.textFormat, TextLocation_1.TextLocation.body);
|
|
1226
1237
|
}
|
|
1227
1238
|
// Stop traversal of this branch
|
|
1228
1239
|
return false;
|
|
@@ -1230,10 +1241,9 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1230
1241
|
else {
|
|
1231
1242
|
// Table
|
|
1232
1243
|
this.writeNL();
|
|
1233
|
-
this.
|
|
1244
|
+
this.writeTextOrValue(node.value, this.textFormat, TextLocation_1.TextLocation.body);
|
|
1234
1245
|
}
|
|
1235
1246
|
}
|
|
1236
|
-
// this.write(node.value);
|
|
1237
1247
|
}
|
|
1238
1248
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> captionDefinitionList
|
|
1239
1249
|
between_captionDefinitionList(_node, _left, _right, route) {
|
|
@@ -1249,7 +1259,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1249
1259
|
return true;
|
|
1250
1260
|
if (node.value) {
|
|
1251
1261
|
this.writeNL();
|
|
1252
|
-
this.
|
|
1262
|
+
this.writeTextOrValue(node.value, this.textFormat, TextLocation_1.TextLocation.body);
|
|
1253
1263
|
}
|
|
1254
1264
|
// Stop traversal of this branch
|
|
1255
1265
|
return false;
|
|
@@ -1261,7 +1271,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1261
1271
|
return true;
|
|
1262
1272
|
if (node.value) {
|
|
1263
1273
|
this.writeNL();
|
|
1264
|
-
this.
|
|
1274
|
+
this.writeTextOrValue(node.value, this.textFormat, TextLocation_1.TextLocation.body);
|
|
1265
1275
|
}
|
|
1266
1276
|
// Stop traversal of this branch
|
|
1267
1277
|
return false;
|
|
@@ -1281,7 +1291,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1281
1291
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.definitions)
|
|
1282
1292
|
return;
|
|
1283
1293
|
// Ignore cards if not allowed
|
|
1284
|
-
if (!this.isCardAllowed
|
|
1294
|
+
if (!this.isCardAllowed)
|
|
1285
1295
|
return;
|
|
1286
1296
|
if (right.key === NodeType_1.NodeType.definition) {
|
|
1287
1297
|
this.writeCardSetSideDivider();
|
|
@@ -1310,7 +1320,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1310
1320
|
if (ingredient.title != null) {
|
|
1311
1321
|
this.writeNL();
|
|
1312
1322
|
this.writeOPHASH();
|
|
1313
|
-
this.
|
|
1323
|
+
this.writeTextOrValue(ingredient.title, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
1314
1324
|
this.writeCL();
|
|
1315
1325
|
// this.writeNL();
|
|
1316
1326
|
}
|
|
@@ -1326,7 +1336,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1326
1336
|
// [!43]
|
|
1327
1337
|
if (ingredient.quantity != null) {
|
|
1328
1338
|
this.writeOPB();
|
|
1329
|
-
this.
|
|
1339
|
+
this.writeTextOrValue(`${ingredient.quantity}`, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
1330
1340
|
this.writeCL();
|
|
1331
1341
|
}
|
|
1332
1342
|
// [@unit:kilograms]
|
|
@@ -1360,7 +1370,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1360
1370
|
// item
|
|
1361
1371
|
if (ingredient.item != null) {
|
|
1362
1372
|
this.writeNL();
|
|
1363
|
-
this.
|
|
1373
|
+
this.writeTextOrValue(ingredient.item, this.textFormat, TextLocation_1.TextLocation.body);
|
|
1364
1374
|
}
|
|
1365
1375
|
// Stop traversal of this branch
|
|
1366
1376
|
return false;
|
|
@@ -1386,7 +1396,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1386
1396
|
return;
|
|
1387
1397
|
this.writeNL();
|
|
1388
1398
|
this.writeOPB();
|
|
1389
|
-
this.
|
|
1399
|
+
this.writeTextOrValue(node.value, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
1390
1400
|
this.writeCL();
|
|
1391
1401
|
}
|
|
1392
1402
|
// bitmarkAst -> bits -> bitsValue -> cardNode -> botResponses -> botResponsesValue -> reaction
|
|
@@ -1406,10 +1416,10 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1406
1416
|
const parent = this.getParentNode(route);
|
|
1407
1417
|
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.botResponsesValue)
|
|
1408
1418
|
return;
|
|
1409
|
-
const
|
|
1410
|
-
if (
|
|
1419
|
+
const feedback = node.value;
|
|
1420
|
+
if (feedback) {
|
|
1411
1421
|
this.writeNL();
|
|
1412
|
-
this.
|
|
1422
|
+
this.writeTextOrValue(feedback, this.textFormat, TextLocation_1.TextLocation.body);
|
|
1413
1423
|
}
|
|
1414
1424
|
}
|
|
1415
1425
|
// bitmarkAst -> bits -> bitsValue -> imagePlaceholder
|
|
@@ -1477,6 +1487,29 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1477
1487
|
}
|
|
1478
1488
|
// bitmarkAst -> bits -> bitsValue -> bitType
|
|
1479
1489
|
// bitmarkAst -> bits -> bitsValue -> textFormat
|
|
1490
|
+
// bitmarkAst -> bits -> level
|
|
1491
|
+
leaf_level(node, route) {
|
|
1492
|
+
// Ensure this is at the bit level
|
|
1493
|
+
const parent = this.getParentNode(route);
|
|
1494
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.key) !== NodeType_1.NodeType.bitsValue)
|
|
1495
|
+
return true;
|
|
1496
|
+
// Ensure this is a chapter bit
|
|
1497
|
+
if (!Config_1.Config.isOfBitType(this.bitType, [BitType_1.BitType.chapter]))
|
|
1498
|
+
return true;
|
|
1499
|
+
const level = node.value;
|
|
1500
|
+
const bit = parent === null || parent === void 0 ? void 0 : parent.value;
|
|
1501
|
+
if (level > 0 && bit.title == null) {
|
|
1502
|
+
// If the level is set, but there is no title, this is a [.chapter] bit with an empty title.
|
|
1503
|
+
// We need to write an empty title tag at the correct level.
|
|
1504
|
+
this.writeNL();
|
|
1505
|
+
this.writeOP();
|
|
1506
|
+
for (let i = 0; i < +level; i++)
|
|
1507
|
+
this.writeHash();
|
|
1508
|
+
this.writeCL();
|
|
1509
|
+
}
|
|
1510
|
+
// Stop traversal of this branch
|
|
1511
|
+
return false;
|
|
1512
|
+
}
|
|
1480
1513
|
// bitmarkAst -> bits -> title
|
|
1481
1514
|
enter_title(node, route) {
|
|
1482
1515
|
// Ensure this is at the bit level
|
|
@@ -1492,7 +1525,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1492
1525
|
this.writeOP();
|
|
1493
1526
|
for (let i = 0; i < +level; i++)
|
|
1494
1527
|
this.writeHash();
|
|
1495
|
-
this.
|
|
1528
|
+
this.writeTextOrValue(title, this.tagTextFormat, TextLocation_1.TextLocation.tag);
|
|
1496
1529
|
this.writeCL();
|
|
1497
1530
|
}
|
|
1498
1531
|
// Stop traversal of this branch
|
|
@@ -1512,7 +1545,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1512
1545
|
this.writeOP();
|
|
1513
1546
|
for (let i = 0; i < level; i++)
|
|
1514
1547
|
this.writeHash();
|
|
1515
|
-
this.
|
|
1548
|
+
this.writeTextOrValue(subtitle, this.tagTextFormat, TextLocation_1.TextLocation.tag);
|
|
1516
1549
|
this.writeCL();
|
|
1517
1550
|
}
|
|
1518
1551
|
// Stop traversal of this branch
|
|
@@ -1536,11 +1569,11 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1536
1569
|
});
|
|
1537
1570
|
if (book.reference) {
|
|
1538
1571
|
this.writeOPRANGLE();
|
|
1539
|
-
this.
|
|
1572
|
+
this.writeTextOrValue(book.reference, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
1540
1573
|
this.writeCL();
|
|
1541
1574
|
if (book.referenceEnd) {
|
|
1542
1575
|
this.writeOPRANGLE();
|
|
1543
|
-
this.
|
|
1576
|
+
this.writeTextOrValue(book.referenceEnd, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
1544
1577
|
this.writeCL();
|
|
1545
1578
|
}
|
|
1546
1579
|
}
|
|
@@ -1561,11 +1594,11 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1561
1594
|
});
|
|
1562
1595
|
if (bit.reference) {
|
|
1563
1596
|
this.writeOPRANGLE();
|
|
1564
|
-
this.
|
|
1597
|
+
this.writeTextOrValue(bit.reference, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
1565
1598
|
this.writeCL();
|
|
1566
1599
|
if (bit.referenceEnd) {
|
|
1567
1600
|
this.writeOPRANGLE();
|
|
1568
|
-
this.
|
|
1601
|
+
this.writeTextOrValue(bit.referenceEnd, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
1569
1602
|
this.writeCL();
|
|
1570
1603
|
}
|
|
1571
1604
|
}
|
|
@@ -1576,7 +1609,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1576
1609
|
if (node.value) {
|
|
1577
1610
|
this.writeNL();
|
|
1578
1611
|
this.writeOPDANGLE();
|
|
1579
|
-
this.
|
|
1612
|
+
this.writeTextOrValue(node.value, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
1580
1613
|
this.writeCL();
|
|
1581
1614
|
}
|
|
1582
1615
|
}
|
|
@@ -1589,7 +1622,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1589
1622
|
if (!bit.book) {
|
|
1590
1623
|
this.writeNL();
|
|
1591
1624
|
this.writeOPRANGLE();
|
|
1592
|
-
this.
|
|
1625
|
+
this.writeTextOrValue(node.value, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
1593
1626
|
this.writeCL();
|
|
1594
1627
|
}
|
|
1595
1628
|
}
|
|
@@ -1603,7 +1636,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1603
1636
|
if (!this.isEmptyText(text)) {
|
|
1604
1637
|
this.writeNL_IfNotChain(route);
|
|
1605
1638
|
this.writeOPQ();
|
|
1606
|
-
this.
|
|
1639
|
+
this.writeTextOrValue(text, this.tagTextFormat, TextLocation_1.TextLocation.tag);
|
|
1607
1640
|
this.writeCL();
|
|
1608
1641
|
}
|
|
1609
1642
|
// Stop traversal of this branch
|
|
@@ -1616,7 +1649,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1616
1649
|
if (!this.isEmptyText(text)) {
|
|
1617
1650
|
this.writeNL_IfNotChain(route);
|
|
1618
1651
|
this.writeOPB();
|
|
1619
|
-
this.
|
|
1652
|
+
this.writeTextOrValue(text, this.tagTextFormat, TextLocation_1.TextLocation.tag);
|
|
1620
1653
|
this.writeCL();
|
|
1621
1654
|
}
|
|
1622
1655
|
// Stop traversal of this branch
|
|
@@ -1704,18 +1737,18 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1704
1737
|
this.writeString('example');
|
|
1705
1738
|
this.writeColon();
|
|
1706
1739
|
if (example === true) {
|
|
1707
|
-
this.writeString('true');
|
|
1740
|
+
this.writeString(' true ');
|
|
1708
1741
|
}
|
|
1709
1742
|
else if (example === false) {
|
|
1710
|
-
this.writeString('false');
|
|
1743
|
+
this.writeString(' false ');
|
|
1711
1744
|
}
|
|
1712
1745
|
else if (Array.isArray(example)) {
|
|
1713
1746
|
// TextAst
|
|
1714
|
-
this.
|
|
1747
|
+
this.writeTextOrValue(example, this.tagTextFormat, TextLocation_1.TextLocation.tag);
|
|
1715
1748
|
}
|
|
1716
1749
|
else {
|
|
1717
1750
|
// String
|
|
1718
|
-
this.
|
|
1751
|
+
this.writeTextOrValue(example, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
1719
1752
|
}
|
|
1720
1753
|
this.writeCL();
|
|
1721
1754
|
}
|
|
@@ -1730,7 +1763,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1730
1763
|
leaf_elementsValue(node, _route) {
|
|
1731
1764
|
if (node.value) {
|
|
1732
1765
|
this.writeNL();
|
|
1733
|
-
this.
|
|
1766
|
+
this.writeTextOrValue(node.value, this.textFormat, TextLocation_1.TextLocation.body);
|
|
1734
1767
|
}
|
|
1735
1768
|
}
|
|
1736
1769
|
// bitmarkAst -> bits -> bitsValue -> body -> bodyValue -> gap -> solutions -> solution
|
|
@@ -1741,7 +1774,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1741
1774
|
return;
|
|
1742
1775
|
if (node.value != null) {
|
|
1743
1776
|
this.writeOPU();
|
|
1744
|
-
this.
|
|
1777
|
+
this.writeTextOrValue(node.value, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
1745
1778
|
this.writeCL();
|
|
1746
1779
|
}
|
|
1747
1780
|
}
|
|
@@ -1750,7 +1783,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1750
1783
|
leaf_prefix(node, _route) {
|
|
1751
1784
|
if (node.value) {
|
|
1752
1785
|
this.writeOPPRE();
|
|
1753
|
-
this.
|
|
1786
|
+
this.writeTextOrValue(node.value, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
1754
1787
|
this.writeCL();
|
|
1755
1788
|
}
|
|
1756
1789
|
}
|
|
@@ -1759,7 +1792,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1759
1792
|
leaf_postfix(node, _route) {
|
|
1760
1793
|
if (node.value) {
|
|
1761
1794
|
this.writeOPPOST();
|
|
1762
|
-
this.
|
|
1795
|
+
this.writeTextOrValue(node.value, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
1763
1796
|
this.writeCL();
|
|
1764
1797
|
}
|
|
1765
1798
|
}
|
|
@@ -1777,21 +1810,21 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1777
1810
|
leaf_forKeys(node, _route) {
|
|
1778
1811
|
this.writeNL();
|
|
1779
1812
|
this.writeOPHASH();
|
|
1780
|
-
this.
|
|
1813
|
+
this.writeTextOrValue(node.value, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
1781
1814
|
this.writeCL();
|
|
1782
1815
|
}
|
|
1783
1816
|
// bitmarkAst -> bits -> bitsValue -> heading -> forValues
|
|
1784
1817
|
leaf_forValues(node, _route) {
|
|
1785
1818
|
this.writeNL();
|
|
1786
1819
|
this.writeOPHASH();
|
|
1787
|
-
this.
|
|
1820
|
+
this.writeTextOrValue(node.value, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
1788
1821
|
this.writeCL();
|
|
1789
1822
|
}
|
|
1790
1823
|
// bitmarkAst -> bits -> bitsValue -> heading -> forValuesValue
|
|
1791
1824
|
leaf_forValuesValue(node, _route) {
|
|
1792
1825
|
this.writeNL();
|
|
1793
1826
|
this.writeOPHASH();
|
|
1794
|
-
this.
|
|
1827
|
+
this.writeTextOrValue(node.value, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
1795
1828
|
this.writeCL();
|
|
1796
1829
|
}
|
|
1797
1830
|
// bitmarkAst -> bits -> bitsValue -> pairs -> pairsValue -> key
|
|
@@ -1799,7 +1832,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1799
1832
|
leaf_key(node, _route) {
|
|
1800
1833
|
if (node.value) {
|
|
1801
1834
|
this.writeNL();
|
|
1802
|
-
this.
|
|
1835
|
+
this.writeTextOrValue(node.value, this.textFormat, TextLocation_1.TextLocation.body);
|
|
1803
1836
|
}
|
|
1804
1837
|
}
|
|
1805
1838
|
// bitmarkAst -> bits -> bitsValue -> pairs -> pairsValue -> values -> valuesValue
|
|
@@ -1807,7 +1840,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1807
1840
|
leaf_valuesValue(node, _route) {
|
|
1808
1841
|
if (node.value) {
|
|
1809
1842
|
this.writeNL();
|
|
1810
|
-
this.
|
|
1843
|
+
this.writeTextOrValue(node.value, this.textFormat, TextLocation_1.TextLocation.body);
|
|
1811
1844
|
}
|
|
1812
1845
|
}
|
|
1813
1846
|
// bitmarkAst -> bits -> bitsValue -> questions -> questionsValue -> question
|
|
@@ -1819,7 +1852,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1819
1852
|
return;
|
|
1820
1853
|
if (node.value) {
|
|
1821
1854
|
this.writeNL();
|
|
1822
|
-
this.
|
|
1855
|
+
this.writeTextOrValue(node.value, this.textFormat, TextLocation_1.TextLocation.body);
|
|
1823
1856
|
}
|
|
1824
1857
|
}
|
|
1825
1858
|
// bitmarkAst -> bits -> bitsValue -> statements -> text
|
|
@@ -1876,9 +1909,8 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
1876
1909
|
ignoreEmpty: true,
|
|
1877
1910
|
});
|
|
1878
1911
|
}
|
|
1879
|
-
leaf_zoomDisabled(node,
|
|
1880
|
-
|
|
1881
|
-
if (Config_1.Config.isOfBitType(bitType, [
|
|
1912
|
+
leaf_zoomDisabled(node, _route) {
|
|
1913
|
+
if (Config_1.Config.isOfBitType(this.bitType, [
|
|
1882
1914
|
BitType_1.BitType.imageSeparator,
|
|
1883
1915
|
BitType_1.BitType.pageBanner,
|
|
1884
1916
|
BitType_1.BitType.imagesLogoGrave,
|
|
@@ -2143,8 +2175,7 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
2143
2175
|
return false;
|
|
2144
2176
|
}
|
|
2145
2177
|
else if (footer.footer && footer.footer.length > 0) {
|
|
2146
|
-
|
|
2147
|
-
if (isBitmarkText) {
|
|
2178
|
+
if (this.isBodyBitmarkText) {
|
|
2148
2179
|
// handle bitmark text
|
|
2149
2180
|
return true;
|
|
2150
2181
|
}
|
|
@@ -2156,17 +2187,108 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
2156
2187
|
}
|
|
2157
2188
|
return false;
|
|
2158
2189
|
}
|
|
2190
|
+
/**
|
|
2191
|
+
* Calculate the number of spaces around values from the options.
|
|
2192
|
+
*
|
|
2193
|
+
* This function should only be called from the constructor.
|
|
2194
|
+
* Otherwise use this.spacesAroundValues.
|
|
2195
|
+
*
|
|
2196
|
+
* @returns
|
|
2197
|
+
*/
|
|
2198
|
+
calcSpacesAroundValues() {
|
|
2199
|
+
const val = this.options.spacesAroundValues;
|
|
2200
|
+
let spaces = DEFAULT_SPACES_AROUND_VALUES;
|
|
2201
|
+
if (val != null) {
|
|
2202
|
+
if (val === true) {
|
|
2203
|
+
spaces = DEFAULT_SPACES_AROUND_VALUES;
|
|
2204
|
+
}
|
|
2205
|
+
else if (val === false) {
|
|
2206
|
+
spaces = 0;
|
|
2207
|
+
}
|
|
2208
|
+
else {
|
|
2209
|
+
spaces = val;
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
spaces = Math.min(Math.max(spaces, 0), MAX_SPACES_AROUND_VALUES);
|
|
2213
|
+
return spaces;
|
|
2214
|
+
}
|
|
2159
2215
|
// END UTILITY FUNCTIONS
|
|
2160
2216
|
//
|
|
2161
2217
|
// WRITE FUNCTIONS
|
|
2162
2218
|
//
|
|
2163
|
-
|
|
2219
|
+
/**
|
|
2220
|
+
* Helper function to write a tag key, breakscaping appropriately.
|
|
2221
|
+
* Use only to write a tag key.
|
|
2222
|
+
*
|
|
2223
|
+
* @param s
|
|
2224
|
+
*/
|
|
2225
|
+
writeTagKey(s) {
|
|
2164
2226
|
if (s != null) {
|
|
2165
2227
|
this.write(Breakscape_1.Breakscape.breakscape(`${s}`, {
|
|
2166
|
-
textFormat: TextFormat_1.TextFormat.
|
|
2228
|
+
textFormat: TextFormat_1.TextFormat.text,
|
|
2229
|
+
textLocation: TextLocation_1.TextLocation.tag,
|
|
2167
2230
|
}));
|
|
2168
2231
|
}
|
|
2169
2232
|
}
|
|
2233
|
+
/**
|
|
2234
|
+
* Write text or value, handling the format and location (i.e. conversion to text and breakscaping).
|
|
2235
|
+
*
|
|
2236
|
+
* @param text
|
|
2237
|
+
* @param format
|
|
2238
|
+
* @param location
|
|
2239
|
+
* @param options
|
|
2240
|
+
*/
|
|
2241
|
+
writeTextOrValue(text, format, location, options) {
|
|
2242
|
+
const isTagValue = location === TextLocation_1.TextLocation.tag;
|
|
2243
|
+
const s = StringUtils_1.StringUtils.isString(text) ? text : undefined;
|
|
2244
|
+
const ast = Array.isArray(text) ? text : undefined;
|
|
2245
|
+
const isBitmarkText = format === TextFormat_1.TextFormat.bitmarkPlusPlus || format === TextFormat_1.TextFormat.bitmarkMinusMinus;
|
|
2246
|
+
const isPlainText = !isBitmarkText;
|
|
2247
|
+
const spacesAroundValues = isTagValue ? this.spacesAroundValuesStr : '';
|
|
2248
|
+
if (isPlainText) {
|
|
2249
|
+
// Plain text
|
|
2250
|
+
if (s != null) {
|
|
2251
|
+
this.write(`${spacesAroundValues}${Breakscape_1.Breakscape.breakscape(`${s}`, {
|
|
2252
|
+
textFormat: TextFormat_1.TextFormat.text,
|
|
2253
|
+
textLocation: location,
|
|
2254
|
+
})}${spacesAroundValues}`);
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
else {
|
|
2258
|
+
// Bitmark text (but might not be AST as some values are just strings (and all v2 values are strings))
|
|
2259
|
+
if (s != null) {
|
|
2260
|
+
this.write(`${spacesAroundValues}${Breakscape_1.Breakscape.breakscape(`${s}`, {
|
|
2261
|
+
textFormat: format,
|
|
2262
|
+
textLocation: location,
|
|
2263
|
+
})}${spacesAroundValues}`);
|
|
2264
|
+
}
|
|
2265
|
+
else if (ast != null) {
|
|
2266
|
+
// When writing a tag value, we don't know if it is empty until we write it, so we need to
|
|
2267
|
+
// write it using the part writer, and then check if it is empty before writing to the main writer.
|
|
2268
|
+
// Body values can be written directly to the main writer.
|
|
2269
|
+
if (isTagValue) {
|
|
2270
|
+
// Change the writer to the part writer
|
|
2271
|
+
this.writer = this.partWriter;
|
|
2272
|
+
this.partWriter.openSync();
|
|
2273
|
+
// Write the text
|
|
2274
|
+
this.textGenerator.generateSync(ast, format, location, options);
|
|
2275
|
+
// Get the written text
|
|
2276
|
+
this.partWriter.closeSync();
|
|
2277
|
+
const text = this.partWriter.getString();
|
|
2278
|
+
// Restore the main writer
|
|
2279
|
+
this.writer = this.mainWriter;
|
|
2280
|
+
// Write the text to the main writer, adding spaces around it where required
|
|
2281
|
+
if (text) {
|
|
2282
|
+
this.write(`${spacesAroundValues}${text.trim()}${spacesAroundValues}`);
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
else {
|
|
2286
|
+
// Write the text directly to the main writer
|
|
2287
|
+
this.textGenerator.generateSync(ast, format, location, options);
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2170
2292
|
writeString(s) {
|
|
2171
2293
|
if (s != null)
|
|
2172
2294
|
this.write(`${s}`);
|
|
@@ -2235,8 +2357,14 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
2235
2357
|
this.write('[');
|
|
2236
2358
|
}
|
|
2237
2359
|
writeCL() {
|
|
2238
|
-
// HACK to fix breakscaping when string ends with a ^ (must add a space)
|
|
2239
|
-
|
|
2360
|
+
// HACK to fix breakscaping when string ends with a ^ (must add a space) if
|
|
2361
|
+
// options.spacesAroundValues is 0
|
|
2362
|
+
if (this.spacesAroundValues === 0) {
|
|
2363
|
+
this.writer.getLastWrite().endsWith('^') ? this.write(' ]') : this.write(']');
|
|
2364
|
+
}
|
|
2365
|
+
else {
|
|
2366
|
+
this.write(']');
|
|
2367
|
+
}
|
|
2240
2368
|
}
|
|
2241
2369
|
writeAmpersand() {
|
|
2242
2370
|
this.write('&');
|
|
@@ -2250,6 +2378,9 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
2250
2378
|
writeHash() {
|
|
2251
2379
|
this.write('#');
|
|
2252
2380
|
}
|
|
2381
|
+
writeSpacesAroundValues() {
|
|
2382
|
+
this.write(this.spacesAroundValuesStr);
|
|
2383
|
+
}
|
|
2253
2384
|
writePlainTextDivider() {
|
|
2254
2385
|
this.writeNL();
|
|
2255
2386
|
this.write('==== text ====');
|
|
@@ -2319,9 +2450,9 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
2319
2450
|
const resourceData = resource[resourceTag];
|
|
2320
2451
|
const src = resourceData ? resourceData.src || resourceData.url || resourceData.body || '' : '';
|
|
2321
2452
|
this.writeOPA();
|
|
2322
|
-
this.
|
|
2453
|
+
this.writeTagKey(key);
|
|
2323
2454
|
this.writeColon();
|
|
2324
|
-
this.
|
|
2455
|
+
this.writeTextOrValue(src, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
2325
2456
|
if (resource.type === ResourceTag_1.ResourceTag.article) {
|
|
2326
2457
|
// this.writeNL();
|
|
2327
2458
|
}
|
|
@@ -2333,9 +2464,9 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
2333
2464
|
if (type) {
|
|
2334
2465
|
// Standard case
|
|
2335
2466
|
this.writeOPAMP();
|
|
2336
|
-
this.
|
|
2467
|
+
this.writeTagKey(type);
|
|
2337
2468
|
this.writeColon();
|
|
2338
|
-
this.
|
|
2469
|
+
this.writeTextOrValue(value, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
2339
2470
|
if (type === ResourceTag_1.ResourceTag.article) {
|
|
2340
2471
|
// this.writeNL();
|
|
2341
2472
|
}
|
|
@@ -2352,9 +2483,9 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
2352
2483
|
if (options.ignoreEmpty && isBitmarkText && this.isEmptyText(values))
|
|
2353
2484
|
return;
|
|
2354
2485
|
this.writeOPA();
|
|
2355
|
-
this.
|
|
2486
|
+
this.writeTagKey(name);
|
|
2356
2487
|
this.writeColon();
|
|
2357
|
-
this.
|
|
2488
|
+
this.writeTextOrValue(values, (_a = TextFormat_1.TextFormat.fromValue(options.format)) !== null && _a !== void 0 ? _a : TextFormat_1.TextFormat.bitmarkMinusMinus, TextLocation_1.TextLocation.tag);
|
|
2358
2489
|
this.writeCL();
|
|
2359
2490
|
}
|
|
2360
2491
|
else {
|
|
@@ -2377,9 +2508,9 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
2377
2508
|
if (options.ignoreEmpty && val === '')
|
|
2378
2509
|
continue;
|
|
2379
2510
|
this.writeOPA();
|
|
2380
|
-
this.
|
|
2511
|
+
this.writeTagKey(name);
|
|
2381
2512
|
this.writeColon();
|
|
2382
|
-
this.
|
|
2513
|
+
this.writeTextOrValue(`${val}`, TextFormat_1.TextFormat.text, TextLocation_1.TextLocation.tag);
|
|
2383
2514
|
this.writeCL();
|
|
2384
2515
|
// propertyIndex++;
|
|
2385
2516
|
}
|
|
@@ -2416,35 +2547,14 @@ class BitmarkGenerator extends AstWalkerGenerator_1.AstWalkerGenerator {
|
|
|
2416
2547
|
const writeFormat = !isDefault || this.options.explicitTextFormat;
|
|
2417
2548
|
return !!writeFormat;
|
|
2418
2549
|
}
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
if (node.key === NodeType_1.NodeType.bitsValue) {
|
|
2422
|
-
const n = node.value;
|
|
2423
|
-
return n === null || n === void 0 ? void 0 : n.textFormat;
|
|
2424
|
-
}
|
|
2425
|
-
}
|
|
2426
|
-
return undefined;
|
|
2427
|
-
}
|
|
2428
|
-
isCardAllowed(route) {
|
|
2429
|
-
const textFormat = this.getTextFormat(route);
|
|
2430
|
-
const isBitmarkText = textFormat === TextFormat_1.TextFormat.bitmarkMinusMinus || textFormat === TextFormat_1.TextFormat.bitmarkPlusPlus;
|
|
2431
|
-
return isBitmarkText && !this.isOfBitType1(route);
|
|
2432
|
-
}
|
|
2433
|
-
isOfBitType1(route) {
|
|
2434
|
-
return this.isOfBitType(route, [BitType_1.BitType.trueFalse1, BitType_1.BitType.multipleChoice1, BitType_1.BitType.multipleResponse1]);
|
|
2550
|
+
calculateIsCardAllowed() {
|
|
2551
|
+
return this.isBodyBitmarkText && !this.isOfBitType1();
|
|
2435
2552
|
}
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
return Config_1.Config.isOfBitType(bt, baseBitType);
|
|
2553
|
+
isOfBitType1() {
|
|
2554
|
+
return this.isOfBitType([BitType_1.BitType.trueFalse1, BitType_1.BitType.multipleChoice1, BitType_1.BitType.multipleResponse1]);
|
|
2439
2555
|
}
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
if (node.key === NodeType_1.NodeType.bitsValue) {
|
|
2443
|
-
const n = node.value;
|
|
2444
|
-
return n === null || n === void 0 ? void 0 : n.bitType;
|
|
2445
|
-
}
|
|
2446
|
-
}
|
|
2447
|
-
return undefined;
|
|
2556
|
+
isOfBitType(baseBitType) {
|
|
2557
|
+
return Config_1.Config.isOfBitType(this.bitType, baseBitType);
|
|
2448
2558
|
}
|
|
2449
2559
|
//
|
|
2450
2560
|
// Writer interface
|