malt 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. data/.ruby +156 -0
  2. data/Assembly +28 -0
  3. data/COPYING.rdoc +33 -0
  4. data/Gemfile +10 -0
  5. data/HISTORY.rdoc +102 -0
  6. data/README.rdoc +16 -10
  7. data/Reapfile +4 -0
  8. data/lib/malt.rb +36 -8
  9. data/lib/malt.yml +156 -0
  10. data/lib/malt/conversions.rb +42 -0
  11. data/lib/malt/core_ext.rb +81 -3
  12. data/lib/malt/engines/abstract.rb +259 -50
  13. data/lib/malt/engines/bluecloth.rb +19 -9
  14. data/lib/malt/engines/builder.rb +93 -32
  15. data/lib/malt/engines/coffee.rb +46 -0
  16. data/lib/malt/engines/creole.rb +60 -0
  17. data/lib/malt/engines/erb.rb +69 -44
  18. data/lib/malt/engines/erector.rb +61 -30
  19. data/lib/malt/engines/erubis.rb +41 -31
  20. data/lib/malt/engines/haml.rb +13 -37
  21. data/lib/malt/engines/kramdown.rb +40 -15
  22. data/lib/malt/engines/less.rb +15 -14
  23. data/lib/malt/engines/liquid.rb +24 -14
  24. data/lib/malt/engines/markaby.rb +44 -22
  25. data/lib/malt/engines/maruku.rb +89 -0
  26. data/lib/malt/engines/mustache.rb +20 -14
  27. data/lib/malt/engines/nokogiri.rb +89 -0
  28. data/lib/malt/engines/radius.rb +72 -34
  29. data/lib/malt/engines/ragtag.rb +26 -18
  30. data/lib/malt/engines/rdiscount.rb +18 -11
  31. data/lib/malt/engines/rdoc.rb +21 -15
  32. data/lib/malt/engines/redcarpet.rb +137 -0
  33. data/lib/malt/engines/redcloth.rb +15 -7
  34. data/lib/malt/engines/ruby.rb +13 -12
  35. data/lib/malt/engines/sass.rb +30 -17
  36. data/lib/malt/engines/string.rb +36 -0
  37. data/lib/malt/engines/tenjin.rb +70 -27
  38. data/lib/malt/engines/wikicloth.rb +48 -0
  39. data/lib/malt/formats/abstract.rb +90 -29
  40. data/lib/malt/formats/abstract_template.rb +10 -8
  41. data/lib/malt/formats/builder.rb +39 -13
  42. data/lib/malt/formats/coffee.rb +54 -0
  43. data/lib/malt/formats/css.rb +3 -3
  44. data/lib/malt/formats/erb.rb +31 -66
  45. data/lib/malt/formats/haml.rb +8 -8
  46. data/lib/malt/formats/html.rb +1 -7
  47. data/lib/malt/formats/javascript.rb +27 -0
  48. data/lib/malt/formats/latex.rb +1 -1
  49. data/lib/malt/formats/less.rb +13 -11
  50. data/lib/malt/formats/liquid.rb +7 -7
  51. data/lib/malt/formats/markdown.rb +43 -44
  52. data/lib/malt/formats/mediawiki.rb +70 -0
  53. data/lib/malt/formats/mustache.rb +5 -5
  54. data/lib/malt/formats/pdf.rb +1 -7
  55. data/lib/malt/formats/radius.rb +5 -4
  56. data/lib/malt/formats/ragtag.rb +14 -13
  57. data/lib/malt/formats/rbhtml.rb +28 -20
  58. data/lib/malt/formats/rdoc.rb +5 -4
  59. data/lib/malt/formats/rhtml.rb +19 -43
  60. data/lib/malt/formats/ruby.rb +11 -45
  61. data/lib/malt/formats/sass.rb +16 -24
  62. data/lib/malt/formats/scss.rb +13 -30
  63. data/lib/malt/formats/string.rb +61 -0
  64. data/lib/malt/formats/tenjin.rb +4 -4
  65. data/lib/malt/formats/text.rb +1 -1
  66. data/lib/malt/formats/textile.rb +7 -19
  67. data/lib/malt/kernel.rb +1 -2
  68. data/lib/malt/machine.rb +83 -13
  69. data/lib/malt/tilted.rb +216 -0
  70. data/lib/malt/version.rb +21 -0
  71. data/test/helper.rb +15 -0
  72. data/test/unit/engines/case_engine_bluecloth.rb +40 -0
  73. data/test/unit/engines/case_engine_builder.rb +30 -0
  74. data/test/unit/engines/case_engine_coffee.rb +30 -0
  75. data/test/unit/engines/case_engine_creole.rb +35 -0
  76. data/test/unit/engines/case_engine_erb.rb +28 -0
  77. data/test/unit/engines/case_engine_erector.rb +36 -0
  78. data/test/unit/engines/case_engine_erubis.rb +28 -0
  79. data/test/unit/engines/case_engine_haml.rb +30 -0
  80. data/test/unit/engines/case_engine_kramdown.rb +30 -0
  81. data/test/unit/engines/case_engine_less.rb +40 -0
  82. data/test/unit/engines/case_engine_liquid.rb +28 -0
  83. data/test/unit/engines/case_engine_markaby.rb +20 -0
  84. data/test/unit/engines/case_engine_maruku.rb +30 -0
  85. data/test/unit/engines/case_engine_mustache.rb +28 -0
  86. data/test/unit/engines/case_engine_nokogiri.rb +30 -0
  87. data/test/unit/engines/case_engine_radius.rb +30 -0
  88. data/test/unit/engines/case_engine_ragtag.rb +40 -0
  89. data/test/unit/engines/case_engine_rdiscount.rb +30 -0
  90. data/test/unit/engines/case_engine_rdoc.rb +31 -0
  91. data/test/unit/engines/case_engine_redcarpet.rb +30 -0
  92. data/test/unit/engines/case_engine_redcloth.rb +31 -0
  93. data/test/unit/engines/case_engine_ruby.rb +28 -0
  94. data/test/unit/engines/case_engine_sass.rb +36 -0
  95. data/test/unit/engines/case_engine_string.rb +28 -0
  96. data/test/unit/engines/case_engine_tenjin.rb +28 -0
  97. data/test/unit/engines/case_engine_wikicloth.rb +25 -0
  98. data/test/unit/machine.rb +27 -0
  99. data/test/unit/malt.rb +12 -0
  100. metadata +364 -266
  101. data/History.rdoc +0 -64
  102. data/License.txt +0 -205
  103. data/Syckfile +0 -80
  104. data/features/consistent_rendering.feature +0 -36
  105. data/features/samples/sample.erb +0 -1
  106. data/features/samples/sample.erubis +0 -1
  107. data/features/samples/sample.liquid +0 -1
  108. data/features/samples/sample.mustache +0 -1
  109. data/features/samples/sample.radius +0 -1
  110. data/features/step_definitions/engine_steps.rb +0 -49
  111. data/features/support/loadpath.rb +0 -1
  112. data/features/support/sample_class.rb +0 -8
  113. data/lib/malt/formats/erector.rb +0 -53
  114. data/lib/malt/formats/markaby.rb +0 -53
  115. data/lib/malt/meta/data.rb +0 -26
  116. data/lib/malt/meta/package +0 -21
  117. data/lib/malt/meta/profile +0 -21
  118. data/meta/data.rb +0 -26
  119. data/meta/package +0 -21
  120. data/meta/profile +0 -21
  121. data/qed/01_overview.rdoc +0 -8
  122. data/qed/02_formats.rdoc +0 -39
  123. data/qed/03_formats/01_overview.rdoc +0 -7
  124. data/qed/03_formats/02_rdoc.rdoc +0 -83
  125. data/qed/03_formats/03_textile.rdoc +0 -48
  126. data/qed/03_formats/04_markdown.rdoc +0 -66
  127. data/qed/03_formats/05_erb.rdoc +0 -65
  128. data/qed/03_formats/06_liquid.rdoc +0 -54
  129. data/qed/03_formats/07_haml.rdoc +0 -44
  130. data/qed/03_formats/08_ragtag.rdoc +0 -19
  131. data/qed/03_formats/09_radius.rdoc +0 -43
  132. data/qed/03_formats/11_tenjin.rdoc +0 -47
  133. data/qed/03_formats/12_rbhtml.rdoc +0 -55
  134. data/qed/03_formats/13_sass.rdoc +0 -55
  135. data/qed/03_formats/14_scss.rdoc +0 -58
  136. data/qed/03_formats/15_less.rdoc +0 -46
  137. data/qed/03_formats/16_ruby.rdoc +0 -48
  138. data/qed/03_formats/17_markaby.rdoc +0 -50
  139. data/qed/03_formats/18_builder.rb +0 -50
  140. data/qed/03_formats/19_erector.rb +0 -50
  141. data/qed/03_formats/20_mustache.rdoc +0 -54
  142. data/qed/05_machine/01_limited_formats.rdoc +0 -29
  143. data/qed/05_machine/02_prioritized_engines.rdoc +0 -34
  144. data/qed/applique/malt.rb +0 -13
  145. data/qed/samples/data.yml +0 -4
  146. data/qed/samples/output-erb.txt +0 -1
  147. data/qed/samples/output-liquid.txt +0 -1
  148. data/qed/samples/output-mustache.txt +0 -1
  149. data/qed/samples/output-radius.txt +0 -1
  150. data/qed/samples/sample.erb +0 -1
  151. data/qed/samples/sample.liquid +0 -1
  152. data/qed/samples/sample.markdown +0 -308
  153. data/qed/samples/sample.mustache +0 -1
  154. data/qed/samples/sample.radius +0 -1
  155. data/qed/samples/sample.rdoc +0 -8
@@ -3,6 +3,9 @@ require 'malt/formats/html'
3
3
  require 'malt/formats/latex'
4
4
  require 'malt/engines/rdiscount'
5
5
  require 'malt/engines/bluecloth'
6
+ require 'malt/engines/maruku'
7
+ require 'malt/engines/redcarpet'
8
+ require 'malt/engines/kramdown'
6
9
 
7
10
  module Malt::Format
8
11
 
@@ -12,22 +15,24 @@ module Malt::Format
12
15
  register('markdown', 'md')
13
16
 
14
17
  #
15
- def html(*)
16
- render_engine.render(:text=>text, :file=>file, :format=>:html)
18
+ def markdown(*)
19
+ text
17
20
  end
18
21
 
19
- #
20
- def latex(*)
21
- render_engine.render(:text=>text, :file=>file, :format=>:latex)
22
- end
22
+ alias_method :md, :markdown
23
23
 
24
24
  #
25
- def markdown(*)
26
- text
25
+ def to_markdown(*)
26
+ self
27
27
  end
28
28
 
29
+ alias_method :to_md, :to_markdown
30
+
29
31
  #
30
- alias_method :md, :markdown
32
+ def html(*data, &context)
33
+ #engine.render(:text=>text, :file=>file, :format=>:html)
34
+ render_into(:html, *data, &context)
35
+ end
31
36
 
32
37
  # Convert to HTML.
33
38
  def to_html(*)
@@ -35,49 +40,43 @@ module Malt::Format
35
40
  HTML.new(opts)
36
41
  end
37
42
 
43
+ #
44
+ def latex(*data, &content)
45
+ render_into(:latex, *data, &content)
46
+ #render_engine.render(:text=>text, :file=>file, :format=>:latex)
47
+ end
48
+
38
49
  # Latex is only supported by the Kramdown engine.
39
50
  def to_latex(*)
40
51
  opts = options.merge(:text=>html, :file=>refile(:latex), :type=>:latex)
41
52
  Latex.new(opts)
42
53
  end
43
54
 
44
- #
45
- def to_markdown(*)
46
- self
55
+ =begin
56
+ private
57
+
58
+ # Select rendering engine.
59
+ def render_engine
60
+ @render_engine ||= (
61
+ case engine
62
+ when :bluecloth
63
+ Malt::Engine::BlueCloth.new(options)
64
+ when :kramdown
65
+ Malt::Engine::Kramdown.new(options)
66
+ when :rdiscount
67
+ Malt::Engine::RDiscount.new(options)
68
+ when :redcarpet
69
+ Malt::Engine::Redcarpet.new(options)
70
+ when :maruku
71
+ Malt::Engine::Maruku.new(options)
72
+ else
73
+ #Malt::Engine::Redcarpet.new(options) # TODO: new default ?
74
+ Malt::Engine::RDiscount.new(options)
75
+ end
76
+ )
47
77
  end
48
-
49
- #
50
- alias_method :to_md, :to_markdown
51
-
52
- #
53
- #def render_to(to, *)
54
- # case to
55
- # when :markdown, :md
56
- # text
57
- # when :html
58
- # malt_engine.render_html(text, file)
59
- # when :txt # THINK: Does this make sense?
60
- # text
61
- # end
62
- #end
63
-
64
- private
65
-
66
- #
67
- def render_engine
68
- @render_engine ||= (
69
- case engine
70
- when :bluecloth
71
- Malt::Engine::BlueCloth.new(options)
72
- when :kramdown
73
- Malt::Engine::Kramdown.new(options)
74
- else
75
- Malt::Engine::RDiscount.new(options)
76
- end
77
- )
78
- end
78
+ =end
79
79
 
80
80
  end
81
81
 
82
82
  end
83
-
@@ -0,0 +1,70 @@
1
+ require 'malt/formats/abstract'
2
+ require 'malt/formats/html'
3
+ #require 'malt/formats/latex'
4
+ require 'malt/engines/creole'
5
+ require 'malt/engines/wikicloth'
6
+
7
+ module Malt::Format
8
+
9
+ #
10
+ class MediaWiki < Abstract
11
+
12
+ file_extension 'mediawiki', 'mw'
13
+
14
+ #
15
+ def mediawiki(*)
16
+ text
17
+ end
18
+
19
+ #
20
+ def to_mediawiki(*)
21
+ self
22
+ end
23
+
24
+ alias_method :mw, :mediawiki
25
+ alias_method :to_mw, :to_mediawiki
26
+
27
+ #
28
+ def html(*data, &content)
29
+ #render_engine.render(:text=>text, :file=>file, :format=>:html)
30
+ render_into(:html, *data, &content)
31
+ end
32
+
33
+ # Convert to HTML.
34
+ def to_html(*)
35
+ opts = options.merge(:text=>html, :file=>refile(:html), :type=>:html)
36
+ HTML.new(opts)
37
+ end
38
+
39
+ #
40
+ #def latex(*)
41
+ # render_engine.render(:text=>text, :file=>file, :format=>:latex)
42
+ #end
43
+
44
+ # Latex is only supported by the Kramdown engine.
45
+ #def to_latex(*)
46
+ # opts = options.merge(:text=>html, :file=>refile(:latex), :type=>:latex)
47
+ # Latex.new(opts)
48
+ #end
49
+
50
+ =begin
51
+ private
52
+
53
+ # Select rendering engine.
54
+ def render_engine
55
+ @render_engine ||= (
56
+ case engine
57
+ when :creole
58
+ Malt::Engine::Creole.new(options)
59
+ when :wikicloth
60
+ Malt::Engine::WikiCloth.new(options)
61
+ else
62
+ Malt::Engine::WikiCloth.new(options)
63
+ end
64
+ )
65
+ end
66
+ =end
67
+
68
+ end
69
+
70
+ end
@@ -9,7 +9,7 @@ module Malt::Format
9
9
  #
10
10
  class Mustache < AbstractTemplate
11
11
 
12
- register('mustache')
12
+ file_extension 'mustache'
13
13
 
14
14
  #
15
15
  def mustache(*)
@@ -21,12 +21,12 @@ module Malt::Format
21
21
  self
22
22
  end
23
23
 
24
- private
24
+ #private
25
25
 
26
26
  #
27
- def render_engine
28
- @render_engine ||= Malt::Engine::Mustache.new(options)
29
- end
27
+ #def render_engine
28
+ # @render_engine ||= Malt::Engine::Mustache.new(options)
29
+ #end
30
30
 
31
31
  end
32
32
 
@@ -5,7 +5,7 @@ module Malt::Format
5
5
  #
6
6
  class PDF < Abstract
7
7
 
8
- register 'pdf'
8
+ file_extension 'pdf'
9
9
 
10
10
  #
11
11
  def pdf(*)
@@ -17,12 +17,6 @@ module Malt::Format
17
17
  self
18
18
  end
19
19
 
20
- private
21
-
22
- #
23
- def render_engine
24
- end
25
-
26
20
  end
27
21
 
28
22
  end
@@ -23,13 +23,14 @@ module Malt::Format
23
23
  end
24
24
 
25
25
  #
26
- def html(data=nil, &yld)
27
- render_engine.render(:text=>text, :file=>file, :data=>data, &yld)
26
+ def html(*data, &content)
27
+ render_into(:html, *data, &content)
28
+ #render_engine.render(:text=>text, :file=>file, :data=>data, &yld)
28
29
  end
29
30
 
30
31
  #
31
- def to_html(data=nil, &yld)
32
- text = html(data, &yld)
32
+ def to_html(*data, &content)
33
+ text = html(*data, &content)
33
34
  opts = options.merge(:text=>text, :file=>refile(:html), :type=>:html)
34
35
  HTML.new(opts)
35
36
  end
@@ -11,38 +11,39 @@ module Malt::Format
11
11
  #
12
12
  class RagTag < Abstract
13
13
 
14
- register('ragtag', 'rt')
14
+ file_extension 'ragtag', 'rt'
15
15
 
16
16
  #
17
- def html(data=nil, &yld)
18
- render_engine.render(:text=>text, :data=>data, &yld)
17
+ def html(*data, &content)
18
+ render_into(:html, *data, &content)
19
+ #render_engine.render(:text=>text, :data=>data, &yld)
19
20
  end
20
21
 
21
22
  #
22
- def to_html(data=nil, &yld)
23
- text = html(data, &yld)
23
+ def to_html(*data, &yld)
24
+ text = html(*data, &yld)
24
25
  opts = options.merge(:text=>text, :file=>refile(:html), :type=>:html)
25
26
  HTML.new(opts)
26
27
  end
27
28
 
28
29
  #
29
- def xml(data=nil, &yld)
30
- render_engine.render(:text=>text, :data=>data, &yld)
30
+ def xml(*data, &yld)
31
+ render_into(:xml, *data, &content)
31
32
  end
32
33
 
33
34
  #
34
- def to_xml(data=nil, &yld)
35
- text = xml(data, &yld)
35
+ def to_xml(*data, &yld)
36
+ text = xml(*data, &yld)
36
37
  opts = options.merge(:text=>text, :file=>refile(:xml), :type=>:xml)
37
38
  XML.new(opts)
38
39
  end
39
40
 
40
- private
41
+ #private
41
42
 
42
43
  #
43
- def render_engine
44
- @render_engine ||= Malt::Engine::RagTag.new(options)
45
- end
44
+ #def render_engine
45
+ # @render_engine ||= Malt::Engine::RagTag.new(options)
46
+ #end
46
47
 
47
48
  end
48
49
 
@@ -8,8 +8,27 @@ module Malt::Format
8
8
  # RBHTML is a variant of Tenjin, but limited to HTML conversion.
9
9
  class RBHTML < Abstract
10
10
 
11
- register 'rbhtml'
11
+ file_extension 'rbhtml'
12
12
 
13
+ #
14
+ def html(*data, &content)
15
+ render_into(:html, *data, &content)
16
+ end
17
+
18
+ #
19
+ def to_html(*data, &yld)
20
+ text = html(*data, &yld)
21
+ opts = options.merge(
22
+ :text => text,
23
+ :file => refile(:html),
24
+ :type => :html,
25
+ :engine => nil
26
+ )
27
+ HTML.new(opts)
28
+ end
29
+
30
+ # TODO: to_rb
31
+ =begin
13
32
  # RHTML templates can be "pre-compiled" into Ruby templates.
14
33
  def rb(*)
15
34
  render_engine.compile(:text=>text, :file=>file)
@@ -26,25 +45,14 @@ module Malt::Format
26
45
 
27
46
  #
28
47
  alias_method(:precompile, :to_rb)
29
-
30
- #
31
- def html(data=nil, &yld)
32
- render_engine.render(:text=>text, :file=>file, :data=>data, :format=>:html, &yld)
33
- end
34
-
35
- #
36
- def to_html(data=nil, &yld)
37
- text = html(data, &yld)
38
- opts = options.merge(:text=>text, :file=>refile(:html), :type=>:html)
39
- HTML.new(opts)
40
- end
41
-
42
- private
43
-
44
- #
45
- def render_engine
46
- @render_engine ||= Malt::Engine::Tenjin.new(options)
47
- end
48
+ =end
49
+
50
+ #private
51
+ #
52
+ # #
53
+ # def render_engine
54
+ # @render_engine ||= Malt::Engine::Tenjin.new(options)
55
+ # end
48
56
 
49
57
  end
50
58
 
@@ -7,7 +7,7 @@ module Malt::Format
7
7
  #
8
8
  class RDoc < Abstract
9
9
 
10
- register('rdoc')
10
+ file_extension 'rdoc'
11
11
 
12
12
  #
13
13
  def rdoc(*)
@@ -20,13 +20,14 @@ module Malt::Format
20
20
  end
21
21
 
22
22
  #
23
- def html(*)
24
- render_engine.render(:text=>text, :file=>file, :format=>:html)
23
+ def html(*data, &content)
24
+ render_into(:html, *data, &content)
25
+ #render_engine.render(:format=>:html, :text=>text, :file=>file)
25
26
  end
26
27
 
27
28
  #
28
29
  def to_html(*)
29
- opts = options.merge(:text=>html, :file=>refile(:html), :type=>:html)
30
+ opts = options.merge(:type=>:html, :text=>html, :file=>refile(:html))
30
31
  HTML.new(opts)
31
32
  end
32
33
 
@@ -8,8 +8,9 @@ module Malt::Format
8
8
  # RHTML is a variant of Erb files which are limited to conversion to HTML.
9
9
  class RHTML < Abstract
10
10
 
11
- register 'rhtml'
11
+ file_extension 'rhtml'
12
12
 
13
+ =begin
13
14
  # RHTML templates can be "pre-compiled" into Ruby templates.
14
15
  def rb(*)
15
16
  render_engine.compile(:text=>text, :file=>file)
@@ -26,60 +27,35 @@ module Malt::Format
26
27
 
27
28
  #
28
29
  alias_method(:precompile, :to_rb)
30
+ =end
29
31
 
30
32
  #
31
- def html(data=nil, &yld)
32
- render_engine.render(:text=>text, :file=>file, :format=>:html)
33
+ def html(*data, &content)
34
+ render_into(:html, *data, &content)
35
+ #render_engine.render(:text=>text, :file=>file, :data=>data, :to=>:html, &yld)
33
36
  end
34
37
 
35
38
  #
36
- def to_html(data=nil, &yld)
39
+ def to_html(*data, &yld)
37
40
  text = html(data, &yld)
38
41
  opts = options.merge(:text=>text, :file=>refile(:html), :type=>:html)
39
42
  HTML.new(opts)
40
43
  end
41
44
 
42
- #
43
- #def render(data, &yld)
44
- # if options[:recompile]
45
- # result = render_engine.render(db, &yld)
46
- # else
47
- # result = precompile.compile(db, &yld)
48
- # end
49
- #
50
- # HTML.new(:text=>result, :file=>refile(:html))
51
- #end
52
-
53
- #
54
- #def to_html(db, &yld)
55
- # # unless pre-compilation is turned off, convert to ruby
56
- # return to_ruby.to_html(db, &yld) unless options[:recompile]
57
- # convert(:html, db, &yld)
58
- #end
59
-
60
- #
61
- #def render_to(to, db, &yld)
62
- # #if options[:recompile]
63
- # render_engine.render(text, file, db, &yld)
64
- # #else
65
- # # to_ruby.render(db, &yld)
66
- # #end
45
+ #private
46
+
47
+ ##
48
+ #def render_engine
49
+ # @render_engine ||= (
50
+ # case engine
51
+ # when :erubis
52
+ # Malt::Engine::Erubis.new(options)
53
+ # else
54
+ # Malt::Engine::Erb.new(options)
55
+ # end
56
+ # )
67
57
  #end
68
58
 
69
- private
70
-
71
- #
72
- def render_engine
73
- @render_engine ||= (
74
- case engine
75
- when :erubis
76
- Malt::Engine::Erubis.new(options)
77
- else
78
- Malt::Engine::Erb.new(options)
79
- end
80
- )
81
- end
82
-
83
59
  end
84
60
 
85
61
  end