File tree 1 file changed +4
-13
lines changed
1 file changed +4
-13
lines changed Original file line number Diff line number Diff line change @@ -21,10 +21,6 @@ mkdir -p "${SRC_TARGET_DIR}"
21
21
DEST_TARGET_DIR=$( realpath " $DEST_TARGET_DIR " )
22
22
SRC_TARGET_DIR=$( realpath " $SRC_TARGET_DIR " )
23
23
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
-
28
24
echo " Working with DEST_TARGET_DIR=${DEST_TARGET_DIR} "
29
25
echo " Working with SRC_TARGET_DIR=${SRC_TARGET_DIR} "
30
26
@@ -57,25 +53,20 @@ function convert_to_mdx() {
57
53
for f in * .py * .sh; do
58
54
if [ -f " $f " ]; then
59
55
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'
66
59
# Create .mdx file with correct code fences
67
60
awk -v lang=" $lang " ' BEGIN {print "```" lang}
68
61
{print}
69
62
END {print "```"}' " $f " > " ${f} .mdx"
70
- rm " $f "
63
+ rm " $f " # Remove the original file
71
64
else
72
65
echo " No files to convert in ${CODE_DIR} "
73
66
fi
74
67
done
75
68
}
76
69
77
-
78
-
79
70
convert_to_mdx " ${DEST_TARGET_DIR} "
80
71
convert_to_mdx " ${SRC_TARGET_DIR} "
81
72
You can’t perform that action at this time.
0 commit comments