diff --git a/convert_to_markdown-bash.sh b/convert_to_markdown-bash.sh new file mode 100644 index 0000000..7453956 --- /dev/null +++ b/convert_to_markdown-bash.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +INPUT_FILE="input.txt" +OUTPUT_FILE="output.md" + +# Schritt 1: Tabs durch 4 Leerzeichen ersetzen (ohne expand) +sed 's/\t/ /g' "$INPUT_FILE" > temp_processed.txt + +# Schritt 2: Hierarchische Listen generieren +while IFS= read -r line; do + # Zähle führende Leerzeichen + spaces=$(echo "$line" | grep -o '^ *' | wc -c) + spaces=$((spaces - 1)) # wc -c zählt Nullbyte + + # Berechne Ebene + level=$((spaces / 4)) + + # Generiere Einrückung + indent="" + for ((i=0; i 0 )); then + # Entferne originale Einrückung und füge MD-Formatierung hinzu + clean_line="${line:$spaces}" + new_line="${indent}- ${clean_line}" + else + new_line="$line" + fi + + echo "$new_line" +done < temp_processed.txt > "$OUTPUT_FILE" + +# Aufräumen +rm temp_processed.txt