@gmb/bitmark-parser-generator 3.30.0 → 3.31.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/ast/Builder.js +1 -1
- package/dist/cjs/ast/Builder.js.map +1 -1
- package/dist/cjs/breakscaping/Breakscape.js +23 -269
- package/dist/cjs/breakscaping/Breakscape.js.map +1 -1
- package/dist/cjs/config/raw/bits.js +15 -0
- package/dist/cjs/config/raw/bits.js.map +1 -1
- package/dist/cjs/config/raw/properties.js +9 -0
- package/dist/cjs/config/raw/properties.js.map +1 -1
- package/dist/cjs/generated/build-info.js +1 -1
- package/dist/cjs/generator/bitmark/BitmarkGenerator.js +44 -44
- package/dist/cjs/generator/bitmark/BitmarkGenerator.js.map +1 -1
- package/dist/cjs/generator/json/JsonGenerator.js +7 -0
- package/dist/cjs/generator/json/JsonGenerator.js.map +1 -1
- package/dist/cjs/model/ast/NodeType.js +4 -0
- package/dist/cjs/model/ast/NodeType.js.map +1 -1
- package/dist/cjs/model/config/enum/PropertyConfigKey.js +2 -0
- package/dist/cjs/model/config/enum/PropertyConfigKey.js.map +1 -1
- package/dist/cjs/model/enum/BitType.js +1 -0
- package/dist/cjs/model/enum/BitType.js.map +1 -1
- package/dist/esm/ast/Builder.js +1 -1
- package/dist/esm/ast/Builder.js.map +1 -1
- package/dist/esm/breakscaping/Breakscape.js +23 -269
- package/dist/esm/breakscaping/Breakscape.js.map +1 -1
- package/dist/esm/config/raw/bits.js +15 -0
- package/dist/esm/config/raw/bits.js.map +1 -1
- package/dist/esm/config/raw/properties.js +9 -0
- package/dist/esm/config/raw/properties.js.map +1 -1
- package/dist/esm/generated/build-info.js +1 -1
- package/dist/esm/generator/bitmark/BitmarkGenerator.js +44 -44
- package/dist/esm/generator/bitmark/BitmarkGenerator.js.map +1 -1
- package/dist/esm/generator/json/JsonGenerator.js +7 -0
- package/dist/esm/generator/json/JsonGenerator.js.map +1 -1
- package/dist/esm/model/ast/NodeType.js +4 -0
- package/dist/esm/model/ast/NodeType.js.map +1 -1
- package/dist/esm/model/config/enum/PropertyConfigKey.js +2 -0
- package/dist/esm/model/config/enum/PropertyConfigKey.js.map +1 -1
- package/dist/esm/model/enum/BitType.js +1 -0
- package/dist/esm/model/enum/BitType.js.map +1 -1
- package/dist/types/ast/Builder.d.ts +2 -0
- package/dist/types/ast/Builder.d.ts.map +1 -1
- package/dist/types/breakscaping/Breakscape.d.ts +7 -17
- 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/generator/bitmark/BitmarkGenerator.d.ts.map +1 -1
- package/dist/types/generator/json/JsonGenerator.d.ts.map +1 -1
- package/dist/types/model/ast/NodeType.d.ts +8 -0
- package/dist/types/model/ast/NodeType.d.ts.map +1 -1
- package/dist/types/model/ast/Nodes.d.ts +2 -0
- package/dist/types/model/ast/Nodes.d.ts.map +1 -1
- package/dist/types/model/config/enum/ConfigKey.d.ts +4 -0
- package/dist/types/model/config/enum/ConfigKey.d.ts.map +1 -1
- package/dist/types/model/config/enum/PropertyConfigKey.d.ts +6 -0
- package/dist/types/model/config/enum/PropertyConfigKey.d.ts.map +1 -1
- package/dist/types/model/enum/BitType.d.ts +2 -0
- package/dist/types/model/enum/BitType.d.ts.map +1 -1
- package/dist/types/model/enum/PropertyTag.d.ts +4 -0
- package/dist/types/model/enum/PropertyTag.d.ts.map +1 -1
- package/dist/types/model/json/BitJson.d.ts +2 -0
- package/dist/types/model/json/BitJson.d.ts.map +1 -1
- package/package.json +2 -1
|
@@ -3,152 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Breakscape = void 0;
|
|
4
4
|
const TextFormat_1 = require("../model/enum/TextFormat");
|
|
5
5
|
const TextLocation_1 = require("../model/enum/TextLocation");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* Utility class for breakscaping strings.
|
|
9
|
-
*
|
|
10
|
-
* ============
|
|
11
|
-
* Breakscaping
|
|
12
|
-
* ============
|
|
13
|
-
*
|
|
14
|
-
* Breakscaping is the process of escaping certain character sequences in a string so that they are not interpreted as
|
|
15
|
-
* special sequences by the parser.
|
|
16
|
-
*
|
|
17
|
-
* This is different from escaping in that when escaping, single characters tend to be escaped, rather than sequences
|
|
18
|
-
* being broken (split) by a special charater.
|
|
19
|
-
*
|
|
20
|
-
* The special character is ^
|
|
21
|
-
* To include the special character in a text which is breakscaped, use ^^ (once), ^^^ (twice), etc.
|
|
22
|
-
*
|
|
23
|
-
* Any sequence can be breakscaped by breaking it with a single ^ character.
|
|
24
|
-
*
|
|
25
|
-
* When breakscaping text programmatically, the following rules apply to keep the breakscaping to a minimum:
|
|
26
|
-
*
|
|
27
|
-
* The following breakscaping rules are applied when breakscaping text:
|
|
28
|
-
* <item> <from> <to> <textFormat>
|
|
29
|
-
* - hat: ^ ==> ^^ [bodyBitmark, tagBitmark, tagPlain]
|
|
30
|
-
* - hat: ^^ ==> ^^^ [bodyBitmark, tagBitmark, tagPlain]
|
|
31
|
-
* - hat: ^..N ==> ^..N+1 [bodyBitmark, tagBitmark, tagPlain]
|
|
32
|
-
* - inline: == ==> =^= [bodyBitmark, tagBitmark]
|
|
33
|
-
* - bold: ** ==> *^* [bodyBitmark, tagBitmark]
|
|
34
|
-
* - light: `` ==> `^` [bodyBitmark, tagBitmark]
|
|
35
|
-
* - italic: __ ==> _^_ [bodyBitmark, tagBitmark]
|
|
36
|
-
* - highlight: !! ==> !^! [bodyBitmark, tagBitmark]
|
|
37
|
-
*
|
|
38
|
-
* - title block: (SOL)[##]#(space) ==> (SOL)[##]#^(space) [bodyBitmark]
|
|
39
|
-
* - new block: (SOL)|(WS EOL) ==> (SOL)|^(WS EOL) [bodyBitmark]
|
|
40
|
-
* - code block: (SOL)|code(:type) ==> (SOL)|^code(:type) [bodyBitmark]
|
|
41
|
-
* - image block: (SOL)|image:(url) ==> (SOL)|^image:(url) [bodyBitmark]
|
|
42
|
-
* - bullet list: (SOL)•(space) ==> (SOL)•^(space) [bodyBitmark]
|
|
43
|
-
* - simple list: (SOL)•_(space) ==> (SOL)•^_(space) [bodyBitmark]
|
|
44
|
-
* - ordered list (numeric): (SOL)•<numbers>(space) ==> (SOL)•^<numbers>(space) [bodyBitmark]
|
|
45
|
-
* - ordered list: (roman,lower) (SOL)•<numbers>i(space) ==> (SOL)•^<numbers>i(space) [bodyBitmark]
|
|
46
|
-
* - ordered list: (roman,upper) (SOL)•<numbers>I(space) ==> (SOL)•^<numbers>I(space) [bodyBitmark]
|
|
47
|
-
* - ordered list: (SOL)•<letters>(space) ==> (SOL)•^<letters>(space) [bodyBitmark]
|
|
48
|
-
* - tag list +: (SOL)•+(space) ==> (SOL)•^+(space) [bodyBitmark]
|
|
49
|
-
* - tag list -: (SOL)•-(space) ==> (SOL)•^-(space) [bodyBitmark]
|
|
50
|
-
*
|
|
51
|
-
* - start of bit: [. ==> [^. [bodyBitmark]
|
|
52
|
-
* - start of property: [@ ==> [^@ [bodyBitmark]
|
|
53
|
-
* - start of title: [# ==> [^# [bodyBitmark]
|
|
54
|
-
* - start of anchor: [▼ ==> [^▼ [bodyBitmark]
|
|
55
|
-
* - start of reference: [► ==> [^► [bodyBitmark]
|
|
56
|
-
* - start of item/lead: [% ==> [^% [bodyBitmark]
|
|
57
|
-
* - start of instruction: [! ==> [^! [bodyBitmark]
|
|
58
|
-
* - start of hint: [? ==> [^? [bodyBitmark]
|
|
59
|
-
* - start of true statement: [+ ==> [^+ [bodyBitmark]
|
|
60
|
-
* - start of false statement: [- ==> [^- [bodyBitmark]
|
|
61
|
-
* - start of sample solution: [$ ==> [^$ [bodyBitmark]
|
|
62
|
-
* - start of gap: [_ ==> [^_ [bodyBitmark]
|
|
63
|
-
* - start of mark: [= ==> [^= [bodyBitmark]
|
|
64
|
-
* - start of resource: [& ==> [^& [bodyBitmark]
|
|
65
|
-
* - old plain text divider: $$$$ ==> $^$$$ [bodyBitmark]
|
|
66
|
-
* - old footer divider: ~~~~ ==> ~^~~~ [bodyBitmark]
|
|
67
|
-
*
|
|
68
|
-
* - start of bit: (SOL)[. ==> (SOL)[^. [bodyPlain]
|
|
69
|
-
* - start of bit: (SOL)[^. ==> (SOL)[^^. [bodyPlain]
|
|
70
|
-
* - start of bit: (SOL)[^..N. ==> (SOL)[^..N+1. [bodyPlain]
|
|
71
|
-
*
|
|
72
|
-
* - end of tag: ] ==> ^] [tagBitmark, tagPlain]
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* ==============
|
|
76
|
-
* Unbreakscaping
|
|
77
|
-
* ==============
|
|
78
|
-
*
|
|
79
|
-
* Unbreakscaping is the process of removing the breakscaping characters from a string.
|
|
80
|
-
* It is the opposite of breakscaping.
|
|
81
|
-
*
|
|
82
|
-
* In all text but plain text:
|
|
83
|
-
* ^ is always removed/reduced wherever it is found.
|
|
84
|
-
* ^^ is always needed to represent a ^.
|
|
85
|
-
*
|
|
86
|
-
* In plain text:
|
|
87
|
-
* ^ is only removed/reduced when it would break the start of a bit.
|
|
88
|
-
*
|
|
89
|
-
* The following unbreakscaping rules apply when unbreakscaping text:
|
|
90
|
-
* <item> <from> <to> <textFormat>
|
|
91
|
-
* - hat: ^ ==> [bodyBitmark, tagBitmark, tagPlain]
|
|
92
|
-
* - hat: ^^ ==> ^ [bodyBitmark, tagBitmark, tagPlain]
|
|
93
|
-
* - hat: ^..N ==> ^..N-1 [bodyBitmark, tagBitmark, tagPlain]
|
|
94
|
-
*
|
|
95
|
-
* - start of bit: (SOL)[^. ==> (SOL)[. [bodyPlain]
|
|
96
|
-
* - start of bit: (SOL)[^^. ==> (SOL)[^. [bodyPlain]
|
|
97
|
-
* - start of bit: (SOL)[^..N. ==> (SOL)[^..N-1. [bodyPlain]
|
|
98
|
-
*
|
|
99
|
-
*/
|
|
100
|
-
//
|
|
101
|
-
// Breakscaping
|
|
102
|
-
//
|
|
103
|
-
const REGEX_MARKS = /([*`_!=])(?=\1)/; // BM_TAG: $1^ --BODY: $1^ ++BODY: $1^
|
|
104
|
-
const REGEX_BLOCKS = /^(\|)(code[\s]*|code:|image:|[\s]*$)/; // ++BODY: $2^$3
|
|
105
|
-
const REGEX_TITLE_BLOCKS = /^([#]{1,3})([^\S\r\n]+)/; // ++BODY: $4^$5
|
|
106
|
-
const REGEX_LIST_BLOCKS = /^(•)([0-9]+[iI]*|[a-zA-Z]{1}|_|\+|-|)([^\S\r\n]+)/; // ++BODY: $6^$7$8
|
|
107
|
-
const REGEX_START_OF_TAG = /(\[)([.@#▼►%!?+\-$_=&])/; // --BODY: $2^$3 ++BODY: $9^$10
|
|
108
|
-
const REGEX_FOOTER_DIVIDER = /^(~)(~~~[ \t]*)$/; // --BODY: $4^$5 ++BODY: $11^$12
|
|
109
|
-
const REGEX_PLAIN_TEXT_DIVIDER = /^(\$)(\$\$\$[ \t]*)$/; // --BODY: $6^$7 ++BODY: $13^$14
|
|
110
|
-
const REGEX_END_OF_TAG = /(\^*])/; // BM_TAG: ^$2 PLAIN_TAG: ^$1
|
|
111
|
-
const REGEX_BIT_START = /^(\[)(\^*)(\.)/; // PLAIN_BODY: $1^$2$3
|
|
112
|
-
const REGEX_HATS = /(\^+)/; // BM_TAG: $3^ PLAIN_TAG: $2^ --BODY: ^$8 ++BODY: $15^ // Must be last
|
|
113
|
-
const BREAKSCAPE_BITMARK_TAG_REGEX_SOURCE = `${REGEX_MARKS.source}|${REGEX_END_OF_TAG.source}|${REGEX_HATS.source}`;
|
|
114
|
-
const BREAKSCAPE_PLAIN_TAG_REGEX_SOURCE = `${REGEX_END_OF_TAG.source}|${REGEX_HATS.source}`;
|
|
115
|
-
const BREAKSCAPE_BITMARK_BODY_REGEX_SOURCE = `${REGEX_MARKS.source}|${REGEX_BLOCKS.source}|${REGEX_TITLE_BLOCKS.source}|${REGEX_LIST_BLOCKS.source}|${REGEX_START_OF_TAG.source}|${REGEX_FOOTER_DIVIDER.source}|${REGEX_PLAIN_TEXT_DIVIDER.source}|${REGEX_HATS.source}`;
|
|
116
|
-
const BREAKSCAPE_PLAIN_BODY_REGEX_SOURCE = `${REGEX_BIT_START.source}`;
|
|
117
|
-
// Breakscape regex for bitmarkText (bitmark+) in tags
|
|
118
|
-
const BREAKSCAPE_BITMARK_TAG_REGEX = new RegExp(BREAKSCAPE_BITMARK_TAG_REGEX_SOURCE, 'gm');
|
|
119
|
-
const BREAKSCAPE_BITMARK_TAG_REGEX_REPLACER = '$1$3^$2';
|
|
120
|
-
// Breakscape regex for plain text in tags
|
|
121
|
-
const BREAKSCAPE_PLAIN_TAG_REGEX = new RegExp(BREAKSCAPE_PLAIN_TAG_REGEX_SOURCE, 'gm');
|
|
122
|
-
const BREAKSCAPE_PLAIN_TAG_REGEX_REPLACER = '$2^$1';
|
|
123
|
-
// Breakscape regex for bitmarkText (bitmark++) in body
|
|
124
|
-
const BREAKSCAPE_BITMARK_BODY_REGEX = new RegExp(BREAKSCAPE_BITMARK_BODY_REGEX_SOURCE, 'gm');
|
|
125
|
-
const BREAKSCAPE_BITMARK_BODY_REGEX_REPLACER = '$1$2$4$6$9$11$13$15^$3$5$7$8$10$12$14';
|
|
126
|
-
// Breakscape regex for plain text in body
|
|
127
|
-
const BREAKSCAPE_PLAIN_BODY_REGEX = new RegExp(BREAKSCAPE_PLAIN_BODY_REGEX_SOURCE, 'gm');
|
|
128
|
-
const BREAKSCAPE_PLAIN_BODY_REGEX_REPLACER = '$1^$2$3';
|
|
129
|
-
// Breakscape regex for v2 tag. Not required, same as BREAKSCAPE_PLAIN_TAG_REGEX
|
|
130
|
-
// const BREAKSCAPE_V2_TAG_REGEX = new RegExp('^(\\^*])|(\\^+)', 'gm');
|
|
131
|
-
// const BREAKSCAPE_V2_TAG_REGEX_REPLACER = '$2^$1';
|
|
132
|
-
// Breakscape regex for v2 body
|
|
133
|
-
const BREAKSCAPE_V2_BODY_REGEX = new RegExp('^(?:(\\[)(\\^*)(\\.))|(\\^+)', 'gm');
|
|
134
|
-
const BREAKSCAPE_V2_BODY_REGEX_REPLACER = '$1$4^$2$3';
|
|
135
|
-
// Unbreakscape regex for everything but plain text in the body
|
|
136
|
-
const UNBREAKSCAPE_REGEX = new RegExp('\\^([\\^]*)', 'gm');
|
|
137
|
-
const UNBREAKSCAPE_REGEX_REPLACER = '$1';
|
|
138
|
-
// Unbreakscape regex for plain text in the body
|
|
139
|
-
const UNBREAKSCAPE_PLAIN_IN_BODY_REGEX = new RegExp('^(\\[)\\^(\\^*)(\\.)', 'gm');
|
|
140
|
-
const UNBREAKSCAPE_PLAIN_IN_BODY_REGEX_REPLACER = '$1$2$3';
|
|
141
|
-
// Regex explanation:
|
|
142
|
-
// - match a single | or • or # character at the start of a line and capture in group 1
|
|
143
|
-
// This will capture all new block characters within the code text.
|
|
144
|
-
// Replace with group 1, ^
|
|
145
|
-
// TODO: Not sure this is used any longer. #code blocks are not separate bits as far as I am aware?
|
|
146
|
-
const BREAKSCAPE_CODE_REGEX = new RegExp('^(\\||•|#)', 'gm');
|
|
147
|
-
const BREAKSCAPE_CODE_REGEX_REPLACER = '$1^';
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
7
|
+
const ExternalBreakscape = require('@gmb/bitmark-breakscape');
|
|
148
8
|
const DEFAULT_BREAKSCAPE_OPTIONS = {
|
|
149
9
|
textFormat: TextFormat_1.TextFormat.bitmarkText,
|
|
150
10
|
textLocation: TextLocation_1.TextLocation.body,
|
|
11
|
+
inPlaceArray: false,
|
|
12
|
+
v2: false,
|
|
151
13
|
};
|
|
14
|
+
const externalBreakscape = new ExternalBreakscape.Breakscape();
|
|
152
15
|
class Breakscape {
|
|
153
16
|
constructor() {
|
|
154
17
|
this.EMPTY_STRING = '';
|
|
@@ -163,31 +26,13 @@ class Breakscape {
|
|
|
163
26
|
* @returns the input value with any strings breakscaped.
|
|
164
27
|
*/
|
|
165
28
|
breakscape(val, options) {
|
|
166
|
-
if (val == null)
|
|
167
|
-
return val;
|
|
168
29
|
const opts = Object.assign({}, DEFAULT_BREAKSCAPE_OPTIONS, options);
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
return str;
|
|
176
|
-
};
|
|
177
|
-
if (Array.isArray(val)) {
|
|
178
|
-
const newVal = opts.inPlaceArray ? val : new Array(val.length);
|
|
179
|
-
for (let i = 0, len = val.length; i < len; i++) {
|
|
180
|
-
const v = val[i];
|
|
181
|
-
if (StringUtils_1.StringUtils.isString(v)) {
|
|
182
|
-
newVal[i] = breakscapeStr(v);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
val = newVal;
|
|
186
|
-
}
|
|
187
|
-
else if (StringUtils_1.StringUtils.isString(val)) {
|
|
188
|
-
val = breakscapeStr(val);
|
|
189
|
-
}
|
|
190
|
-
return val;
|
|
30
|
+
return externalBreakscape.breakscape(val, {
|
|
31
|
+
format: opts.textFormat,
|
|
32
|
+
location: opts.textLocation,
|
|
33
|
+
inPlaceArray: opts.inPlaceArray,
|
|
34
|
+
v2: opts.v2,
|
|
35
|
+
});
|
|
191
36
|
}
|
|
192
37
|
/**
|
|
193
38
|
* Unbreakscape a string or an array of strings.
|
|
@@ -198,34 +43,13 @@ class Breakscape {
|
|
|
198
43
|
* @returns the input value with any strings unbreakscaped.
|
|
199
44
|
*/
|
|
200
45
|
unbreakscape(val, options) {
|
|
201
|
-
if (val == null)
|
|
202
|
-
return val;
|
|
203
46
|
const opts = Object.assign({}, DEFAULT_BREAKSCAPE_OPTIONS, options);
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
return str;
|
|
211
|
-
};
|
|
212
|
-
if (Array.isArray(val)) {
|
|
213
|
-
const newVal = opts.inPlaceArray ? val : new Array(val.length);
|
|
214
|
-
for (let i = 0, len = val.length; i < len; i++) {
|
|
215
|
-
const v = val[i];
|
|
216
|
-
if (StringUtils_1.StringUtils.isString(v)) {
|
|
217
|
-
newVal[i] = unbreakscapeStr(v);
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
newVal[i] = v;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
val = newVal;
|
|
224
|
-
}
|
|
225
|
-
else if (StringUtils_1.StringUtils.isString(val)) {
|
|
226
|
-
val = unbreakscapeStr(val);
|
|
227
|
-
}
|
|
228
|
-
return val;
|
|
47
|
+
return externalBreakscape.unbreakscape(val, {
|
|
48
|
+
format: opts.textFormat,
|
|
49
|
+
location: opts.textLocation,
|
|
50
|
+
inPlaceArray: opts.inPlaceArray,
|
|
51
|
+
v2: opts.v2,
|
|
52
|
+
});
|
|
229
53
|
}
|
|
230
54
|
/**
|
|
231
55
|
* Breakscape a code string or an array of code strings.
|
|
@@ -236,83 +60,13 @@ class Breakscape {
|
|
|
236
60
|
* @returns the input value with any strings breakscaped
|
|
237
61
|
*/
|
|
238
62
|
breakscapeCode(val, options) {
|
|
239
|
-
if (val == null)
|
|
240
|
-
return val;
|
|
241
63
|
const opts = Object.assign({}, DEFAULT_BREAKSCAPE_OPTIONS, options);
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
const newVal = opts.inPlaceArray ? val : [val.length];
|
|
249
|
-
for (let i = 0, len = val.length; i < len; i++) {
|
|
250
|
-
const v = val[i];
|
|
251
|
-
if (StringUtils_1.StringUtils.isString(v)) {
|
|
252
|
-
val[i] = breakscapeStr(v);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
val = newVal;
|
|
256
|
-
}
|
|
257
|
-
else if (StringUtils_1.StringUtils.isString(val)) {
|
|
258
|
-
val = breakscapeStr(val);
|
|
259
|
-
}
|
|
260
|
-
return val;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* For breakscaping, select the correct regex and replacer for the text format and location.
|
|
264
|
-
*
|
|
265
|
-
* @param textFormat the format of the text
|
|
266
|
-
* @param textLocation the location of the text
|
|
267
|
-
* @param v2 if true, use v2 breakscaping
|
|
268
|
-
* @returns the regex and replacer
|
|
269
|
-
*/
|
|
270
|
-
selectBreakscapeRegexAndReplacer(textFormat, textLocation, v2) {
|
|
271
|
-
let regex;
|
|
272
|
-
let replacer;
|
|
273
|
-
if (textLocation === TextLocation_1.TextLocation.tag) {
|
|
274
|
-
regex = BREAKSCAPE_PLAIN_TAG_REGEX;
|
|
275
|
-
replacer = BREAKSCAPE_PLAIN_TAG_REGEX_REPLACER;
|
|
276
|
-
if (!v2 && textFormat === TextFormat_1.TextFormat.bitmarkText) {
|
|
277
|
-
regex = BREAKSCAPE_BITMARK_TAG_REGEX;
|
|
278
|
-
replacer = BREAKSCAPE_BITMARK_TAG_REGEX_REPLACER;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
else {
|
|
282
|
-
// if (textLocation === TextLocation.body) {
|
|
283
|
-
regex = BREAKSCAPE_PLAIN_BODY_REGEX;
|
|
284
|
-
replacer = BREAKSCAPE_PLAIN_BODY_REGEX_REPLACER;
|
|
285
|
-
if (textFormat === TextFormat_1.TextFormat.bitmarkText) {
|
|
286
|
-
if (v2) {
|
|
287
|
-
// Hack for v2 breakscaping (still needed??)
|
|
288
|
-
regex = BREAKSCAPE_V2_BODY_REGEX;
|
|
289
|
-
replacer = BREAKSCAPE_V2_BODY_REGEX_REPLACER;
|
|
290
|
-
}
|
|
291
|
-
else {
|
|
292
|
-
regex = BREAKSCAPE_BITMARK_BODY_REGEX;
|
|
293
|
-
replacer = BREAKSCAPE_BITMARK_BODY_REGEX_REPLACER;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
return { regex, replacer };
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* For unbreakscaping, select the correct regex and replacer for the text format and location.
|
|
301
|
-
*
|
|
302
|
-
* @param textFormat the format of the text
|
|
303
|
-
* @param textLocation the location of the text
|
|
304
|
-
* @returns the regex and replacer
|
|
305
|
-
*/
|
|
306
|
-
selectUnbreakscapeRegexAndReplacer(textFormat, textLocation) {
|
|
307
|
-
const isBitmarkText = textFormat === TextFormat_1.TextFormat.bitmarkText;
|
|
308
|
-
const isPlain = !isBitmarkText;
|
|
309
|
-
let regex = UNBREAKSCAPE_REGEX;
|
|
310
|
-
let replacer = UNBREAKSCAPE_REGEX_REPLACER;
|
|
311
|
-
if (textLocation === TextLocation_1.TextLocation.body && isPlain) {
|
|
312
|
-
regex = UNBREAKSCAPE_PLAIN_IN_BODY_REGEX;
|
|
313
|
-
replacer = UNBREAKSCAPE_PLAIN_IN_BODY_REGEX_REPLACER;
|
|
314
|
-
}
|
|
315
|
-
return { regex, replacer };
|
|
64
|
+
return externalBreakscape.breakscapeCode(val, {
|
|
65
|
+
format: opts.textFormat,
|
|
66
|
+
location: opts.textLocation,
|
|
67
|
+
inPlaceArray: opts.inPlaceArray,
|
|
68
|
+
v2: opts.v2,
|
|
69
|
+
});
|
|
316
70
|
}
|
|
317
71
|
/**
|
|
318
72
|
* Concatenate two breakscaped strings.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Breakscape.js","sourceRoot":"","sources":["../../../src/breakscaping/Breakscape.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Breakscape.js","sourceRoot":"","sources":["../../../src/breakscaping/Breakscape.ts"],"names":[],"mappings":";;;AAGA,yDAAsE;AACtE,6DAA4E;AAE5E,iEAAiE;AACjE,MAAM,kBAAkB,GAAG,OAAO,CAAC,yBAAyB,CAA4B,CAAC;AAgCzF,MAAM,0BAA0B,GAAsB;IACpD,UAAU,EAAE,uBAAU,CAAC,WAAW;IAClC,YAAY,EAAE,2BAAY,CAAC,IAAI;IAC/B,YAAY,EAAE,KAAK;IACnB,EAAE,EAAE,KAAK;CACV,CAAC;AAEF,MAAM,kBAAkB,GAAG,IAAI,kBAAkB,CAAC,UAAU,EAAE,CAAC;AAE/D,MAAM,UAAU;IAAhB;QACkB,iBAAY,GAAG,EAAuB,CAAC;IAqFzD,CAAC;IAnFC;;;;;;;;OAQG;IACI,UAAU,CACf,GAAM,EACN,OAA0B;QAI1B,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,0BAA0B,EAAE,OAAO,CAAC,CAAC;QAEpE,OAAO,kBAAkB,CAAC,UAAU,CAAC,GAAwB,EAAE;YAC7D,MAAM,EAAE,IAAI,CAAC,UAAU;YACvB,QAAQ,EAAE,IAAI,CAAC,YAAY;YAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,EAAE,EAAE,IAAI,CAAC,EAAE;SACZ,CAAM,CAAC;IACV,CAAC;IAED;;;;;;;OAOG;IACI,YAAY,CACjB,GAAM,EACN,OAA0B;QAI1B,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,0BAA0B,EAAE,OAAO,CAAC,CAAC;QAEpE,OAAO,kBAAkB,CAAC,YAAY,CAAC,GAAwB,EAAE;YAC/D,MAAM,EAAE,IAAI,CAAC,UAAU;YACvB,QAAQ,EAAE,IAAI,CAAC,YAAY;YAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,EAAE,EAAE,IAAI,CAAC,EAAE;SACZ,CAAM,CAAC;IACV,CAAC;IAED;;;;;;;OAOG;IACI,cAAc,CACnB,GAAM,EACN,OAA2B;QAI3B,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,0BAA0B,EAAE,OAAO,CAAC,CAAC;QAEpE,OAAO,kBAAkB,CAAC,cAAc,CAAC,GAAwB,EAAE;YACjE,MAAM,EAAE,IAAI,CAAC,UAAU;YACvB,QAAQ,EAAE,IAAI,CAAC,YAAY;YAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,EAAE,EAAE,IAAI,CAAC,EAAE;SACZ,CAAM,CAAC;IACV,CAAC;IAED;;;;;;OAMG;IACI,WAAW,CAAC,EAAqB,EAAE,EAAqB;QAC7D,OAAO,CAAC,EAAE,GAAG,EAAE,CAAsB,CAAC;IACxC,CAAC;CACF;AAED,MAAM,QAAQ,GAAG,IAAI,UAAU,EAAE,CAAC;AAEb,8BAAU"}
|
|
@@ -2172,6 +2172,10 @@ const BITS = {
|
|
|
2172
2172
|
type: BitTagType_1.BitTagType.property,
|
|
2173
2173
|
configKey: PropertyConfigKey_1.PropertyConfigKey.tableFixedHeader,
|
|
2174
2174
|
},
|
|
2175
|
+
{
|
|
2176
|
+
type: BitTagType_1.BitTagType.property,
|
|
2177
|
+
configKey: PropertyConfigKey_1.PropertyConfigKey.tableHeaderWhitespaceNoWrap,
|
|
2178
|
+
},
|
|
2175
2179
|
{
|
|
2176
2180
|
type: BitTagType_1.BitTagType.property,
|
|
2177
2181
|
configKey: PropertyConfigKey_1.PropertyConfigKey.tableSearch,
|
|
@@ -2265,6 +2269,17 @@ const BITS = {
|
|
|
2265
2269
|
},
|
|
2266
2270
|
],
|
|
2267
2271
|
},
|
|
2272
|
+
[BitType_1.BitType.tocResource]: {
|
|
2273
|
+
since: '3.31.0',
|
|
2274
|
+
baseBitType: BitType_1.BitType.toc,
|
|
2275
|
+
tags: [
|
|
2276
|
+
{
|
|
2277
|
+
type: BitTagType_1.BitTagType.property,
|
|
2278
|
+
configKey: PropertyConfigKey_1.PropertyConfigKey.tocResource,
|
|
2279
|
+
maxCount: Count_1.Count.infinity,
|
|
2280
|
+
},
|
|
2281
|
+
],
|
|
2282
|
+
},
|
|
2268
2283
|
[BitType_1.BitType.anchor]: { since: '1.3.0', baseBitType: BitType_1.BitType._standard },
|
|
2269
2284
|
[BitType_1.BitType.bitBookEnding]: { since: '1.3.0', baseBitType: BitType_1.BitType._standard },
|
|
2270
2285
|
[BitType_1.BitType.bitBookSummary]: { since: '1.3.0', baseBitType: BitType_1.BitType._standard },
|