File tree Expand file tree Collapse file tree 1 file changed +4
-13
lines changed Expand file tree Collapse file tree 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}"
2121DEST_TARGET_DIR=$( realpath " $DEST_TARGET_DIR " )
2222SRC_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-
2824echo " Working with DEST_TARGET_DIR=${DEST_TARGET_DIR} "
2925echo " 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-
7970convert_to_mdx " ${DEST_TARGET_DIR} "
8071convert_to_mdx " ${SRC_TARGET_DIR} "
8172
You can’t perform that action at this time.
0 commit comments