qiita-markdown 0.42.0 → 0.44.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: 0430156d41ed0b17c5ba246e32ca78024e9d3fb834d8a003924a7e3526d9b278
4
- data.tar.gz: cb4ea8e9542c5aaeffed2f8d359c06e3e72c3ff08e90f9c97cf3c6bc9c3f7f63
3
+ metadata.gz: bb18cd9f37329069980cc0322cff454cb1dcbd57ad3fe6836f40b3d8e968e304
4
+ data.tar.gz: ad7d5e7d89eeb283616d04e2fbdc8a1bb2b090897bf1538f6033d061cbe8d958
5
5
  SHA512:
6
- metadata.gz: 9488a97467616a4ca6e64a2483a4ba9789f3d69f1025aee5f5350a6baa6ada4e215de77af3dbb98f9ecb3a99c94680e6fc1dd7535a2acfccf70d82b1abd685db
7
- data.tar.gz: 414798bddd8fc8d76e9f77d8165cb96907969c77b0e8c2e2678cbfeb5e44f1d43e2d888447005a1c9b7195f56e2757aa99f4ac6712933cdf5ea986ba0511d813
6
+ metadata.gz: 4f38820e6f6eafd5135f7d6788e9b0f31ff45b42e85afc0ffb14213e263bb951250f734b1473cf1ffbcc21a5b22d823aed16235ab06bf2f218c39ff9aa59a42f
7
+ data.tar.gz: 0f4b493d2cb3c06de1c2a7d68455f39a9e496d2ae95ed6ff845b8caf3367128ae0ca863a937b44ddb87147573b261178bd6573c4c6042de14a19c7c56d3e5ca1
@@ -11,6 +11,27 @@ permissions:
11
11
  contents: read
12
12
 
13
13
  jobs:
14
+ codeclimate:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - name: Get branch names
18
+ id: branch-name
19
+ uses: tj-actions/branch-names@v4.9
20
+ - uses: actions/checkout@v3
21
+ - uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: '2.6'
24
+ bundler-cache: true
25
+ - name: Test & publish code coverage
26
+ if: "${{ env.CC_TEST_REPORTER_ID != '' }}"
27
+ uses: paambaati/codeclimate-action@v2.7.5
28
+ env:
29
+ CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
30
+ GIT_BRANCH: ${{ steps.branch-name.outputs.current_branch }}
31
+ GIT_COMMIT_SHA: ${{ github.sha }}
32
+ with:
33
+ coverageCommand: bundle exec rake
34
+
14
35
  test:
15
36
  strategy:
16
37
  fail-fast: false
@@ -25,19 +46,10 @@ jobs:
25
46
  runs-on: ${{ matrix.os }}
26
47
  continue-on-error: ${{ matrix.experimental }}
27
48
  steps:
28
- - name: Get branch names
29
- id: branch-name
30
- uses: tj-actions/branch-names@v4.9
31
- - uses: actions/checkout@v2
49
+ - uses: actions/checkout@v3
32
50
  - uses: ruby/setup-ruby@v1
33
51
  with:
34
52
  ruby-version: ${{ matrix.ruby }}
35
53
  bundler-cache: true
36
- - name: Test & publish code coverage
37
- uses: paambaati/codeclimate-action@v2.7.5
38
- env:
39
- CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
40
- GIT_BRANCH: ${{ steps.branch-name.outputs.current_branch }}
41
- GIT_COMMIT_SHA: ${{ github.sha }}
42
- with:
43
- coverageCommand: bundle exec rake
54
+ - name: Test
55
+ run: bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 0.44.0
4
+
5
+ - Support Figma embedding scripts
6
+ - Fix bug of checkbox filter
7
+
8
+ ## 0.43.0
9
+
10
+ - Fix GitHub Actions can't be executed when public fork
11
+ - Support new embed scripts and iframes
12
+ - Docswell
13
+
3
14
  ## 0.42.0
4
15
 
5
16
  - Add for Ruby 3.0, 3.1 support
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Qiita
4
+ module Markdown
5
+ module Embed
6
+ module Docswell
7
+ SCRIPT_HOSTS = [
8
+ "docswell.com",
9
+ "www.docswell.com",
10
+ ].freeze
11
+ SCRIPT_URLS = [
12
+ "https://www.docswell.com/assets/libs/docswell-embed/docswell-embed.min.js",
13
+ "//www.docswell.com/assets/libs/docswell-embed/docswell-embed.min.js",
14
+ ].freeze
15
+ CLASS_NAME = %w[docswell-embed].freeze
16
+ DATA_ATTRIBUTES = %w[
17
+ data-src data-aspect data-height-offset data-width-offset
18
+ ].freeze
19
+ ATTRIBUTES = %w[class] + DATA_ATTRIBUTES
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Qiita
4
+ module Markdown
5
+ module Embed
6
+ module Figma
7
+ SCRIPT_HOST = "www.figma.com"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -31,7 +31,7 @@ module Qiita
31
31
  end
32
32
 
33
33
  def convert
34
- first_text_node.content = first_text_node.content.sub(checkbox_mark, "")
34
+ first_text_node.content = first_text_node.content.sub(checkbox_mark, "").lstrip
35
35
  first_text_node.add_previous_sibling(checkbox_node)
36
36
  @node["class"] = "task-list-item"
37
37
  end
@@ -49,6 +49,7 @@ module Qiita
49
49
  "type",
50
50
  ].concat(
51
51
  Embed::SpeekerDeck::ATTRIBUTES,
52
+ Embed::Docswell::ATTRIBUTES,
52
53
  ),
53
54
  "span" => [
54
55
  "style",
@@ -96,8 +97,9 @@ module Qiita
96
97
  },
97
98
  css: {
98
99
  properties: [
99
- "text-align",
100
100
  "background-color",
101
+ "border",
102
+ "text-align",
101
103
  ],
102
104
  },
103
105
  elements: [
@@ -26,7 +26,7 @@ module Qiita
26
26
  "li" => %w[id],
27
27
  "p" => Embed::CodePen::ATTRIBUTES,
28
28
  "q" => %w[cite],
29
- "script" => %w[async src id].concat(Embed::SpeekerDeck::ATTRIBUTES),
29
+ "script" => %w[async src id].concat(Embed::SpeekerDeck::ATTRIBUTES, Embed::Docswell::ATTRIBUTES),
30
30
  "iframe" => %w[
31
31
  allowfullscreen
32
32
  frameborder
@@ -48,7 +48,10 @@ module Qiita
48
48
  "q" => { "cite" => ["http", "https", :relative] },
49
49
  },
50
50
  css: {
51
- properties: %w[text-align],
51
+ properties: %w[
52
+ text-align
53
+ border
54
+ ],
52
55
  },
53
56
  transformers: [
54
57
  Transformers::FilterAttributes,
@@ -9,6 +9,8 @@ module Qiita
9
9
  Embed::Youtube::SCRIPT_HOSTS,
10
10
  Embed::SlideShare::SCRIPT_HOST,
11
11
  Embed::GoogleSlide::SCRIPT_HOST,
12
+ Embed::Docswell::SCRIPT_HOSTS,
13
+ Embed::Figma::SCRIPT_HOST,
12
14
  ].flatten.freeze
13
15
 
14
16
  def self.call(**args)
@@ -6,6 +6,7 @@ module Qiita
6
6
  Embed::CodePen::SCRIPT_URLS,
7
7
  Embed::Tweet::SCRIPT_URL,
8
8
  Embed::SpeekerDeck::SCRIPT_URLS,
9
+ Embed::Docswell::SCRIPT_URLS,
9
10
  ].flatten.freeze
10
11
 
11
12
  HOST_WHITE_LIST = [
@@ -1,5 +1,5 @@
1
1
  module Qiita
2
2
  module Markdown
3
- VERSION = "0.42.0"
3
+ VERSION = "0.44.0"
4
4
  end
5
5
  end
@@ -14,6 +14,8 @@ require "qiita/markdown/embed/youtube"
14
14
  require "qiita/markdown/embed/slide_share"
15
15
  require "qiita/markdown/embed/google_slide"
16
16
  require "qiita/markdown/embed/speeker_deck"
17
+ require "qiita/markdown/embed/docswell"
18
+ require "qiita/markdown/embed/figma"
17
19
  require "qiita/markdown/transformers/filter_attributes"
18
20
  require "qiita/markdown/transformers/filter_script"
19
21
  require "qiita/markdown/transformers/filter_iframe"
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Qiita::Markdown::Filters::Checkbox do
4
+ subject(:filter) do
5
+ described_class.new(input_html)
6
+ end
7
+
8
+ context "with checkbox" do
9
+ let(:input_html) do
10
+ <<~HTML
11
+ <li>[ ] a</li>
12
+ <li>[x] a</li>
13
+ HTML
14
+ end
15
+
16
+ let(:output_html) do
17
+ <<~HTML
18
+ <li class="task-list-item">
19
+ <input type="checkbox" class="task-list-item-checkbox" disabled>a</li>
20
+ <li class="task-list-item">
21
+ <input type="checkbox" class="task-list-item-checkbox" checked disabled>a</li>
22
+ HTML
23
+ end
24
+
25
+ it "replaces checkboxes" do
26
+ expect(filter.call.to_s).to eq(output_html)
27
+ end
28
+
29
+ context "when input html has many spaces after checkbox mark" do
30
+ let(:input_html) do
31
+ <<~HTML
32
+ <li>[ ] a</li>
33
+ <li>[x] a</li>
34
+ HTML
35
+ end
36
+
37
+ it "replaces checkboxes and remove spaces" do
38
+ expect(filter.call.to_s).to eq(output_html)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1620,6 +1620,44 @@ describe Qiita::Markdown::Processor do
1620
1620
  end
1621
1621
  end
1622
1622
 
1623
+ context "with HTML embed code for Figma" do
1624
+ shared_examples "embed code figma example" do
1625
+ let(:markdown) do
1626
+ <<-MARKDOWN.strip_heredoc
1627
+ <iframe style="border: 1px solid rgba(0, 0, 0, 0.1);" width="100" height="100" src="#{url}"></iframe>
1628
+ MARKDOWN
1629
+ end
1630
+ let(:url) { "#{scheme}//www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com" }
1631
+ let(:encoded_url) { CGI.escapeHTML(url) }
1632
+
1633
+ if allowed
1634
+ it "does not sanitize embed code" do
1635
+ should eq <<-HTML.strip_heredoc
1636
+ <iframe style="border: 1px solid rgba(0, 0, 0, 0.1);" width="100" height="100" src="#{encoded_url}"></iframe>
1637
+ HTML
1638
+ end
1639
+ else
1640
+ it "forces width attribute on iframe" do
1641
+ should eq <<-HTML.strip_heredoc
1642
+ <iframe style="border: 1px solid rgba(0, 0, 0, 0.1);" width="100%" height="100" src="#{encoded_url}"></iframe>
1643
+ HTML
1644
+ end
1645
+ end
1646
+ end
1647
+
1648
+ context "with scheme" do
1649
+ let(:scheme) { "https:" }
1650
+
1651
+ include_examples "embed code figma example"
1652
+ end
1653
+
1654
+ context "without scheme" do
1655
+ let(:scheme) { "" }
1656
+
1657
+ include_examples "embed code figma example"
1658
+ end
1659
+ end
1660
+
1623
1661
  context "with HTML embed code for SpeekerDeck" do
1624
1662
  let(:markdown) do
1625
1663
  <<-MARKDOWN.strip_heredoc
@@ -1642,6 +1680,63 @@ describe Qiita::Markdown::Processor do
1642
1680
  end
1643
1681
  end
1644
1682
 
1683
+ context "with HTML embed code for Docswell" do
1684
+ let(:markdown) do
1685
+ <<-MARKDOWN.strip_heredoc
1686
+ <script async class="docswell-embed" src="https://www.docswell.com/assets/libs/docswell-embed/docswell-embed.min.js" data-src="https://www.docswell.com/slide/example/embed" data-aspect="0.5625"></script>
1687
+ MARKDOWN
1688
+ end
1689
+
1690
+ if allowed
1691
+ it "does not sanitize embed code" do
1692
+ should eq <<-HTML.strip_heredoc
1693
+ <script async class="docswell-embed" src="https://www.docswell.com/assets/libs/docswell-embed/docswell-embed.min.js" data-src="https://www.docswell.com/slide/example/embed" data-aspect="0.5625"></script>
1694
+ HTML
1695
+ end
1696
+ else
1697
+ it "forces async attribute on script" do
1698
+ should eq <<-HTML.strip_heredoc
1699
+ <script async class="docswell-embed" src="https://www.docswell.com/assets/libs/docswell-embed/docswell-embed.min.js" data-src="https://www.docswell.com/slide/example/embed" data-aspect="0.5625"></script>
1700
+ HTML
1701
+ end
1702
+ end
1703
+
1704
+ shared_examples "iframe code docswell example" do
1705
+ let(:markdown) do
1706
+ <<-MARKDOWN.strip_heredoc
1707
+ <iframe src="#{url}" allowfullscreen="true" width="620" height="405" style="width:100%"></iframe>
1708
+ MARKDOWN
1709
+ end
1710
+ let(:url) { "#{scheme}//www.docswell.com/slide/example/embed" }
1711
+
1712
+ if allowed
1713
+ it "does not sanitize embed code" do
1714
+ should eq <<-HTML.strip_heredoc
1715
+ <iframe src="#{url}" allowfullscreen="true" width="620" height="405"></iframe>
1716
+ HTML
1717
+ end
1718
+ else
1719
+ it "forces width attribute on iframe" do
1720
+ should eq <<-HTML.strip_heredoc
1721
+ <iframe src="#{url}" allowfullscreen="true" width="100%" height="405"></iframe>
1722
+ HTML
1723
+ end
1724
+ end
1725
+ end
1726
+
1727
+ context "with scheme" do
1728
+ let(:scheme) { "https:" }
1729
+
1730
+ include_examples "iframe code docswell example"
1731
+ end
1732
+
1733
+ context "without scheme" do
1734
+ let(:scheme) { "" }
1735
+
1736
+ include_examples "iframe code docswell example"
1737
+ end
1738
+ end
1739
+
1645
1740
  context "with embed code for Tweet" do
1646
1741
  let(:markdown) do
1647
1742
  <<-MARKDOWN.strip_heredoc
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qiita-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.42.0
4
+ version: 0.44.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-22 00:00:00.000000000 Z
11
+ date: 2022-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gemoji
@@ -290,7 +290,7 @@ dependencies:
290
290
  - - "~>"
291
291
  - !ruby/object:Gem::Version
292
292
  version: 1.27.0
293
- description:
293
+ description:
294
294
  email:
295
295
  - r7kamura@gmail.com
296
296
  executables: []
@@ -314,6 +314,8 @@ files:
314
314
  - lib/qiita/markdown/base_processor.rb
315
315
  - lib/qiita/markdown/embed/asciinema.rb
316
316
  - lib/qiita/markdown/embed/code_pen.rb
317
+ - lib/qiita/markdown/embed/docswell.rb
318
+ - lib/qiita/markdown/embed/figma.rb
317
319
  - lib/qiita/markdown/embed/google_slide.rb
318
320
  - lib/qiita/markdown/embed/slide_share.rb
319
321
  - lib/qiita/markdown/embed/speeker_deck.rb
@@ -347,6 +349,7 @@ files:
347
349
  - lib/qiita/markdown/transformers/strip_invalid_node.rb
348
350
  - lib/qiita/markdown/version.rb
349
351
  - qiita-markdown.gemspec
352
+ - spec/qiita/markdown/filters/checkbox_spec.rb
350
353
  - spec/qiita/markdown/filters/greenmat_spec.rb
351
354
  - spec/qiita/markdown/filters/inline_code_color_spec.rb
352
355
  - spec/qiita/markdown/greenmat/html_toc_renderer_spec.rb
@@ -357,7 +360,7 @@ homepage: https://github.com/increments/qiita-markdown
357
360
  licenses:
358
361
  - MIT
359
362
  metadata: {}
360
- post_install_message:
363
+ post_install_message:
361
364
  rdoc_options: []
362
365
  require_paths:
363
366
  - lib
@@ -372,11 +375,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
372
375
  - !ruby/object:Gem::Version
373
376
  version: '0'
374
377
  requirements: []
375
- rubygems_version: 3.1.6
376
- signing_key:
378
+ rubygems_version: 3.1.4
379
+ signing_key:
377
380
  specification_version: 4
378
381
  summary: Qiita-specified markdown processor.
379
382
  test_files:
383
+ - spec/qiita/markdown/filters/checkbox_spec.rb
380
384
  - spec/qiita/markdown/filters/greenmat_spec.rb
381
385
  - spec/qiita/markdown/filters/inline_code_color_spec.rb
382
386
  - spec/qiita/markdown/greenmat/html_toc_renderer_spec.rb