upmark 0.10.0 → 1.0.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1e6c728e71452e9983f7fe6ef59948cca6fd691b
4
- data.tar.gz: 87daa0b2e4e6105b43e88502b6f645a2e84e423a
2
+ SHA256:
3
+ metadata.gz: e6e70467bec74fa706947ab9b0aea3c6cf626c6cf201a07aa918b5fba980a1a2
4
+ data.tar.gz: a237b227e1c64e116dad035548ac4d364f9fca96956b26ad7b90f0b5919b29fc
5
5
  SHA512:
6
- metadata.gz: 25919f578df35140965011b7c2cb2ce57308f52adf0a05373ba26f4aff5973d3c810c6fb53b473efc9ce50744325b12a9331ee0a1934b715e61be6a8df830cf5
7
- data.tar.gz: 018f24f9bf5db7e63e79c5301c3ee6035d7028ff9521951a4c03de346358b32a14fc716ead14ac8da41ad146d2e24edd0543a2ee26f42f5610fd0c3734102f01
6
+ metadata.gz: 8c132b5f1a0fdc78cd7c5a4e3c7b3a9bad1a7aacfc7ad3e59f9d2a88bdb03bdd610bd5a907bddf565e2183c0c70dc0558834b80e7fddac8ad9421fe245f2e99c
7
+ data.tar.gz: 7a4997aea6c74b5a2ee3adcf377e963663ca1ce6e4aec1cb48dc7d3066f0f8ec46710235885df300e6bd0fe15923825b130f0ab1de22bfc15d649bacbaae98b8
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 The Conversation Media Group
1
+ Copyright (c) 2016 The Conversation Media Group
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
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
- require "upmark"
14
- html = %q{<p>messenger <strong>bag</strong> skateboard</p>}
15
- markdown = Upmark.convert(html)
16
- puts markdown
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.
@@ -1,7 +1,5 @@
1
1
  require "parslet"
2
2
 
3
- require "core_ext/array"
4
-
5
3
  require 'upmark/errors'
6
4
  require "upmark/parser/xml"
7
5
  require 'upmark/transform_helpers'
@@ -1,14 +1,14 @@
1
1
  module Upmark
2
2
  class ParseFailed < StandardError
3
+ attr_reader :cause
3
4
 
4
5
  def initialize(message, cause)
5
6
  @cause = cause
6
7
  super(message)
7
8
  end
8
9
 
9
- def cause
10
- @cause
10
+ def ascii_tree
11
+ @cause && @cause.ascii_tree
11
12
  end
12
-
13
13
  end
14
14
  end
@@ -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.map_with_index {|value, i| "#{i + 1}. #{value}\n" }
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
@@ -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.10.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: 2016-06-17 00:00:00.000000000 Z
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.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.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.7.0
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.7.0
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: '0'
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.5.1
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
@@ -1,9 +0,0 @@
1
- class Array
2
- def map_with_index
3
- result = []
4
- each_with_index do |element, index|
5
- result << yield(element, index)
6
- end
7
- result
8
- end
9
- end