Skip to content

Instantly share code, notes, and snippets.

@austinjp
Created August 23, 2016 18:17
Show Gist options
  • Save austinjp/c71b71dcd0869a33c66d3f854af7d39d to your computer and use it in GitHub Desktop.
Save austinjp/c71b71dcd0869a33c66d3f854af7d39d to your computer and use it in GitHub Desktop.
Creates a single page that includes every file. Outputs "onepage.md". You need to add this to your SUMMARY.md (or equivalent) for gitbook to render it.
#!/bin/bash
# Expand current directory to absolute path:
declare wd="."
declare wd=$( cd $(dirname $wd) ; pwd -P )
declare filelistfile="/tmp/onepager.txt"
# FIXME use $wd in redirect
# cat "$wd/SUMMARY.md" | perl -ne "s/^.+\((.+)\)$/$wd/$1/msg; s/^\#.*$//msg; s/\s+/ /msg; //; print;" > "$filelistfile"
cat "$wd/SUMMARY.md" | perl -ne 's/^.*\((.+)\).*$/$1/msg; s/^\#.*$//msg; s/\s+/ /msg; print $_."\n" if($_);' > "$filelistfile"
declare gitbook_files=`cat "$filelistfile"`
cat "$filelistfile" | perl -ne 'chomp; print "{% include \"".$_."\" %}\n\n" if (/[a-zA-Z0-9]/msg)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment