Skip to content

Commit d8abce3

Browse files
last bump
1 parent efe2f16 commit d8abce3

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

scripts/make_mdx.sh

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ mkdir -p "${SRC_TARGET_DIR}"
2121
DEST_TARGET_DIR=$(realpath "$DEST_TARGET_DIR")
2222
SRC_TARGET_DIR=$(realpath "$SRC_TARGET_DIR")
2323

24-
# Ensure directories end with a slash
25-
[[ "${DEST_TARGET_DIR}" != */ ]] && DEST_TARGET_DIR="${DEST_TARGET_DIR}/"
26-
[[ "${SRC_TARGET_DIR}" != */ ]] && SRC_TARGET_DIR="${SRC_TARGET_DIR}/"
27-
2824
echo "Working with DEST_TARGET_DIR=${DEST_TARGET_DIR}"
2925
echo "Working with SRC_TARGET_DIR=${SRC_TARGET_DIR}"
3026

@@ -57,25 +53,20 @@ function convert_to_mdx() {
5753
for f in *.py *.sh; do
5854
if [ -f "$f" ]; then
5955
local extension="${f##*.}"
60-
local lang=""
61-
if [ "$extension" = "py" ]; then
62-
lang="python"
63-
elif [ "$extension" = "sh" ]; then
64-
lang="bash"
65-
fi
56+
local lang="${extension:0:2}" # Simplified logic for language detection
57+
lang=${lang/py/python} # If Python, set to 'python'
58+
lang=${lang/sh/bash} # If Shell, set to 'bash'
6659
# Create .mdx file with correct code fences
6760
awk -v lang="$lang" 'BEGIN {print "```" lang}
6861
{print}
6962
END {print "```"}' "$f" > "${f}.mdx"
70-
rm "$f"
63+
rm "$f" # Remove the original file
7164
else
7265
echo "No files to convert in ${CODE_DIR}"
7366
fi
7467
done
7568
}
7669

77-
78-
7970
convert_to_mdx "${DEST_TARGET_DIR}"
8071
convert_to_mdx "${SRC_TARGET_DIR}"
8172

0 commit comments

Comments
 (0)