markitdown 0.0.7 → 0.0.8

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.
@@ -20,6 +20,7 @@ module Markitdown
20
20
  after = nil
21
21
  states.unshift node.name.downcase
22
22
  pre = prefix(states)
23
+ recurse = true
23
24
  strip_contents = false
24
25
  case node.name
25
26
  when "head"
@@ -82,7 +83,7 @@ module Markitdown
82
83
  when "blockquote"
83
84
  results << "\n\n"
84
85
  results << pre
85
- after = "\n"
86
+ after = "\n\n"
86
87
  when "ol"
87
88
  unless self.nested_list?(states)
88
89
  results << self.newline(pre, nil)
@@ -108,11 +109,16 @@ module Markitdown
108
109
  results << ") "
109
110
  when "text"
110
111
  results << node.text.strip.gsub("\n","").gsub(/ {2,}/," ")
112
+ when "code"
113
+ results << " `#{node.text}` "
114
+ recurse = false
111
115
  end
112
- node.children.each do |child|
113
- contents = self.parse_node(child, states)
114
- contents = contents.flatten.compact.join.strip if strip_content
115
- results << contents
116
+ if recurse
117
+ node.children.each do |child|
118
+ contents = self.parse_node(child, states)
119
+ contents = contents.flatten.compact.join.strip if strip_content
120
+ results << contents
121
+ end
116
122
  end
117
123
  results << after
118
124
  states.shift
@@ -1,3 +1,3 @@
1
1
  module Markitdown
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -29,5 +29,14 @@
29
29
  <blockquote>
30
30
  And here's a blockquote, right at the end.
31
31
  </blockquote>
32
+ This is some more free text
33
+ <code>
34
+ This
35
+ is
36
+ a
37
+ block
38
+ of
39
+ code
40
+ </code>
32
41
  </body>
33
42
  </html>
@@ -22,3 +22,12 @@ This is paragraph two.
22
22
  This is some free text
23
23
 
24
24
  > And here's a blockquote, right at the end.
25
+
26
+ This is some more free text `
27
+ This
28
+ is
29
+ a
30
+ block
31
+ of
32
+ code
33
+ `
@@ -101,6 +101,7 @@ describe Markitdown do
101
101
  > This is a quote with a list
102
102
  > * item 1
103
103
  > * item 2
104
+
104
105
  "
105
106
  end
106
107
  end
@@ -128,6 +129,7 @@ describe Markitdown do
128
129
  > 1. item [2.1](http://www.google.com)
129
130
  > 1. item 2.2
130
131
  > * item 1.2
132
+
131
133
  "
132
134
  end
133
135
  end
@@ -199,7 +199,7 @@ describe Markitdown do
199
199
  let(:html) { "<blockquote>this is a block quote</blockquote>" }
200
200
 
201
201
  it "should return valid markdown" do
202
- Markitdown.from_html(html).should == "\n\n > this is a block quote\n"
202
+ Markitdown.from_html(html).should == "\n\n > this is a block quote\n\n"
203
203
  end
204
204
  end
205
205
 
@@ -211,7 +211,16 @@ describe Markitdown do
211
211
  </blockquote>" }
212
212
 
213
213
  it "should return valid markdown" do
214
- Markitdown.from_html(html).should == "\n\n > line 1 line 2 line 3\n"
214
+ Markitdown.from_html(html).should == "\n\n > line 1 line 2 line 3\n\n"
215
215
  end
216
216
  end
217
+
218
+ context "When parsing an CODE element" do
219
+ let(:html) { "<code>code block</code>" }
220
+
221
+ it "should return valid markdown" do
222
+ Markitdown.from_html(html).should == " `code block` "
223
+ end
224
+ end
225
+
217
226
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markitdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
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-11-10 00:00:00.000000000 Z
12
+ date: 2013-05-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -96,7 +96,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
96
96
  version: '0'
97
97
  segments:
98
98
  - 0
99
- hash: -705547097769987992
99
+ hash: 966018070183228939
100
100
  required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  none: false
102
102
  requirements:
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  segments:
107
107
  - 0
108
- hash: -705547097769987992
108
+ hash: 966018070183228939
109
109
  requirements: []
110
110
  rubyforge_project:
111
111
  rubygems_version: 1.8.24