Last active
December 24, 2015 11:09
-
-
Save fernandolopez/6788747 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Transformar páginas de didiwiki a markdown | |
sed -i -r 's/\x00/\n/g' * # Las páginas de didiwiki terminan en \0 | |
sed -i -r 's/\[(\S+)\s(.+)\]/[\2](\1)/g' * # Los links tienen formato distinto | |
# Los links locales no tienen extensión | |
sed -i -r 's/(\[.+\]\([^(https?:)].+)\)/\1.md)/g' * | |
sed -i -r 's/\[([^(https?:)][^]]+)\]\s+$/[\1](\1.md)/g' * | |
# Los headings tienen sintaxis un poco distinta | |
sed -i -r 's/\s*=(\S+)/#\1/g;s/\s*==(\S+)/##\1/g;s/\s*===(\S+)/###\1/g;s/\s*====(\S+)/####\1/g' * | |
sed -i -r 's/\s*#=(\S+)/##\1/g;s/\s*#==(\S+)/###\1/g;s/\s*#===(\S+)/####\1/g' * | |
# Ya podemos considerar que están más o menos en markdown | |
for each in *; do | |
# No queremos renombrar el css ni archivos ya renombrados | |
[ -n "$(echo $each | grep -E -e '\.css$' -e '\.md$')" ] && continue | |
mv $each $each.md | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment