mato 2.1.4 → 2.2.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: 07f98ac00c95a368f2a81c27f5a44db4cbda10822f277e9ab95d3dced807dd7d
4
- data.tar.gz: f1d1bd02baf2fa8facd9237f484b4fbfd555fcaf0629da7847c7eaba1cc80b8a
3
+ metadata.gz: d94a4026d7fadd8bc561d9489f2a89238ce6b4100e4e8d887832be86304feb33
4
+ data.tar.gz: fb26a18fa1f92dfc655f2b53a5aac5af2b3fe945bf2a42cbc8c0966d8f964044
5
5
  SHA512:
6
- metadata.gz: 6ee8be2d2dd1044edd529505aa336cadbfd4d472444d782427872e27bc39ae4b8b3bdbe236ff8507c33786ab5af42da07469dc9dc5f654a0b9464f2f2b6afb1a
7
- data.tar.gz: e69736d4e45aab72a7607fcc0ba15f3a5d4a5534d2e2efb537010de14517cbc69fdee2a0b9a64c06d841c19c11cea48ee48e5a8f743946f3e6bd8a333eaac537
6
+ metadata.gz: d698ea373d885e1c9716077dffd1aefc50426c398b68038c288e83f05fb016f26aa1302a1fc93447ec9d8c1b409f2c6f03e2474315075cfdb6e72037c20dfb1a
7
+ data.tar.gz: c39ed1a90becdb01f2d3b8447b67b79f3ce6efa8dcfbfce39d4c4c5d7e315ae69941655ff0d831829e955b6fd0102db592923501354c6cc74208f3065b8926ad
@@ -1,11 +1,16 @@
1
1
  # See also https://github.com/onk/onkcop/blob/master/config/rubocop.yml
2
+ require:
3
+ - rubocop-performance
2
4
 
3
5
  AllCops:
4
- TargetRubyVersion: 2.3
6
+ TargetRubyVersion: 2.4
5
7
  DisplayCopNames: true
6
8
  Exclude:
7
9
  - bin/**/*
8
10
 
11
+ Metrics:
12
+ Enabled: false
13
+
9
14
  Lint/UnusedBlockArgument:
10
15
  Enabled: false
11
16
 
@@ -21,31 +26,7 @@ Layout/MultilineMethodCallIndentation:
21
26
  Layout/EmptyLinesAroundClassBody:
22
27
  Enabled: false
23
28
 
24
- Metrics/AbcSize:
25
- Max: 35
26
-
27
- Metrics/PerceivedComplexity:
28
- Max: 10
29
-
30
- Metrics/CyclomaticComplexity:
31
- Max: 10
32
-
33
- Metrics/ClassLength:
34
- Enabled: false
35
-
36
- Metrics/BlockLength:
37
- Enabled: false
38
-
39
- Metrics/LineLength:
40
- Enabled: false
41
-
42
- Metrics/MethodLength:
43
- Max: 45
44
-
45
- Metrics/ModuleLength:
46
- Enabled: false
47
-
48
- Metrics/ParameterLists:
29
+ Layout/LineLength:
49
30
  Enabled: false
50
31
 
51
32
  Style/RescueStandardError:
@@ -63,6 +44,12 @@ Style/Documentation:
63
44
  Naming/FileName:
64
45
  Enabled: false
65
46
 
47
+ Naming/MethodParameterName:
48
+ Enabled: false
49
+
50
+ Naming/RescuedExceptionsVariableName:
51
+ Enabled: false
52
+
66
53
  Style/GuardClause:
67
54
  Enabled: false
68
55
 
@@ -120,6 +107,9 @@ Style/AsciiComments:
120
107
  Style/EmptyMethod:
121
108
  EnforcedStyle: expanded
122
109
 
110
+ Style/RaiseArgs:
111
+ Enabled: false
112
+
123
113
  Naming/VariableNumber:
124
114
  Enabled: false
125
115
 
@@ -146,3 +136,20 @@ Style/NonNilCheck:
146
136
 
147
137
  Performance/RedundantBlockCall:
148
138
  Enabled: false
139
+
140
+ # Configure pending cops
141
+
142
+ Layout/SpaceAroundMethodCallOperator:
143
+ Enabled: true
144
+ Lint/RaiseException:
145
+ Enabled: true
146
+ Lint/StructNewOverride:
147
+ Enabled: true
148
+ Style/ExponentialNotation:
149
+ Enabled: true
150
+ Style/HashEachMethods:
151
+ Enabled: true
152
+ Style/HashTransformKeys:
153
+ Enabled: true
154
+ Style/HashTransformValues:
155
+ Enabled: true
@@ -1,10 +1,9 @@
1
- sudo: false
2
1
  language: ruby
3
2
  rvm:
4
- - 2.3
5
3
  - 2.4
6
4
  - 2.5
7
5
  - 2.6
6
+ - 2.7
8
7
  - ruby-head
9
8
 
10
9
  matrix:
@@ -1,5 +1,12 @@
1
1
  # The revision history of Mato
2
2
 
3
+ ## v2.2.0 - 2020/05/08
4
+
5
+ https://github.com/bitjourney/mato/compare/v2.1.4...v2.2.0
6
+
7
+ * Display code block as plan text if Rouge raises an error [#21](https://github.com/bitjourney/mato/pull/21)
8
+
9
+
3
10
  ## v2.1.4 - 2019/4/11
4
11
 
5
12
  https://github.com/bitjourney/mato/compare/v2.1.3...v2.1.4
data/Gemfile CHANGED
@@ -12,4 +12,6 @@ gem "m"
12
12
  gem "minitest"
13
13
  gem "minitest-power_assert"
14
14
  gem "rake", ">= 10.0"
15
- gem "rubocop"
15
+ gem 'rr'
16
+ gem "rubocop", '>= 0.78.0'
17
+ gem 'rubocop-performance'
@@ -5,6 +5,12 @@
5
5
  module Mato
6
6
  module HtmlFilters
7
7
  class SyntaxHighlight
8
+ class RougeError < StandardError
9
+ end
10
+
11
+ def initialize(on_rouge_error: ->(ex) { warn ex })
12
+ @on_rouge_error = on_rouge_error
13
+ end
8
14
 
9
15
  # @param [Nokogiri::HTML::DocumentFragment] doc
10
16
  def call(doc)
@@ -57,11 +63,21 @@ module Mato
57
63
 
58
64
  lexer = guess_lexer(language, filename, source)
59
65
 
60
- document = Nokogiri::HTML.fragment(%{<div class="code-frame"/>})
61
-
62
- div = document.at('div')
63
- div.add_child(label_fragment(filename || language || lexer.tag)) if filename || !lexer.is_a?(Rouge::Lexers::PlainText)
64
- div.add_child(%{<pre class="highlight"><code data-lang="#{lexer.tag}">#{format(lexer, source)}</code></pre>})
66
+ begin
67
+ document = Nokogiri::HTML.fragment(%{<div class="code-frame"/>})
68
+ div = document.at('div')
69
+ div.add_child(label_fragment(filename || language || lexer.tag)) if filename || !lexer.is_a?(Rouge::Lexers::PlainText)
70
+ div.add_child(%{<pre class="highlight"><code data-lang="#{lexer.tag}">#{format(lexer, source)}</code></pre>})
71
+ rescue => ex
72
+ if ex.is_a?(RougeError) && !lexer.is_a?(Rouge::Lexers::PlainText)
73
+ # Retry highlighting with PlainText lexer if Rouge raises an error.
74
+ # It avoids to affect the error to whole of converting.
75
+ lexer = Rouge::Lexers::PlainText.new
76
+ retry
77
+ else
78
+ raise ex
79
+ end
80
+ end
65
81
 
66
82
  document
67
83
  end
@@ -79,6 +95,9 @@ module Mato
79
95
  def format(lexer, source)
80
96
  tokens = lexer.lex(source)
81
97
  formatter.format(tokens)
98
+ rescue => ex
99
+ @on_rouge_error.call(ex)
100
+ raise RougeError.new
82
101
  end
83
102
  end
84
103
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mato
4
- VERSION = "2.1.4"
4
+ VERSION = "2.2.0"
5
5
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.required_ruby_version = ">= 2.3"
23
+ spec.required_ruby_version = ">= 2.4"
24
24
 
25
25
  spec.add_runtime_dependency "commonmarker", ">= 0.18.1"
26
26
  spec.add_runtime_dependency "nokogiri", ">= 1.6"
@@ -0,0 +1,4 @@
1
+ linter:
2
+ rubocop:
3
+ gems:
4
+ - "rubocop-performance"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mato
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.4
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - FUJI Goro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-11 00:00:00.000000000 Z
11
+ date: 2020-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commonmarker
@@ -89,6 +89,7 @@ files:
89
89
  - lib/mato/timeout.rb
90
90
  - lib/mato/version.rb
91
91
  - mato.gemspec
92
+ - sider.yml
92
93
  homepage: https://github.com/bitjourney/mato
93
94
  licenses:
94
95
  - MIT
@@ -101,14 +102,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
102
  requirements:
102
103
  - - ">="
103
104
  - !ruby/object:Gem::Version
104
- version: '2.3'
105
+ version: '2.4'
105
106
  required_rubygems_version: !ruby/object:Gem::Requirement
106
107
  requirements:
107
108
  - - ">="
108
109
  - !ruby/object:Gem::Version
109
110
  version: '0'
110
111
  requirements: []
111
- rubygems_version: 3.0.1
112
+ rubygems_version: 3.2.0.pre1
112
113
  signing_key:
113
114
  specification_version: 4
114
115
  summary: MArkdown TOolkit