Skip to content

Commit

Permalink
Fixed a name confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
samvasko committed Jan 26, 2014
1 parent f5e542c commit 89af476
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 4 deletions.
2 changes: 1 addition & 1 deletion header.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link rel="stylesheet" href="core.css" type="base.css"/>
<link rel="stylesheet" href="style.css" type="text/css"/>
</head>
<body>
21 changes: 18 additions & 3 deletions lib/convert.rb
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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'))
Expand All @@ -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'))
Expand Down
62 changes: 62 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 89af476

Please sign in to comment.