Skip to content

Commit c9e73b2

Browse files
committed
Fix link-checker error parsing bug
- Fixed parsing logic that failed to capture error links - Old code stopped parsing when encountering blank lines - New code only ends error block when hitting new section headers - Now correctly displays specific broken links in PR comments
1 parent aad7bf4 commit c9e73b2

File tree

1 file changed

+14
-26
lines changed

1 file changed

+14
-26
lines changed

.github/workflows/link-checker.yml

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -145,34 +145,22 @@ jobs:
145145
let inErrorBlock = false;
146146
147147
for (const line of lycheeLines) {
148-
// Start/end detection for lychee sections
149-
if (line.startsWith('### Errors in')) {
150-
inErrorBlock = true;
151-
continue;
152-
}
153-
if (line.startsWith('## ') && !line.startsWith('### Errors in')) {
154-
inErrorBlock = false;
155-
}
156-
157-
// Bullet-format errors
158-
if (inErrorBlock && line.startsWith('* [')) {
159-
errors.push(line);
160-
continue;
161-
}
162-
163-
// Table-format errors under "🚫 Errors" sections
164-
if (line.startsWith('🚫 Errors')) {
165-
inErrorBlock = true;
166-
continue;
167-
}
168-
if (inErrorBlock && line.startsWith('| [')) {
169-
errors.push(line);
170-
continue;
148+
// End error block when hitting a new section
149+
if (line.startsWith('##')) {
150+
if (line.startsWith('### Errors in') || line.startsWith('🚫 Errors')) {
151+
inErrorBlock = true;
152+
continue;
153+
} else {
154+
inErrorBlock = false;
155+
continue;
156+
}
171157
}
172158
173-
// Blank line ends current block
174-
if (inErrorBlock && line.trim() === '') {
175-
inErrorBlock = false;
159+
// Capture error lines
160+
if (inErrorBlock) {
161+
if (line.startsWith('* [') || line.startsWith('| [')) {
162+
errors.push(line);
163+
}
176164
}
177165
}
178166

0 commit comments

Comments
 (0)