From 7d38b3cb7552ec2096e7557adfa101b44b486560 Mon Sep 17 00:00:00 2001 From: maedana Date: Mon, 8 Jan 2024 10:43:57 +0900 Subject: [PATCH 1/3] upgrade github-linguist from 4.x to 7.x --- lib/qiita/markdown/filters/code_block.rb | 2 +- qiita-markdown.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/qiita/markdown/filters/code_block.rb b/lib/qiita/markdown/filters/code_block.rb index abdbe45..d10eed3 100644 --- a/lib/qiita/markdown/filters/code_block.rb +++ b/lib/qiita/markdown/filters/code_block.rb @@ -86,7 +86,7 @@ def has_only_filename? end def linguist_language - @linguist_language ||= Linguist::Language.find_by_filename(filename).first + @linguist_language ||= Linguist::Language.find_by_extension(filename).first end def sections diff --git a/qiita-markdown.gemspec b/qiita-markdown.gemspec index 88c5540..c981e73 100644 --- a/qiita-markdown.gemspec +++ b/qiita-markdown.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |spec| spec.add_dependency "addressable" spec.add_dependency "gemoji" - spec.add_dependency "github-linguist", "~> 4.0" + spec.add_dependency "github-linguist", "~> 7.0" spec.add_dependency "html-pipeline", "~> 2.0" spec.add_dependency "mem" spec.add_dependency "qiita_marker", "~> 0.23.9" From 8ac07087a85b46ccc0bb9efc3d52edde4244a0c9 Mon Sep 17 00:00:00 2001 From: nagaya Date: Fri, 5 Apr 2024 18:48:18 +0900 Subject: [PATCH 2/3] Add test for code_block filter --- .../qiita/markdown/filters/code_block_spec.rb | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 spec/qiita/markdown/filters/code_block_spec.rb diff --git a/spec/qiita/markdown/filters/code_block_spec.rb b/spec/qiita/markdown/filters/code_block_spec.rb new file mode 100644 index 0000000..3356a6f --- /dev/null +++ b/spec/qiita/markdown/filters/code_block_spec.rb @@ -0,0 +1,126 @@ +# frozen_string_literal: true + +describe Qiita::Markdown::Filters::CodeBlock do + subject(:filter) { described_class.new(input_html) } + + let(:context) { nil } + + context "without code" do + let(:input_html) do + <<~HTML +
+        
+ HTML + end + + it "does not change" do + expect(filter.call.to_s).to eq(input_html) + end + end + + context "with code" do + let(:input_html) do + <<~HTML +

+        
+ HTML + end + + it "does not change" do + expect(filter.call.to_s).to eq(input_html) + end + + context "with data-metadata" do + let(:input_html) do + <<~HTML +

+          
+ HTML + end + + it "does not change" do + expect(filter.call.to_s).to eq(input_html) + end + + context "with data-metadata value" do + let(:input_html) do + <<~HTML +

+            
+ HTML + end + + let(:output_html) do + <<~HTML +

+            
+ HTML + end + + it "adds lang on pre" do + expect(filter.call.to_s).to eq(output_html) + end + + context "with value include filename" do + let(:input_html) do + <<~HTML +

+              
+ HTML + end + + let(:output_html) do + <<~HTML +

+              
+ HTML + end + + it "adds lang and filename on pre" do + expect(filter.call.to_s).to eq(output_html) + end + end + end + + context "with data-metadata value like filename" do + let(:input_html) do + <<~HTML +

+            
+ HTML + end + + let(:output_html) do + <<~HTML +

+            
+ HTML + end + + it "adds lang and filename on pre" do + expect(filter.call.to_s).to eq(output_html) + end + end + + context "with data-metadata value like filename without extension" do + let(:input_html) do + <<~HTML +

+            
+ HTML + end + + let(:output_html) do + <<~HTML +

+            
+ HTML + end + + it "adds lang and filename on pre" do + expect(filter.call.to_s).to eq(output_html) + end + end + end + end +end From 45e868e8ebd0a3eb44ef0fa1731d222d7205b50f Mon Sep 17 00:00:00 2001 From: Umekawa Date: Wed, 10 Apr 2024 17:34:48 +0900 Subject: [PATCH 3/3] Release v1.1.2 --- CHANGELOG.md | 5 +++++ lib/qiita/markdown/version.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3bb80f..9cff6bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## Unreleased +## 1.1.2 + +- Add test for code_block filter +- Upgrade github-linguist from 4.x to 7.x + ## 1.1.1 - Allow open attribute on details diff --git a/lib/qiita/markdown/version.rb b/lib/qiita/markdown/version.rb index 0ea6658..6509f9d 100644 --- a/lib/qiita/markdown/version.rb +++ b/lib/qiita/markdown/version.rb @@ -1,5 +1,5 @@ module Qiita module Markdown - VERSION = "1.1.1" + VERSION = "1.1.2" end end