reverse_markdown 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/reverse_markdown.rb +10 -6
  2. metadata +1 -1
@@ -32,7 +32,8 @@ class ReverseMarkdown
32
32
  # - @outout: fancy markdown code in here!
33
33
  # - @indent: control indention level for nested lists
34
34
  # - @errors: appearing errors, like unknown tags, go into this array
35
- def initialize()
35
+ def initialize(options = {})
36
+ @options = {links: :inline}.merge(options)
36
37
  @li_counter = 0
37
38
  @links = []
38
39
  @output = ""
@@ -173,12 +174,15 @@ class ReverseMarkdown
173
174
  when :code
174
175
  parent.eql?(:pre) ? "" : "`"
175
176
  when :a
176
- @links << type.attribute('href').to_s
177
- "][" + @links.size.to_s + "] "
177
+ if @options[:links] == :inline
178
+ "](#{type['href']})"
179
+ else
180
+ @links << type['href']
181
+ "][#{@links.size}] "
182
+ end
178
183
  when :img
179
- @links << type.attribute('src').to_s
180
- "" + type.attribute('alt').to_s + "][" + @links.size.to_s + "] "
181
- "#{type.attribute('alt')}][#{@links.size}] "
184
+ @links << type['src']
185
+ "#{type['alt']}][#{@links.size}] "
182
186
  else
183
187
  @errors << " unknown end tag: "+type.name.to_s
184
188
  ""
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reverse_markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: