Skip to content

Commit 4047d26

Browse files
JoannaaKLCopilot
andcommitted
Ignore fence lines when checking pull request descriptions
Fence lines counted as section content, so a section with only an empty code block passed, and any fence line toggled code mode. Skip fence lines and only close a fence with a matching one. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 3e5557a commit 4047d26

2 files changed

Lines changed: 23 additions & 7 deletions

File tree

‎.github/workflows/pr-triage.lock.yml‎

Lines changed: 12 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.github/workflows/pr-triage.md‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,18 @@ jobs:
5555
5656
const sections = new Map();
5757
let current = null;
58-
let inFence = false;
58+
let fence = null;
5959
for (const line of (pr.body ?? '').replace(/<!--[\s\S]*?-->/g, '').split(/\r?\n/)) {
60-
if (/^\s*(```|~~~)/.test(line)) inFence = !inFence;
61-
const heading = !inFence && line.match(/^#{1,6}\s+(.*?)\s*$/);
60+
const marker = line.match(/^ {0,3}(`{3,}|~{3,})(.*)$/);
61+
if (marker && !fence) {
62+
fence = marker[1];
63+
continue;
64+
}
65+
if (marker && marker[1][0] === fence?.[0] && marker[1].length >= fence.length && marker[2].trim() === '') {
66+
fence = null;
67+
continue;
68+
}
69+
const heading = !fence && line.match(/^#{1,6}\s+(.*?)\s*$/);
6270
if (heading) {
6371
current = [];
6472
sections.set(heading[1].toLowerCase(), current);

0 commit comments

Comments
 (0)