-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclean-wiki.sh
26 lines (18 loc) · 1020 Bytes
/
clean-wiki.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
# Sum of all wiki - worst solution ever...
rm ./docs/wiki/_Footer.md
rm ./docs/wiki/_Sidebar.md
rm ./docs/wiki/README---old-reference.md
rm ./docs/wiki/readme.md
rm ./docs/wiki/Home.md
#find ./docs/wiki -name "*.md" -exec cat > ./docs/wiki/_.md {} ';'
for f in ./docs/wiki/*.md; do (cat "${f}"; echo) >> ./docs/wiki/_.md; done
# Move headers to +1 depth
#find ./docs/wiki -name "*.md" -exec sed -i '' 's/^#/##/g' {} ';'
rexreplace '^#' '##' ./docs/wiki/*.md
# We dont want relative links or header 1 from the wiki
# Links formatted like (Nice link)[link]
#find ./docs/wiki -name "*.md" -exec sed -i '' '/)\[http/! s/)\[\([^\]]+\)\]/)\[\/search\.html\?q=\1\]/g' {} ';' # This will ignore all lines with full URL :-(
rexreplace '\]\(((?![A-z]+:\/\/).*)\)' '](/search.html?q=$1)' ./docs/wiki/*.md
# Links formatted like [[pagename]]
#find ./docs/wiki -name "*.md" -exec sed -i '' 's/\[\[\([^\]]+\)\]\]/(\1)\[\/search\.html\?q=\1\]/g' {} ';'
rexreplace '\[\[(.*?)\]\]' '[$1](/search.html?q=$1)' ./docs/wiki/*.md