conversio 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CONTRIBUTORS ADDED
@@ -0,0 +1,2 @@
1
+ Mykhaylo Zynovyev
2
+ Dennis KLein
data/HISTORY.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.1.2
2
+
3
+ * supporting files with suffix `.md`
4
+ * fixing bug with input files without suffix
5
+ * check that destination is a directory
6
+
1
7
  ## 0.1.1
2
8
 
3
9
  * finishing Kramdown support
data/README.md CHANGED
@@ -2,11 +2,7 @@ Conversio by Jörg Behrendt and Victor Penso
2
2
 
3
3
  # Description
4
4
 
5
- Renders plain text files with [Markdown][1] syntax to XHTML pages.
6
- User can define their own Ruby ERB templates to customize the
7
- XHTML page generation. Also the creation of a table of content
8
- using the HTML header elements (like `<h1>`) and the syntax
9
- high-lighting of code snippets is supported.
5
+ Renders plain text files with [Markdown][1] syntax to XHTML pages. User can define their own Ruby ERB templates to customize the XHTML page generation. Also the creation of a table of content using the HTML header elements (like `<h1>`) and the syntax high-lighting of code snippets is supported.
10
6
 
11
7
  ## Installation
12
8
 
@@ -14,7 +10,7 @@ Conversio RubyGem:
14
10
 
15
11
  gem install conversio
16
12
 
17
- Syntax high-lighting is done with Pyhton [Pygments][2]:
13
+ Syntax high-lighting is done with Phyton [Pygments][2]:
18
14
 
19
15
  easy_install pygments
20
16
 
@@ -24,9 +20,7 @@ Take a look to the help text:
24
20
 
25
21
  conversio -h
26
22
 
27
- Convert all files called `*.markdown` inside a defined directory
28
- and all sub-directories into HTML and store the in the destination
29
- directory.
23
+ Convert all files called `*.markdown` or `*.md` inside a defined directory and all sub-directories into HTML and store them in the destination directory.
30
24
 
31
25
  conversio ~/docs/path/to/files ~/public/path
32
26
 
@@ -35,6 +29,15 @@ using the 'dark' template:
35
29
 
36
30
  conversio -t -p dark readme.markdown
37
31
 
32
+ ### Syntax High-Lighting
33
+
34
+ Using the `-c` option syntax colorization can be enabled. Conversio will inspect all code blocks for a syntax tag in the first line. This tag needs to be part of the code block (indented with four spaces) and is prefixed with two dashes followed by the language definition. For example to high-light a code block as Ruby write `--ruby` as first line or for C++ `--c++`. If this tag is not present Conversio will not apply any high-lighting. The tag itself is passes to Pygments, therefore any
35
+ language supported by it can be high-lighted.
36
+
37
+ For a list of supported languages type:
38
+
39
+ pygmentize -L lexers
40
+
38
41
  ## License
39
42
 
40
43
  GPLv3 - see the COPYING file.
data/bin/conversio CHANGED
@@ -42,7 +42,10 @@ Options
42
42
 
43
43
  -c, --colorize:
44
44
 
45
- Enable syntax high-lighting for marked code blocks.
45
+ Enable syntax high-lighting for taged code blocks. Tags need
46
+ to be in the first line of the code block and have the form
47
+ of two dashes followed by the language like '--ruby' or
48
+ '--c++'.
46
49
 
47
50
  -e, --engine:
48
51
 
@@ -104,15 +107,6 @@ def overwrite?(*str)
104
107
  end
105
108
 
106
109
 
107
- # -------------------------------------------------------------
108
- # class extensions
109
- # -------------------------------------------------------------
110
-
111
- class Array
112
- def resolv_path
113
- Hash[ *self.collect { |e| [e,e.gsub(/.markdown/,'.html') ] }.flatten ]
114
- end
115
- end
116
110
 
117
111
  # -------------------------------------------------------------
118
112
  # main program
@@ -176,9 +170,12 @@ begin
176
170
  end
177
171
 
178
172
 
179
- # get the input source
173
+ # get the input source
180
174
  src = ARGV[0] || raise("no input defined")
181
- dst = ARGV[1] # optional parameter!
175
+ unless ARGV[1].nil?
176
+ raise('destination not a directory') unless File.directory?(ARGV[1])
177
+ end
178
+ dst = ARGV[1]
182
179
 
183
180
  # read the default configuration of the user
184
181
  if not options.ignore_config and File.exists? user_config then
@@ -217,22 +214,32 @@ begin
217
214
  # get all the input files
218
215
  input_files = Array.new
219
216
  if File.directory?(src) then
220
- input_files = Dir["#{src}/**/*.markdown"]
217
+ input_files = Dir["#{src}/**/*.markdown"] + Dir["#{src}/**/*.md"]
221
218
  else
222
219
  file = File.expand_path(src)
223
220
  input_files << file
224
221
  src = File.dirname(file)
225
222
  end
226
- src_dst_pairs = input_files.resolv_path
227
- # fix the destination path if needed
223
+ sdp = Hash.new # source destination pairs
224
+ input_files.each do |s|
225
+ case s
226
+ when /.markdown/
227
+ sdp[s] = s.gsub(/.markdown/,'.html')
228
+ when /.md/
229
+ sdp[s] = s.gsub(/.md/,'.html')
230
+ else
231
+ # make sure we have the always the right suffix
232
+ sdp[s] = s << '.html'
233
+ end
234
+ end
228
235
  unless dst.nil? then
229
- src_dst_pairs.each_pair do |src_path,dst_path|
230
- src_dst_pairs[src_path] = dst_path.gsub(/#{src}/,dst)
236
+ sdp.each_pair do |s,d|
237
+ sdp[s] = d.gsub(/#{src}/,dst)
231
238
  end
232
239
  end
233
240
  # render the XHTML docs
234
241
  STDERR.puts 'Created files:' if options.verbose
235
- src_dst_pairs.each_pair do |s,d|
242
+ sdp.each_pair do |s,d|
236
243
  converter.markdown_to_xhtml(s,d)
237
244
  STDERR.print ' ', d, "\n" if options.verbose
238
245
  end
data/conversio.gemspec CHANGED
@@ -3,11 +3,11 @@
3
3
  Gem::Specification.new do |s|
4
4
 
5
5
  s.name = %q{conversio}
6
- s.version = "0.1.1"
6
+ s.version = "0.1.2"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
9
9
  s.authors = ["Jörg Behrendt","Victor Penso"]
10
- s.date = %q{2010-11-19}
10
+ s.date = %q{2010-12-10}
11
11
  s.default_executable = %q{conversio}
12
12
  s.homepage = 'https://github.com/vpenso/conversio'
13
13
 
@@ -29,6 +29,7 @@ s.extra_rdoc_files = [
29
29
  "lib/conversio/pygmentizer.rb"
30
30
  ]
31
31
  s.files = [
32
+ 'CONTRIBUTORS',
32
33
  "README.md",
33
34
  "HISTORY.md",
34
35
  "bin/conversio",
@@ -49,7 +50,7 @@ s.rubygems_version = %q{1.3.6}
49
50
  s.summary = %q{Renders Markdown plain text files to HTML}
50
51
 
51
52
  s.add_dependency('bluecloth', '>= 2.0.9')
52
- s.add_dependency('kramdown')
53
+ s.add_dependency('kramdown', '>= 0.6.0')
53
54
  s.requirements << 'Pygments (http://pygments.org/)'
54
55
  s.licenses = 'GPLv3'
55
56
 
@@ -2,36 +2,6 @@ require 'fileutils'
2
2
 
3
3
  module Conversio
4
4
 
5
- class Hash
6
-
7
- def deep_merge(hash)
8
- target = dup
9
-
10
- hash.keys.each do |key|
11
- if hash[key].is_a? Hash and self[key].is_a? Hash
12
- target[key] = target[key].deep_merge(hash[key])
13
- next
14
- end
15
-
16
- target[key] = hash[key]
17
- end
18
-
19
- target
20
- end
21
-
22
-
23
- def deep_merge!(second)
24
- second.each_pair do |k,v|
25
- if self[k].is_a?(Hash) and second[k].is_a?(Hash)
26
- self[k].deep_merge!(second[k])
27
- else
28
- self[k] = second[k]
29
- end
30
- end
31
- end
32
- end
33
-
34
-
35
5
  class Converter
36
6
 
37
7
  attr_accessor :table_of_content, :color
@@ -40,11 +10,6 @@ class Converter
40
10
  @template = template
41
11
  @table_of_content = false
42
12
  @color = false
43
- #user_config = "#{ENV['HOME']}/.conversiorc"
44
- #if File.exists?(user_config)
45
- # overwrite defaults
46
- #@meta_data = @meta_data.deep_merge(YAML.load_file(user_config))
47
- #end
48
13
  # Holds the input Markdown plain text
49
14
  @source = nil
50
15
  # Hold Markdown rendered to HTML
@@ -85,25 +50,6 @@ class Converter
85
50
 
86
51
  private
87
52
 
88
- def configure()
89
- config = nil
90
- # read the header of the source file
91
- start = @source.index("|--")
92
- ende = @source.index("--|")
93
- #if start != nil and ende != nil then
94
- if false
95
- STDERR.puts 'Meta data found in file!' if $DEBUG
96
- yamlheader = @source[start+3,ende-start-3]
97
- # overwrite defaults
98
- config = @meta_data.deep_merge(YAML.load(yamlheader))
99
- splitted = @source.split('--|',2)
100
- @source = splitted[1]
101
- else
102
- config = @meta_data
103
- end
104
- return config
105
- end
106
-
107
53
  def load_template(tpl)
108
54
  puts "Loading template : "+tpl.to_s
109
55
  raise "Couldn't open ERB template: #{tpl}" unless File.exists?(File.expand_path(tpl))
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - "J\xC3\xB6rg Behrendt"
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-19 00:00:00 +01:00
18
+ date: 2010-12-10 00:00:00 +01:00
19
19
  default_executable: conversio
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -41,7 +41,9 @@ dependencies:
41
41
  - !ruby/object:Gem::Version
42
42
  segments:
43
43
  - 0
44
- version: "0"
44
+ - 6
45
+ - 0
46
+ version: 0.6.0
45
47
  type: :runtime
46
48
  version_requirements: *id002
47
49
  description: |
@@ -63,6 +65,7 @@ extra_rdoc_files:
63
65
  - lib/conversio/htmltoc.rb
64
66
  - lib/conversio/pygmentizer.rb
65
67
  files:
68
+ - CONTRIBUTORS
66
69
  - README.md
67
70
  - HISTORY.md
68
71
  - bin/conversio