Skip to content

Commit dcc3569

Browse files
committed
Merge branch 'check-markdown' into test-markdown-check
2 parents ea38d51 + 5b34caa commit dcc3569

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

markdown-link-check/action.yml

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,48 +35,42 @@ runs:
3535
current_file=""
3636
file_summaries=()
3737
in_summary_section=0
38-
current_summary=""
3938
4039
# Process output line by line
4140
while IFS= read -r line; do
4241
# Detect file header lines
4342
if [[ "$line" =~ ^FILE:[[:space:]]*(.+) ]]; then
4443
# Save previous file summary
45-
if [ -n "$current_file" ] && [ -n "$current_summary" ]; then
46-
file_summaries+=("$current_file|$current_summary")
47-
current_summary=""
44+
if [ -n "$current_file" ] && [ $in_summary_section -eq 1 ]; then
45+
file_summaries+=("$current_file")
46+
in_summary_section=0
4847
fi
4948
5049
current_file="${BASH_REMATCH[1]}"
51-
in_summary_section=0
5250
5351
# Detect start of summary section (after "n links checked.")
5452
elif [[ "$line" =~ ^[[:space:]]*[0-9]+[[:space:]]*links[[:space:]]*checked\. ]]; then
5553
in_summary_section=1
56-
current_summary="$line"
54+
# Start new summary for this file
55+
file_summaries+=("$current_file")
56+
file_summaries+=("$line")
5757
5858
# Collect summary content
5959
elif [ $in_summary_section -eq 1 ]; then
60-
# Skip empty lines at the start of summary
61-
if [[ -z "$line" && -z "$current_summary" ]]; then
62-
continue
63-
fi
64-
6560
# Add to current summary
66-
current_summary+="\n$line"
61+
file_summaries+=("$line")
6762
6863
# Check if this line indicates an error
6964
if [[ "$line" =~ ERROR: ]] || [[ "$line" =~ \[✖\] ]]; then
7065
has_errors=1
7166
fi
67+
68+
# Reset summary section flag when we hit a blank line or new file
69+
elif [[ -z "$line" ]] || [[ "$line" =~ ^FILE: ]]; then
70+
in_summary_section=0
7271
fi
7372
done <<< "$MLC_OUTPUT"
7473
75-
# Save last file summary
76-
if [ -n "$current_file" ] && [ -n "$current_summary" ]; then
77-
file_summaries+=("$current_file|$current_summary")
78-
fi
79-
8074
# Output final conclusion
8175
if [ $has_errors -eq 0 ]; then
8276
echo "✅ All links are valid"
@@ -88,17 +82,23 @@ runs:
8882
echo "===== DETAILS ====="
8983
9084
# Output error details
91-
for entry in "${file_summaries[@]}"; do
92-
# Split into filename and summary
93-
IFS='|' read -r filename summary <<< "$entry"
85+
current_filename=""
86+
for line in "${file_summaries[@]}"; do
87+
# If line is a filename
88+
if [[ "$line" =~ ^FILE: ]]; then
89+
current_filename="${line#FILE: }"
90+
continue
91+
fi
9492
9593
# Only show summaries that contain errors
96-
if [[ "$summary" =~ ERROR: ]] || [[ "$summary" =~ \[✖\] ]]; then
97-
echo "File: $filename"
98-
# Preserve newlines in summary
99-
printf "%s\n" "$summary" | while IFS= read -r s_line; do
100-
echo " $s_line"
101-
done
102-
echo
94+
if [[ "$line" =~ ERROR: ]] || [[ "$line" =~ \[✖\] ]]; then
95+
# Print filename if it's the start of a summary block
96+
if [ -n "$current_filename" ]; then
97+
echo "File: $current_filename"
98+
current_filename=""
99+
fi
100+
101+
# Print the line with proper indentation
102+
echo " $line"
103103
fi
104104
done

0 commit comments

Comments
 (0)