commonmarker 0.23.6 → 0.23.7.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of commonmarker might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/commonmarker/config.rb +15 -13
- data/lib/commonmarker/renderer.rb +1 -1
- data/lib/commonmarker/version.rb +1 -1
- data/lib/commonmarker.rb +27 -25
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f41f7e434edcc989547b4cc9d02007ae0eed60c393bd6f7ee8a288f139c6b537
|
4
|
+
data.tar.gz: 1c92f108fb98a076cf403c9e643f8a10b96d8c7ef359293686a27173e1e70436
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee9ef9c3ff7bcee7d054e1961ce402ddc067a082ea969752346b9642510473547f1fa8aea5e534b5113b7035ea8ddacdbb67c50e2490585bc3d1197d888ea4ac
|
7
|
+
data.tar.gz: 74b8df6b443d787cb9ce7110e7cabc34d5a0233a865b8cb67839b9bf1b11b636c02cd107a119e4fc02ca1122d3e736b84fc3fba0a674f5bd17928e25e3c4e8cf
|
data/lib/commonmarker/config.rb
CHANGED
@@ -33,20 +33,22 @@ module CommonMarker
|
|
33
33
|
format: [:html, :xml, :commonmark, :plaintext].freeze,
|
34
34
|
}.freeze
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
class << self
|
37
|
+
def process_options(option, type)
|
38
|
+
case option
|
39
|
+
when Symbol
|
40
|
+
OPTS.fetch(type).fetch(option)
|
41
|
+
when Array
|
42
|
+
raise TypeError if option.none?
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
# neckbearding around. the map will both check the opts and then bitwise-OR it
|
45
|
+
OPTS.fetch(type).fetch_values(*option).inject(0, :|)
|
46
|
+
else
|
47
|
+
raise TypeError, "option type must be a valid symbol or array of symbols within the #{name}::OPTS[:#{type}] context"
|
48
|
+
end
|
49
|
+
rescue KeyError => e
|
50
|
+
raise TypeError, "option ':#{e.key}' does not exist for #{name}::OPTS[:#{type}]"
|
47
51
|
end
|
48
|
-
|
49
|
-
raise TypeError, "option ':#{e.key}' does not exist for #{name}::OPTS[:#{type}]"
|
50
|
-
end
|
52
|
+
end
|
51
53
|
end
|
52
54
|
end
|
data/lib/commonmarker/version.rb
CHANGED
data/lib/commonmarker.rb
CHANGED
@@ -12,32 +12,34 @@ begin
|
|
12
12
|
require "awesome_print"
|
13
13
|
rescue LoadError; end # rubocop:disable Lint/SuppressedException
|
14
14
|
module CommonMarker
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
15
|
+
class << self
|
16
|
+
# Public: Parses a Markdown string into an HTML string.
|
17
|
+
#
|
18
|
+
# text - A {String} of text
|
19
|
+
# option - Either a {Symbol} or {Array of Symbol}s indicating the render options
|
20
|
+
# extensions - An {Array of Symbol}s indicating the extensions to use
|
21
|
+
#
|
22
|
+
# Returns a {String} of converted HTML.
|
23
|
+
def render_html(text, options = :DEFAULT, extensions = [])
|
24
|
+
raise TypeError, "text must be a String; got a #{text.class}!" unless text.is_a?(String)
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
opts = Config.process_options(options, :render)
|
27
|
+
Node.markdown_to_html(text.encode("UTF-8"), opts, extensions)
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
30
|
+
# Public: Parses a Markdown string into a `document` node.
|
31
|
+
#
|
32
|
+
# string - {String} to be parsed
|
33
|
+
# option - A {Symbol} or {Array of Symbol}s indicating the parse options
|
34
|
+
# extensions - An {Array of Symbol}s indicating the extensions to use
|
35
|
+
#
|
36
|
+
# Returns the `document` node.
|
37
|
+
def render_doc(text, options = :DEFAULT, extensions = [])
|
38
|
+
raise TypeError, "text must be a String; got a #{text.class}!" unless text.is_a?(String)
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
opts = Config.process_options(options, :parse)
|
41
|
+
text = text.encode("UTF-8")
|
42
|
+
Node.parse_document(text, text.bytesize, opts, extensions)
|
43
|
+
end
|
44
|
+
end
|
43
45
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commonmarker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.23.
|
4
|
+
version: 0.23.7.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-11-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: awesome_print
|
@@ -251,11 +251,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
251
251
|
version: '4.0'
|
252
252
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
253
253
|
requirements:
|
254
|
-
- - "
|
254
|
+
- - ">"
|
255
255
|
- !ruby/object:Gem::Version
|
256
|
-
version:
|
256
|
+
version: 1.3.1
|
257
257
|
requirements: []
|
258
|
-
rubygems_version: 3.
|
258
|
+
rubygems_version: 3.3.7
|
259
259
|
signing_key:
|
260
260
|
specification_version: 4
|
261
261
|
summary: CommonMark parser and renderer. Written in C, wrapped in Ruby.
|