diff --git a/README.asciidoc b/README.asciidoc index 5be24f9..f61cab0 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -12,6 +12,8 @@ Sell: Kindle, iBooks, Lulu, Pledgie(?) https://github.com/oreilly/couchdb-guide +A good cheat sheet: http://powerman.name/doc/asciidoc#_text + Start a Book =================== @@ -111,16 +113,16 @@ The layout that the `git scribe init` produces looks like this: |`--* 01_first_chapter.asciidoc |`--* 02_second_chapter.asciidoc |`--* 99_backmatter.asciidoc -|`--* img/ +|`--* image/ | `--* 01.01-example-image.png | `--* 01.02-another-image.png | `--* 02.01-an-image.png +|`--* include/ +| `--* 02.01-code.c * style/ |`--* style.css * site/ |`--* layout.html -* code/ -|`--* 01_example.rb * test/ |`--* 01_test.rb * LICENSE.txt diff --git a/example/book/01_book.asciidoc b/example/book/01_book.asciidoc index 3aab4d8..c9ac621 100644 --- a/example/book/01_book.asciidoc +++ b/example/book/01_book.asciidoc @@ -5,6 +5,8 @@ Nec vitae mus fringilla eu vel pede sed pellentesque. Nascetur fugiat nobis. Eu felis id mauris sollicitudin ut. Sem volutpat feugiat. Ornare convallis urna vitae. +image::octocat_professor.png[] + Nec mauris sed aliquam nam mauris dolor lorem imperdiet. == The second chapter @@ -14,3 +16,8 @@ cras. Id tellus cubilia erat. Quisque nullam et. Blandit dui tempor. Posuere in elit diam egestas sem vivamus vel ac. + +[c] +source~~~~ +include::hello.c[] +source~~~~ diff --git a/example/book/image/octocat_professor.png b/example/book/image/octocat_professor.png new file mode 100644 index 0000000..ba0d604 Binary files /dev/null and b/example/book/image/octocat_professor.png differ diff --git a/example/book/include/hello.c b/example/book/include/hello.c new file mode 100644 index 0000000..4bc3fdf --- /dev/null +++ b/example/book/include/hello.c @@ -0,0 +1,10 @@ +#include + +main() +{ + char hex[] = "599955586da1c3ad514f3e65f1081d2012ec862d"; + git_oid oid; + + git_oid_mkstr(&oid, hex); + printf("Raw 20 bytes: [%s]\n", (&oid)->id); +} diff --git a/lib/git-scribe.rb b/lib/git-scribe.rb index fa748f5..793b811 100644 --- a/lib/git-scribe.rb +++ b/lib/git-scribe.rb @@ -68,15 +68,23 @@ def gen def prepare_output_dir Dir.mkdir('output') rescue nil Dir.chdir('output') do + Dir.mkdir('resources') rescue nil Dir.mkdir('stylesheets') rescue nil from_stdir = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'stylesheets')) FileUtils.cp_r from_stdir, '.' end end + def a2x(type) + "a2x -f #{type} -d book -r resources" + end + def a2x_wss(type) + a2x(type) + " --stylesheet=stylesheets/handbookish.css" + end + def do_pdf puts "GENERATING PDF" - `a2x -f pdf -d book #{BOOK_FILE}` + `#{a2x('pdf')} #{BOOK_FILE}` if $?.exitstatus == 0 'book.pdf' end @@ -84,21 +92,21 @@ def do_pdf def do_epub puts "GENERATING EPUB" - `a2x -f epub -d book --epubcheck --stylesheet=stylesheets/handbookish.css #{BOOK_FILE}` + `#{a2x_wss('epub')} --epubcheck #{BOOK_FILE}` puts 'exit status', $?.exitstatus 'book.epub' end def do_html puts "GENERATING HTML" - `a2x -f xhtml -d book --stylesheet=stylesheets/handbookish.css #{BOOK_FILE}` + `#{a2x_wss('xhtml')} #{BOOK_FILE}` puts 'exit status', $?.exitstatus 'book.html' end def do_site puts "GENERATING SITE" - `a2x -f chunked -d book --stylesheet=stylesheets/handbookish.css #{BOOK_FILE}` + `#{a2x_wss('chunked')} #{BOOK_FILE}` puts 'exit status', $?.exitstatus 'book.html' end @@ -112,6 +120,12 @@ def gather_and_process f.puts File.read(file) end end + files = Dir.glob("book/image/**/*") + FileUtils.cp_r(files, 'output/resources/') + + files = Dir.glob("book/include/**/*") + FileUtils.cp_r(files, 'output/') + pp files end # DISPLAY HELPER FUNCTIONS #