upmark 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/upmark/parser/xml.rb +4 -3
- data/lib/upmark/transform/preprocess.rb +4 -2
- data/spec/acceptance/upmark_spec.rb +30 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e6c728e71452e9983f7fe6ef59948cca6fd691b
|
4
|
+
data.tar.gz: 87daa0b2e4e6105b43e88502b6f645a2e84e423a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25919f578df35140965011b7c2cb2ce57308f52adf0a05373ba26f4aff5973d3c810c6fb53b473efc9ce50744325b12a9331ee0a1934b715e61be6a8df830cf5
|
7
|
+
data.tar.gz: 018f24f9bf5db7e63e79c5301c3ee6035d7028ff9521951a4c03de346358b32a14fc716ead14ac8da41ad146d2e24edd0543a2ee26f42f5610fd0c3734102f01
|
data/lib/upmark/parser/xml.rb
CHANGED
@@ -79,14 +79,15 @@ module Upmark
|
|
79
79
|
end
|
80
80
|
|
81
81
|
rule(:double_quoted_attribute_value) do
|
82
|
-
(str('"').absent? >> (match(/[
|
82
|
+
(str('"').absent? >> (match(/[^<]/) | string_entity | numeric_entity)).repeat
|
83
83
|
end
|
84
84
|
|
85
85
|
rule(:single_quoted_attribute_value) do
|
86
|
-
(str("'").absent? >> (match(/[
|
86
|
+
(str("'").absent? >> (match(/[^<]/) | string_entity | numeric_entity)).repeat
|
87
87
|
end
|
88
88
|
|
89
|
-
rule(:
|
89
|
+
rule(:string_entity) { match("&") >> name >> match(";") }
|
90
|
+
rule(:numeric_entity) { match(/&#\d+;/) }
|
90
91
|
|
91
92
|
rule(:space) { match(/\s/).repeat(1) }
|
92
93
|
rule(:space?) { space.maybe }
|
@@ -41,8 +41,10 @@ module Upmark
|
|
41
41
|
.select { |c| Array === c }
|
42
42
|
.map do |children|
|
43
43
|
children.map do |child|
|
44
|
-
if child
|
45
|
-
child[:text]
|
44
|
+
if child.is_a?(Hash) # if the td doesn't contain nested elements
|
45
|
+
if child[:text]
|
46
|
+
child[:text].to_s.gsub!(/^\n */,'')
|
47
|
+
end
|
46
48
|
end
|
47
49
|
child
|
48
50
|
end + ["\n"]
|
@@ -33,6 +33,28 @@ RSpec.describe Upmark, ".convert" do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
context "<a> with numeric entity" do
|
37
|
+
specify 'converts as []()' do
|
38
|
+
expect(<<-HTML.strip
|
39
|
+
<p><a href=\"http://www.abc.net.au/news/2016-02-18/haylen-we-need-a-drug-summit-because-we're-losing-the-war/7177152\">blah</a></p>
|
40
|
+
HTML
|
41
|
+
).to convert_to <<-MD.strip
|
42
|
+
[blah](http://www.abc.net.au/news/2016-02-18/haylen-we-need-a-drug-summit-because-we're-losing-the-war/7177152 "")
|
43
|
+
MD
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "<a> with query string" do
|
48
|
+
specify 'converts as []()' do
|
49
|
+
expect(<<-HTML.strip
|
50
|
+
<p><a href=\"http://www.abc.net.au/news/2016-02-18/blah?blah=lol&lol=rofl\">blah</a></p>
|
51
|
+
HTML
|
52
|
+
).to convert_to <<-MD.strip
|
53
|
+
[blah](http://www.abc.net.au/news/2016-02-18/blah?blah=lol&lol=rofl "")
|
54
|
+
MD
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
36
58
|
context "<img>" do
|
37
59
|
specify 'converts as ![]()' do
|
38
60
|
expect(<<-HTML.strip
|
@@ -289,4 +311,12 @@ messenger **bag** skateboard
|
|
289
311
|
}.to raise_error(Upmark::ParseFailed)
|
290
312
|
end
|
291
313
|
end
|
314
|
+
|
315
|
+
context "nested table" do
|
316
|
+
let(:html) { "<table><tr><td><table><tr><td><p>Hi <br />there</p></td></tr></table></td></tr></table>"}
|
317
|
+
|
318
|
+
it "should strip both tables" do
|
319
|
+
expect(html).to convert_to("Hi\nthere")
|
320
|
+
end
|
321
|
+
end
|
292
322
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: upmark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Bassett
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2016-06-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -111,12 +111,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
113
|
rubyforge_project: upmark
|
114
|
-
rubygems_version: 2.
|
114
|
+
rubygems_version: 2.5.1
|
115
115
|
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: A HTML to Markdown converter.
|
118
118
|
test_files:
|
119
|
-
- spec/unit/lib/upmark/transform/markdown_spec.rb
|
120
119
|
- spec/unit/lib/upmark/parser/xml_spec.rb
|
120
|
+
- spec/unit/lib/upmark/transform/markdown_spec.rb
|
121
121
|
- spec/spec_helper.rb
|
122
122
|
- spec/acceptance/upmark_spec.rb
|