markdown 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -15,6 +15,7 @@ Hoe.spec 'markdown' do
15
15
 
16
16
  self.extra_deps = [
17
17
  ['props','>= 0.1.0'],
18
+ ['textutils','>=0.1.0'],
18
19
  ['kramdown','>= 0.13.6']
19
20
  ]
20
21
 
@@ -15,7 +15,7 @@ require 'fileutils'
15
15
 
16
16
  # rubygems
17
17
 
18
- require 'props' # manage properties/settings/env
18
+ require 'props' # manage properties/settings/env
19
19
 
20
20
  class Env
21
21
  def self.markdown_lib
@@ -24,6 +24,8 @@ class Env
24
24
  end # class Env
25
25
 
26
26
 
27
+ require 'textutils' # text filters and helpers
28
+
27
29
  # our own code
28
30
 
29
31
  require 'markdown/config'
@@ -40,7 +42,7 @@ require 'markdown/gen'
40
42
 
41
43
  module Markdown
42
44
 
43
- VERSION = '0.2.0'
45
+ VERSION = '0.3.0'
44
46
 
45
47
  # version string for generator meta tag (includes ruby version)
46
48
  def self.banner
@@ -36,9 +36,9 @@ DEFAULTS = { 'libs' => [
36
36
  'no_intra_emphasis',
37
37
  'fenced_code_blocks',
38
38
  'tables',
39
- 'strikethrough' ] # todo/fix: merge nested hash??
40
- },
41
- }
39
+ 'strikethrough' ] }, # todo/fix: merge nested hash??
40
+ 'filters' => [] # optional (preprocessing) text filters: e.g. comments-percent-style, skip-end-directive, etc. (see textutils gem)
41
+ }
42
42
 
43
43
 
44
44
  def initialize
@@ -69,6 +69,10 @@ DEFAULTS = { 'libs' => [
69
69
  def markdown_extnames
70
70
  @props.fetch( 'extnames', nil )
71
71
  end
72
+
73
+ def markdown_filters
74
+ @props.fetch( 'filters', nil )
75
+ end
72
76
 
73
77
  def known_markdown_libs
74
78
  # returns an array of known markdown engines e.g.
@@ -16,6 +16,8 @@ module Markdown
16
16
 
17
17
  class Gen
18
18
 
19
+ include TextUtils::Filter # include filters such as comments_percent_style, etc. (see textutils gem)
20
+
19
21
  attr_reader :logger
20
22
  attr_reader :opts
21
23
 
@@ -62,7 +64,15 @@ module Markdown
62
64
  puts "*** #{inname} (#{dirname}) => #{outname} (#{(opts.output_path == '.') ? dirname : opts.output_path})..."
63
65
 
64
66
  content = File.read( inname )
65
- content = Markdown.new( content ).to_html # convert light-weight markup to hypertext
67
+
68
+ # step 1) run (optional) preprocessing text filters
69
+ Markdown.filters.each do |filter|
70
+ mn = filter.tr( '-', '_' ).to_sym # construct method name (mn)
71
+ content = send( mn, content ) # call filter e.g. include_helper_hack( content )
72
+ end
73
+
74
+ # step 2) convert light-weight markup to hypertext
75
+ content = Markdown.new( content ).to_html
66
76
 
67
77
 
68
78
  ## todo: add Markdown.lib_options inspect/dump to banner
@@ -195,10 +205,12 @@ EOS
195
205
  logger.level = Logger::DEBUG
196
206
  end
197
207
 
208
+
209
+ ## todo: add markdown.lib options (e.g. extensions,etc)
198
210
 
199
211
  usage =<<EOS
200
212
 
201
- markdown - Lets you convert plain text documents (#{Markdown.extnames.join(', ')}) to hypertext (.html) with your Markdown engine of choice (#{Markdown.lib}).
213
+ markdown - Lets you convert plain text documents (#{Markdown.extnames.join(', ')}) to hypertext (.html) with your Markdown engine of choice (#{Markdown.lib}) and preprocessing text filters (#{Markdown.filters.join(', ')}).
202
214
 
203
215
  #{cmd.help}
204
216
 
@@ -41,6 +41,14 @@ module Markdown
41
41
  @@config.markdown_extnames
42
42
  end
43
43
 
44
+ def self.filters
45
+ if @@config.nil?
46
+ @@config = Config.new
47
+ end
48
+ @@config.markdown_filters
49
+ end
50
+
51
+
44
52
  def self.new( content, options={} )
45
53
 
46
54
  ## todo: allow options to pass in
@@ -55,7 +63,7 @@ module Markdown
55
63
  mn = @@config.markdown_to_html_method # lets you use differnt options/converters for a single markdown lib
56
64
  defaults = @@config.markdown_lib_defaults ## todo/fix: use mn / converter from defaults hash?? mn no longer needed??
57
65
 
58
- props = Props.new( options, 'USER', Props.new( defaults, 'SYSTEM' ))
66
+ props = Props.new( options, 'USER', Props.new( defaults, 'SYSTEM' ))
59
67
 
60
68
  Wrapper.new( lib, mn, content, props )
61
69
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdown
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 0.2.0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gerald Bauer
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-06-06 00:00:00 Z
18
+ date: 2012-06-09 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: props
@@ -34,9 +34,25 @@ dependencies:
34
34
  type: :runtime
35
35
  version_requirements: *id001
36
36
  - !ruby/object:Gem::Dependency
37
- name: kramdown
37
+ name: textutils
38
38
  prerelease: false
39
39
  requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 27
45
+ segments:
46
+ - 0
47
+ - 1
48
+ - 0
49
+ version: 0.1.0
50
+ type: :runtime
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: kramdown
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
40
56
  none: false
41
57
  requirements:
42
58
  - - ">="
@@ -48,11 +64,11 @@ dependencies:
48
64
  - 6
49
65
  version: 0.13.6
50
66
  type: :runtime
51
- version_requirements: *id002
67
+ version_requirements: *id003
52
68
  - !ruby/object:Gem::Dependency
53
69
  name: rdoc
54
70
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
71
+ requirement: &id004 !ruby/object:Gem::Requirement
56
72
  none: false
57
73
  requirements:
58
74
  - - ~>
@@ -63,11 +79,11 @@ dependencies:
63
79
  - 10
64
80
  version: "3.10"
65
81
  type: :development
66
- version_requirements: *id003
82
+ version_requirements: *id004
67
83
  - !ruby/object:Gem::Dependency
68
84
  name: hoe
69
85
  prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
86
+ requirement: &id005 !ruby/object:Gem::Requirement
71
87
  none: false
72
88
  requirements:
73
89
  - - ~>
@@ -78,7 +94,7 @@ dependencies:
78
94
  - 0
79
95
  version: "3.0"
80
96
  type: :development
81
- version_requirements: *id004
97
+ version_requirements: *id005
82
98
  description: Markdown Engine Wrapper - Use Your Markdown Library of Choice
83
99
  email: webslideshow@googlegroups.com
84
100
  executables: