File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ set -e
4+
5+ BOOK_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) /../book" && pwd) "
6+ cd " $BOOK_DIR "
7+
8+ echo " Checking for orphaned cross-references..."
9+
10+ # Extract all cross-references with filenames
11+ refs_with_files=$( grep -roh " <<[^>]*>>" * .adoc | sed ' s/<<//g; s/>>//g' )
12+ refs=$( echo " $refs_with_files " | sort -u)
13+
14+ # Extract all anchor definitions
15+ anchors=$( grep -roh " \[\[[^]]*\]\]" * .adoc | sed ' s/\[\[//g; s/\]\]//g' | sort -u)
16+
17+ # Find orphaned references with their files
18+ orphaned=()
19+ while IFS= read -r ref; do
20+ if ! echo " $anchors " | grep -qx " $ref " ; then
21+ # Find which files contain this orphaned reference
22+ files=$( grep -l " <<$ref >>" * .adoc | tr ' \n' ' ' )
23+ orphaned+=(" $ref (in: $files )" )
24+ fi
25+ done <<< " $refs"
26+
27+ if [ ${# orphaned[@]} -gt 0 ]; then
28+ echo " ERROR: Found ${# orphaned[@]} orphaned cross-reference(s):"
29+ printf ' - %s\n' " ${orphaned[@]} "
30+ exit 1
31+ fi
32+
33+ echo " ✓ No orphaned cross-references found"
Original file line number Diff line number Diff line change 11#! /bin/bash
22
3+ set -e
4+
5+ # Check for orphaned cross-references
6+ ./bin/check-refs.sh
7+
38# create the target directory for where the book will build
49rm -rf target
510mkdir target
You can’t perform that action at this time.
0 commit comments