Skip to content

Commit c7f790a

Browse files
readmd.md update
1 parent 166d7e7 commit c7f790a

File tree

3 files changed

+54
-39
lines changed

3 files changed

+54
-39
lines changed

.github/workflows/sync-wiki.yml

Lines changed: 53 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -86,53 +86,68 @@ jobs:
8686
fi
8787
done
8888
89-
# Process HTML img tags separately
89+
# Process HTML img tags separately - preserving all attributes
9090
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"
91+
# Store the file content in a temporary variable to process with awk
92+
readme_content=$(cat "./$rel_path")
93+
94+
# Use awk to find all img tags and process them
95+
img_tags=$(echo "$readme_content" | grep -o '<img[^>]*>' || echo "")
96+
if [ -n "$img_tags" ]; then
97+
echo "Found HTML img tags to process"
98+
echo "$img_tags" | while read -r img_tag; do
99+
# Extract src attribute
100+
img_src=$(echo "$img_tag" | grep -o 'src="[^"]*"' | sed 's/src="\([^"]*\)"/\1/')
115101
116-
# Escape special characters in the path for sed
117-
escaped_img_src=$(echo "$img_src" | sed 's/[\/&]/\\&/g')
102+
# Skip if no src or if it's a URL
103+
if [ -z "$img_src" ] || [[ $img_src == http* ]]; then
104+
continue
105+
fi
118106
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"
127-
fi
128-
done
107+
# Determine the absolute path of the image
108+
if [[ $img_src == /* ]]; then
109+
# Absolute path within repository
110+
abs_img_path="./$img_src"
111+
else
112+
# Relative path to the README
113+
abs_img_path="$base_dir/$img_src"
114+
fi
115+
116+
# Extract just the filename
117+
img_filename=$(basename "$img_src")
118+
wiki_img_path="images/$img_filename"
119+
120+
# Copy the image to wiki repository if it exists
121+
if [ -f "$abs_img_path" ]; then
122+
echo "Copying image: $abs_img_path -> ./wiki/$wiki_img_path"
123+
cp -v "$abs_img_path" "./wiki/$wiki_img_path" || echo "Error copying image"
124+
125+
# Escape special characters in the path for sed
126+
escaped_img_src=$(echo "$img_src" | sed 's/[\/&]/\\&/g')
127+
escaped_img_tag=$(echo "$img_tag" | sed 's/[\/&]/\\&/g')
128+
129+
# Create the new tag with the updated src but preserving all other attributes
130+
new_img_tag=$(echo "$img_tag" | sed "s|src=\"$escaped_img_src\"|src=\"$wiki_img_path\"|g")
131+
132+
# Replace the entire img tag in content
133+
content=$(echo "$content" | sed "s|$escaped_img_tag|$new_img_tag|g")
134+
echo "Replaced HTML image tag while preserving all attributes"
135+
else
136+
echo "Warning: HTML image file not found: $abs_img_path"
137+
# Add more debug info
138+
echo "Current directory: $(pwd)"
139+
echo "Files in $base_dir:"
140+
ls -la "$base_dir"
141+
fi
142+
done
143+
fi
129144
130145
# Debug output
131146
echo "Wiki page content preview (first 100 chars): ${content:0:100}"
132147
133148
# Replace the wiki page with the updated content rather than appending
134149
mkdir -p "$(dirname "./wiki/$wiki_page")" # Ensure directory exists
135-
echo -e "# $(basename "$wiki_page" .md)\n\nContent from $rel_path:\n\n$content" > "./wiki/$wiki_page"
150+
echo -e "# $(basename "$wiki_page" .md)\n\n$content" > "./wiki/$wiki_page"
136151
echo "Updated wiki page: $wiki_page"
137152
fi
138153
done

benchmarks/rotatingDrum/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This benchmark compares the performance of phasicFlow with a well-stablished com
77
## Simulation Setup
88

99
<div align="center">
10-
<img src="./images/commerical DEM snapshot.png" style="width: 400px;" />
10+
<img src="./images/commericalDEMsnapshot.png" style="width: 400px;" />
1111
<div align="center">
1212
<p>Figure 1. Commercial DEM simulation snapshot</p>
1313
</div>

0 commit comments

Comments
 (0)