qiita-markdown 0.37.0 → 0.38.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: a632599e029a2372e999818df8cf19474233cdafe5b0454b944d6fe93d4423ca
4
- data.tar.gz: 6ee085f30d1b6008fe9ada38b62c91f6a7d5b68e0f656f20afdc69b5aa067c96
3
+ metadata.gz: f0133d912562a9dcb693c507e7ec0caadb6ca0c509da6af2c57773d87a2af745
4
+ data.tar.gz: 997e0e521830183eccc1f009634352379a7697a8a9e95edb9bae1a9d4f4f7c78
5
5
  SHA512:
6
- metadata.gz: a7d84a2dd88cd53380b8b7c5ec3264ae3cbcdf29c718031dfb9d22038d7349ffeaa2cba6e6a8654b3d357c4c7a28994fecdc51f8381cdbff276930a4238ab866
7
- data.tar.gz: 78bcee81ab1f08a311e7bf73f9bcbe6c79234c0ed999da679c285f10d69d482bf9c6e3373b2eb39896e2b8cdcd0890631539adf9fe6bfe69250f84ddcd1f4df1
6
+ metadata.gz: 44318b683d2df089695d572a037ec393c495dd23a3d48f82be77287165eff54d3e7d1fb68143f4ad7004eca337df8ed83cfcdd921de6fe7133aaaddeaffe7248
7
+ data.tar.gz: 883a123e2dad403e8da8d87457be977270ac7dad837e2502d873aa3208e024e2593d784ae0105923658243771d497232e6776a5011a4e354df995447d8fe7c49
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 0.38.0
4
+ - Change default syntax highlighter from pygments to rouge
5
+
3
6
  ## 0.37.0
4
7
  - Change keyword of notation
5
8
 
@@ -4,7 +4,7 @@ require "html/pipeline"
4
4
  require "linguist"
5
5
  require "mem"
6
6
  require "nokogiri"
7
- require "pygments"
7
+ require "rouge"
8
8
  require "sanitize"
9
9
 
10
10
  require "qiita/markdown/embed/code_pen"
@@ -4,6 +4,7 @@ module Qiita
4
4
  class SyntaxHighlight < HTML::Pipeline::Filter
5
5
  DEFAULT_LANGUAGE = "text"
6
6
  DEFAULT_TIMEOUT = Float::INFINITY
7
+ DEFAULT_OPTION = "html_legacy"
7
8
 
8
9
  def call
9
10
  elapsed = 0
@@ -79,11 +80,11 @@ module Qiita
79
80
  end
80
81
 
81
82
  def highlight(language)
82
- Pygments.highlight(code, lexer: language, options: pygments_options)
83
+ Rouge.highlight(code, language, DEFAULT_OPTION)
83
84
  end
84
85
 
85
86
  def highlighted_node
86
- if specific_language && Pygments::Lexer.find(specific_language)
87
+ if specific_language && Rouge::Lexer.find(specific_language)
87
88
  begin
88
89
  highlight(specific_language).presence or raise
89
90
  rescue
@@ -102,14 +103,6 @@ module Qiita
102
103
  Nokogiri::HTML.fragment(%Q[<div class="code-frame" data-lang="#{language}"></div>])
103
104
  end
104
105
 
105
- def pygments_options
106
- @pygments_options ||= begin
107
- options = { encoding: "utf-8", stripnl: false }
108
- options[:startinline] = true if has_inline_php?
109
- options
110
- end
111
- end
112
-
113
106
  def specific_language
114
107
  @specific_language || @node["lang"]
115
108
  end
@@ -1,5 +1,5 @@
1
1
  module Qiita
2
2
  module Markdown
3
- VERSION = "0.37.0"
3
+ VERSION = "0.38.0"
4
4
  end
5
5
  end
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency "github-linguist", "~> 4.0"
23
23
  spec.add_dependency "html-pipeline", "~> 2.0"
24
24
  spec.add_dependency "mem"
25
- spec.add_dependency "pygments.rb", "~> 1.0"
25
+ spec.add_dependency "rouge", "3.26.0"
26
26
  spec.add_dependency "greenmat", "3.5.1.2"
27
27
  spec.add_dependency "sanitize"
28
28
  spec.add_dependency "addressable"
@@ -149,8 +149,8 @@ describe Qiita::Markdown::Processor do
149
149
  should eq <<-HTML.strip_heredoc
150
150
  <div class="code-frame" data-lang="ruby">
151
151
  <div class="code-lang"><span class="bold">example.rb</span></div>
152
- <div class="highlight"><pre><span></span><span class="mi">1</span>
153
- </pre></div>
152
+ <div class="highlight"><pre class="codehilite"><code><span class="mi">1</span>
153
+ </code></pre></div>
154
154
  </div>
155
155
  HTML
156
156
  end
@@ -169,8 +169,8 @@ describe Qiita::Markdown::Processor do
169
169
  should eq <<-HTML.strip_heredoc
170
170
  <div class="code-frame" data-lang="php">
171
171
  <div class="code-lang"><span class="bold">example.php</span></div>
172
- <div class="highlight"><pre><span></span><span class="mi">1</span>
173
- </pre></div>
172
+ <div class="highlight"><pre class="codehilite"><code><span class="mi">1</span>
173
+ </code></pre></div>
174
174
  </div>
175
175
  HTML
176
176
  end
@@ -187,8 +187,8 @@ describe Qiita::Markdown::Processor do
187
187
 
188
188
  it "returns code-frame and highlighted pre element" do
189
189
  should eq <<-HTML.strip_heredoc
190
- <div class="code-frame" data-lang="ruby"><div class="highlight"><pre><span></span><span class="mi">1</span>
191
- </pre></div></div>
190
+ <div class="code-frame" data-lang="ruby"><div class="highlight"><pre class="codehilite"><code><span class="mi">1</span>
191
+ </code></pre></div></div>
192
192
  HTML
193
193
  end
194
194
  end
@@ -226,10 +226,10 @@ describe Qiita::Markdown::Processor do
226
226
 
227
227
  it "does not strip the newlines" do
228
228
  should eq <<-HTML.strip_heredoc
229
- <div class="code-frame" data-lang="text"><div class="highlight"><pre><span></span>
229
+ <div class="code-frame" data-lang="text"><div class="highlight"><pre class="codehilite"><code>
230
230
  foo
231
231
 
232
- </pre></div></div>
232
+ </code></pre></div></div>
233
233
  HTML
234
234
  end
235
235
  end
@@ -311,8 +311,8 @@ describe Qiita::Markdown::Processor do
311
311
  should include(<<-HTML.strip_heredoc.rstrip)
312
312
  <div class="code-frame" data-lang="ruby">
313
313
  <div class="code-lang"><span class="bold">@alice</span></div>
314
- <div class="highlight"><pre><span></span><span class="mi">1</span>
315
- </pre></div>
314
+ <div class="highlight"><pre class="codehilite"><code><span class="mi">1</span>
315
+ </code></pre></div>
316
316
  </div>
317
317
  HTML
318
318
  end
@@ -659,9 +659,9 @@ describe Qiita::Markdown::Processor do
659
659
 
660
660
  it "does not replace checkbox" do
661
661
  should eq <<-HTML.strip_heredoc
662
- <div class="code-frame" data-lang="text"><div class="highlight"><pre><span></span>- [ ] a
662
+ <div class="code-frame" data-lang="text"><div class="highlight"><pre class="codehilite"><code>- [ ] a
663
663
  - [x] b
664
- </pre></div></div>
664
+ </code></pre></div></div>
665
665
  HTML
666
666
  end
667
667
  end
@@ -768,9 +768,9 @@ describe Qiita::Markdown::Processor do
768
768
 
769
769
  it "generates only code blocks without footnotes" do
770
770
  should eq <<-HTML.strip_heredoc
771
- <div class="code-frame" data-lang="text"><div class="highlight"><pre><span></span>[^1]
771
+ <div class="code-frame" data-lang="text"><div class="highlight"><pre class="codehilite"><code>[^1]
772
772
  [^1]: test
773
- </pre></div></div>
773
+ </code></pre></div></div>
774
774
  HTML
775
775
  end
776
776
  end
@@ -1067,8 +1067,8 @@ describe Qiita::Markdown::Processor do
1067
1067
  expect(subject).to eq <<-HTML.strip_heredoc
1068
1068
  <p><details><summary>Folding sample</summary><div>
1069
1069
 
1070
- <div class="code-frame" data-lang="rb"><div class="highlight"><pre><span></span><span class="nb">puts</span> <span class="s2">"Hello, World"</span>
1071
- </pre></div></div>
1070
+ <div class="code-frame" data-lang="rb"><div class="highlight"><pre class="codehilite"><code><span class="nb">puts</span> <span class="s2">"Hello, World"</span>
1071
+ </code></pre></div></div>
1072
1072
 
1073
1073
  <p></p>
1074
1074
  </div></details></p>
@@ -1124,8 +1124,8 @@ describe Qiita::Markdown::Processor do
1124
1124
  should eq <<-HTML.strip_heredoc
1125
1125
  <div class="code-frame" data-lang="js">
1126
1126
  <div class="code-lang"><span class="bold">test<script>alert(1)</script></span></div>
1127
- <div class="highlight"><pre><span></span><span class="mi">1</span>
1128
- </pre></div>
1127
+ <div class="highlight"><pre class="codehilite"><code><span class="mi">1</span>
1128
+ </code></pre></div>
1129
1129
  </div>
1130
1130
  HTML
1131
1131
  end
@@ -1134,8 +1134,8 @@ describe Qiita::Markdown::Processor do
1134
1134
  should eq <<-HTML.strip_heredoc
1135
1135
  <div class="code-frame" data-lang="js">
1136
1136
  <div class="code-lang"><span class="bold">test</span></div>
1137
- <div class="highlight"><pre><span></span><span class="mi">1</span>
1138
- </pre></div>
1137
+ <div class="highlight"><pre class="codehilite"><code><span class="mi">1</span>
1138
+ </code></pre></div>
1139
1139
  </div>
1140
1140
  HTML
1141
1141
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qiita-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.37.0
4
+ version: 0.38.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
@@ -67,19 +67,19 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: pygments.rb
70
+ name: rouge
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: '1.0'
75
+ version: 3.26.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: '1.0'
82
+ version: 3.26.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: greenmat
85
85
  requirement: !ruby/object:Gem::Requirement