-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make README elements suitable for mkdocs
- Loading branch information
Atick
committed
Dec 30, 2024
1 parent
a9de94b
commit a10e427
Showing
2 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# This script processes a README.md file and converts it to a docs/index.md file. | ||
# It converts GitHub README admonitions to mkdocs admonitions. | ||
# It also updates image paths from 'docs/assets/' to 'assets/'. | ||
|
||
while read -r line; do | ||
if [[ $line =~ ^\>.* ]]; then # Detect if line starts with '>' | ||
if [[ $line =~ \[\!TIP\] ]]; then | ||
echo "!!! tip" | ||
elif [[ $line =~ \[\!NOTE\] ]]; then | ||
echo "!!! note" | ||
elif [[ $line =~ \[\!WARNING\] ]]; then | ||
echo "!!! warning" | ||
elif [[ $line =~ \[\!IMPORTANT\] ]]; then | ||
echo "!!! danger" | ||
else | ||
echo " ${line:1}" | ||
fi | ||
else | ||
# Pass through any line not part of a block | ||
echo "${line}" | sed -e 's/docs\/assets\/\([a-zA-Z0-9_\-]\+\.\(png\|jpg\|gif\)\)/assets\/\1/g' | ||
fi | ||
|
||
done < README.md > docs/index.md |