Skip to content

Commit 166d7e7

Browse files
rrr
1 parent c126f9a commit 166d7e7

2 files changed

Lines changed: 78 additions & 81 deletions

File tree

.github/workflows/sync-wiki.yml

Lines changed: 77 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -45,92 +45,89 @@ jobs:
4545
# Read content of the README file
4646
content=$(cat "./$rel_path")
4747
48-
# Process image references line by line for more reliable detection
49-
while IFS= read -r line; do
50-
# Check for Markdown style image references
51-
if [[ "$line" =~ !\[(.*)\]\((.*)\) ]]; then
52-
img_path="${BASH_REMATCH[2]}"
53-
54-
# Skip URLs
55-
if [[ $img_path == http* ]]; then
56-
continue
57-
fi
58-
59-
# Handle Markdown image syntax
60-
if [[ $img_path == /* ]]; then
61-
# Absolute path within repository
62-
abs_img_path="./$img_path"
63-
else
64-
# Relative path to the README
65-
abs_img_path="$base_dir/$img_path"
66-
fi
67-
68-
# Extract just the filename
69-
img_filename=$(basename "$img_path")
70-
wiki_img_path="images/$img_filename"
71-
72-
# Copy the image to wiki repository if it exists
73-
if [ -f "$abs_img_path" ]; then
74-
echo "Copying image: $abs_img_path -> ./wiki/$wiki_img_path"
75-
cp -v "$abs_img_path" "./wiki/$wiki_img_path" || echo "Error copying image"
76-
77-
# Escape special characters in the path for sed
78-
escaped_img_path=$(echo "$img_path" | sed 's/[\/&]/\\&/g')
79-
80-
# Replace the image reference in content - simpler approach with sed
81-
content=$(echo "$content" | sed "s|!\\[.*\\]($escaped_img_path)|![\\1]($wiki_img_path)|g")
82-
echo "Replaced image reference: $img_path → $wiki_img_path"
83-
else
84-
echo "Warning: Image file not found: $abs_img_path"
85-
# Add more debug info
86-
echo "Current directory: $(pwd)"
87-
echo "Files in $base_dir:"
88-
ls -la "$base_dir"
89-
fi
90-
# Check for HTML style image tags - look for <img tags and extract src attribute
91-
elif [[ "$line" =~ \<img[[:space:]][^>]*src=\"([^\"]+)\"[^>]*\> ]]; then
92-
img_path="${BASH_REMATCH[1]}"
48+
# Use grep to identify and process image paths instead of regex
49+
echo "Processing Markdown image references..."
50+
for img_ref in $(grep -o '!\[.*\](.*[^)]*)' "./$rel_path" | sed -E 's/!\[.*\]\((.*)\)/\1/'); do
51+
# Skip URLs
52+
if [[ $img_ref == http* ]]; then
53+
continue
54+
fi
55+
56+
# Process markdown image as before
57+
if [[ $img_ref == /* ]]; then
58+
# Absolute path within repository
59+
abs_img_path="./$img_ref"
60+
else
61+
# Relative path to the README
62+
abs_img_path="$base_dir/$img_ref"
63+
fi
64+
65+
# Extract just the filename
66+
img_filename=$(basename "$img_ref")
67+
wiki_img_path="images/$img_filename"
68+
69+
# Copy the image to wiki repository if it exists
70+
if [ -f "$abs_img_path" ]; then
71+
echo "Copying image: $abs_img_path -> ./wiki/$wiki_img_path"
72+
cp -v "$abs_img_path" "./wiki/$wiki_img_path" || echo "Error copying image"
9373
94-
# Skip URLs
95-
if [[ $img_path == http* ]]; then
96-
continue
97-
fi
74+
# Escape special characters in the path for sed
75+
escaped_img_path=$(echo "$img_ref" | sed 's/[\/&]/\\&/g')
9876
99-
# Determine the absolute path of the image
100-
if [[ $img_path == /* ]]; then
101-
# Absolute path within repository
102-
abs_img_path="./$img_path"
103-
else
104-
# Relative path to the README
105-
abs_img_path="$base_dir/$img_path"
106-
fi
77+
# Replace the image reference in content - simpler approach with sed
78+
content=$(echo "$content" | sed "s|!\\[.*\\]($escaped_img_path)|![\\1]($wiki_img_path)|g")
79+
echo "Replaced image reference: $img_ref → $wiki_img_path"
80+
else
81+
echo "Warning: Image file not found: $abs_img_path"
82+
# Add more debug info
83+
echo "Current directory: $(pwd)"
84+
echo "Files in $base_dir:"
85+
ls -la "$base_dir"
86+
fi
87+
done
88+
89+
# Process HTML img tags separately
90+
echo "Processing HTML image references..."
91+
# Extract src attributes from img tags using grep and sed
92+
for img_src in $(grep -o '<img [^>]*src="[^"]*"' "./$rel_path" | sed -E 's/.*src="([^"]*)".*/\1/'); do
93+
# Skip URLs
94+
if [[ $img_src == http* ]]; then
95+
continue
96+
fi
97+
98+
# Determine the absolute path of the image
99+
if [[ $img_src == /* ]]; then
100+
# Absolute path within repository
101+
abs_img_path="./$img_src"
102+
else
103+
# Relative path to the README
104+
abs_img_path="$base_dir/$img_src"
105+
fi
106+
107+
# Extract just the filename
108+
img_filename=$(basename "$img_src")
109+
wiki_img_path="images/$img_filename"
110+
111+
# Copy the image to wiki repository if it exists
112+
if [ -f "$abs_img_path" ]; then
113+
echo "Copying image: $abs_img_path -> ./wiki/$wiki_img_path"
114+
cp -v "$abs_img_path" "./wiki/$wiki_img_path" || echo "Error copying image"
107115
108-
# Extract just the filename
109-
img_filename=$(basename "$img_path")
110-
wiki_img_path="images/$img_filename"
116+
# Escape special characters in the path for sed
117+
escaped_img_src=$(echo "$img_src" | sed 's/[\/&]/\\&/g')
111118
112-
# Copy the image to wiki repository if it exists
113-
if [ -f "$abs_img_path" ]; then
114-
echo "Copying image: $abs_img_path -> ./wiki/$wiki_img_path"
115-
cp -v "$abs_img_path" "./wiki/$wiki_img_path" || echo "Error copying image"
116-
117-
# Escape special characters in the path for sed
118-
escaped_img_path=$(echo "$img_path" | sed 's/[\/&]/\\&/g')
119-
120-
# Replace the HTML image reference in content
121-
content=$(echo "$content" | sed "s|src=\"$escaped_img_path\"|src=\"$wiki_img_path\"|g")
122-
echo "Replaced HTML image reference: $img_path → $wiki_img_path"
123-
else
124-
echo "Warning: HTML image file not found: $abs_img_path"
125-
# Add more debug info
126-
echo "Current directory: $(pwd)"
127-
echo "Files in $base_dir:"
128-
ls -la "$base_dir"
129-
fi
119+
# Replace the HTML image reference in content
120+
content=$(echo "$content" | sed "s|src=\"$escaped_img_src\"|src=\"$wiki_img_path\"|g")
121+
echo "Replaced HTML image reference: $img_src → $wiki_img_path"
122+
else
123+
echo "Warning: HTML image file not found: $abs_img_path"
124+
echo "Current directory: $(pwd)"
125+
echo "Files in $base_dir:"
126+
ls -la "$base_dir"
130127
fi
131-
done < "./$rel_path"
128+
done
132129
133-
# Add debug info
130+
# Debug output
134131
echo "Wiki page content preview (first 100 chars): ${content:0:100}"
135132
136133
# Replace the wiki page with the updated content rather than appending

benchmarks/rotatingDrum/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This benchmark compares the performance of phasicFlow with a well-stablished com
1313
</div>
1414
</div>
1515

16-
.
16+
1717
<div align="center">
1818
<img src="./images/phasicFlow_snapshot.png" style="width: 400px;" />
1919
<div align="center">

0 commit comments

Comments
 (0)