Dateien nach „/“ hochladen
This commit is contained in:
parent
9d631c8c85
commit
016dc44973
1 changed files with 37 additions and 0 deletions
37
convert_to_markdown-bash.sh
Normal file
37
convert_to_markdown-bash.sh
Normal file
|
@ -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<level; i++)); do
|
||||||
|
indent+=" "
|
||||||
|
done
|
||||||
|
|
||||||
|
# Konstruiere neue Zeile
|
||||||
|
if (( level > 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
|
Loading…
Reference in a new issue