commonmarker 2.10.1 → 3.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.
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: 2.10.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
@@ -35,6 +35,7 @@ files:
35
35
  - Cargo.toml
36
36
  - LICENSE.txt
37
37
  - README.md
38
+ - UPGRADING.md
38
39
  - ext/commonmarker/Cargo.toml
39
40
  - ext/commonmarker/build.rs
40
41
  - ext/commonmarker/extconf.rb
@@ -47,15 +48,11 @@ files:
47
48
  - ext/commonmarker/src/rctree.rs
48
49
  - ext/commonmarker/src/utils.rs
49
50
  - lib/commonmarker.rb
50
- - lib/commonmarker/config.rb
51
- - lib/commonmarker/constants.rb
52
51
  - lib/commonmarker/errors.rb
53
52
  - lib/commonmarker/extension.rb
54
53
  - lib/commonmarker/node.rb
55
54
  - lib/commonmarker/node/ast.rb
56
55
  - lib/commonmarker/node/inspect.rb
57
- - lib/commonmarker/renderer.rb
58
- - lib/commonmarker/utils.rb
59
56
  - lib/commonmarker/version.rb
60
57
  homepage: https://github.com/gjtorikian/commonmarker
61
58
  licenses:
@@ -1,119 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Commonmarker
4
- module Config
5
- # For details, see
6
- # https://github.com/kivikakk/comrak/blob/162ef9354deb2c9b4a4e05be495aa372ba5bb696/src/main.rs#L201
7
- OPTIONS = {
8
- parse: {
9
- smart: false,
10
- default_info_string: "",
11
- relaxed_tasklist_matching: false,
12
- relaxed_autolinks: false,
13
- leave_footnote_definitions: false,
14
- ignore_setext: false,
15
- sourcepos_chars: false,
16
- max_nesting_depth: 1000,
17
- }.freeze,
18
- render: {
19
- hardbreaks: true,
20
- github_pre_lang: true,
21
- full_info_string: false,
22
- width: 80,
23
- unsafe: false,
24
- escape: false,
25
- sourcepos: false,
26
- escaped_char_spans: true,
27
- ignore_empty_links: false,
28
- gfm_quirks: false,
29
- prefer_fenced: false,
30
- tasklist_classes: false,
31
- compact_html: false,
32
- alert_style: "specific",
33
- }.freeze,
34
- extension: {
35
- strikethrough: true,
36
- table: true,
37
- autolink: true,
38
- tasklist: true,
39
- superscript: false,
40
- header_ids: "",
41
- header_id_prefix_in_href: false,
42
- footnotes: false,
43
- inline_footnotes: false,
44
- description_lists: false,
45
- front_matter_delimiter: "",
46
- multiline_block_quotes: false,
47
- math_dollars: false,
48
- math_code: false,
49
- math_latex: false,
50
- shortcodes: true,
51
- wikilinks_title_before_pipe: false,
52
- wikilinks_title_after_pipe: false,
53
- underline: false,
54
- spoiler: false,
55
- greentext: false,
56
- subscript: false,
57
- subtext: false,
58
- alerts: false,
59
- cjk_friendly_emphasis: false,
60
- highlight: false,
61
- insert: false,
62
- block_directive: false,
63
- }.freeze,
64
- format: [:html].freeze,
65
- }.freeze
66
-
67
- PLUGINS = {
68
- syntax_highlighter: {
69
- theme: "base16-ocean.dark",
70
- path: "",
71
- }.freeze,
72
- }.freeze
73
-
74
- class << self
75
- include Commonmarker::Utils
76
-
77
- def process_options(options)
78
- {
79
- parse: process_parse_options(options[:parse].dup),
80
- render: process_render_options(options[:render].dup),
81
- extension: process_extension_options(options[:extension].dup),
82
- }
83
- end
84
-
85
- def process_plugins(plugins)
86
- {
87
- syntax_highlighter: process_syntax_highlighter_plugin(plugins&.fetch(:syntax_highlighter, nil)),
88
- }
89
- end
90
- end
91
-
92
- [:parse, :render, :extension].each do |type|
93
- define_singleton_method :"process_#{type}_options" do |options|
94
- Commonmarker::Config::OPTIONS[type].each_with_object({}) do |(key, value), hash|
95
- if options.nil? || !options.key?(key) # option not provided, use the default
96
- hash[key] = value
97
- next
98
- end
99
-
100
- if options[key].nil? # # option explicitly not included, remove it
101
- options.delete(key)
102
- next
103
- end
104
-
105
- hash[key] = fetch_kv(options, key, value, type)
106
- end
107
- end
108
- end
109
-
110
- define_singleton_method :process_syntax_highlighter_plugin do |options|
111
- return if options.nil? # plugin explicitly nil, remove it
112
-
113
- raise TypeError, "Expected a Hash for syntax_highlighter plugin, got #{options.class}" unless options.is_a?(Hash)
114
- raise TypeError, "Expected a Hash for syntax_highlighter plugin, got nothing" if options.empty?
115
-
116
- Commonmarker::Config::PLUGINS[:syntax_highlighter].merge(options)
117
- end
118
- end
119
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Commonmarker
4
- module Constants
5
- BOOLS = [true, false].freeze
6
- end
7
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "set"
4
- require "stringio"
5
-
6
- module Commonmarker
7
- class Renderer
8
- end
9
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "commonmarker/constants"
4
-
5
- module Commonmarker
6
- module Utils
7
- include Commonmarker::Constants
8
-
9
- def fetch_kv(options, key, value, type)
10
- value_klass = value.class
11
-
12
- if Constants::BOOLS.include?(value) && BOOLS.include?(options[key])
13
- options[key]
14
- elsif options[key].is_a?(value_klass)
15
- options[key]
16
- else
17
- expected_type = Constants::BOOLS.include?(value) ? "Boolean" : value_klass.to_s
18
- raise TypeError, "#{type} option `:#{key}` must be #{expected_type}; got #{options[key].class}"
19
- end
20
- end
21
- end
22
- end