Dateien nach „/“ hochladen
This commit is contained in:
parent
fdb9468feb
commit
9e1f6d0840
1 changed files with 33 additions and 0 deletions
33
convert_to_markdown.sh
Normal file
33
convert_to_markdown.sh
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
INPUT_FILE="input.txt"
|
||||||
|
OUTPUT_FILE="output.md"
|
||||||
|
|
||||||
|
# Tabs zu 4 Leerzeichen konvertieren OHNE andere Leerzeichen zu verändern
|
||||||
|
sed 's/\t/ /g' "$INPUT_FILE" > temp_processed.txt
|
||||||
|
|
||||||
|
# AWK-Verarbeitung mit exakter Ebenenerkennung
|
||||||
|
awk '
|
||||||
|
{
|
||||||
|
# Gesamtzahl der führenden Leerzeichen ermitteln
|
||||||
|
match($0, /^ */)
|
||||||
|
total_spaces = RLENGTH
|
||||||
|
|
||||||
|
# Ebene berechnen (1 Ebene = 4 Leerzeichen)
|
||||||
|
level = int(total_spaces / 4)
|
||||||
|
|
||||||
|
# Neue Einrückung generieren
|
||||||
|
indent = ""
|
||||||
|
for (i = 0; i < level; i++) {
|
||||||
|
indent = indent " "
|
||||||
|
}
|
||||||
|
|
||||||
|
# Zeile neu aufbauen
|
||||||
|
if (level > 0) {
|
||||||
|
# Original-Leerzeichen entfernen und durch MD-konforme ersetzen
|
||||||
|
$0 = indent "- " substr($0, total_spaces + 1)
|
||||||
|
}
|
||||||
|
print
|
||||||
|
}' temp_processed.txt > "$OUTPUT_FILE"
|
||||||
|
|
||||||
|
rm temp_processed.txt
|
Loading…
Reference in a new issue