431
const fenceMatch = /^(?<fence>(`{3,}|~{3,}))/u.exec(trimmedLine);
432
if (fenceMatch) {
434
>
const fenceChar = fence[0];
435
>
const fenceLength = fence.length;
436
>
const restOfLine = trimmedLine.slice(fence.length);
437
>
438
>
if (!inFencedCodeBlock) {
439
>
// Opening fence: record fence char/length and enter fenced code block
440
>
inFencedCodeBlock = true;
441
>
fencedCodeBlockFenceChar = fenceChar;
442
>
fencedCodeBlockFenceLength = fenceLength;
443
>
lineStartOffset += line.length;
444
>
continue;
445
>
}
446
447
// Potential closing fence: must match fence char and have at least the same length,
448
// and only whitespace is allowed after the fence.
449
>
if (fencedCodeBlockFenceChar === fenceChar && fenceLength >= fencedCodeBlockFenceLength && /^\s*$/.test(restOfLine)) {
promptFileParser.ts
450
inFencedCodeBlock = false;
451
fencedCodeBlockFenceChar = undefined;