Skip to content

Commit f5b710e

Browse files
committed
markdown auto-convert
1 parent b8ba8ca commit f5b710e

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

driver-ci

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,47 @@ TUTORIAL_DST="$DOCS_SOURCE_DIR/tutorial.md"
2929
{
3030
found_title=false
3131
while IFS= read -r line; do
32+
# Replace first heading with '# Tutorial'
3233
if ! $found_title && [[ "$line" =~ ^# ]]; then
3334
echo "# Tutorial"
3435
found_title=true
36+
continue
37+
fi
38+
39+
# Convert [!XYZ] → ```{xyz}
40+
if [[ "$line" =~ ^\[!\([A-Z]+\)\] ]]; then
41+
admonition=$(echo "$line" | sed -E 's/^\[!([A-Z]+)\].*/\L\1/') # lowercase XYZ
42+
content=$(echo "$line" | sed -E 's/^\[![A-Z]+\]\s*//')
43+
echo "\`\`\`{$admonition}"
44+
echo "$content"
45+
echo "\`\`\`"
3546
else
3647
echo "$line"
3748
fi
3849
done < "$TUTORIAL_SRC"
3950
} > "$TUTORIAL_DST"
4051

41-
# === Copy and transform README.md into index.md ===
52+
# === Copy and transform README.md into index.md (Home) ===
4253
README_SRC="$TMP_DIR/amago-crr_k/README.md"
4354
INDEX_DST="$DOCS_SOURCE_DIR/index.md"
4455

4556
{
4657
found_title=false
4758
while IFS= read -r line; do
59+
# Replace first heading with '# Home'
4860
if ! $found_title && [[ "$line" =~ ^# ]]; then
4961
echo "# Home"
5062
found_title=true
63+
continue
64+
fi
65+
66+
# Convert [!XYZ] → ```{xyz}
67+
if [[ "$line" =~ ^\[!\([A-Z]+\)\] ]]; then
68+
admonition=$(echo "$line" | sed -E 's/^\[!([A-Z]+)\].*/\L\1/') # lowercase XYZ
69+
content=$(echo "$line" | sed -E 's/^\[![A-Z]+\]\s*//')
70+
echo "\`\`\`{$admonition}"
71+
echo "$content"
72+
echo "\`\`\`"
5173
else
5274
echo "$line"
5375
fi
@@ -69,4 +91,4 @@ make html
6991
# === Copy media into final HTML output ===
7092
cd "$BUILD_DIR/html"
7193
mkdir -p media
72-
cp -r "$STATIC_MEDIA_DIR"/* media/
94+
cp -r "$STATIC_MEDIA_DIR"/* media/

0 commit comments

Comments
 (0)