upmark 1.0.0 → 1.1.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 +4 -4
- data/README.md +1 -1
- data/lib/upmark/transform/markdown.rb +2 -2
- data/spec/acceptance/upmark_spec.rb +33 -1
- metadata +8 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b50ae60e763766a5a5b4276591f488e17668ef3d85d2f78079d2a259e81fcdc
|
4
|
+
data.tar.gz: 3d5722b9cee80ab15a9d9f975b0b6f5d662a53d325a54849ec47bbe6c17ee4d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bed12a83c45c01bc2033d4c41bd3a5af61aa2777925f51b19322a0655756f8d4aab7f76b1db1a633b08bd9d43a1f30001b0489ca4bb8ad7105666d3e5f3f7d50
|
7
|
+
data.tar.gz: b2ffc99286769acc223f9065bbdacf82c3c3ca2c6132120b7af036ec8a71721950bd03125f61767c6411fb93c5f19ab10ea78f780ad534449ab670c4410e312c
|
data/README.md
CHANGED
@@ -42,7 +42,7 @@ It will also pass through block and span-level HTML elements (e.g. `table`, `div
|
|
42
42
|
|
43
43
|
## How it works
|
44
44
|
|
45
|
-
Upmark defines a parsing expression grammar (PEG) using the very awesome [Parslet](
|
45
|
+
Upmark defines a parsing expression grammar (PEG) using the very awesome [Parslet](https://github.com/kschiess/parslet/) gem. This PEG is then used to convert HTML into Markdown in 4 steps:
|
46
46
|
|
47
47
|
1. Parse the XHTML into an abstract syntax tree (AST).
|
48
48
|
2. Normalize the AST into a nested hash of HTML elements.
|
@@ -48,12 +48,12 @@ module Upmark
|
|
48
48
|
element(:li) {|element| "#{text(element)}" }
|
49
49
|
|
50
50
|
element(:ul) do |element|
|
51
|
-
children = element[:children].map {|value| value.strip != "" ? value : nil }.compact
|
51
|
+
children = element[:children].flatten.map {|value| value.strip != "" ? value : nil }.compact
|
52
52
|
children.map {|value| "* #{value.gsub(/^\s*•\s*/,'')}\n" }
|
53
53
|
end
|
54
54
|
|
55
55
|
element(:ol) do |element|
|
56
|
-
children = element[:children].map {|value| value.strip != "" ? value : nil }.compact
|
56
|
+
children = element[:children].flatten.map {|value| value.strip != "" ? value : nil }.compact
|
57
57
|
children.map.with_index {|value, i| "#{i + 1}. #{value}\n" }
|
58
58
|
end
|
59
59
|
|
@@ -341,4 +341,36 @@ messenger **bag** skateboard
|
|
341
341
|
expect(html).to convert_to("Hi\nthere")
|
342
342
|
end
|
343
343
|
end
|
344
|
-
|
344
|
+
|
345
|
+
context "nested unordered lists" do
|
346
|
+
let(:html) do
|
347
|
+
<<-HTML
|
348
|
+
<ul>
|
349
|
+
<ul>
|
350
|
+
<li>List item</li>
|
351
|
+
</ul>
|
352
|
+
</ul>
|
353
|
+
HTML
|
354
|
+
end
|
355
|
+
|
356
|
+
it "generates readable output" do
|
357
|
+
expect(html).to convert_to("* * List item")
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
context "nested ordered lists" do
|
362
|
+
let(:html) do
|
363
|
+
<<-HTML
|
364
|
+
<ol>
|
365
|
+
<ol>
|
366
|
+
<li>List item</li>
|
367
|
+
</ol>
|
368
|
+
</ol>
|
369
|
+
HTML
|
370
|
+
end
|
371
|
+
|
372
|
+
it "generates readable output" do
|
373
|
+
expect(html).to convert_to("1. 1. List item")
|
374
|
+
end
|
375
|
+
end
|
376
|
+
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: upmark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Bassett
|
8
8
|
- Gus Gollings
|
9
9
|
- James Healy
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2024-04-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -95,7 +95,7 @@ files:
|
|
95
95
|
homepage: http://github.com/conversation/upmark
|
96
96
|
licenses: []
|
97
97
|
metadata: {}
|
98
|
-
post_install_message:
|
98
|
+
post_install_message:
|
99
99
|
rdoc_options: []
|
100
100
|
require_paths:
|
101
101
|
- lib
|
@@ -110,14 +110,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
|
-
|
114
|
-
|
115
|
-
signing_key:
|
113
|
+
rubygems_version: 3.4.10
|
114
|
+
signing_key:
|
116
115
|
specification_version: 4
|
117
116
|
summary: A HTML to Markdown converter.
|
118
117
|
test_files:
|
118
|
+
- spec/acceptance/upmark_spec.rb
|
119
|
+
- spec/errors_spec.rb
|
119
120
|
- spec/spec_helper.rb
|
120
121
|
- spec/unit/lib/upmark/parser/xml_spec.rb
|
121
122
|
- spec/unit/lib/upmark/transform/markdown_spec.rb
|
122
|
-
- spec/acceptance/upmark_spec.rb
|
123
|
-
- spec/errors_spec.rb
|