Skip to content

Commit 6d3d3c3

Browse files
committed
Meir kompatibel sed-regex
1 parent 155e867 commit 6d3d3c3

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

.github/workflows/docsygen.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ jobs:
137137
# Test the sed commands manually first
138138
echo "=== Testing sed commands ==="
139139
echo "Test 1 - ../images/file.png:"
140-
echo "![ErrorModelWithBoth](../images/ErrorModelWithBoth.png)" | sed -E 's|!\[([^\]]*)\]\(([^/]*/)*(([^/)]+\.(png|jpg|jpeg|gif|svg|webp)))\)|![\1](./images/\4)|g; s|(image:[[:space:]]*)([^/]*/)*(([^/[:space:]]+\.(png|jpg|jpeg|gif|svg|webp)))|\1./images/\4|g'
140+
echo "![ErrorModelWithBoth](../images/ErrorModelWithBoth.png)" | sed 's|!\[\([^]]*\)\](\([^/]*/\)*\([^/)]*\.\(png\|jpg\|jpeg\|gif\|svg\|webp\))\)|![\1](./images/\3)|g'
141141
echo "Test 2 - /images/file.png:"
142-
echo "![ErrorModelWithBoth](/images/ErrorModelWithBoth.png)" | sed -E 's|!\[([^\]]*)\]\(([^/]*/)*(([^/)]+\.(png|jpg|jpeg|gif|svg|webp)))\)|![\1](./images/\4)|g; s|(image:[[:space:]]*)([^/]*/)*(([^/[:space:]]+\.(png|jpg|jpeg|gif|svg|webp)))|\1./images/\4|g'
142+
echo "![ErrorModelWithBoth](/images/ErrorModelWithBoth.png)" | sed 's|!\[\([^]]*\)\](\([^/]*/\)*\([^/)]*\.\(png\|jpg\|jpeg\|gif\|svg\|webp\))\)|![\1](./images/\3)|g'
143143
echo "Test 3 - ./images/file.png:"
144-
echo "![Spellingdir](./images/spellingdir.png)" | sed -E 's|!\[([^\]]*)\]\(([^/]*/)*(([^/)]+\.(png|jpg|jpeg|gif|svg|webp)))\)|![\1](./images/\4)|g; s|(image:[[:space:]]*)([^/]*/)*(([^/[:space:]]+\.(png|jpg|jpeg|gif|svg|webp)))|\1./images/\4|g'
144+
echo "![Spellingdir](./images/spellingdir.png)" | sed 's|!\[\([^]]*\)\](\([^/]*/\)*\([^/)]*\.\(png\|jpg\|jpeg\|gif\|svg\|webp\))\)|![\1](./images/\3)|g'
145145
echo "Test 4 - YAML image property:"
146-
echo "image: ../images/ErrorModelWithBoth.png" | sed -E 's|!\[([^\]]*)\]\(([^/]*/)*(([^/)]+\.(png|jpg|jpeg|gif|svg|webp)))\)|![\1](./images/\4)|g; s|(image:[[:space:]]*)([^/]*/)*(([^/[:space:]]+\.(png|jpg|jpeg|gif|svg|webp)))|\1./images/\4|g'
146+
echo "image: ../images/ErrorModelWithBoth.png" | sed 's|image: \([^/]*/\)*\([^/]*\.\(png\|jpg\|jpeg\|gif\|svg\|webp\)\)|image: ./images/\2|g'
147147
echo "Test 5 - Complex path:"
148-
echo "![Test](./subdir/images/test.png)" | sed -E 's|!\[([^\]]*)\]\(([^/]*/)*(([^/)]+\.(png|jpg|jpeg|gif|svg|webp)))\)|![\1](./images/\4)|g; s|(image:[[:space:]]*)([^/]*/)*(([^/[:space:]]+\.(png|jpg|jpeg|gif|svg|webp)))|\1./images/\4|g'
148+
echo "![Test](./subdir/images/test.png)" | sed 's|!\[\([^]]*\)\](\([^/]*/\)*\([^/)]*\.\(png\|jpg\|jpeg\|gif\|svg\|webp\))\)|![\1](./images/\3)|g'
149149
150150
# Process content step by step using temp files
151151
echo "=== Step 1 - Original content ==="
@@ -156,8 +156,9 @@ jobs:
156156
grep "images/" "$slidev_dir/step2.md" || echo "No images found"
157157
158158
# Normalize all image paths to ./images/filename since we copied all images there
159-
# This handles: ../images/file.png, ./images/file.png, /images/file.png, images/file.png
160-
sed -E 's|!\[([^\]]*)\]\(([^/]*/)*(([^/)]+\.(png|jpg|jpeg|gif|svg|webp)))\)|![\1](./images/\4)|g; s|(image:[[:space:]]*)([^/]*/)*(([^/[:space:]]+\.(png|jpg|jpeg|gif|svg|webp)))|\1./images/\4|g' "$slidev_dir/step2.md" > "$slidev_dir/step3.md"
159+
# Handle markdown images: ![alt](any/path/file.ext) -> ![alt](./images/file.ext)
160+
# Handle YAML images: image: any/path/file.ext -> image: ./images/file.ext
161+
sed 's|!\[\([^]]*\)\](\([^/]*/\)*\([^/)]*\.\(png\|jpg\|jpeg\|gif\|svg\|webp\))\)|![\1](./images/\3)|g; s|image: \([^/]*/\)*\([^/]*\.\(png\|jpg\|jpeg\|gif\|svg\|webp\)\)|image: ./images/\2|g' "$slidev_dir/step2.md" > "$slidev_dir/step3.md"
161162
echo "=== Step 3 - After image path conversion ==="
162163
grep "images/" "$slidev_dir/step3.md" || echo "No images found"
163164

0 commit comments

Comments
 (0)