reverse_markdown 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/reverse_markdown.rb +10 -6
- metadata +1 -1
data/lib/reverse_markdown.rb
CHANGED
@@ -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
|
177
|
-
|
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
|
180
|
-
"
|
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
|
""
|