update
This commit is contained in:
parent
4a20dde950
commit
5e3590e329
17
fix-link.sh
17
fix-link.sh
@ -44,22 +44,29 @@ while IFS=':' read -r file_path line_err status desc data; do
|
|||||||
|
|
||||||
if [ "$desc" = "undefined label" ]; then
|
if [ "$desc" = "undefined label" ]; then
|
||||||
echo -e "${GRAY}DEBUG: Found 'undefined label' case${NC}"
|
echo -e "${GRAY}DEBUG: Found 'undefined label' case${NC}"
|
||||||
# Replace \, /, or _ with - in data
|
# Check if data is enclosed in < and >
|
||||||
new_data=$(echo "$data" | tr '\\/_' '-')
|
if [[ "$data" =~ ^\<.*\>$ ]]; then
|
||||||
echo -e "${GRAY}DEBUG: Changing '$data' to '$new_data'${NC}"
|
# Remove < and > for processing
|
||||||
|
clean_data=$(echo "$data" | sed 's/^<//;s/>$//')
|
||||||
|
# Replace \, /, or _ with - in clean_data
|
||||||
|
new_data=$(echo "$clean_data" | tr '\\/_' '-')
|
||||||
|
echo -e "${GRAY}DEBUG: Changing '$data' to '<$new_data>'${NC}"
|
||||||
|
|
||||||
# Check if the data appears in an {image} directive
|
# Check if the data appears in an {image} directive
|
||||||
if grep -B1 "$data" "$file_path" | grep -q "{image}"; then
|
if grep -B1 "$data" "$file_path" | grep -q "{image}"; then
|
||||||
echo -e "${GRAY}DEBUG: Skipping '$data' as it appears in an {image} directive${NC}"
|
echo -e "${GRAY}DEBUG: Skipping '$data' as it appears in an {image} directive${NC}"
|
||||||
else
|
else
|
||||||
# Replace the old data with new data in the file, only if not preceded by {image}
|
# Replace the old data with new data in the file, only if not preceded by {image}
|
||||||
if sed -i "/{image}/!s|$data|$new_data|g" "$file_path" 2>/dev/null; then
|
if sed -i "/{image}/!s|$data|<$new_data>|g" "$file_path" 2>/dev/null; then
|
||||||
changes_made=$((changes_made + 1))
|
changes_made=$((changes_made + 1))
|
||||||
echo -e "${GREEN}Processed: $file_path - Changed '$data' to '$new_data'${NC}"
|
echo -e "${GREEN}Processed: $file_path - Changed '$data' to '<$new_data>'${NC}"
|
||||||
else
|
else
|
||||||
echo -e "${RED}WARNING: Failed to modify $file_path${NC}"
|
echo -e "${RED}WARNING: Failed to modify $file_path${NC}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo -e "${GRAY}DEBUG: Skipping '$data' as it is not enclosed in <>${NC}"
|
||||||
|
fi
|
||||||
|
|
||||||
elif [[ "$desc" =~ "toctree contains reference to nonexisting document" ]]; then
|
elif [[ "$desc" =~ "toctree contains reference to nonexisting document" ]]; then
|
||||||
echo -e "${GRAY}DEBUG: Found 'toctree' case${NC}"
|
echo -e "${GRAY}DEBUG: Found 'toctree' case${NC}"
|
||||||
|
Loading…
Reference in New Issue
Block a user