redcloth-formatters-ast 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -99,17 +99,14 @@ module RedCloth::Formatters::AST
99
99
  end
100
100
 
101
101
  def link(opts)
102
- @@ast << { :type => :link, :href => opts[:href], :name => opts[:name], :options => parse_css(opts[:style]) }
103
- ""
102
+ "<u><link href='#{opts[:href]}'>#{opts[:name] || opts[:href]}</link></u>"
104
103
  end
105
104
 
106
105
  def image(opts)
107
- title = opts[:title]
108
- id = title.split(" ").join(".")
109
106
  options = parse_css(opts[:style])
110
107
  width = options[:width] || "100%"
111
108
 
112
- @@ast << { :type => :image, :title => title, :src => opts[:src], :width => width, :options => options }
109
+ @@ast << { :type => :image, :title => opts[:title], :src => opts[:src], :width => width, :options => options }
113
110
  ""
114
111
  end
115
112
 
@@ -131,7 +128,7 @@ module RedCloth::Formatters::AST
131
128
  opts[:block] = true
132
129
  opts[:append_to_parent] = true
133
130
  options = parse_css(opts[:style])
134
- @@ast << { :type => :code, :text => "", :title => options[:name], :options => options }
131
+ @@ast << { :type => :code, :text => "", :title => options[:name], :options => options, :language => (options[:language] rescue nil) }
135
132
  ""
136
133
  end
137
134
 
@@ -139,7 +136,8 @@ module RedCloth::Formatters::AST
139
136
  if opts[:append_to_parent]
140
137
  @@ast.last[:text] << "#{opts[:text]}\n\n"
141
138
  else
142
- @@ast << { :type => :code, :text => opts[:text], :options => parse_css(opts[:style]) }
139
+ options = parse_css(opts[:style])
140
+ @@ast << { :type => :code, :text => opts[:text], :options => parse_css(opts[:style]), :language => (options[:language] rescue nil) }
143
141
  end
144
142
  ""
145
143
  end
@@ -1,7 +1,7 @@
1
1
  module Redcloth
2
2
  module Formatters
3
3
  module AST
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.3"
5
5
  end
6
6
  end
7
7
  end
data/spec/ast_spec.rb CHANGED
@@ -78,8 +78,8 @@ describe RedCloth::Formatters::AST do
78
78
  it "should compile links and images" do
79
79
  textile = File.read "spec/fixtures/link_image.textile"
80
80
  RedCloth.new(textile).to_ast.should == [
81
- { :type=>:link, :href=>"http://example.com", :name=>"Text to display", :options=>{}},
82
- { :type=>:link, :href=>"http://example.com", :name=>"Text to display", :options=>{}},
81
+ { :type=>:p, :text=> "This is a paragraph with a link to <u><link href='http://google.com'>Google</link></u> that continues here.", :options=>{}},
82
+ { :type=>:p, :text=>"<u><link href='http://southdesign.de'>southdesign</link></u>", :options=>{}},
83
83
  { :type=>:image, :title=>"A great image", :src=>"../images/image.png", :width=>"100%", :options=>{}},
84
84
  { :type=>:image, :title=>"A great image", :src=>"../images/image.png", :width=>"90%", :options=>{:width=>"90%"}},
85
85
  ]
@@ -1,4 +1,6 @@
1
- "Text to display":http://example.com
2
- "Text to display (Title text)":http://example.com
1
+ This is a paragraph with a link to "Google":http://google.com that continues here.
2
+
3
+ "southdesign":http://southdesign.de
4
+
3
5
  !../images/image.png(A great image)!
4
6
  !{width: 90%;}../images/image.png(A great image)!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redcloth-formatters-ast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-30 00:00:00.000000000 Z
12
+ date: 2012-06-01 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A RedCloth formatter that compiles textile to an AST
15
15
  email: