fnando-kitabu 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -25,7 +25,6 @@ TXT
25
25
  gem.add_dependency "unicode"
26
26
  gem.add_dependency "main"
27
27
  gem.add_dependency "ultraviolet"
28
- gem.add_dependency "colorize"
29
28
 
30
29
  gem.requirements << "Install the Oniguruma RE library"
31
30
  gem.requirements << "Install colorize using gem install fnando-colorize -s http://gems.github.com"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.8
1
+ 0.3.9
data/kitabu.gemspec CHANGED
@@ -1,12 +1,15 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{kitabu}
5
- s.version = "0.3.8"
8
+ s.version = "0.3.9"
6
9
 
7
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
11
  s.authors = ["Nando Vieira"]
9
- s.date = %q{2009-08-14}
12
+ s.date = %q{2009-08-28}
10
13
  s.default_executable = %q{kitabu}
11
14
  s.description = %q{A framework for creating e-books from Markdown/Textile text markup using Ruby.
12
15
  Using the Prince PDF generator, you'll be able to get high quality PDFs.
@@ -64,14 +67,12 @@ Using the Prince PDF generator, you'll be able to get high quality PDFs.
64
67
  s.add_runtime_dependency(%q<unicode>, [">= 0"])
65
68
  s.add_runtime_dependency(%q<main>, [">= 0"])
66
69
  s.add_runtime_dependency(%q<ultraviolet>, [">= 0"])
67
- s.add_runtime_dependency(%q<colorize>, [">= 0"])
68
70
  else
69
71
  s.add_dependency(%q<rdiscount>, [">= 0"])
70
72
  s.add_dependency(%q<hpricot>, [">= 0"])
71
73
  s.add_dependency(%q<unicode>, [">= 0"])
72
74
  s.add_dependency(%q<main>, [">= 0"])
73
75
  s.add_dependency(%q<ultraviolet>, [">= 0"])
74
- s.add_dependency(%q<colorize>, [">= 0"])
75
76
  end
76
77
  else
77
78
  s.add_dependency(%q<rdiscount>, [">= 0"])
@@ -79,6 +80,5 @@ Using the Prince PDF generator, you'll be able to get high quality PDFs.
79
80
  s.add_dependency(%q<unicode>, [">= 0"])
80
81
  s.add_dependency(%q<main>, [">= 0"])
81
82
  s.add_dependency(%q<ultraviolet>, [">= 0"])
82
- s.add_dependency(%q<colorize>, [">= 0"])
83
83
  end
84
84
  end
data/lib/kitabu.rb CHANGED
@@ -5,6 +5,7 @@ require "ostruct"
5
5
  require "rexml/streamlistener"
6
6
  require "rexml/document"
7
7
  require "hpricot"
8
+ require "activesupport"
8
9
 
9
10
  $LOAD_PATH.unshift File.dirname(__FILE__)
10
11
 
@@ -19,5 +20,5 @@ rescue LoadError => e
19
20
  end
20
21
 
21
22
  module Kitabu
22
- VERSION = "0.3.8"
23
+ VERSION = "0.3.9"
23
24
  end
@@ -64,7 +64,7 @@ class BlackCloth < RedCloth
64
64
  # get syntax
65
65
  m, syntax = *attrs.match(/class="(.*?)([# ].*?)?"/)
66
66
  syntax = 'plain_text' if tag == "pre"
67
-
67
+
68
68
  # set source
69
69
  source_file = content
70
70
 
data/lib/kitabu/tasks.rb CHANGED
@@ -17,13 +17,6 @@ rescue LoadError => e
17
17
  "Install using `sudo gem install ultraviolet`.\n\n"
18
18
  end
19
19
 
20
- begin
21
- require "hpricot"
22
- rescue LoadError => e
23
- puts "\nHpricot gem not found. NO TOC for you.\n" +
24
- "Install using `sudo gem install hpricot`.\n\n"
25
- end
26
-
27
20
  begin
28
21
  require "unicode"
29
22
  rescue LoadError => e
@@ -38,6 +31,11 @@ rescue LoadError => e
38
31
  "Install using `sudo gem install fnando-colorize -s http://gems.github.com`.\n\n"
39
32
  end
40
33
 
34
+ # extend BlackCloth if module Helpers is defined
35
+ BlackCloth.__send__(:include, ::Helpers) if defined?(::Helpers)
36
+
37
+ task :default => "kitabu:auto"
38
+
41
39
  namespace :kitabu do
42
40
  desc "Generate PDF from markup files"
43
41
  task :pdf => :html do
@@ -64,29 +62,24 @@ namespace :kitabu do
64
62
  desc "List all titles and its permalinks"
65
63
  task :titles => :html do
66
64
  contents = File.new(Kitabu::Base.html_path).read
67
- doc = Hpricot(contents)
68
- counter = {}
69
-
70
- titles = (doc/"h2, h3, h4, h5, h6").collect do |node|
71
- title = node.inner_text
72
- permalink = Kitabu::Base.to_permalink(title)
73
-
74
- # initialize and increment counter
75
- counter[permalink] ||= 0
76
- counter[permalink] += 1
65
+ output = ""
66
+
67
+ contents.scan(/<h([1-6])(.*?)>(.*?)<\/h[1-6]>/sim) do
68
+ level = $1.to_i - 1
69
+ output << "-" * level
70
+ output << " " if level > 0
77
71
 
78
- # set a incremented permalink if more than one occurrence
79
- # is found
80
- permalink = "#{permalink}-#{counter[permalink]}" if counter[permalink] > 1
72
+ if level == 0
73
+ output << Colorize.yellow($3.upcase, :style => :underscore)
74
+ else
75
+ output << $3
76
+ end
81
77
 
82
- [title, permalink]
78
+ output << Colorize.green($2.to_s.gsub(/^.*?id=['"](.*?)['"].*?$/, ' #\1'))
79
+ output << "\n"
83
80
  end
84
81
 
85
- titles.sort_by {|items| items.last }.each do |items|
86
- puts items.first
87
- puts %(##{items.last})
88
- puts
89
- end
82
+ puts output
90
83
  end
91
84
 
92
85
  task :watch => :auto
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fnando-kitabu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-14 00:00:00 -07:00
12
+ date: 2009-08-28 00:00:00 -07:00
13
13
  default_executable: kitabu
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -62,16 +62,6 @@ dependencies:
62
62
  - !ruby/object:Gem::Version
63
63
  version: "0"
64
64
  version:
65
- - !ruby/object:Gem::Dependency
66
- name: colorize
67
- type: :runtime
68
- version_requirement:
69
- version_requirements: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- version: "0"
74
- version:
75
65
  description: A framework for creating e-books from Markdown/Textile text markup using Ruby. Using the Prince PDF generator, you'll be able to get high quality PDFs.
76
66
  email: fnando.vieira@gmail.com
77
67
  executables: