malt 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +18 -0
- data/README.rdoc +6 -2
- data/lib/malt.rb +9 -0
- data/lib/malt/engines/abstract.rb +7 -7
- data/lib/malt/engines/bluecloth.rb +3 -3
- data/lib/malt/engines/builder.rb +72 -0
- data/lib/malt/engines/erb.rb +2 -0
- data/lib/malt/engines/erector.rb +59 -0
- data/lib/malt/engines/haml.rb +2 -2
- data/lib/malt/engines/kramdown.rb +6 -4
- data/lib/malt/engines/less.rb +8 -8
- data/lib/malt/engines/markaby.rb +51 -0
- data/lib/malt/engines/mustache.rb +44 -0
- data/lib/malt/engines/radius.rb +4 -4
- data/lib/malt/engines/ragtag.rb +49 -0
- data/lib/malt/engines/rdiscount.rb +1 -1
- data/lib/malt/engines/rdoc.rb +3 -3
- data/lib/malt/engines/redcloth.rb +1 -1
- data/lib/malt/engines/sass.rb +8 -8
- data/lib/malt/engines/tenjin.rb +6 -6
- data/lib/malt/formats/abstract.rb +8 -2
- data/lib/malt/formats/builder.rb +56 -0
- data/lib/malt/formats/css.rb +8 -8
- data/lib/malt/formats/erector.rb +53 -0
- data/lib/malt/formats/haml.rb +2 -2
- data/lib/malt/formats/html.rb +3 -3
- data/lib/malt/formats/latex.rb +4 -4
- data/lib/malt/formats/less.rb +5 -5
- data/lib/malt/formats/liquid.rb +11 -1
- data/lib/malt/formats/markaby.rb +53 -0
- data/lib/malt/formats/markdown.rb +6 -6
- data/lib/malt/formats/mustache.rb +34 -0
- data/lib/malt/formats/pdf.rb +2 -2
- data/lib/malt/formats/radius.rb +4 -4
- data/lib/malt/formats/{rtals.rb → ragtag.rb} +13 -9
- data/lib/malt/formats/rdoc.rb +4 -4
- data/lib/malt/formats/ruby.rb +2 -2
- data/lib/malt/formats/sass.rb +10 -0
- data/lib/malt/formats/scss.rb +10 -0
- data/lib/malt/formats/tenjin.rb +4 -4
- data/lib/malt/formats/textile.rb +12 -12
- data/lib/malt/formats/xml.rb +29 -0
- data/lib/malt/formats/yaml.rb +2 -2
- data/lib/malt/meta/data.rb +4 -4
- data/lib/malt/meta/{gemfile → package} +6 -2
- data/lib/malt/render.rb +37 -9
- data/meta/data.rb +4 -4
- data/meta/{gemfile → package} +6 -2
- data/qed/03_formats/08_ragtag.rdoc +19 -0
- data/qed/03_formats/17_markaby.rdoc +50 -0
- data/qed/03_formats/18_builder.rb +50 -0
- data/qed/03_formats/19_erector.rb +50 -0
- data/qed/03_formats/20_mustache.rdoc +54 -0
- data/{test/samples/sample.md → qed/samples/sample.markdown} +0 -0
- data/{test → qed}/samples/sample.rdoc +0 -0
- metadata +81 -12
- data/lib/malt/engines/rtals.rb +0 -46
- data/qed/03_formats/08_rtal.rdoc +0 -15
data/lib/malt/engines/rdoc.rb
CHANGED
@@ -15,9 +15,9 @@ module Malt::Engine
|
|
15
15
|
|
16
16
|
# Convert rdoc text to html.
|
17
17
|
def render(params)
|
18
|
-
text
|
19
|
-
|
20
|
-
case
|
18
|
+
text = params[:text]
|
19
|
+
into = params[:to]
|
20
|
+
case into
|
21
21
|
when :html, nil
|
22
22
|
html_engine.convert(text).to_s
|
23
23
|
else
|
data/lib/malt/engines/sass.rb
CHANGED
@@ -10,11 +10,11 @@ module Malt::Engine
|
|
10
10
|
|
11
11
|
#
|
12
12
|
def render(params, &yld)
|
13
|
-
text
|
14
|
-
file
|
15
|
-
|
13
|
+
text = params[:text]
|
14
|
+
file = params[:file]
|
15
|
+
into = params[:to]
|
16
16
|
|
17
|
-
case
|
17
|
+
case into
|
18
18
|
when :css, nil
|
19
19
|
engine = intermediate(params)
|
20
20
|
engine.render
|
@@ -39,10 +39,10 @@ module Malt::Engine
|
|
39
39
|
require_library 'sass'
|
40
40
|
end
|
41
41
|
|
42
|
-
def engine_options
|
43
|
-
|
44
|
-
|
45
|
-
end
|
42
|
+
#def engine_options
|
43
|
+
# opts = {}
|
44
|
+
# opts
|
45
|
+
#end
|
46
46
|
|
47
47
|
end
|
48
48
|
|
data/lib/malt/engines/tenjin.rb
CHANGED
@@ -15,13 +15,13 @@ module Malt::Engine
|
|
15
15
|
|
16
16
|
#
|
17
17
|
def render(params, &yld)
|
18
|
-
text
|
19
|
-
file
|
20
|
-
data
|
21
|
-
type
|
22
|
-
|
18
|
+
text = params[:text]
|
19
|
+
file = params[:file]
|
20
|
+
data = params[:data]
|
21
|
+
type = params[:type]
|
22
|
+
into = params[:to] || :html
|
23
23
|
|
24
|
-
return super(params, &yld) if type == :rbhtml &&
|
24
|
+
return super(params, &yld) if type == :rbhtml && into != :html
|
25
25
|
|
26
26
|
data = make_hash(data, &yld)
|
27
27
|
template = intermediate(params)
|
@@ -28,7 +28,9 @@ module Format
|
|
28
28
|
@extensions
|
29
29
|
end
|
30
30
|
|
31
|
-
|
31
|
+
#--
|
32
|
+
# TODO: warning: instance variable @engine not initialized
|
33
|
+
#++
|
32
34
|
def self.engine(set=nil)
|
33
35
|
@engine = set if set
|
34
36
|
@engine
|
@@ -47,7 +49,6 @@ module Format
|
|
47
49
|
def initialize_engine
|
48
50
|
end
|
49
51
|
|
50
|
-
|
51
52
|
public
|
52
53
|
|
53
54
|
# Access to the options given to the initializer.
|
@@ -160,6 +161,11 @@ module Format
|
|
160
161
|
text
|
161
162
|
end
|
162
163
|
|
164
|
+
#
|
165
|
+
def to_default(data=nil, &yld)
|
166
|
+
to(default, data, &yld)
|
167
|
+
end
|
168
|
+
|
163
169
|
# Default rendering type is +:html+. Override if it
|
164
170
|
# differs for the subclassing format.
|
165
171
|
def default
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'malt/formats/abstract'
|
2
|
+
require 'malt/formats/html'
|
3
|
+
require 'malt/engines/builder'
|
4
|
+
|
5
|
+
module Malt::Format
|
6
|
+
|
7
|
+
# Builder looks like a Markup format, but it is a template format
|
8
|
+
# as Ruby code.
|
9
|
+
#
|
10
|
+
# http://builder.rubyforge.org/
|
11
|
+
#
|
12
|
+
class Builder < Abstract
|
13
|
+
|
14
|
+
register 'builder'
|
15
|
+
|
16
|
+
#
|
17
|
+
def builder(*)
|
18
|
+
text
|
19
|
+
end
|
20
|
+
|
21
|
+
#
|
22
|
+
def to_builder(*)
|
23
|
+
self
|
24
|
+
end
|
25
|
+
|
26
|
+
#
|
27
|
+
def html(data=nil, &yld)
|
28
|
+
render_engine.render(:format=>:html, :text=>text, :file=>file, :data=>data, &yld)
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
def to_html(data=nil, &yld)
|
33
|
+
text = html(data, &yld)
|
34
|
+
opts = options.merge(:text=>text, :file=>refile(:html), :type=>:html)
|
35
|
+
HTML.new(opts)
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
#def to_ruby(db, &yld)
|
40
|
+
# @ruby ||= (
|
41
|
+
# source = engine.compile(text, file)
|
42
|
+
# Ruby.new(:text=>source, :file=>refile(:rb))
|
43
|
+
# )
|
44
|
+
#end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
#
|
49
|
+
def render_engine
|
50
|
+
@render_engine ||= Malt::Engine::Builder.new(options)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
data/lib/malt/formats/css.rb
CHANGED
@@ -19,14 +19,14 @@ module Malt::Format
|
|
19
19
|
|
20
20
|
private
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
#
|
23
|
+
def render_engine
|
24
|
+
end
|
25
|
+
|
26
|
+
# CSS default output type is itself.
|
27
|
+
def default
|
28
|
+
:css
|
29
|
+
end
|
30
30
|
|
31
31
|
end
|
32
32
|
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'malt/formats/abstract'
|
2
|
+
require 'malt/formats/html'
|
3
|
+
require 'malt/engines/erector'
|
4
|
+
|
5
|
+
module Malt::Format
|
6
|
+
|
7
|
+
# Erecotr looks like a Markup format, but it is a template format
|
8
|
+
# Much like pure Ruby too.
|
9
|
+
class Erector < Abstract
|
10
|
+
|
11
|
+
register 'erector'
|
12
|
+
|
13
|
+
#
|
14
|
+
def erector(*)
|
15
|
+
text
|
16
|
+
end
|
17
|
+
|
18
|
+
#
|
19
|
+
def to_erector(*)
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
def html(data=nil, &yld)
|
25
|
+
render_engine.render(:format=>:html, :text=>text, :file=>file, :data=>data, &yld)
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
def to_html(data=nil, &yld)
|
30
|
+
text = html(data, &yld)
|
31
|
+
opts = options.merge(:text=>text, :file=>refile(:html), :type=>:html)
|
32
|
+
HTML.new(opts)
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
#def to_ruby(db, &yld)
|
37
|
+
# @ruby ||= (
|
38
|
+
# source = engine.compile(text, file)
|
39
|
+
# Ruby.new(:text=>source, :file=>refile(:rb))
|
40
|
+
# )
|
41
|
+
#end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
#
|
46
|
+
def render_engine
|
47
|
+
@render_engine ||= Malt::Engine::Erector.new(options)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
data/lib/malt/formats/haml.rb
CHANGED
data/lib/malt/formats/html.rb
CHANGED
data/lib/malt/formats/latex.rb
CHANGED
@@ -9,22 +9,22 @@ module Malt::Format
|
|
9
9
|
register 'latex'
|
10
10
|
|
11
11
|
#
|
12
|
-
def latex
|
12
|
+
def latex(*)
|
13
13
|
text
|
14
14
|
end
|
15
15
|
|
16
16
|
#
|
17
|
-
def to_latex
|
17
|
+
def to_latex(*)
|
18
18
|
self
|
19
19
|
end
|
20
20
|
|
21
21
|
# TODO
|
22
|
-
def pdf
|
22
|
+
def pdf(*)
|
23
23
|
raise "not implemented yet"
|
24
24
|
end
|
25
25
|
|
26
26
|
# TODO
|
27
|
-
def to_pdf
|
27
|
+
def to_pdf(*)
|
28
28
|
text = pdf
|
29
29
|
opts = options.merge(:text=>text, :file=>refile(:pdf), :type=>:pdf)
|
30
30
|
PDF.new(opts)
|
data/lib/malt/formats/less.rb
CHANGED
@@ -12,24 +12,24 @@ module Malt::Format
|
|
12
12
|
register('less')
|
13
13
|
|
14
14
|
#
|
15
|
-
def less
|
15
|
+
def less(*)
|
16
16
|
text
|
17
17
|
end
|
18
18
|
|
19
19
|
#
|
20
|
-
def to_less
|
20
|
+
def to_less(*)
|
21
21
|
self
|
22
22
|
end
|
23
23
|
|
24
24
|
#
|
25
|
-
def css
|
25
|
+
def css(*)
|
26
26
|
render_engine.render(:text=>text, :file=>:file, :format=>:css)
|
27
27
|
end
|
28
28
|
|
29
29
|
#
|
30
|
-
def to_css
|
30
|
+
def to_css(*)
|
31
31
|
text = css
|
32
|
-
opts = options.merge(:text=>text, file=>refile(:css), :type=>:css)
|
32
|
+
opts = options.merge(:text=>text, :file=>refile(:css), :type=>:css)
|
33
33
|
CSS.new(opts)
|
34
34
|
end
|
35
35
|
|
data/lib/malt/formats/liquid.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'malt/formats/abstract'
|
2
|
+
require 'malt/formats/html'
|
3
|
+
require 'malt/engines/markaby'
|
4
|
+
|
5
|
+
module Malt::Format
|
6
|
+
|
7
|
+
# Erecotr looks like a Markup format, but it is a template format
|
8
|
+
# Much like pure Ruby too.
|
9
|
+
class Markaby < Abstract
|
10
|
+
|
11
|
+
register 'markaby', 'mab'
|
12
|
+
|
13
|
+
#
|
14
|
+
def markaby(*)
|
15
|
+
text
|
16
|
+
end
|
17
|
+
|
18
|
+
#
|
19
|
+
def to_markaby(*)
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
def html(data=nil, &yld)
|
25
|
+
render_engine.render(:format=>:html, :text=>text, :file=>file, :data=>data, &yld)
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
def to_html(data=nil, &yld)
|
30
|
+
text = html(data, &yld)
|
31
|
+
opts = options.merge(:text=>text, :file=>refile(:html), :type=>:html)
|
32
|
+
HTML.new(opts)
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
#def to_ruby(db, &yld)
|
37
|
+
# @ruby ||= (
|
38
|
+
# source = engine.compile(text, file)
|
39
|
+
# Ruby.new(:text=>source, :file=>refile(:rb))
|
40
|
+
# )
|
41
|
+
#end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
#
|
46
|
+
def render_engine
|
47
|
+
@render_engine ||= Malt::Engine::Markaby.new(options)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
@@ -12,17 +12,17 @@ module Malt::Format
|
|
12
12
|
register('markdown', 'md')
|
13
13
|
|
14
14
|
#
|
15
|
-
def html
|
15
|
+
def html(*)
|
16
16
|
render_engine.render(:text=>text, :file=>file, :format=>:html)
|
17
17
|
end
|
18
18
|
|
19
19
|
#
|
20
|
-
def latex
|
20
|
+
def latex(*)
|
21
21
|
render_engine.render(:text=>text, :file=>file, :format=>:latex)
|
22
22
|
end
|
23
23
|
|
24
24
|
#
|
25
|
-
def markdown
|
25
|
+
def markdown(*)
|
26
26
|
text
|
27
27
|
end
|
28
28
|
|
@@ -30,19 +30,19 @@ module Malt::Format
|
|
30
30
|
alias_method :md, :markdown
|
31
31
|
|
32
32
|
# Convert to HTML.
|
33
|
-
def to_html
|
33
|
+
def to_html(*)
|
34
34
|
opts = options.merge(:text=>html, :file=>refile(:html), :type=>:html)
|
35
35
|
HTML.new(opts)
|
36
36
|
end
|
37
37
|
|
38
38
|
# Latex is only supported by the Kramdown engine.
|
39
|
-
def to_latex
|
39
|
+
def to_latex(*)
|
40
40
|
opts = options.merge(:text=>html, :file=>refile(:latex), :type=>:latex)
|
41
41
|
Latex.new(opts)
|
42
42
|
end
|
43
43
|
|
44
44
|
#
|
45
|
-
def to_markdown
|
45
|
+
def to_markdown(*)
|
46
46
|
self
|
47
47
|
end
|
48
48
|
|