unmarkdown 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d25eed05ed6d0b08e001758df1cc8db2ea53c8fd5394cf2c85c536e77132e14
4
- data.tar.gz: da4e1677918388764eb2579d59839c2f1a89737e55ea76cce94df4798dd9ec5b
3
+ metadata.gz: 68e58ef7f5ad3f18f2f4aee2d450ff433cfdb927ee9564836bb9be4faac80370
4
+ data.tar.gz: e120e545f74052e2ea8362c242632de139876f1aaa95b54b5ee77e2956a22e50
5
5
  SHA512:
6
- metadata.gz: 15aa39424402e1a165f0f1a3d23d06cd82ea945a3f768c0189be9d278f6cd8262379429ac93e60791d1943e0e324e5675c594a8fc8c64921c39352cf13549f13
7
- data.tar.gz: 0a00d62f297eda5bff87e6ddf598a781ea404fe2e8cec3385ed53bd8641d31cac222a8c4df7b43f8045c099adf75c9e8e2e998c5e923959ab159031a9636330b
6
+ metadata.gz: eda7204e94c3f8865bf219af0de252121a891021cf608d429cc1c4bddec8dcb049a201151cb4e5176e40632812e692a464a47c73d24658a4f07adb9b51934fd5
7
+ data.tar.gz: 1e253bae1d7dc7e4301add86543bfaf2b37c0c936eeb25c4afc36ce0a59346ea3c16f2489b0fd55a7f60c26b34286fabd68c4c623638b1ba821f2b75ad0ea129
@@ -12,8 +12,15 @@ module Unmarkdown
12
12
  end
13
13
 
14
14
  def parse
15
+ # If the HTML fragment starts with a comment, it is ignored. Add an
16
+ # enclosing body tag to ensure everything is included.
17
+ html = @html
18
+ unless html.include?('<body')
19
+ html = "<body>#{@html}</body>"
20
+ end
21
+
15
22
  # Setup document
16
- doc = Nokogiri::HTML(@html)
23
+ doc = Nokogiri::HTML(html)
17
24
  doc.encoding = 'UTF-8'
18
25
 
19
26
  # Reset bookkeeping
@@ -117,10 +124,11 @@ module Unmarkdown
117
124
  when 'script'
118
125
  next unless @options[:allow_scripts]
119
126
  output << node.to_html
120
- else
121
- # If it's an supported node or a node that just contains text, just get
122
- # its content
127
+ when 'p'
123
128
  output << parse_content(node)
129
+ else
130
+ # If it's an supported node or a node that just contains text, just append it
131
+ output << node.to_html
124
132
  end
125
133
 
126
134
  output << "\n\n" if BLOCK_ELEMENT_NAMES.include?(node.name)
@@ -1,3 +1,3 @@
1
1
  module Unmarkdown
2
- VERSION = '0.1.2'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -153,4 +153,26 @@ class ParserTest < Unmarkdown::Test
153
153
  markdown = 'Head to <http://soff.es> and email <sam@soff.es>'
154
154
  assert_equal markdown, parse(html, autolink: true)
155
155
  end
156
+
157
+ def test_unknown
158
+ html = %Q{Some custom tag: <expand-note>hello</expand-note>. <span class="spoiler">a secret</span>}
159
+ assert_equal html, parse(html)
160
+ end
161
+
162
+ def test_comments
163
+ html = %Q{<!--One-line comment by itself-->
164
+
165
+ Line with an <!--inline comment--> inside
166
+
167
+ <!--
168
+ Block comment
169
+ -->
170
+
171
+ surrounding stuff
172
+ <!--
173
+ Block comment
174
+ -->
175
+ surrounding stuff}
176
+ assert_equal html, parse(html)
177
+ end
156
178
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.required_ruby_version = '>= 1.9.2'
21
21
 
22
- spec.add_development_dependency 'bundler', '~> 1.0'
22
+ spec.add_development_dependency 'bundler', '~> 2.0'
23
23
 
24
24
  # HTML parsing
25
25
  spec.add_dependency 'nokogiri', '~> 1.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unmarkdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Soffes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-02 00:00:00.000000000 Z
11
+ date: 2020-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '2.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  requirements: []
79
- rubygems_version: 3.0.3
79
+ rubygems_version: 3.1.2
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: Convert HTML to Markdown