├── README.md └── wikitopdf.sh /README.md: -------------------------------------------------------------------------------- 1 | # WikiToPdf 2 | A bash script to export a Github repo's wiki as a well-structured PDF ebook. 3 | 4 | ## Requirements 5 | - [Git](https://git-scm.com/) 6 | - [Pandoc](http://pandoc.org/) 7 | - [LaTex](https://www.latex-project.org/) 8 | 9 | ## Installation 10 | Download the [script](https://raw.githubusercontent.com/ousmanedev/wikitopdf/master/wikitopdf.sh) file and make it executable: 11 | ``` 12 | curl https://raw.githubusercontent.com/ousmanedev/wikitopdf/master/wikitopdf.sh -o wikitopdf.sh && chmod +x wikitopdf.sh 13 | ``` 14 | 15 | 16 | ## Usage 17 | Run the script file with the repository url as argument. 18 | 19 | For example, to export the [https://github.com/arsduo/koala/wiki](https://github.com/arsduo/koala/wiki) repository's wiki, you just have to do: 20 | ``` 21 | ./wikitopdf.sh https://github.com/arsduo/koala/wiki 22 | ``` 23 | 24 | ## Contributions 25 | Contributions are more than welcome. 26 | -------------------------------------------------------------------------------- /wikitopdf.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | if [ "$1" == "" ]; then 6 | echo "You must provide the full Github repository url (https://github.com/owner/repo)" 7 | exit 1 8 | fi 9 | 10 | WIKI_FOLDER="wiki" 11 | 12 | git clone "$1.wiki.git" $WIKI_FOLDER 13 | 14 | TEX_FILE="wiki.tex" 15 | 16 | for file in "$WIKI_FOLDER"/*.md 17 | do 18 | echo "\chapter{${file:${#WIKI_FOLDER}+1:${#file}-${#WIKI_FOLDER}-4}}" >> $TEX_FILE 19 | 20 | pandoc "$file" -f "gfm" -t "latex" >> $TEX_FILE 21 | done 22 | 23 | rm -rf $WIKI_FOLDER 24 | 25 | PDF_FILE="wiki.pdf" 26 | 27 | pandoc $TEX_FILE -s -o $PDF_FILE --variable documentclass="report" --toc 28 | 29 | rm $TEX_FILE 30 | 31 | echo "PDF file generated at $PDF_FILE" 32 | 33 | exit 0 34 | --------------------------------------------------------------------------------