upmark 0.10.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/{LICENSE → LICENSE.md} +1 -1
- data/README.md +7 -9
- data/lib/upmark.rb +0 -2
- data/lib/upmark/errors.rb +3 -3
- data/lib/upmark/transform/markdown.rb +1 -1
- data/spec/acceptance/upmark_spec.rb +22 -0
- data/spec/errors_spec.rb +12 -0
- metadata +12 -11
- data/lib/core_ext/array.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e6e70467bec74fa706947ab9b0aea3c6cf626c6cf201a07aa918b5fba980a1a2
|
4
|
+
data.tar.gz: a237b227e1c64e116dad035548ac4d364f9fca96956b26ad7b90f0b5919b29fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c132b5f1a0fdc78cd7c5a4e3c7b3a9bad1a7aacfc7ad3e59f9d2a88bdb03bdd610bd5a907bddf565e2183c0c70dc0558834b80e7fddac8ad9421fe245f2e99c
|
7
|
+
data.tar.gz: 7a4997aea6c74b5a2ee3adcf377e963663ca1ce6e4aec1cb48dc7d3066f0f8ec46710235885df300e6bd0fe15923825b130f0ab1de22bfc15d649bacbaae98b8
|
data/{LICENSE → LICENSE.md}
RENAMED
data/README.md
CHANGED
@@ -4,16 +4,18 @@ A HTML to Markdown converter.
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
gem install upmark
|
7
|
+
> gem install upmark
|
8
8
|
|
9
9
|
## Usage
|
10
10
|
|
11
11
|
In ruby:
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
```ruby
|
14
|
+
require "upmark"
|
15
|
+
html = "<p>messenger <strong>bag</strong> skateboard</p>"
|
16
|
+
markdown = Upmark.convert(html)
|
17
|
+
puts markdown
|
18
|
+
```
|
17
19
|
|
18
20
|
From the command-line:
|
19
21
|
|
@@ -46,7 +48,3 @@ Upmark defines a parsing expression grammar (PEG) using the very awesome [Parsle
|
|
46
48
|
2. Normalize the AST into a nested hash of HTML elements.
|
47
49
|
3. Mark the block and span-level subtrees which should be ignored (`table`, `div`, `span`, etc).
|
48
50
|
4. Convert the AST leaves into Markdown.
|
49
|
-
|
50
|
-
## License
|
51
|
-
|
52
|
-
Upmark is Copyright (c) 2014 The Conversation Media Group and distributed under the MIT license.
|
data/lib/upmark.rb
CHANGED
data/lib/upmark/errors.rb
CHANGED
@@ -54,7 +54,7 @@ module Upmark
|
|
54
54
|
|
55
55
|
element(:ol) do |element|
|
56
56
|
children = element[:children].map {|value| value.strip != "" ? value : nil }.compact
|
57
|
-
children.
|
57
|
+
children.map.with_index {|value, i| "#{i + 1}. #{value}\n" }
|
58
58
|
end
|
59
59
|
|
60
60
|
element(:a) do |element|
|
@@ -55,6 +55,28 @@ RSpec.describe Upmark, ".convert" do
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
+
context "<a> with inline elements, no href" do
|
59
|
+
specify 'converts as plain text' do
|
60
|
+
expect(<<-HTML.strip
|
61
|
+
<a>How Australia can respond to the security challenges posed by climate change in the Asian Century</a>
|
62
|
+
HTML
|
63
|
+
).to convert_to <<-MD.strip
|
64
|
+
How Australia can respond to the security challenges posed by climate change in the Asian Century
|
65
|
+
MD
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context "<a> with id href" do
|
70
|
+
specify 'converts as plain text' do
|
71
|
+
expect(<<-HTML.strip
|
72
|
+
<a href=\"#sdfootnote3anc\">Labor MP calls to end dogs</a>
|
73
|
+
HTML
|
74
|
+
).to convert_to <<-MD.strip
|
75
|
+
Labor MP calls to end dogs
|
76
|
+
MD
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
58
80
|
context "<img>" do
|
59
81
|
specify 'converts as ![]()' do
|
60
82
|
expect(<<-HTML.strip
|
data/spec/errors_spec.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
RSpec.describe Upmark::ParseFailed, ".ascii_tree" do
|
2
|
+
it "delegates to a cause object" do
|
3
|
+
cause = double(ascii_tree: double)
|
4
|
+
error = Upmark::ParseFailed.new("oh noes", cause)
|
5
|
+
expect(error.ascii_tree).to be(cause.ascii_tree)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "returns nil when there is no cause" do
|
9
|
+
error = Upmark::ParseFailed.new("oh noes", nil)
|
10
|
+
expect(error.ascii_tree).to be_nil
|
11
|
+
end
|
12
|
+
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: 1.0.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: 2018-03-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '3.
|
21
|
+
version: '3.7'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: '3.
|
28
|
+
version: '3.7'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: rake
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,14 +60,14 @@ dependencies:
|
|
60
60
|
requirements:
|
61
61
|
- - "~>"
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: 1.
|
63
|
+
version: 1.8.2
|
64
64
|
type: :runtime
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
68
|
- - "~>"
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version: 1.
|
70
|
+
version: 1.8.2
|
71
71
|
description: Upmark has the skills to convert your HTML to Markdown.
|
72
72
|
email: dev@theconversation.edu.au
|
73
73
|
executables:
|
@@ -75,11 +75,10 @@ executables:
|
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
|
-
- LICENSE
|
78
|
+
- LICENSE.md
|
79
79
|
- README.md
|
80
80
|
- Rakefile
|
81
81
|
- bin/upmark
|
82
|
-
- lib/core_ext/array.rb
|
83
82
|
- lib/upmark.rb
|
84
83
|
- lib/upmark/errors.rb
|
85
84
|
- lib/upmark/parser/xml.rb
|
@@ -89,6 +88,7 @@ files:
|
|
89
88
|
- lib/upmark/transform/preprocess.rb
|
90
89
|
- lib/upmark/transform_helpers.rb
|
91
90
|
- spec/acceptance/upmark_spec.rb
|
91
|
+
- spec/errors_spec.rb
|
92
92
|
- spec/spec_helper.rb
|
93
93
|
- spec/unit/lib/upmark/parser/xml_spec.rb
|
94
94
|
- spec/unit/lib/upmark/transform/markdown_spec.rb
|
@@ -103,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
103
|
requirements:
|
104
104
|
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
version:
|
106
|
+
version: 1.9.3
|
107
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
109
|
- - ">="
|
@@ -111,12 +111,13 @@ 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.7.0
|
115
115
|
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: A HTML to Markdown converter.
|
118
118
|
test_files:
|
119
|
+
- spec/spec_helper.rb
|
119
120
|
- spec/unit/lib/upmark/parser/xml_spec.rb
|
120
121
|
- spec/unit/lib/upmark/transform/markdown_spec.rb
|
121
|
-
- spec/spec_helper.rb
|
122
122
|
- spec/acceptance/upmark_spec.rb
|
123
|
+
- spec/errors_spec.rb
|