2020 with :
2121 fetch-depth : 0
2222
23- - name : Get Added/Modified Markdown Files (PR only)
24- id : changed-files
23+ - name : Get Added/Modified Markdown Files
24+ id : changed
2525 if : github.event_name == 'pull_request'
2626 run : |
2727 git fetch origin ${{ github.base_ref }}
@@ -30,32 +30,77 @@ jobs:
3030 echo "$files" >> $GITHUB_OUTPUT
3131 echo "EOF" >> $GITHUB_OUTPUT
3232
33- - name : Strip HTML comments from markdown
34- if : github.event_name == 'pull_request' && steps.changed-files .outputs.md_files != ''
33+ - name : Strip HTML comments from Markdown
34+ if : github.event_name == 'pull_request' && steps.changed.outputs.md_files != ''
3535 run : |
36- for file in ${{ steps.changed-files.outputs.md_files }}; do
37- # Remove all HTML comments (multi-line aware) in-place
38- sed -z -i 's/<!--[\s\S]*?-->//g' "$file"
36+ for file in ${{ steps.changed.outputs.md_files }}; do
37+ awk -v FS="" '
38+ BEGIN { in_comment = 0 }
39+ {
40+ if (in_comment) {
41+ if (match($0, /-->/)) {
42+ $0 = substr($0, RSTART + RLENGTH)
43+ in_comment = 0
44+ } else { next }
45+ }
46+ while (match($0, /<!--/)) {
47+ prefix = substr($0, 1, RSTART - 1)
48+ rest = substr($0, RSTART + 4)
49+ if (match(rest, /-->/)) {
50+ rest = substr(rest, RSTART + RLENGTH)
51+ $0 = prefix rest
52+ } else {
53+ $0 = prefix
54+ in_comment = 1
55+ break
56+ }
57+ }
58+ print
59+ }
60+ ' "$file" > tmp && mv tmp "$file"
3961 done
4062
41- - name : Check Broken Links in Added/Modified Files (PR)
42- if : github.event_name == 'pull_request' && steps.changed-files .outputs.md_files != ''
63+ - name : Check Broken Links in Added/Modified Files
64+ if : github.event_name == 'pull_request' && steps.changed.outputs.md_files != ''
4365 uses :
lycheeverse/[email protected] 4466 with :
4567 args : >
4668 --verbose --exclude-mail --no-progress --exclude ^https?://
47- ${{ steps.changed-files .outputs.md_files }}
69+ ${{ steps.changed.outputs.md_files }}
4870 env :
4971 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5072
5173 - name : Strip HTML comments (manual run)
5274 if : github.event_name == 'workflow_dispatch'
5375 run : |
5476 for file in **/*.md; do
55- sed -z -i 's/<!--[\s\S]*?-->//g' "$file"
77+ awk -v FS="" '
78+ BEGIN { in_comment = 0 }
79+ {
80+ if (in_comment) {
81+ if (match($0, /-->/)) {
82+ $0 = substr($0, RSTART + RLENGTH)
83+ in_comment = 0
84+ } else { next }
85+ }
86+ while (match($0, /<!--/)) {
87+ prefix = substr($0, 1, RSTART - 1)
88+ rest = substr($0, RSTART + 4)
89+ if (match(rest, /-->/)) {
90+ rest = substr(rest, RSTART + RLENGTH)
91+ $0 = prefix rest
92+ } else {
93+ $0 = prefix
94+ in_comment = 1
95+ break
96+ }
97+ }
98+ print
99+ }
100+ ' "$file" > tmp && mv tmp "$file"
56101 done
57102
58- - name : Check Broken Links in Entire Repo (Manual)
103+ - name : Check Broken Links in Entire Repo
59104 if : github.event_name == 'workflow_dispatch'
60105 uses :
lycheeverse/[email protected] 61106 with :
0 commit comments