@gmb/bitmark-parser-generator 3.30.0 → 3.31.1
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 +22 -269
- package/dist/cjs/breakscaping/Breakscape.js.map +1 -1
- package/dist/cjs/breakscaping/BreakscapeLoop.js +305 -0
- package/dist/cjs/breakscaping/BreakscapeLoop.js.map +1 -0
- package/dist/cjs/breakscaping/BreakscapeOptions.js +3 -0
- package/dist/cjs/breakscaping/BreakscapeOptions.js.map +1 -0
- package/dist/cjs/breakscaping/BreakscapeRegex.js +213 -0
- package/dist/cjs/breakscaping/BreakscapeRegex.js.map +1 -0
- package/dist/cjs/breakscaping/RegexConfigs.js +38 -0
- package/dist/cjs/breakscaping/RegexConfigs.js.map +1 -0
- 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 +22 -269
- package/dist/esm/breakscaping/Breakscape.js.map +1 -1
- package/dist/esm/breakscaping/BreakscapeLoop.js +302 -0
- package/dist/esm/breakscaping/BreakscapeLoop.js.map +1 -0
- package/dist/esm/breakscaping/BreakscapeOptions.js +2 -0
- package/dist/esm/breakscaping/BreakscapeOptions.js.map +1 -0
- package/dist/esm/breakscaping/BreakscapeRegex.js +177 -0
- package/dist/esm/breakscaping/BreakscapeRegex.js.map +1 -0
- package/dist/esm/breakscaping/RegexConfigs.js +35 -0
- package/dist/esm/breakscaping/RegexConfigs.js.map +1 -0
- 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/breakscaping/BreakscapeLoop.d.ts +142 -0
- package/dist/types/breakscaping/BreakscapeLoop.d.ts.map +1 -0
- package/dist/types/breakscaping/BreakscapeOptions.d.ts +30 -0
- package/dist/types/breakscaping/BreakscapeOptions.d.ts.map +1 -0
- package/dist/types/breakscaping/BreakscapeRegex.d.ts +96 -0
- package/dist/types/breakscaping/BreakscapeRegex.d.ts.map +1 -0
- package/dist/types/breakscaping/RegexConfigs.d.ts +35 -0
- package/dist/types/breakscaping/RegexConfigs.d.ts.map +1 -0
- 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 +1 -1
|
@@ -3,152 +3,14 @@ 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
|
-
const
|
|
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
|
+
const BreakscapeRegex_1 = require("./BreakscapeRegex");
|
|
148
7
|
const DEFAULT_BREAKSCAPE_OPTIONS = {
|
|
149
8
|
textFormat: TextFormat_1.TextFormat.bitmarkText,
|
|
150
9
|
textLocation: TextLocation_1.TextLocation.body,
|
|
10
|
+
inPlaceArray: false,
|
|
11
|
+
v2: false,
|
|
151
12
|
};
|
|
13
|
+
const externalBreakscape = new BreakscapeRegex_1.Breakscape();
|
|
152
14
|
class Breakscape {
|
|
153
15
|
constructor() {
|
|
154
16
|
this.EMPTY_STRING = '';
|
|
@@ -163,31 +25,13 @@ class Breakscape {
|
|
|
163
25
|
* @returns the input value with any strings breakscaped.
|
|
164
26
|
*/
|
|
165
27
|
breakscape(val, options) {
|
|
166
|
-
if (val == null)
|
|
167
|
-
return val;
|
|
168
28
|
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;
|
|
29
|
+
return externalBreakscape.breakscape(val, {
|
|
30
|
+
format: opts.textFormat,
|
|
31
|
+
location: opts.textLocation,
|
|
32
|
+
inPlaceArray: opts.inPlaceArray,
|
|
33
|
+
v2: opts.v2,
|
|
34
|
+
});
|
|
191
35
|
}
|
|
192
36
|
/**
|
|
193
37
|
* Unbreakscape a string or an array of strings.
|
|
@@ -198,34 +42,13 @@ class Breakscape {
|
|
|
198
42
|
* @returns the input value with any strings unbreakscaped.
|
|
199
43
|
*/
|
|
200
44
|
unbreakscape(val, options) {
|
|
201
|
-
if (val == null)
|
|
202
|
-
return val;
|
|
203
45
|
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;
|
|
46
|
+
return externalBreakscape.unbreakscape(val, {
|
|
47
|
+
format: opts.textFormat,
|
|
48
|
+
location: opts.textLocation,
|
|
49
|
+
inPlaceArray: opts.inPlaceArray,
|
|
50
|
+
v2: opts.v2,
|
|
51
|
+
});
|
|
229
52
|
}
|
|
230
53
|
/**
|
|
231
54
|
* Breakscape a code string or an array of code strings.
|
|
@@ -236,83 +59,13 @@ class Breakscape {
|
|
|
236
59
|
* @returns the input value with any strings breakscaped
|
|
237
60
|
*/
|
|
238
61
|
breakscapeCode(val, options) {
|
|
239
|
-
if (val == null)
|
|
240
|
-
return val;
|
|
241
62
|
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 };
|
|
63
|
+
return externalBreakscape.breakscapeCode(val, {
|
|
64
|
+
format: opts.textFormat,
|
|
65
|
+
location: opts.textLocation,
|
|
66
|
+
inPlaceArray: opts.inPlaceArray,
|
|
67
|
+
v2: opts.v2,
|
|
68
|
+
});
|
|
316
69
|
}
|
|
317
70
|
/**
|
|
318
71
|
* Concatenate two breakscaped strings.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Breakscape.js","sourceRoot":"","sources":["../../../src/breakscaping/Breakscape.ts"],"names":[],"mappings":";;;AACA,yDAAsE;AACtE,6DAA4E;
|
|
1
|
+
{"version":3,"file":"Breakscape.js","sourceRoot":"","sources":["../../../src/breakscaping/Breakscape.ts"],"names":[],"mappings":";;;AACA,yDAAsE;AACtE,6DAA4E;AAE5E,uDAAiE;AAgCjE,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,4BAAc,EAAE,CAAC;AAEhD,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"}
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* breakscape.ts
|
|
4
|
+
* ------------------------------------------------------------
|
|
5
|
+
* Breakscaping for bitmark text.
|
|
6
|
+
* (c) 2025 — MIT / public domain
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.Breakscape = void 0;
|
|
10
|
+
const build_info_1 = require("../generated/build-info");
|
|
11
|
+
const BodyTextFormat_1 = require("../model/enum/BodyTextFormat");
|
|
12
|
+
const TextLocation_1 = require("../model/enum/TextLocation");
|
|
13
|
+
const DEF = {
|
|
14
|
+
format: BodyTextFormat_1.BodyTextFormat.bitmarkPlusPlus,
|
|
15
|
+
location: TextLocation_1.TextLocation.body,
|
|
16
|
+
};
|
|
17
|
+
// -----------------------------------------------------------------------------
|
|
18
|
+
// ╭──────────────────────────────────────────────────────────────────────────╮
|
|
19
|
+
// │ 1. LOW‑LEVEL helpers │
|
|
20
|
+
// ╰──────────────────────────────────────────────────────────────────────────╯
|
|
21
|
+
// 1‑a) Trigger characters that start a bit tag construct when they follow "["
|
|
22
|
+
const TRIGGERS = new Set('.@#▼►%!?+-$_=&');
|
|
23
|
+
// 1‑b) Paired punctuation we have to split with a caret
|
|
24
|
+
const HALF_TAGS = new Set(['*', '`', '_', '!', '=']);
|
|
25
|
+
/**
|
|
26
|
+
* Predicate – true for every flavour that the spec calls “bitmark text”
|
|
27
|
+
*/
|
|
28
|
+
function isBitmarkText(fmt) {
|
|
29
|
+
// Only bitmarkPlusPlus is defined in TextFormat, so only check for that
|
|
30
|
+
return fmt === BodyTextFormat_1.BodyTextFormat.bitmarkPlusPlus || fmt === 'bitmark+' || fmt === 'bitmark--';
|
|
31
|
+
}
|
|
32
|
+
// -----------------------------------------------------------------------------
|
|
33
|
+
// 1‑c) Single‑buffer worker (BREAKSCAPE)
|
|
34
|
+
// -----------------------------------------------------------------------------
|
|
35
|
+
function breakscapeBuf(src, fmt, loc) {
|
|
36
|
+
// If an unrecognized type is passed, return it as is (e.g. true, false, 0, 1, etc.)
|
|
37
|
+
if (!isString(src))
|
|
38
|
+
return src;
|
|
39
|
+
const bitmarkText = isBitmarkText(fmt);
|
|
40
|
+
const body = loc === TextLocation_1.TextLocation.body;
|
|
41
|
+
const inTag = loc === TextLocation_1.TextLocation.tag;
|
|
42
|
+
const len = src.length;
|
|
43
|
+
// Assume breakscaping will usually increas the length of the string by less than 20%
|
|
44
|
+
// we can allocate a buffer of that size as reallocation is expensive
|
|
45
|
+
const out = new Array(Math.ceil(len * 1.1)); // upper bound
|
|
46
|
+
let atLineStart = true;
|
|
47
|
+
let col = 0;
|
|
48
|
+
for (let i = 0; i < len;) {
|
|
49
|
+
const ch = src.charCodeAt(i); // number
|
|
50
|
+
const nxt = i + 1 < len ? src.charCodeAt(i + 1) : 0;
|
|
51
|
+
// 1) newline ----------------------------------------------------------
|
|
52
|
+
if (ch === 0x0a) {
|
|
53
|
+
// '\n'
|
|
54
|
+
out.push('\n');
|
|
55
|
+
atLineStart = true;
|
|
56
|
+
col = 0;
|
|
57
|
+
i++;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const space = ch === 0x20 || ch === 0x09; // ' ' or '\t'
|
|
61
|
+
const physicalBOC = col === 0; // zero indent
|
|
62
|
+
// 2) hats -------------------------------------------------------------
|
|
63
|
+
if (bitmarkText || inTag) {
|
|
64
|
+
if (ch === 0x5e) {
|
|
65
|
+
// '^'
|
|
66
|
+
let j = i + 1;
|
|
67
|
+
while (j < len && src.charCodeAt(j) === 0x5e)
|
|
68
|
+
j++;
|
|
69
|
+
out.push('^'); // extra one
|
|
70
|
+
out.push(src.slice(i, j)); // original run
|
|
71
|
+
col += j - i;
|
|
72
|
+
i = j;
|
|
73
|
+
atLineStart = false;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// 3) inline doubles ---------------------------------------------------
|
|
78
|
+
if (bitmarkText && HALF_TAGS.has(String.fromCharCode(ch))) {
|
|
79
|
+
out.push(String.fromCharCode(ch));
|
|
80
|
+
if (nxt === ch)
|
|
81
|
+
out.push('^');
|
|
82
|
+
i++;
|
|
83
|
+
col++;
|
|
84
|
+
atLineStart = false;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
// 4) end-of-tag -------------------------------------------------------
|
|
88
|
+
if (inTag && ch === 0x5d /* ']' */ && (i === 0 || src.charCodeAt(i - 1) !== 0x5e)) {
|
|
89
|
+
out.push('^', ']');
|
|
90
|
+
i++;
|
|
91
|
+
col++;
|
|
92
|
+
atLineStart = false;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
// 5) body-only rules --------------------------------------------------
|
|
96
|
+
if (body) {
|
|
97
|
+
// (a) ### | • at BOL
|
|
98
|
+
if (atLineStart && physicalBOC && bitmarkText && (ch === 0x23 || ch === 0x7c || ch === 0x2022)) {
|
|
99
|
+
let j = i;
|
|
100
|
+
while (j < len && src.charCodeAt(j) === ch)
|
|
101
|
+
j++;
|
|
102
|
+
out.push(src.slice(i, j));
|
|
103
|
+
if (nxt !== 0x5e)
|
|
104
|
+
out.push('^');
|
|
105
|
+
col += j - i;
|
|
106
|
+
i = j;
|
|
107
|
+
atLineStart = false;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
// (b) '[' + trigger
|
|
111
|
+
if (bitmarkText && ch === 0x5b /* '[' */ && TRIGGERS.has(String.fromCharCode(nxt))) {
|
|
112
|
+
out.push('[', '^');
|
|
113
|
+
i++;
|
|
114
|
+
col++;
|
|
115
|
+
atLineStart = false;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// 6) plain-text "[." or "[^^... ." at BOL
|
|
120
|
+
if (!bitmarkText && body && atLineStart && physicalBOC && ch === 0x5b /* '[' */) {
|
|
121
|
+
// count carets after '['
|
|
122
|
+
let j = i + 1;
|
|
123
|
+
let count = 0;
|
|
124
|
+
while (j < len && src.charCodeAt(j) === 0x5e /* '^' */) {
|
|
125
|
+
count++;
|
|
126
|
+
j++;
|
|
127
|
+
}
|
|
128
|
+
// if next char is dot, escape by adding one more caret
|
|
129
|
+
if (j < len && src.charCodeAt(j) === 0x2e /* '.' */) {
|
|
130
|
+
out.push('[');
|
|
131
|
+
for (let k = 0; k < count + 1; k++)
|
|
132
|
+
out.push('^');
|
|
133
|
+
col += count + 1;
|
|
134
|
+
i = j; // skip '[' and all carets, next iteration handles '.'
|
|
135
|
+
atLineStart = false;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// default copy --------------------------------------------------------
|
|
140
|
+
out.push(String.fromCharCode(ch));
|
|
141
|
+
if (!space)
|
|
142
|
+
atLineStart = false;
|
|
143
|
+
col++;
|
|
144
|
+
i++;
|
|
145
|
+
}
|
|
146
|
+
return out.join('');
|
|
147
|
+
}
|
|
148
|
+
// -----------------------------------------------------------------------------
|
|
149
|
+
// 1‑d) Single‑buffer worker (UNBREAKSCAPE)
|
|
150
|
+
// -----------------------------------------------------------------------------
|
|
151
|
+
function unbreakscapeBuf(src, fmt, loc) {
|
|
152
|
+
// If an unrecognized type is passed, return it as is (e.g. true, false, 0, 1, etc.)
|
|
153
|
+
if (!isString(src))
|
|
154
|
+
return src;
|
|
155
|
+
const bitmarkText = isBitmarkText(fmt);
|
|
156
|
+
const isTag = loc === TextLocation_1.TextLocation.tag;
|
|
157
|
+
const isPlainBody = loc === TextLocation_1.TextLocation.body && !bitmarkText;
|
|
158
|
+
const len = src.length;
|
|
159
|
+
const out = new Array(len); // upper bound
|
|
160
|
+
let outPos = 0;
|
|
161
|
+
let bol = true; // beginning-of-line flag
|
|
162
|
+
for (let i = 0; i < len;) {
|
|
163
|
+
const ch = src[i];
|
|
164
|
+
// 1) HATS – remove exactly one ^ from each run
|
|
165
|
+
if ((bitmarkText || isTag) && ch === '^') {
|
|
166
|
+
let j = i + 1;
|
|
167
|
+
while (j < len && src[j] === '^')
|
|
168
|
+
j++;
|
|
169
|
+
if (j - i > 1)
|
|
170
|
+
out[outPos++] = src.slice(i + 1, j); // keep the rest
|
|
171
|
+
i = j;
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
// 2) PLAIN-body “[ ^ .” with zero indent
|
|
175
|
+
if (isPlainBody && bol && ch === '[') {
|
|
176
|
+
let j = i + 1;
|
|
177
|
+
let count = 0;
|
|
178
|
+
while (j < len && src[j] === '^') {
|
|
179
|
+
count++;
|
|
180
|
+
j++;
|
|
181
|
+
}
|
|
182
|
+
if (count >= 1 && j < len && src[j] === '.') {
|
|
183
|
+
out[outPos++] = '[';
|
|
184
|
+
for (let k = 0; k < count - 1; k++)
|
|
185
|
+
out[outPos++] = '^';
|
|
186
|
+
out[outPos++] = '.';
|
|
187
|
+
i = j + 1;
|
|
188
|
+
bol = false;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// 3) default copy
|
|
193
|
+
out[outPos++] = ch;
|
|
194
|
+
i++;
|
|
195
|
+
// keep bol up to date
|
|
196
|
+
if (ch === '\n')
|
|
197
|
+
bol = true;
|
|
198
|
+
else if (bol && ch !== ' ' && ch !== '\t')
|
|
199
|
+
bol = false;
|
|
200
|
+
}
|
|
201
|
+
return out.slice(0, outPos).join('');
|
|
202
|
+
}
|
|
203
|
+
// -----------------------------------------------------------------------------
|
|
204
|
+
// ╭──────────────────────────────────────────────────────────────────────────╮
|
|
205
|
+
// │ 2. PUBLIC API │
|
|
206
|
+
// ╰──────────────────────────────────────────────────────────────────────────╯
|
|
207
|
+
function isString(x) {
|
|
208
|
+
return typeof x === 'string' || x instanceof String;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Main class for performing breakscape and unbreakscape operations on bitmark text.
|
|
212
|
+
*
|
|
213
|
+
* Breakscaping is the process of escaping special characters in bitmark text to prevent
|
|
214
|
+
* them from being interpreted as markup. This includes adding caret (^) characters before
|
|
215
|
+
* special characters that would otherwise be interpreted as bitmark syntax.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```typescript
|
|
219
|
+
* const breakscape = new Breakscape();
|
|
220
|
+
*
|
|
221
|
+
* // Breakscape a string
|
|
222
|
+
* const escaped = breakscape.breakscape('[.hello]');
|
|
223
|
+
*
|
|
224
|
+
* // Unbreakscape a string
|
|
225
|
+
* const unescaped = breakscape.unbreakscape('[^.hello]');
|
|
226
|
+
*
|
|
227
|
+
* // Process arrays
|
|
228
|
+
* const escapedArray = breakscape.breakscape(['[.hello]', '[.world]']);
|
|
229
|
+
* ```
|
|
230
|
+
*
|
|
231
|
+
* @public
|
|
232
|
+
*/
|
|
233
|
+
class Breakscape {
|
|
234
|
+
breakscape(val, opts = {}) {
|
|
235
|
+
const { format: fmt, location: loc } = Object.assign(Object.assign({}, DEF), opts);
|
|
236
|
+
if (val == null)
|
|
237
|
+
return undefined;
|
|
238
|
+
const proc = (s) => breakscapeBuf(s, fmt, loc);
|
|
239
|
+
if (Array.isArray(val)) {
|
|
240
|
+
const a = opts.inPlaceArray ? val : [...val];
|
|
241
|
+
for (let i = 0; i < a.length; i++)
|
|
242
|
+
if (isString(a[i]))
|
|
243
|
+
a[i] = proc(a[i]);
|
|
244
|
+
return a;
|
|
245
|
+
}
|
|
246
|
+
return proc(val);
|
|
247
|
+
}
|
|
248
|
+
unbreakscape(val, opts = {}) {
|
|
249
|
+
const { format: fmt, location: loc } = Object.assign(Object.assign({}, DEF), opts);
|
|
250
|
+
if (val == null)
|
|
251
|
+
return undefined;
|
|
252
|
+
const proc = (s) => unbreakscapeBuf(s, fmt, loc);
|
|
253
|
+
if (Array.isArray(val)) {
|
|
254
|
+
const a = opts.inPlaceArray ? val : [...val];
|
|
255
|
+
for (let i = 0; i < a.length; i++)
|
|
256
|
+
if (isString(a[i]))
|
|
257
|
+
a[i] = proc(a[i]);
|
|
258
|
+
return a;
|
|
259
|
+
}
|
|
260
|
+
return proc(val);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Breakscape a code string or an array of code strings.
|
|
264
|
+
* If the input is an array, a new array will be returned.
|
|
265
|
+
*
|
|
266
|
+
* @param val input value
|
|
267
|
+
* @param modifyArray if true, the original array will be modified rather than a copy being made
|
|
268
|
+
* @returns the input value with any strings breakscaped
|
|
269
|
+
*/
|
|
270
|
+
breakscapeCode(_val, _options) {
|
|
271
|
+
_val; // to avoid unused variable warning
|
|
272
|
+
_options; // to avoid unused variable warning
|
|
273
|
+
throw new Error('breakscapeCode is not implemented.');
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Gets the version of the breakscape library.
|
|
277
|
+
*
|
|
278
|
+
* @returns The current version string of the library.
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```typescript
|
|
282
|
+
* const breakscape = new Breakscape();
|
|
283
|
+
* console.log(breakscape.version()); // e.g., "1.0.0"
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
version() {
|
|
287
|
+
return build_info_1.buildInfo.version;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Gets the license information for the breakscape library.
|
|
291
|
+
*
|
|
292
|
+
* @returns The license string for the library.
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```typescript
|
|
296
|
+
* const breakscape = new Breakscape();
|
|
297
|
+
* console.log(breakscape.license()); // e.g., "MIT"
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
license() {
|
|
301
|
+
return build_info_1.buildInfo.license;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
exports.Breakscape = Breakscape;
|
|
305
|
+
//# sourceMappingURL=BreakscapeLoop.js.map
|