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