html_to_prosemirror 0.2.0 → 0.3.1
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/Gemfile.lock +63 -22
- data/README.md +1 -1
- data/RELEASE.md +2 -2
- data/html_to_prosemirror.gemspec +3 -3
- data/lib/html_to_prosemirror/nodes/blockquote.rb +16 -0
- data/lib/html_to_prosemirror/version.rb +1 -1
- data/lib/html_to_prosemirror.rb +13 -13
- metadata +9 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 15936d0d54eaaa75148d8ef9da299e35c2933904f33e32a61ac89d0199d6dd08
|
|
4
|
+
data.tar.gz: 60c292097308090f497bd47c24a1d30f70aea6fd1bf797f260bb9c2717d1de0f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 19545ace09ad128d21c0803dd930be789414c4c049ceb93b55f3b439a552b6a7fae9360d14d22d75cee06754cc0e14fe0fef634353ac8e30f558cc08ac0ce5e3
|
|
7
|
+
data.tar.gz: f3da452f0b622d24e9c8da25b90583beb56025670f730db596485885548fbbe8324a7d772e1651e42725604f325a49825248450384a158f0894e5c1730a2f3fb
|
data/Gemfile.lock
CHANGED
|
@@ -1,41 +1,82 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
html_to_prosemirror (0.
|
|
4
|
+
html_to_prosemirror (0.3.1)
|
|
5
5
|
nokogiri
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
-
diff-lcs (1.
|
|
11
|
-
nokogiri (1.
|
|
12
|
-
racc (~> 1.4)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
diff-lcs (1.6.2)
|
|
11
|
+
nokogiri (1.19.1-aarch64-linux-gnu)
|
|
12
|
+
racc (~> 1.4)
|
|
13
|
+
nokogiri (1.19.1-aarch64-linux-musl)
|
|
14
|
+
racc (~> 1.4)
|
|
15
|
+
nokogiri (1.19.1-arm-linux-gnu)
|
|
16
|
+
racc (~> 1.4)
|
|
17
|
+
nokogiri (1.19.1-arm-linux-musl)
|
|
18
|
+
racc (~> 1.4)
|
|
19
|
+
nokogiri (1.19.1-arm64-darwin)
|
|
20
|
+
racc (~> 1.4)
|
|
21
|
+
nokogiri (1.19.1-x86_64-darwin)
|
|
22
|
+
racc (~> 1.4)
|
|
23
|
+
nokogiri (1.19.1-x86_64-linux-gnu)
|
|
24
|
+
racc (~> 1.4)
|
|
25
|
+
nokogiri (1.19.1-x86_64-linux-musl)
|
|
26
|
+
racc (~> 1.4)
|
|
27
|
+
racc (1.8.1)
|
|
28
|
+
rake (13.3.1)
|
|
29
|
+
rspec (3.13.2)
|
|
30
|
+
rspec-core (~> 3.13.0)
|
|
31
|
+
rspec-expectations (~> 3.13.0)
|
|
32
|
+
rspec-mocks (~> 3.13.0)
|
|
33
|
+
rspec-core (3.13.6)
|
|
34
|
+
rspec-support (~> 3.13.0)
|
|
35
|
+
rspec-expectations (3.13.5)
|
|
22
36
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
23
|
-
rspec-support (~> 3.
|
|
24
|
-
rspec-mocks (3.
|
|
37
|
+
rspec-support (~> 3.13.0)
|
|
38
|
+
rspec-mocks (3.13.7)
|
|
25
39
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
26
|
-
rspec-support (~> 3.
|
|
27
|
-
rspec-support (3.
|
|
28
|
-
yard (0.9.
|
|
40
|
+
rspec-support (~> 3.13.0)
|
|
41
|
+
rspec-support (3.13.7)
|
|
42
|
+
yard (0.9.38)
|
|
29
43
|
|
|
30
44
|
PLATFORMS
|
|
31
|
-
|
|
45
|
+
aarch64-linux-gnu
|
|
46
|
+
aarch64-linux-musl
|
|
47
|
+
arm-linux-gnu
|
|
48
|
+
arm-linux-musl
|
|
49
|
+
arm64-darwin
|
|
50
|
+
x86_64-darwin
|
|
51
|
+
x86_64-linux-gnu
|
|
52
|
+
x86_64-linux-musl
|
|
32
53
|
|
|
33
54
|
DEPENDENCIES
|
|
34
|
-
bundler (
|
|
55
|
+
bundler (>= 1.17)
|
|
35
56
|
html_to_prosemirror!
|
|
36
|
-
rake (~>
|
|
57
|
+
rake (~> 13.0)
|
|
37
58
|
rspec (~> 3.0)
|
|
38
59
|
yard
|
|
39
60
|
|
|
61
|
+
CHECKSUMS
|
|
62
|
+
diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
|
|
63
|
+
html_to_prosemirror (0.3.1)
|
|
64
|
+
nokogiri (1.19.1-aarch64-linux-gnu) sha256=cfdb0eafd9a554a88f12ebcc688d2b9005f9fce42b00b970e3dc199587b27f32
|
|
65
|
+
nokogiri (1.19.1-aarch64-linux-musl) sha256=1e2150ab43c3b373aba76cd1190af7b9e92103564063e48c474f7600923620b5
|
|
66
|
+
nokogiri (1.19.1-arm-linux-gnu) sha256=0a39ed59abe3bf279fab9dd4c6db6fe8af01af0608f6e1f08b8ffa4e5d407fa3
|
|
67
|
+
nokogiri (1.19.1-arm-linux-musl) sha256=3a18e559ee499b064aac6562d98daab3d39ba6cbb4074a1542781b2f556db47d
|
|
68
|
+
nokogiri (1.19.1-arm64-darwin) sha256=dfe2d337e6700eac47290407c289d56bcf85805d128c1b5a6434ddb79731cb9e
|
|
69
|
+
nokogiri (1.19.1-x86_64-darwin) sha256=7093896778cc03efb74b85f915a775862730e887f2e58d6921e3fa3d981e68bf
|
|
70
|
+
nokogiri (1.19.1-x86_64-linux-gnu) sha256=1a4902842a186b4f901078e692d12257678e6133858d0566152fe29cdb98456a
|
|
71
|
+
nokogiri (1.19.1-x86_64-linux-musl) sha256=4267f38ad4fc7e52a2e7ee28ed494e8f9d8eb4f4b3320901d55981c7b995fc23
|
|
72
|
+
racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
|
|
73
|
+
rake (13.3.1) sha256=8c9e89d09f66a26a01264e7e3480ec0607f0c497a861ef16063604b1b08eb19c
|
|
74
|
+
rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587
|
|
75
|
+
rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
|
|
76
|
+
rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836
|
|
77
|
+
rspec-mocks (3.13.7) sha256=0979034e64b1d7a838aaaddf12bf065ea4dc40ef3d4c39f01f93ae2c66c62b1c
|
|
78
|
+
rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c
|
|
79
|
+
yard (0.9.38) sha256=721fb82afb10532aa49860655f6cc2eaa7130889df291b052e1e6b268283010f
|
|
80
|
+
|
|
40
81
|
BUNDLED WITH
|
|
41
|
-
|
|
82
|
+
4.0.6
|
data/README.md
CHANGED
|
@@ -36,7 +36,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
|
36
36
|
|
|
37
37
|
## Contributing
|
|
38
38
|
|
|
39
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
|
39
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/etaminstudio/html_to_prosemirror. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
40
40
|
|
|
41
41
|
## License
|
|
42
42
|
|
data/RELEASE.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Releasing a new version of html_to_prosemirror
|
|
2
2
|
|
|
3
3
|
1. Create a list of all the changes since the prior release
|
|
4
|
-
1. Compare the latest release to master using https://github.com/
|
|
4
|
+
1. Compare the latest release to master using https://github.com/etaminstudio/html_to_prosemirror/compare/`${latest}`...master
|
|
5
5
|
1. Open the linked pull requests from all the `Merge pull request #...` commits
|
|
6
6
|
1. For all non-documentation PRs, copy title (including pull request number) into markdown list items
|
|
7
7
|
1. (optional, but nice) Sort into logical buckets, like "support for additional endpoints", "enhancements", "bugfixes"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
1. Update the constant in `lib/html_to_prosemirror/version.rb`
|
|
12
12
|
1. Commit and push directly to master
|
|
13
13
|
1. Run the `script/release` script to cut a release
|
|
14
|
-
1. Draft a new release at https://github.com/
|
|
14
|
+
1. Draft a new release at https://github.com/etaminstudio/html_to_prosemirror.rb/releases/new containing the curated changelog
|
|
15
15
|
|
|
16
16
|
## Prerequisites
|
|
17
17
|
|
data/html_to_prosemirror.gemspec
CHANGED
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
|
11
11
|
|
|
12
12
|
spec.summary = %q{Takes HTML and outputs ProseMirror compatible JSON.}
|
|
13
13
|
spec.description = %q{Takes HTML and outputs ProseMirror compatible JSON.}
|
|
14
|
-
spec.homepage = "https://github.com/
|
|
14
|
+
spec.homepage = "https://github.com/etaminstudio/html_to_prosemirror"
|
|
15
15
|
spec.license = "MIT"
|
|
16
16
|
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
@@ -36,8 +36,8 @@ Gem::Specification.new do |spec|
|
|
|
36
36
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
37
37
|
spec.require_paths = ["lib"]
|
|
38
38
|
|
|
39
|
-
spec.add_development_dependency "bundler", "
|
|
40
|
-
spec.add_development_dependency "rake", "~>
|
|
39
|
+
spec.add_development_dependency "bundler", ">= 1.17"
|
|
40
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
|
41
41
|
spec.add_development_dependency "rspec", "~> 3.0"
|
|
42
42
|
spec.add_development_dependency "yard"
|
|
43
43
|
spec.add_dependency "nokogiri"
|
data/lib/html_to_prosemirror.rb
CHANGED
|
@@ -5,6 +5,7 @@ require "html_to_prosemirror/marks/code"
|
|
|
5
5
|
require "html_to_prosemirror/marks/italic"
|
|
6
6
|
require "html_to_prosemirror/marks/link"
|
|
7
7
|
require "html_to_prosemirror/nodes/node"
|
|
8
|
+
require "html_to_prosemirror/nodes/blockquote"
|
|
8
9
|
require "html_to_prosemirror/nodes/bullet_list"
|
|
9
10
|
require "html_to_prosemirror/nodes/code_block_wrapper"
|
|
10
11
|
require "html_to_prosemirror/nodes/code_block"
|
|
@@ -24,7 +25,6 @@ module HtmlToProsemirror
|
|
|
24
25
|
class Renderer
|
|
25
26
|
def initialize(case_type: :snake)
|
|
26
27
|
@case_type = case_type
|
|
27
|
-
@stored_marks = []
|
|
28
28
|
@marks = [
|
|
29
29
|
HtmlToProsemirror::Marks::Bold,
|
|
30
30
|
HtmlToProsemirror::Marks::Code,
|
|
@@ -32,6 +32,7 @@ module HtmlToProsemirror
|
|
|
32
32
|
HtmlToProsemirror::Marks::Link
|
|
33
33
|
]
|
|
34
34
|
@nodes = [
|
|
35
|
+
HtmlToProsemirror::Nodes::Blockquote,
|
|
35
36
|
HtmlToProsemirror::Nodes::BulletList,
|
|
36
37
|
HtmlToProsemirror::Nodes::CodeBlockWrapper,
|
|
37
38
|
HtmlToProsemirror::Nodes::CodeBlock,
|
|
@@ -61,7 +62,7 @@ module HtmlToProsemirror
|
|
|
61
62
|
# return @document.search('body')[0];
|
|
62
63
|
# end
|
|
63
64
|
|
|
64
|
-
def render_children(node)
|
|
65
|
+
def render_children(node, inherited_marks = [])
|
|
65
66
|
nodes = []
|
|
66
67
|
node.children.each do |child|
|
|
67
68
|
child_node = get_matching_node(child)
|
|
@@ -69,20 +70,19 @@ module HtmlToProsemirror
|
|
|
69
70
|
item = child_node.data()
|
|
70
71
|
if (item === nil)
|
|
71
72
|
if (child.children.length > 0)
|
|
72
|
-
nodes = nodes + render_children(child)
|
|
73
|
+
nodes = nodes + render_children(child, inherited_marks)
|
|
73
74
|
end
|
|
74
75
|
next
|
|
75
76
|
end
|
|
76
77
|
if (child.children.length > 0)
|
|
77
78
|
item = item.merge({
|
|
78
|
-
content: render_children(child),
|
|
79
|
+
content: render_children(child, inherited_marks),
|
|
79
80
|
})
|
|
80
81
|
end
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
@stored_marks = [];
|
|
82
|
+
if (inherited_marks.count > 0)
|
|
83
|
+
item = item.merge({
|
|
84
|
+
marks: inherited_marks,
|
|
85
|
+
})
|
|
86
86
|
end
|
|
87
87
|
if (@case_type === :lower_camel)
|
|
88
88
|
item = item.merge(type: item[:type].gsub(/_([a-z])/) { $1.upcase })
|
|
@@ -99,9 +99,8 @@ module HtmlToProsemirror
|
|
|
99
99
|
|
|
100
100
|
child_mark = get_matching_mark(child)
|
|
101
101
|
if (child_mark)
|
|
102
|
-
@stored_marks.push(child_mark.data())
|
|
103
102
|
if (child.children.length > 0)
|
|
104
|
-
nodes = nodes + render_children(child)
|
|
103
|
+
nodes = nodes + render_children(child, inherited_marks + [child_mark.data()])
|
|
105
104
|
end
|
|
106
105
|
end
|
|
107
106
|
end
|
|
@@ -132,11 +131,12 @@ module HtmlToProsemirror
|
|
|
132
131
|
# 1.2. Remove javascript comments e.g. /* */ and // \/\*[^\*]*\*\/ and ^(\t|\s)*\/\/.*
|
|
133
132
|
# 3. Replace all carrier return and all tabs by a single space gsub(/(\n|\t)/, ' ').
|
|
134
133
|
# 4. Replace any consecutive spaces by a single space gsub(/\s{2,}/, ' ')
|
|
135
|
-
# 5.
|
|
134
|
+
# 5. Collapse space between tags to a single space gsub(/>\s+</, '> <').strip.
|
|
136
135
|
html.gsub(/(<!--(\w|\s|:|!|#|<|>|'|"|=|;|,|\.|\?)*-->|\/\*[^\*]*\*\/|^(\t|\s)*\/\/.*)/, '').
|
|
137
136
|
gsub(/(\n|\t)/, ' ').
|
|
138
137
|
gsub(/\s{2,}/, ' ').
|
|
139
|
-
gsub(
|
|
138
|
+
gsub(/>(\s+)<(?!\/?(a|abbr|b|bdi|br|cite|code|dfn|em|i|img|kbd|mark|q|s|samp|small|span|strong|sub|sup|time|u|var))/i) { '><' }.
|
|
139
|
+
gsub(/>\s+</, '> <').strip
|
|
140
140
|
end
|
|
141
141
|
end
|
|
142
142
|
end
|
metadata
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: html_to_prosemirror
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brian Kimball
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: bundler
|
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
|
16
15
|
requirements:
|
|
17
|
-
- - "
|
|
16
|
+
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
18
|
version: '1.17'
|
|
20
19
|
type: :development
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
|
-
- - "
|
|
23
|
+
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '1.17'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
@@ -30,14 +29,14 @@ dependencies:
|
|
|
30
29
|
requirements:
|
|
31
30
|
- - "~>"
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
32
|
+
version: '13.0'
|
|
34
33
|
type: :development
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
37
|
- - "~>"
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
39
|
+
version: '13.0'
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
41
|
name: rspec
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -107,6 +106,7 @@ files:
|
|
|
107
106
|
- lib/html_to_prosemirror/marks/italic.rb
|
|
108
107
|
- lib/html_to_prosemirror/marks/link.rb
|
|
109
108
|
- lib/html_to_prosemirror/marks/mark.rb
|
|
109
|
+
- lib/html_to_prosemirror/nodes/blockquote.rb
|
|
110
110
|
- lib/html_to_prosemirror/nodes/bullet_list.rb
|
|
111
111
|
- lib/html_to_prosemirror/nodes/code_block.rb
|
|
112
112
|
- lib/html_to_prosemirror/nodes/code_block_wrapper.rb
|
|
@@ -122,11 +122,10 @@ files:
|
|
|
122
122
|
- lib/html_to_prosemirror/version.rb
|
|
123
123
|
- scripts/package
|
|
124
124
|
- scripts/release
|
|
125
|
-
homepage: https://github.com/
|
|
125
|
+
homepage: https://github.com/etaminstudio/html_to_prosemirror
|
|
126
126
|
licenses:
|
|
127
127
|
- MIT
|
|
128
128
|
metadata: {}
|
|
129
|
-
post_install_message:
|
|
130
129
|
rdoc_options: []
|
|
131
130
|
require_paths:
|
|
132
131
|
- lib
|
|
@@ -141,8 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
141
140
|
- !ruby/object:Gem::Version
|
|
142
141
|
version: '0'
|
|
143
142
|
requirements: []
|
|
144
|
-
rubygems_version:
|
|
145
|
-
signing_key:
|
|
143
|
+
rubygems_version: 4.0.3
|
|
146
144
|
specification_version: 4
|
|
147
145
|
summary: Takes HTML and outputs ProseMirror compatible JSON.
|
|
148
146
|
test_files: []
|