This commit is contained in:
Hamidreza 2025-04-29 20:23:08 +03:30
parent c126f9a8a3
commit 166d7e72c2
2 changed files with 82 additions and 85 deletions

View File

@ -45,28 +45,25 @@ jobs:
# Read content of the README file # Read content of the README file
content=$(cat "./$rel_path") content=$(cat "./$rel_path")
# Process image references line by line for more reliable detection # Use grep to identify and process image paths instead of regex
while IFS= read -r line; do echo "Processing Markdown image references..."
# Check for Markdown style image references for img_ref in $(grep -o '!\[.*\](.*[^)]*)' "./$rel_path" | sed -E 's/!\[.*\]\((.*)\)/\1/'); do
if [[ "$line" =~ !\[(.*)\]\((.*)\) ]]; then
img_path="${BASH_REMATCH[2]}"
# Skip URLs # Skip URLs
if [[ $img_path == http* ]]; then if [[ $img_ref == http* ]]; then
continue continue
fi fi
# Handle Markdown image syntax # Process markdown image as before
if [[ $img_path == /* ]]; then if [[ $img_ref == /* ]]; then
# Absolute path within repository # Absolute path within repository
abs_img_path="./$img_path" abs_img_path="./$img_ref"
else else
# Relative path to the README # Relative path to the README
abs_img_path="$base_dir/$img_path" abs_img_path="$base_dir/$img_ref"
fi fi
# Extract just the filename # Extract just the filename
img_filename=$(basename "$img_path") img_filename=$(basename "$img_ref")
wiki_img_path="images/$img_filename" wiki_img_path="images/$img_filename"
# Copy the image to wiki repository if it exists # Copy the image to wiki repository if it exists
@ -75,11 +72,11 @@ jobs:
cp -v "$abs_img_path" "./wiki/$wiki_img_path" || echo "Error copying image" cp -v "$abs_img_path" "./wiki/$wiki_img_path" || echo "Error copying image"
# Escape special characters in the path for sed # Escape special characters in the path for sed
escaped_img_path=$(echo "$img_path" | sed 's/[\/&]/\\&/g') escaped_img_path=$(echo "$img_ref" | sed 's/[\/&]/\\&/g')
# Replace the image reference in content - simpler approach with sed # Replace the image reference in content - simpler approach with sed
content=$(echo "$content" | sed "s|!\\[.*\\]($escaped_img_path)|![\\1]($wiki_img_path)|g") content=$(echo "$content" | sed "s|!\\[.*\\]($escaped_img_path)|![\\1]($wiki_img_path)|g")
echo "Replaced image reference: $img_path → $wiki_img_path" echo "Replaced image reference: $img_ref → $wiki_img_path"
else else
echo "Warning: Image file not found: $abs_img_path" echo "Warning: Image file not found: $abs_img_path"
# Add more debug info # Add more debug info
@ -87,26 +84,28 @@ jobs:
echo "Files in $base_dir:" echo "Files in $base_dir:"
ls -la "$base_dir" ls -la "$base_dir"
fi fi
# Check for HTML style image tags - look for <img tags and extract src attribute done
elif [[ "$line" =~ \<img[[:space:]][^>]*src=\"([^\"]+)\"[^>]*\> ]]; then
img_path="${BASH_REMATCH[1]}"
# Process HTML img tags separately
echo "Processing HTML image references..."
# Extract src attributes from img tags using grep and sed
for img_src in $(grep -o '<img [^>]*src="[^"]*"' "./$rel_path" | sed -E 's/.*src="([^"]*)".*/\1/'); do
# Skip URLs # Skip URLs
if [[ $img_path == http* ]]; then if [[ $img_src == http* ]]; then
continue continue
fi fi
# Determine the absolute path of the image # Determine the absolute path of the image
if [[ $img_path == /* ]]; then if [[ $img_src == /* ]]; then
# Absolute path within repository # Absolute path within repository
abs_img_path="./$img_path" abs_img_path="./$img_src"
else else
# Relative path to the README # Relative path to the README
abs_img_path="$base_dir/$img_path" abs_img_path="$base_dir/$img_src"
fi fi
# Extract just the filename # Extract just the filename
img_filename=$(basename "$img_path") img_filename=$(basename "$img_src")
wiki_img_path="images/$img_filename" wiki_img_path="images/$img_filename"
# Copy the image to wiki repository if it exists # Copy the image to wiki repository if it exists
@ -115,22 +114,20 @@ jobs:
cp -v "$abs_img_path" "./wiki/$wiki_img_path" || echo "Error copying image" cp -v "$abs_img_path" "./wiki/$wiki_img_path" || echo "Error copying image"
# Escape special characters in the path for sed # Escape special characters in the path for sed
escaped_img_path=$(echo "$img_path" | sed 's/[\/&]/\\&/g') escaped_img_src=$(echo "$img_src" | sed 's/[\/&]/\\&/g')
# Replace the HTML image reference in content # Replace the HTML image reference in content
content=$(echo "$content" | sed "s|src=\"$escaped_img_path\"|src=\"$wiki_img_path\"|g") content=$(echo "$content" | sed "s|src=\"$escaped_img_src\"|src=\"$wiki_img_path\"|g")
echo "Replaced HTML image reference: $img_path → $wiki_img_path" echo "Replaced HTML image reference: $img_src → $wiki_img_path"
else else
echo "Warning: HTML image file not found: $abs_img_path" echo "Warning: HTML image file not found: $abs_img_path"
# Add more debug info
echo "Current directory: $(pwd)" echo "Current directory: $(pwd)"
echo "Files in $base_dir:" echo "Files in $base_dir:"
ls -la "$base_dir" ls -la "$base_dir"
fi fi
fi done
done < "./$rel_path"
# Add debug info # Debug output
echo "Wiki page content preview (first 100 chars): ${content:0:100}" echo "Wiki page content preview (first 100 chars): ${content:0:100}"
# Replace the wiki page with the updated content rather than appending # Replace the wiki page with the updated content rather than appending

View File

@ -13,7 +13,7 @@ This benchmark compares the performance of phasicFlow with a well-stablished com
</div> </div>
</div> </div>
.
<div align="center"> <div align="center">
<img src="./images/phasicFlow_snapshot.png" style="width: 400px;" /> <img src="./images/phasicFlow_snapshot.png" style="width: 400px;" />
<div align="center"> <div align="center">