-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_gh2md.sh
executable file
·40 lines (29 loc) · 1.02 KB
/
run_gh2md.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
[[ ! -d docs ]] || exit 1
# ReaR-User-Guide docs reside under the docs/ directory
cd docs || exit 1
[[ -d issues.old ]] && rm -rf issues.old
[[ -d issues ]] && mv issues issues.old
# run gh2md which will create a fresh issues directory with content
gh2md --multiple-files --idempotent --file-extension .gfm rear/rear issues
find issues/ -type f | while read f
do
b="${f%.*}"
[[ ! -f "$b.md" ]] && pandoc --verbose -f gfm+hard_line_breaks -t markdown_strict "$b.gfm" -o "$b.md"
rm -f "$b.gfm"
done
# To have all issues we copy the content of issues.old in issues/ as well
# as not all issues are dumped by a gh2md run
[[ -d issues.old ]] && cp issues.old/*.md issues/
cd issues || exit 1
# remove the old index file
rm -f index.md
# Create an header
echo -e "# Issues History of Relax-and-Recover (ReaR)\n" > index.md
# create a new index file
for f in $(ls *.md 2>/dev/null)
do
part1="$(head -1 "$f" | cut -d'(' -f 1)"
part2="$(head -1 "$f" | cut -d')' -f 2)"
echo "- ${part1}($f)${part2}" >> index.md
done