Skip to content

Instantly share code, notes, and snippets.

@Turupawn
Created February 7, 2018 01:03
Show Gist options
  • Save Turupawn/99df57c923ba2f649a5026393b60de4c to your computer and use it in GitHub Desktop.
Save Turupawn/99df57c923ba2f649a5026393b60de4c to your computer and use it in GitHub Desktop.
Bakeing A Github Readme into an HTML
#!/bin/bash
#Usage
#Place this scprit in the wiki folder and run the following using your github :
#bash bake_wiki.sh USER PASS
for fullfile in *; do
filename=$(basename "$fullfile")
filename="${filename%.*}"
echo $filename
grip "$filename.md" --export export/"$filename.html" --user=$1 --pass=$2
for fullfile2 in *; do
filename2=$(basename "$fullfile2")
filename2="${filename2%.*}"
find="-"
replace=" "
filename_with_spaces=${filename2//$find/$replace}
sed -i -e "s/\[\[$filename_with_spaces]]/<a href='$filename2.html'>$filename_with_spaces<\/a>/g" export/"$filename.html"
done
done
@nickelc
Copy link

nickelc commented Nov 21, 2019

You can change

for fullfile in *; do
  filename=$(basename "$fullfile")
  filename="${filename%.*}"

to

for fullfile in *.md; do
  filename=$(basename "$fullfile" .md)

@nickelc
Copy link

nickelc commented Nov 21, 2019

I had to add --no-inline for grip (v4.5.2) installed via pip

$ ll -ogh
total 76M
-rw-r--r-- 1 614K Nov 21 04:11  API-Access-options.html
-rw-r--r-- 1 618K Nov 21 04:11  Building.html
-rw-r--r-- 1 621K Nov 21 03:22  Comments.html
-rw-r--r-- 1 622K Nov 21 03:22 'Comments-(C-compatible).html'
-rw-r--r-- 1 614K Nov 21 03:22  Community-options.html
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment