remove escape characters after parsing enclosure
This commit is contained in:
parent
aca114644a
commit
3540f19978
|
@ -112,13 +112,15 @@ export default class MString {
|
||||||
* moves iter to last closing braked if it is enclosure
|
* moves iter to last closing braked if it is enclosure
|
||||||
*/
|
*/
|
||||||
checkIfEnclosure(zIsLink) {
|
checkIfEnclosure(zIsLink) {
|
||||||
const yStart = this.iter + 1;
|
let yStart = this.iter + 1;
|
||||||
|
|
||||||
let yEnd = yStart;
|
let yEnd = yStart;
|
||||||
|
const escapePositions = [];
|
||||||
while (this.txt[yEnd] !== ']') {
|
while (this.txt[yEnd] !== ']') {
|
||||||
const chr = this.txt[yEnd];
|
const chr = this.txt[yEnd];
|
||||||
if (chr === '\\') {
|
if (chr === '\\') {
|
||||||
// escape character
|
// escape character
|
||||||
|
escapePositions.push(yEnd);
|
||||||
yEnd += 2;
|
yEnd += 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -168,7 +170,17 @@ export default class MString {
|
||||||
if (!zIsLink) {
|
if (!zIsLink) {
|
||||||
z = this.txt.slice(zStart, zEnd);
|
z = this.txt.slice(zStart, zEnd);
|
||||||
}
|
}
|
||||||
const y = this.txt.slice(yStart, yEnd);
|
|
||||||
|
let y = '';
|
||||||
|
// remove escape characters
|
||||||
|
for (let iter = 0; iter < escapePositions.length; iter += 1) {
|
||||||
|
const escapePosition = escapePositions[iter];
|
||||||
|
y += this.txt.slice(yStart, escapePosition);
|
||||||
|
yStart = escapePosition + 1;
|
||||||
|
}
|
||||||
|
if (yStart < yEnd) {
|
||||||
|
y += this.txt.slice(yStart, yEnd);
|
||||||
|
}
|
||||||
|
|
||||||
this.iter = zEnd;
|
this.iter = zEnd;
|
||||||
return [y, z];
|
return [y, z];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user