mato 2.4.0 → 2.5.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: a0009a682500eef0ba90fc7166044321a21e0dc8cde9e290938466d81e5d93a9
4
- data.tar.gz: 44dfea37fc148c34c423d91d496316618f24d911dbc340ebba691cd17632a980
3
+ metadata.gz: 8fcbd9aeee5b4c9a0c3a8a101a876fcb403bae92926a0e2c5d9ca0a56295a37e
4
+ data.tar.gz: 2ba4fbdb19c68bb02ed208b6787cb09c9992e31ebbbdd78c3e8f410007084bf1
5
5
  SHA512:
6
- metadata.gz: 703fb8e5f8132eb78887d30d8245c0738ff8b5e14e4662bef1e6f572571429465472b18fe853e3ac58ee1d15f87ef32460f6f2bc716db44e568ffdccd8bd02c1
7
- data.tar.gz: 265481153e3404d01049e6f79550573839024095597168180c6310a8bbc8d9b2ed491dad9723fee3a4d57ca38888b64341c173054c8418ae1eb04497cfc9802a
6
+ metadata.gz: 399ce3de0b8f7e4436c12f8275e40623fb7551ffec521a294d7a807b3d6f2756718bb7cdcf8fb145bd345a50c5c5769bf985d55170596b79fed8a48bca56f29d
7
+ data.tar.gz: 59208ddcb81a19f1cb356715cda80fabdc30e1476c728ac3b8f3ed2ba219b179a1e6a0e21b109f162294fb16231a34bef36034b4be120bcf0a2ce316ef180a9e
@@ -0,0 +1 @@
1
+ dummy
@@ -0,0 +1,41 @@
1
+ name: ReviewDog
2
+ on:
3
+ pull_request:
4
+
5
+ permissions:
6
+ contents: read
7
+ pull-requests: write
8
+
9
+ jobs:
10
+ rubocop:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - name: Use ruby
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: '3.1'
20
+
21
+ - name: rubocop
22
+ uses: reviewdog/action-rubocop@v2
23
+ with:
24
+ rubocop_version: gemfile
25
+ rubocop_extensions: rubocop-performance:gemfile
26
+ github_token: ${{ secrets.GITHUB_TOKEN }}
27
+ reporter: github-pr-review
28
+ fail_on_error: true
29
+
30
+ detect-secrets:
31
+ runs-on: ubuntu-latest
32
+ if: ${{ !contains(github.head_ref, 'dependabot') }}
33
+
34
+ steps:
35
+ - uses: actions/checkout@v3
36
+
37
+ - name: detect-secrets
38
+ uses: reviewdog/action-detect-secrets@master
39
+ with:
40
+ reporter: github-pr-review
41
+ detect_secrets_flags: --all-files --force-use-all-plugins --word-list .github/workflows/detect-secrets-wordlist.txt
@@ -0,0 +1,23 @@
1
+ name: RubyTest
2
+
3
+ on:
4
+ pull_request:
5
+
6
+ permissions:
7
+ contents: read
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby-version: ["3.1", "3.2", "3.3"]
15
+ steps:
16
+ - uses: actions/checkout@v3
17
+ - name: Set up Ruby
18
+ uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: ${{ matrix.ruby-version }}
21
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
22
+ - name: Run tests
23
+ run: bundle exec rake test
data/.rubocop.yml CHANGED
@@ -3,7 +3,7 @@ require:
3
3
  - rubocop-performance
4
4
 
5
5
  AllCops:
6
- TargetRubyVersion: 2.7
6
+ TargetRubyVersion: 3.1
7
7
  DisplayCopNames: true
8
8
  Exclude:
9
9
  - bin/**/*
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # The revision history of Mato
2
2
 
3
+ ## v2.5.0 - 2024/05/07
4
+
5
+ https://github.com/bitjourney/mato/compare/v2.4.0...v2.5.0
6
+
7
+ * Bump up commonmarker to 1.0
8
+
3
9
  ## v2.4.0 - 2021/08/25
4
10
 
5
11
  https://github.com/bitjourney/mato/compare/v2.3.2...v2.4.0
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Mato [![Build Status](https://travis-ci.org/bitjourney/mato.svg?branch=master)](https://travis-ci.org/bitjourney/mato) [![Gem Version](https://badge.fury.io/rb/mato.svg)](https://badge.fury.io/rb/mato)
1
+ # Mato [![Gem Version](https://badge.fury.io/rb/mato.svg)](https://badge.fury.io/rb/mato)
2
2
 
3
3
  **Mato**, standing for **Ma**rkdown **To**oolkit, is an extensible, pipeline-based markdown processing toolkit, inspired by [HTML::Pipeline](https://github.com/jch/html-pipeline).
4
4
 
@@ -89,7 +89,7 @@ mato.process("Hello!").render_html # "<p>HELLO!</p>\n"
89
89
 
90
90
  ### Markdown Filters
91
91
 
92
- A markdown filter is a callable instance that takes a ``CommonMarker::Node`
92
+ A markdown filter is a callable instance that takes a ``Commonmarker::Node`
93
93
  and mutate it in the method. The return value is ignored.
94
94
 
95
95
  For example:
@@ -189,4 +189,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/bitjou
189
189
  ## License
190
190
 
191
191
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
192
-
data/lib/mato/config.rb CHANGED
@@ -6,29 +6,21 @@ require 'nokogiri'
6
6
 
7
7
  module Mato
8
8
  class Config
9
- # https://github.com/gjtorikian/commonmarker#parse-options
10
- DEFAULT_MARKDOWN_PARSE_OPTIONS = %i[
11
- DEFAULT
12
- VALIDATE_UTF8
13
- FOOTNOTES
14
- ].freeze
15
-
16
- # https://github.com/gjtorikian/commonmarker#render-options
17
- DEFAULT_MARKDOWN_RENDER_OPTIONS = [
18
- :DEFAULT,
19
- :HARDBREAKS, # convert "\n" as <br/>
20
- :TABLE_PREFER_STYLE_ATTRIBUTES,
21
- :UNSAFE,
22
- # :SOURCEPOS, // TODO: enable it after assertions are supported
23
- ].freeze
24
-
25
- # https://github.com/github/cmark/tree/master/extensions
26
- DEFAULT_MARKDOWN_EXTENSIONS = %i[
27
- table
28
- strikethrough
29
- autolink
30
- tagfilter
31
- ].freeze
9
+ DEFAULT_MARKDOWN_OPTIONS = {
10
+ render: {
11
+ hardbreaks: true,
12
+ unsafe: true,
13
+ },
14
+ extension: {
15
+ table: true,
16
+ strikethrough: true,
17
+ autolink: true,
18
+ tagfilter: true,
19
+ tasklist: false,
20
+ shortcodes: false,
21
+ footnotes: true,
22
+ },
23
+ }.freeze
32
24
 
33
25
  # @return [Array<Proc>]
34
26
  attr_accessor :text_filters
@@ -39,7 +31,7 @@ module Mato
39
31
  # @return [Array<Proc>]
40
32
  attr_accessor :html_filters
41
33
 
42
- # @return [Class<CommonMarker]
34
+ # @return [Class<Commonmarker]
43
35
  attr_accessor :markdown_parser
44
36
 
45
37
  # @return [Cass<Nokogiri::HTML4::DocumentFragment>]
@@ -48,28 +40,20 @@ module Mato
48
40
  # @return [Class<Mato::Document>]
49
41
  attr_accessor :document_factory
50
42
 
51
- # @return [Array<Symbol>] CommonMarker's parse extensions
52
- attr_accessor :markdown_extensions
53
-
54
- # @return [Array<Symbol>] CommonMarker's pars options
55
- attr_accessor :markdown_parse_options
56
-
57
- # @return [Array<Symbol>] CommonMarker's HTML rendering options
58
- attr_accessor :markdown_render_options
43
+ # @return [Hash] Commonmarker's options
44
+ attr_accessor :markdown_options
59
45
 
60
46
  def initialize
61
47
  @text_filters = []
62
48
  @markdown_filters = []
63
49
  @html_filters = []
64
50
 
65
- @markdown_parser = CommonMarker
51
+ @markdown_parser = Commonmarker
66
52
  @html_parser = Nokogiri::HTML4::DocumentFragment
67
53
 
68
54
  @document_factory = Document
69
55
 
70
- @markdown_extensions = DEFAULT_MARKDOWN_EXTENSIONS
71
- @markdown_parse_options = DEFAULT_MARKDOWN_PARSE_OPTIONS
72
- @markdown_render_options = DEFAULT_MARKDOWN_RENDER_OPTIONS
56
+ @markdown_options = DEFAULT_MARKDOWN_OPTIONS
73
57
  end
74
58
 
75
59
  # @param [Proc] block
@@ -29,7 +29,7 @@ module Mato
29
29
  end
30
30
 
31
31
  def run
32
- # @type [CommonMarker::Node]
32
+ # @type [Commonmarker::Node]
33
33
  document = processor.parse_markdown(content)
34
34
 
35
35
  convert_headings!(document)
@@ -45,14 +45,14 @@ module Mato
45
45
  def convert_headings!(document)
46
46
  document.walk.select do |node|
47
47
  node.type == :text &&
48
- node.sourcepos[:start_column] == 1 &&
48
+ node.source_position[:start_column] == 1 &&
49
49
  node.parent.type == :paragraph &&
50
50
  node.parent.parent.type == :document
51
51
  end.reverse_each do |node|
52
52
  replacement = node.string_content.gsub(/\A(#+)(?=\S)/, '\1 ')
53
53
 
54
54
  if node.string_content != replacement
55
- pos = node.sourcepos
55
+ pos = node.source_position
56
56
  content_lines[pos[:start_line] - 1][(pos[:start_column] - 1)...pos[:end_column]] = replacement
57
57
  end
58
58
  end
@@ -43,15 +43,15 @@ module Mato
43
43
  end
44
44
 
45
45
  # @param [String] text
46
- # @return [CommonMarker::Node]
46
+ # @return [Commonmarker::Node]
47
47
  def parse_markdown(text)
48
- config.markdown_parser.render_doc(text, config.markdown_parse_options, config.markdown_extensions)
48
+ config.markdown_parser.parse(text, options: config.markdown_options)
49
49
  end
50
50
 
51
- # @param [CommonMarker::Node] markdown_node
51
+ # @param [Commonmarker::Node] markdown_node
52
52
  # @return [String]
53
53
  def render_to_html(markdown_node)
54
- markdown_node.to_html(config.markdown_render_options)
54
+ markdown_node.to_html(options: config.markdown_options)
55
55
  end
56
56
 
57
57
  # @param [String] html
data/lib/mato/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mato
4
- VERSION = "2.4.0"
4
+ VERSION = "2.5.0"
5
5
  end
data/mato.gemspec CHANGED
@@ -25,9 +25,9 @@ Gem::Specification.new do |spec|
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ["lib"]
27
27
 
28
- spec.required_ruby_version = ">= 2.7"
28
+ spec.required_ruby_version = "~> 3.1"
29
29
 
30
- spec.add_runtime_dependency "commonmarker", ">= 0.18.1"
30
+ spec.add_runtime_dependency "commonmarker", "~> 1.0"
31
31
  spec.add_runtime_dependency "nokogiri", ">= 1.12"
32
32
  spec.add_runtime_dependency "rouge", ">= 3.0.0"
33
33
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mato
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - FUJI Goro
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-26 00:00:00.000000000 Z
11
+ date: 2024-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commonmarker
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.18.1
19
+ version: '1.0'
20
20
  type: :runtime
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: 0.18.1
26
+ version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -59,9 +59,11 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - ".github/workflows/detect-secrets-wordlist.txt"
63
+ - ".github/workflows/reviewdog.yml"
64
+ - ".github/workflows/ruby_test.yml"
62
65
  - ".gitignore"
63
66
  - ".rubocop.yml"
64
- - ".travis.yml"
65
67
  - CHANGELOG.md
66
68
  - Gemfile
67
69
  - LICENSE.txt
@@ -89,7 +91,6 @@ files:
89
91
  - lib/mato/timeout.rb
90
92
  - lib/mato/version.rb
91
93
  - mato.gemspec
92
- - sider.yml
93
94
  homepage: https://github.com/bitjourney/mato
94
95
  licenses:
95
96
  - MIT
@@ -98,23 +99,23 @@ metadata:
98
99
  source_code_uri: https://github.com/bitjourney/mato
99
100
  changelog_uri: https://github.com/bitjourney/mato/blob/master/CHANGELOG.md
100
101
  bug_tracker_uri: https://github.com/bitjourney/mato/issues
101
- post_install_message:
102
+ post_install_message:
102
103
  rdoc_options: []
103
104
  require_paths:
104
105
  - lib
105
106
  required_ruby_version: !ruby/object:Gem::Requirement
106
107
  requirements:
107
- - - ">="
108
+ - - "~>"
108
109
  - !ruby/object:Gem::Version
109
- version: '2.7'
110
+ version: '3.1'
110
111
  required_rubygems_version: !ruby/object:Gem::Requirement
111
112
  requirements:
112
113
  - - ">="
113
114
  - !ruby/object:Gem::Version
114
115
  version: '0'
115
116
  requirements: []
116
- rubygems_version: 3.1.2
117
- signing_key:
117
+ rubygems_version: 3.3.26
118
+ signing_key:
118
119
  specification_version: 4
119
120
  summary: MArkdown TOolkit
120
121
  test_files: []
data/.travis.yml DELETED
@@ -1,15 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.7
4
- - 3.0
5
- - ruby-head
6
-
7
- matrix:
8
- allow_failures:
9
- - rvm: ruby-head
10
-
11
- cache: bundler
12
- before_install: gem install bundler
13
- notifications:
14
- slack:
15
- secure: W/CuFdMffK19NqZ7hX5Cx1ekLwY5WYtyi91CgYJ5jUYZq6hY7sZAHItfvbB7kwVc5vGzDVzBp1L4+iR44OX1+3sbJQ8OHUfWNksRME5NAHeHKUnkeoMAToTy6gv8GTSDOkBoMxgtZQQwaFFxOVQF4UknLCKvwz1JRBf3zjEG7zyKlBQuYSkMQQm4xA/qmgb6nCAqSzMJxN4Gl57LKphCScKO5ZK6hUuaJv4H6y3NfDbKAEwidEUaMqnU1TtLTkqhSqVve/JMlBoynYFIezBu7R35cyHFdE8l1OaYFvIJo6nsyRZr9RVhp20wlLyL2dsM4IUBTfLf1dCw94U8VE3cCkYEh7MxQv/NAkDpkBsI9E4GGOfmuXRxcoQGoKRI9GHleg8hm/E39134JhVKNL2L5RGg/8ULNPPrQjMf0GWSxhtqBXN7vzuP4ZfAMzEDDGFehCmmzrE5qIdcRwXCI3+QRX7XAWL+Ql+xljoxZjl2f7wHSx3COChkol0V8CEGAyOTJc3qnci5jPs5mSByqv3RyO0meYiJCJ1Ce2FTjCOHs1G9D58xfra6AVA8FmOk43+iN8QZyUIqd+MsenL2k89LqMijoC208xI6WI88C9tMHDA8tmi8yJt6PA00emC+Gzy9xPCYsZ+dZhymOPDcAbBlez+j3weEEDROF0Jlewt4X8Q=
data/sider.yml DELETED
@@ -1,4 +0,0 @@
1
- linter:
2
- rubocop:
3
- gems:
4
- - "rubocop-performance"