Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/github-remote-mcp-auth-test.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion actions/setup/js/markdown_code_region_balancer.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,24 @@ function balanceCodeRegions(markdown) {
const unclosedFences = [];
const pairedBlocks = []; // Track paired blocks with their line ranges

// Helper function to check if a line is inside any paired block
// Helper function to check if a line is inside any paired or unclosed block
const isInsideBlock = lineIndex => {
// Check if inside a successfully paired block
for (const block of pairedBlocks) {
if (lineIndex > block.start && lineIndex < block.end) {
return true;
}
}

// Check if inside an unclosed block
// An unclosed block starts at an opening fence and extends to the end of the document
// if no closer was found
for (const fence of unclosedFences) {
if (lineIndex > fence.lineIndex) {
return true;
}
}

return false;
};

Expand Down
23 changes: 23 additions & 0 deletions actions/setup/js/markdown_code_region_balancer.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,29 @@ content
\`\`\`\`\`\`\`\`\`\`\`\`\`\`\`\``;
expect(balancer.balanceCodeRegions(input)).toBe(input);
});

it("should close unmatched opening fence when shorter fence cannot close it", () => {
// Regression test for GitHub Issue #11630
// When a 4-backtick fence is opened but only a 3-backtick fence follows,
// the 3-backtick fence should be treated as content inside the code block,
// not as a separate unclosed fence.
const input = `#### NPM Versions Available

\`\`\`\`
0.0.56
0.0.57
0.0.58
\`\`\``;
const expected = `#### NPM Versions Available

\`\`\`\`
0.0.56
0.0.57
0.0.58
\`\`\`
\`\`\`\``;
expect(balancer.balanceCodeRegions(input)).toBe(expected);
});
});

describe("trailing content after fence", () => {
Expand Down
Loading