@@ -59,6 +59,10 @@ expected_files=(
5959
6060fail=0
6161
62+ normalize_line () {
63+ sed -e ' s/\r$//' -e ' s/^[[:space:]]*//' -e ' s/[[:space:]]*$//'
64+ }
65+
6266expected_next () {
6367 case " $1 " in
6468 README.md) echo " 01_ROADMAP.md" ;;
@@ -166,14 +170,14 @@ for file in "${expected_files[@]}"; do
166170 continue
167171 fi
168172
169- home_line=" $( sed -n ' 2p ' " $path " ) "
173+ home_line=" $( awk ' NF{count++; if(count==2){print; exit}} ' " $path " | normalize_line ) "
170174 if [[ " $home_line " != " Home: [README](./README.md)" ]]; then
171175 echo " bad home line: $file "
172176 fail=1
173177 fi
174178
175179 # Ensure Next is the final heading.
176- last_heading=" $( rg ' ^## ' " $path " | tail -n1 || true) "
180+ last_heading=" $( rg ' ^## ' " $path " | tail -n1 | normalize_line | | true) "
177181 if [[ " $last_heading " != " ## Next" ]]; then
178182 echo " last heading is not ## Next: $file "
179183 fail=1
@@ -186,14 +190,14 @@ for file in "${expected_files[@]}"; do
186190 path=" $ROOT_DIR /$file "
187191 [[ -f " $path " ]] || continue
188192
189- next_header_line=" $( rg -n ' ^## Next$' " $path " | tail -n1 | cut -d: -f1 || true) "
193+ next_header_line=" $( rg -n ' ^## Next\r? $' " $path " | tail -n1 | cut -d: -f1 || true) "
190194 if [[ -z " $next_header_line " ]]; then
191195 echo " missing ## Next: $file "
192196 fail=1
193197 continue
194198 fi
195199
196- next_target=" $( tail -n +$(( next_header_line + 1 )) " $path " | rg -n ' ^(Go to|Return to) \[[^]]+\]\(\./[^)]+\)' | head -n1 | sed -E ' s#.*\(\./([^)]+)\).*#\1#' || true) "
200+ next_target=" $( tail -n +$(( next_header_line + 1 )) " $path " | normalize_line | rg -n ' ^(Go to|Return to) \[[^]]+\]\(\./[^)]+\)' | head -n1 | sed -E ' s#.*\(\./([^)]+)\).*#\1#' || true) "
197201 expected_target=" $( expected_next " $file " ) "
198202
199203 if [[ -z " $next_target " ]]; then
@@ -215,11 +219,11 @@ for file in "${expected_files[@]}"; do
215219 path=" $ROOT_DIR /$file "
216220 [[ -f " $path " ]] || continue
217221
218- if ! rg -n ' ^## Primary Sources$' " $path " > /dev/null; then
222+ if ! rg -n ' ^## Primary Sources\r? $' " $path " > /dev/null; then
219223 echo " missing Primary Sources: $file "
220224 fail=1
221225 fi
222- if ! rg -n ' ^## Optional Resources$' " $path " > /dev/null; then
226+ if ! rg -n ' ^## Optional Resources\r? $' " $path " > /dev/null; then
223227 echo " missing Optional Resources: $file "
224228 fail=1
225229 fi
0 commit comments