From 89af4767d0aa9326ae5a553276155425e5a912b8 Mon Sep 17 00:00:00 2001 From: Samuel Vasko Date: Sun, 26 Jan 2014 22:51:09 +0100 Subject: [PATCH] Fixed a name confusion --- header.html | 2 +- lib/convert.rb | 21 ++++++++++++++--- style.css | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 style.css diff --git a/header.html b/header.html index 7cfc283..abb012a 100644 --- a/header.html +++ b/header.html @@ -3,6 +3,6 @@ - + diff --git a/lib/convert.rb b/lib/convert.rb index 8a1676a..e952bda 100644 --- a/lib/convert.rb +++ b/lib/convert.rb @@ -1,11 +1,16 @@ require 'eeepub' require 'nokogiri' +require 'pygments' class Convert def self.run toc # Join the forces! - doc = (['header', 'out', 'footer'].map {|f| File.read(f + '.html')}).join + doc = (['header', 'cache/out', 'footer'].map {|f| File.read(f + '.html')}).join toc = self.parse_toc toc + # doc = self.highlight doc + + File.write('cache/joined.html', doc) + epub = EeePub.make do title 'Vala Tutorial' creator 'Gnome' @@ -14,12 +19,22 @@ def self.run toc identifier 'https://github.com/bliker/vala-tutorial-book', :scheme => 'URL' uid 'https://github.com/bliker/vala-tutorial-book' - files ['cache/out.html', 'css/css/base.css'] + files ['cache/joined.html', 'style.css'] nav toc end epub.save('Vala Tutorial.epub') end + # Not jet implemented + def self.highlight doc + doc = Nokogiri::HTML(doc) + doc.css('pre').each do |pre| + pre.content = Pygments.highlight(pre.text, :lexer => 'vala') + end + + doc.to_html + end + def self.parse_toc doc doc = Nokogiri::HTML(doc) self.mush_ol(doc.css('body > ol')) @@ -28,7 +43,7 @@ def self.parse_toc doc def self.mush_li li data = { :label => li.css('> a').text, - :content => 'out.html' + li.css('a').attr('href') + :content => 'joined.html' + li.css('a').attr('href') } unless li.css('ol').empty? data[:nav] = self.mush_ol(li.css('ol')) diff --git a/style.css b/style.css new file mode 100644 index 0000000..396e1b0 --- /dev/null +++ b/style.css @@ -0,0 +1,62 @@ +html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, +p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, +dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, +sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, +label, legend, table, caption, tbody, tfoot, thead, tr, th, td { + margin: 0; + padding: 0; + border: 0; + outline: 0; + font-size: 100%; + vertical-align: baseline; + background: transparent; } + +/* end reset */ + +@page { + margin: 5px !important; +} + +pre { + white-space: pre-wrap; + font-family: monospace; + margin: 10px 0 10px 20px; + font-size: 85%; + display: block; + -webkit-hyphens: none; + hyphens: none; + adobe-hyphenate: none; +} + +h1 { + font-size: 1.5em; + font-weight: bold; + margin-top: 20px !important; +} + +h2 { + font-size: 1.3em; + font-weight: bold; + color: #333; + margin: 15px 0 8px 0 !important; +} + +h3 { + font-size: 1.1em; + font-weight: bold; + margin: 10px 0 8px 0 !important; +} + +h4 { + font-size: bold; + font-weight: 1em; + color: #555; + margin: 9px 0 !important; +} + +h1, h2, h3, h4, h5 { + -webkit-hyphens: none; + hyphens: none; + font-family: Helvetica, Arial, sans-serif; + adobe-hyphenate: none; +} \ No newline at end of file