This commit is contained in:
hoangvv 2025-02-28 10:49:44 +07:00
parent 4a20dde950
commit 5e3590e329

View File

@ -44,21 +44,28 @@ 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
# 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
changes_made=$((changes_made + 1))
echo -e "${GREEN}Processed: $file_path - Changed '$data' to '$new_data'${NC}"
else else
echo -e "${RED}WARNING: Failed to modify $file_path${NC}" # 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
changes_made=$((changes_made + 1))
echo -e "${GREEN}Processed: $file_path - Changed '$data' to '<$new_data>'${NC}"
else
echo -e "${RED}WARNING: Failed to modify $file_path${NC}"
fi
fi fi
else
echo -e "${GRAY}DEBUG: Skipping '$data' as it is not enclosed in <>${NC}"
fi fi
elif [[ "$desc" =~ "toctree contains reference to nonexisting document" ]]; then elif [[ "$desc" =~ "toctree contains reference to nonexisting document" ]]; then