radiant-kramdown_filter-extension 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -1,3 +1,6 @@
1
- # Kramdown Filter
1
+ kramdown is a pure Ruby implementation of standard Markdown plus popular extensions from PHP Markdown Extra and Maruku.
2
2
 
3
- Radiant extension that wraps the _pure-Ruby_ **kramdown** Markdown converter. For more information refer to the [**kramdown** website](http://kramdown.rubyforge.org/index.html).
3
+ Visit the [kramdown website][0] and the [syntax reference][1] for more information about kramdown.
4
+
5
+ [0]: http://kramdown.rubyforge.org/
6
+ [1]: http://kramdown.rubyforge.org/syntax.html
@@ -1,10 +1,10 @@
1
- if File.exist? "#{File.dirname(__FILE__)}/vendor/gems/kramdown-0.8.0"
2
- $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/vendor/gems/kramdown-0.8.0/lib"
1
+ if File.exist? "#{File.dirname(__FILE__)}/vendor/gems/kramdown-0.9.0"
2
+ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/vendor/gems/kramdown-0.9.0/lib"
3
3
  end
4
4
  require 'kramdown'
5
5
 
6
6
  class KramdownFilterExtension < Radiant::Extension
7
- version "1.0.8"
7
+ version "1.0.9"
8
8
  description "kramdown is a fast, pure Ruby Markdown converter."
9
9
  url "http://rubygems.org/gems/radiant-kramdown_filter-extension"
10
10
 
@@ -1,23 +1,62 @@
1
1
  class KramdownFilter < TextFilter
2
2
  description_file File.dirname(__FILE__) + "/../markdown.html"
3
+
4
+ def options
5
+ c = Radiant::Config
6
+ # set default options for the kramdown library
7
+ # the type conversion stuff is due to kramdown having strict rules
8
+ # about the types given as option values but Radiant::Config
9
+ # stores all values as simple strings.
10
+ o = {
11
+ :auto_ids => { :default => true, :type => :boolean },
12
+ :auto_id_prefix => { :default => '', :type => :string },
13
+ :parse_block_html => { :default => false, :type => :boolean },
14
+ :parse_span_html => { :default => true, :type => :boolean },
15
+ :footnote_nr => { :default => 1, :type => :integer },
16
+ :coderay_wrap => { :default => :div, :type => :symbol },
17
+ :coderay_line_numbers => { :default => :inline, :type => :symbol },
18
+ :coderay_line_number_start => { :default => 1, :type => :integer },
19
+ :coderay_tab_width => { :default => 0, :type => :integer },
20
+ :coderay_bold_every => { :default => 10, :type => :integer },
21
+ :coderay_css => { :default => :style, :type => :symbol },
22
+ :numeric_entities => { :default => false, :type => :boolean }
23
+ }
24
+ # overwrite defaults with user set values
25
+ o.keys.each { |key|
26
+ if c["kramdown.#{key.to_s}"]
27
+ case o[key][:type]
28
+ when :boolean
29
+ boolean = c["kramdown.#{key.to_s}"] == "true" ? true : false
30
+ o[key][:default] = boolean
31
+ when :integer
32
+ o[key][:default] = c["kramdown.#{key.to_s}"].to_i
33
+ when :string
34
+ o[key][:default] = c["kramdown.#{key.to_s}"]
35
+ when :symbol
36
+ symbol = c["kramdown.#{key.to_s}"] != "nil" ? c["kramdown.#{key.to_s}"].to_sym : nil
37
+ o[key][:default] = symbol
38
+ end
39
+ end
40
+ }
41
+ return o
42
+ end
43
+
3
44
  def filter(text)
4
- auto_ids = true if Radiant::Config['kramdown.auto_ids'] == 'true'
5
- parse_block_html = true if Radiant::Config['kramdown.parse_block_html'] == 'true'
6
- coderay_wrap = Radiant::Config['kramdown.coderay_wrap'].to_sym if Radiant::Config['kramdown.coderay_wrap']
7
- coderay_line_numbers = Radiant::Config['kramdown.coderay_line_numbers'].to_sym if Radiant::Config['kramdown.coderay_line_numbers'] != nil
8
- coderay_line_number_start = Radiant::Config['kramdown.coderay_line_number_start'].to_i if Radiant::Config['kramdown.coderay_line_number_start']
9
- coderay_tab_width = Radiant::Config['kramdown.coderay_tab_width'].to_i if Radiant::Config['kramdown.coderay_tab_width']
10
- coderay_bold_every = Radiant::Config['kramdown.coderay_bold_every'].to_i if Radiant::Config['kramdown.coderay_bold_every']
11
- coderay_css = Radiant::Config['kramdown.coderay_css'].to_sym if Radiant::Config['kramdown.coderay_css']
12
- Kramdown::Document.new(text, {
13
- :auto_ids => auto_ids || false,
14
- :parse_block_html => parse_block_html || false,
15
- :coderay_wrap => coderay_wrap || nil,
16
- :coderay_line_numbers => coderay_line_numbers || nil,
17
- :coderay_line_number_start => coderay_line_number_start || 1,
18
- :coderay_tab_width => coderay_tab_width || 2,
19
- :coderay_bold_every => coderay_bold_every || 10,
20
- :coderay_css => coderay_css || :style
45
+ o = self.options
46
+ Kramdown::Document.new(text,
47
+ {
48
+ :auto_ids => o[:auto_ids][:default],
49
+ :auto_id_prefix => o[:auto_id_prefix][:default],
50
+ :parse_block_html => o[:parse_block_html][:default],
51
+ :parse_span_html => o[:parse_span_html][:default],
52
+ :footnote_nr => o[:footnote_nr][:default],
53
+ :coderay_wrap => o[:coderay_wrap][:default],
54
+ :coderay_line_numbers => o[:coderay_line_numbers][:default],
55
+ :coderay_line_number_start => o[:coderay_line_number_start][:default],
56
+ :coderay_tab_width => o[:coderay_tab_width][:default],
57
+ :coderay_bold_every => o[:coderay_bold_every][:default],
58
+ :coderay_css => o[:coderay_css][:default],
59
+ :numeric_entities => o[:numeric_entities][:default]
21
60
  }).to_html
22
61
  end
23
62
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-kramdown_filter-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 8
10
- version: 1.0.8
9
+ - 9
10
+ version: 1.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - johnmuhl
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-12 00:00:00 -05:00
18
+ date: 2010-06-23 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,12 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - "="
28
28
  - !ruby/object:Gem::Version
29
- hash: 63
29
+ hash: 59
30
30
  segments:
31
31
  - 0
32
- - 8
32
+ - 9
33
33
  - 0
34
- version: 0.8.0
34
+ version: 0.9.0
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  description: |-