qiita-markdown 1.1.2 → 1.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee1e7e37115360196ad00fb3c77a2c5857c46e3e201214df367d39d6f122347c
4
- data.tar.gz: 3225e9cc689488509a74fef7884bacd84a769ec8b0917c2680d09a47b82ee765
3
+ metadata.gz: 57d4cba4cba7c841c19fd9e3a0933d5920f827a79acdf8bb38f511b49386282d
4
+ data.tar.gz: 389ed7716950987f76db86e1a48964f3f8c59709f45479dfe15f42cb72d657d9
5
5
  SHA512:
6
- metadata.gz: c177b38026f17c092ac7c5896bfdf09392073a130528fa7a20917fbd859fe60bf7e68f310a1720a57d75a2e5cdf2674ed57d5d5edb23173ad0233fc15bd62115
7
- data.tar.gz: 151b887bad5f642f217e710b24c0789035c4fce9c2e44e7bd99c0b34c46eea5d6c852c02a88031ec0f20877bc83a09d4ee39fd685bf5477585798eb058639c9a
6
+ metadata.gz: f811fabd2edaccff2c12d2acb74d3c40af82279a539da45b2c3a4c3362a1ac0dc7320e84ba680c4d3cbc4519eb18a3a4f50ac8308116d0064547a99abddb9fa7
7
+ data.tar.gz: bf449e8687ce87e0e7b0b0fc7582c81fb5775a1ecb2a741443cfea6efa5cb795a96d2a41f528eb7b6ff669a8e862f654b2baa5799d3299e48e0c78a89e1b8f0b
@@ -0,0 +1,5 @@
1
+ # package-ecosystem: bundler, directories: /
2
+ /Gemfile @increments/qiita-dev-group
3
+
4
+ # package-ecosystem: github-actions, directories: /
5
+ /.github/workflows @increments/qiita-dev-group
@@ -0,0 +1,22 @@
1
+ version: 2
2
+ updates:
3
+
4
+ - package-ecosystem: "bundler"
5
+ directories:
6
+ - "/"
7
+ schedule:
8
+ interval: "daily"
9
+ time: "14:00"
10
+ timezone: "Asia/Tokyo"
11
+ open-pull-requests-limit: 5
12
+ rebase-strategy: "disabled"
13
+
14
+ - package-ecosystem: "github-actions"
15
+ directories:
16
+ - "/"
17
+ schedule:
18
+ interval: "daily"
19
+ time: "14:00"
20
+ timezone: "Asia/Tokyo"
21
+ open-pull-requests-limit: 5
22
+ rebase-strategy: "disabled"
@@ -0,0 +1,22 @@
1
+ name: Release
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ jobs:
7
+ release:
8
+ runs-on: ubuntu-latest
9
+
10
+ environment: release
11
+
12
+ permissions:
13
+ id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
14
+ contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
15
+
16
+ steps:
17
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
18
+ - uses: ruby/setup-ruby@a4effe49ee8ee5b8b5091268c473a4628afb5651 # v1.245.0
19
+ with:
20
+ ruby-version: 3.4.4 # Latest stable Ruby for release builds
21
+ bundler-cache: true
22
+ - uses: rubygems/release-gem@a25424ba2ba8b387abc8ef40807c2c85b96cbe32 # v1.1.1
@@ -16,15 +16,15 @@ jobs:
16
16
  steps:
17
17
  - name: Get branch names
18
18
  id: branch-name
19
- uses: tj-actions/branch-names@v7.0.7
20
- - uses: actions/checkout@v3
21
- - uses: ruby/setup-ruby@v1
19
+ uses: tj-actions/branch-names@dde14ac574a8b9b1cedc59a1cf312788af43d8d8 # v8.2.1
20
+ - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
21
+ - uses: ruby/setup-ruby@13e7a03dc3ac6c3798f4570bfead2aed4d96abfb # v1.244.0
22
22
  with:
23
- ruby-version: '3.0'
23
+ ruby-version: '3.2'
24
24
  bundler-cache: true
25
25
  - name: Test & publish code coverage
26
26
  if: "${{ env.CC_TEST_REPORTER_ID != '' }}"
27
- uses: paambaati/codeclimate-action@v2.7.5
27
+ uses: paambaati/codeclimate-action@7bcf9e73c0ee77d178e72c0ec69f1a99c1afc1f3 # v2.7.5
28
28
  env:
29
29
  CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
30
30
  GIT_BRANCH: ${{ steps.branch-name.outputs.current_branch }}
@@ -37,7 +37,7 @@ jobs:
37
37
  fail-fast: false
38
38
  matrix:
39
39
  os: ['ubuntu-latest', 'macos-latest']
40
- ruby: ['3.0', '3.1']
40
+ ruby: ['3.2', '3.3', '3.4']
41
41
  experimental: [false]
42
42
  include:
43
43
  - os: 'ubuntu-latest'
@@ -46,8 +46,8 @@ jobs:
46
46
  runs-on: ${{ matrix.os }}
47
47
  continue-on-error: ${{ matrix.experimental }}
48
48
  steps:
49
- - uses: actions/checkout@v3
50
- - uses: ruby/setup-ruby@v1
49
+ - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
50
+ - uses: ruby/setup-ruby@13e7a03dc3ac6c3798f4570bfead2aed4d96abfb # v1.244.0
51
51
  with:
52
52
  ruby-version: ${{ matrix.ruby }}
53
53
  bundler-cache: true
data/.rubocop.yml CHANGED
@@ -3,9 +3,16 @@ inherit_from: .rubocop_todo.yml
3
3
  AllCops:
4
4
  NewCops: enable
5
5
 
6
+ Layout/LineLength:
7
+ Enabled: false
8
+
6
9
  Metrics/ClassLength:
7
10
  Enabled: false
8
11
 
12
+ Naming/PredicatePrefix:
13
+ ForbiddenPrefixes:
14
+ - is_
15
+
9
16
  Style/Documentation:
10
17
  Enabled: false
11
18
 
@@ -15,10 +22,6 @@ Style/EmptyCaseCondition:
15
22
  Style/GuardClause:
16
23
  Enabled: false
17
24
 
18
- Style/PredicateName:
19
- ForbiddenPrefixes:
20
- - is_
21
-
22
25
  Style/StringLiterals:
23
26
  EnforcedStyle: double_quotes
24
27
 
@@ -34,9 +37,6 @@ Style/TrailingCommaInArrayLiteral:
34
37
  Style/RedundantPercentQ:
35
38
  Enabled: false
36
39
 
37
- Metrics/LineLength:
38
- Enabled: false
39
-
40
40
  Metrics/BlockLength:
41
41
  Exclude:
42
42
  - qiita-markdown.gemspec
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 1.3.0
4
+
5
+ - Support embedding new iframes
6
+ - Google Drive
7
+ - StackBlitz
8
+
9
+ ## 1.2.0
10
+
11
+ - Accept new codepen script url (public.codepenassets.com)
12
+
3
13
  ## 1.1.2
4
14
 
5
15
  - Add test for code_block filter
data/Gemfile CHANGED
@@ -9,5 +9,5 @@ gem "codeclimate-test-reporter", "0.4.4"
9
9
  gem "pry"
10
10
  gem "rake"
11
11
  gem "rspec", "~> 3.1"
12
- gem "rubocop", "~> 1.60.2"
12
+ gem "rubocop", "~> 1.76.0"
13
13
  gem "simplecov", "!= 0.18.0", "!= 0.18.1", "!= 0.18.2", "!= 0.18.3", "!= 0.18.4", "!= 0.18.5", "!= 0.19.0", "!= 0.19.1"
@@ -6,6 +6,7 @@ module Qiita
6
6
  "https://production-assets.codepen.io/assets/embed/ei.js",
7
7
  "https://static.codepen.io/assets/embed/ei.js",
8
8
  "https://cpwebassets.codepen.io/assets/embed/ei.js",
9
+ "https://public.codepenassets.com/embed/index.js",
9
10
  ]
10
11
  CLASS_NAME = %w[codepen]
11
12
  DATA_ATTRIBUTES = %w[
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Qiita
4
+ module Markdown
5
+ module Embed
6
+ module GoogleDrive
7
+ SCRIPT_HOST = "drive.google.com"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Qiita
4
+ module Markdown
5
+ module Embed
6
+ module StackBlitz
7
+ SCRIPT_HOST = "stackblitz.com"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -82,7 +82,7 @@ module Qiita
82
82
  end
83
83
 
84
84
  def has_only_filename?
85
- sections[1].nil? && sections[0] && sections[0].include?(".")
85
+ sections[1].nil? && sections[0]&.include?(".")
86
86
  end
87
87
 
88
88
  def linguist_language
@@ -10,6 +10,8 @@ module Qiita
10
10
  Embed::GoogleSlide::SCRIPT_HOST,
11
11
  Embed::Docswell::SCRIPT_HOSTS,
12
12
  Embed::Figma::SCRIPT_HOST,
13
+ Embed::GoogleDrive::SCRIPT_HOST,
14
+ Embed::StackBlitz::SCRIPT_HOST,
13
15
  ].flatten.freeze
14
16
 
15
17
  def self.call(**args)
@@ -1,5 +1,5 @@
1
1
  module Qiita
2
2
  module Markdown
3
- VERSION = "1.1.2"
3
+ VERSION = "1.3.0"
4
4
  end
5
5
  end
@@ -12,11 +12,13 @@ require "qiita/markdown/embed/code_pen"
12
12
  require "qiita/markdown/embed/tweet"
13
13
  require "qiita/markdown/embed/asciinema"
14
14
  require "qiita/markdown/embed/youtube"
15
+ require "qiita/markdown/embed/google_drive"
15
16
  require "qiita/markdown/embed/slide_share"
16
17
  require "qiita/markdown/embed/google_slide"
17
18
  require "qiita/markdown/embed/speeker_deck"
18
19
  require "qiita/markdown/embed/docswell"
19
20
  require "qiita/markdown/embed/figma"
21
+ require "qiita/markdown/embed/stack_blitz"
20
22
  require "qiita/markdown/transformers/filter_attributes"
21
23
  require "qiita/markdown/transformers/filter_script"
22
24
  require "qiita/markdown/transformers/filter_iframe"
@@ -1406,52 +1406,34 @@ describe Qiita::Markdown::Processor do
1406
1406
  end
1407
1407
 
1408
1408
  shared_examples_for "override embed code attributes" do |allowed:|
1409
- context "with HTML embed code for CodePen using old script url" do
1410
- let(:markdown) do
1411
- <<-MARKDOWN.strip_heredoc
1412
- <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p>
1413
- <script src="https://production-assets.codepen.io/assets/embed/ei.js"></script>
1414
- MARKDOWN
1415
- end
1416
-
1417
- if allowed
1418
- it "does not sanitize embed code" do
1419
- should eq <<-HTML.strip_heredoc
1420
- <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p>
1421
- <script src="https://production-assets.codepen.io/assets/embed/ei.js"></script>
1422
- HTML
1423
- end
1424
- else
1425
- it "forces async attribute on script" do
1426
- should eq <<-HTML.strip_heredoc
1409
+ [
1410
+ "https://production-assets.codepen.io/assets/embed/ei.js",
1411
+ "https://static.codepen.io/assets/embed/ei.js",
1412
+ "https://cpwebassets.codepen.io/assets/embed/ei.js",
1413
+ "https://public.codepenassets.com/embed/index.js",
1414
+ ].each do |script_url|
1415
+ context "with HTML embed code for CodePen using script url `#{script_url}`" do
1416
+ let(:markdown) do
1417
+ <<-MARKDOWN.strip_heredoc
1427
1418
  <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p>
1428
- <script src="https://production-assets.codepen.io/assets/embed/ei.js" async="async"></script>
1429
- HTML
1419
+ <script src="#{script_url}"></script>
1420
+ MARKDOWN
1430
1421
  end
1431
- end
1432
- end
1433
-
1434
- context "with HTML embed code for CodePen" do
1435
- let(:markdown) do
1436
- <<-MARKDOWN.strip_heredoc
1437
- <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p>
1438
- <script src="https://static.codepen.io/assets/embed/ei.js"></script>
1439
- MARKDOWN
1440
- end
1441
1422
 
1442
- if allowed
1443
- it "does not sanitize embed code" do
1444
- should eq <<-HTML.strip_heredoc
1445
- <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p>
1446
- <script src="https://static.codepen.io/assets/embed/ei.js"></script>
1447
- HTML
1448
- end
1449
- else
1450
- it "forces async attribute on script" do
1451
- should eq <<-HTML.strip_heredoc
1452
- <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p>
1453
- <script src="https://static.codepen.io/assets/embed/ei.js" async="async"></script>
1454
- HTML
1423
+ if allowed
1424
+ it "does not sanitize embed code" do
1425
+ should eq <<-HTML.strip_heredoc
1426
+ <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p>
1427
+ <script src="#{script_url}"></script>
1428
+ HTML
1429
+ end
1430
+ else
1431
+ it "forces async attribute on script" do
1432
+ should eq <<-HTML.strip_heredoc
1433
+ <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p>
1434
+ <script src="#{script_url}" async="async"></script>
1435
+ HTML
1436
+ end
1455
1437
  end
1456
1438
  end
1457
1439
  end
@@ -1538,6 +1520,42 @@ describe Qiita::Markdown::Processor do
1538
1520
  end
1539
1521
  end
1540
1522
 
1523
+ context "with HTML embed code for Google Drive" do
1524
+ shared_examples "embed code googledrive example" do
1525
+ let(:markdown) do
1526
+ <<-MARKDOWN.strip_heredoc
1527
+ <iframe src="#{url}" width="640" height="480" frameborder="0" allowfullscreen="true"></iframe>
1528
+ MARKDOWN
1529
+ end
1530
+ let(:file_id) { "DRIVE_FILE_ID_EXAMPLE" }
1531
+ let(:url) { "#{scheme}//drive.google.com/file/d/#{file_id}/preview" }
1532
+
1533
+ if allowed
1534
+ it "does not sanitize embed code" do
1535
+ should eq <<-HTML.strip_heredoc
1536
+ <iframe src="#{url}" width="640" height="480" frameborder="0" allowfullscreen="true"></iframe>
1537
+ HTML
1538
+ end
1539
+ else
1540
+ it "forces width attribute on iframe" do
1541
+ should eq <<-HTML.strip_heredoc
1542
+ <iframe src="#{url}" width="100%" height="480" frameborder="0" allowfullscreen="true"></iframe>
1543
+ HTML
1544
+ end
1545
+ end
1546
+ end
1547
+
1548
+ context "with scheme" do
1549
+ let(:scheme) { "https:" }
1550
+ include_examples "embed code googledrive example"
1551
+ end
1552
+
1553
+ context "without scheme" do
1554
+ let(:scheme) { "" }
1555
+ include_examples "embed code googledrive example"
1556
+ end
1557
+ end
1558
+
1541
1559
  context "with HTML embed code for SlideShare" do
1542
1560
  shared_examples "embed code slideshare example" do
1543
1561
  let(:markdown) do
@@ -1729,6 +1747,43 @@ describe Qiita::Markdown::Processor do
1729
1747
  end
1730
1748
  end
1731
1749
 
1750
+ context "with HTML embed code for StackBlitz" do
1751
+ shared_examples "embed code stackblitz example" do
1752
+ let(:markdown) do
1753
+ <<~MARKDOWN
1754
+ <iframe src="#{url}" width="800" height="600" frameborder="0" allowfullscreen="true"></iframe>
1755
+ MARKDOWN
1756
+ end
1757
+ let(:url) { "#{scheme}//stackblitz.com/embed/example" }
1758
+
1759
+ if allowed
1760
+ it "does not sanitize embed code" do
1761
+ should eq <<~HTML
1762
+ <iframe src="#{url}" width="800" height="600" frameborder="0" allowfullscreen="true"></iframe>
1763
+ HTML
1764
+ end
1765
+ else
1766
+ it "forces width attribute on iframe" do
1767
+ should eq <<~HTML
1768
+ <iframe src="#{url}" width="100%" height="600" frameborder="0" allowfullscreen="true"></iframe>
1769
+ HTML
1770
+ end
1771
+ end
1772
+ end
1773
+
1774
+ context "with scheme" do
1775
+ let(:scheme) { "https:" }
1776
+
1777
+ include_examples "embed code stackblitz example"
1778
+ end
1779
+
1780
+ context "without scheme" do
1781
+ let(:scheme) { "" }
1782
+
1783
+ include_examples "embed code stackblitz example"
1784
+ end
1785
+ end
1786
+
1732
1787
  context "with embed code for Tweet" do
1733
1788
  let(:markdown) do
1734
1789
  <<-MARKDOWN.strip_heredoc
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qiita-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-04-10 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: addressable
@@ -122,13 +121,15 @@ dependencies:
122
121
  - - ">="
123
122
  - !ruby/object:Gem::Version
124
123
  version: '0'
125
- description:
126
124
  email:
127
125
  - r7kamura@gmail.com
128
126
  executables: []
129
127
  extensions: []
130
128
  extra_rdoc_files: []
131
129
  files:
130
+ - ".github/CODEOWNERS"
131
+ - ".github/dependabot.yml"
132
+ - ".github/workflows/release.yml"
132
133
  - ".github/workflows/test.yml"
133
134
  - ".gitignore"
134
135
  - ".rspec"
@@ -146,9 +147,11 @@ files:
146
147
  - lib/qiita/markdown/embed/code_pen.rb
147
148
  - lib/qiita/markdown/embed/docswell.rb
148
149
  - lib/qiita/markdown/embed/figma.rb
150
+ - lib/qiita/markdown/embed/google_drive.rb
149
151
  - lib/qiita/markdown/embed/google_slide.rb
150
152
  - lib/qiita/markdown/embed/slide_share.rb
151
153
  - lib/qiita/markdown/embed/speeker_deck.rb
154
+ - lib/qiita/markdown/embed/stack_blitz.rb
152
155
  - lib/qiita/markdown/embed/tweet.rb
153
156
  - lib/qiita/markdown/embed/youtube.rb
154
157
  - lib/qiita/markdown/filters/checkbox.rb
@@ -192,7 +195,6 @@ licenses:
192
195
  - MIT
193
196
  metadata:
194
197
  rubygems_mfa_required: 'true'
195
- post_install_message:
196
198
  rdoc_options: []
197
199
  require_paths:
198
200
  - lib
@@ -207,8 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
209
  - !ruby/object:Gem::Version
208
210
  version: '0'
209
211
  requirements: []
210
- rubygems_version: 3.2.33
211
- signing_key:
212
+ rubygems_version: 3.6.7
212
213
  specification_version: 4
213
214
  summary: Qiita-specified markdown processor.
214
215
  test_files: []