-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadmeconv.sh
More file actions
executable file
·22 lines (20 loc) · 917 Bytes
/
readmeconv.sh
File metadata and controls
executable file
·22 lines (20 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env bash
# convert all the files with name ending with `*.adoc` into `*.md`.
# except ones with `_` as prefix.
# E.g, `readme_.adoc` will be converted into `readme_.md`
find . -iname "*.adoc" -type f -maxdepth 1 -not -name "_*.adoc" | while read fname; do
target=${fname//adoc/md}
xml=${fname//adoc/xml}
echo "converting $fname into $target"
asciidoctor -b docbook -a leveloffset=+1 -o - "$fname" | pandoc --markdown-headings=atx --wrap=preserve -t markdown_strict -f docbook - > "$target"
echo deleting $xml
rm -f "$xml"
done
# if we find a readme*.md (or README*.md),
# we rename all of them to a single README.md while overwriting,
# effectively the last wins.
# E.g, if we have `readme_.md`, it will be overwritten into `README.md`
find . -iname "readme*.md" -not -name "README.md" -type f -maxdepth 1 | while read fname; do
echo Renaming $fname to README.md
mv $fname README.md
done