qiita-markdown 0.43.0 → 0.44.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: 925ca9666fc91e263d0b8fb4d704900d52b92964d6d53d63730d84403304df3b
4
- data.tar.gz: 47a27d59b58ced30484eadfc1dd59bfb94f96673a6e5e20fafc76f19c10065ea
3
+ metadata.gz: bb18cd9f37329069980cc0322cff454cb1dcbd57ad3fe6836f40b3d8e968e304
4
+ data.tar.gz: ad7d5e7d89eeb283616d04e2fbdc8a1bb2b090897bf1538f6033d061cbe8d958
5
5
  SHA512:
6
- metadata.gz: d0613208602c957acd488a6050095a5ba79cc085fa08a8c18aa6ea98711e3ca61313cd68a9d166308b4d1cdd6efabe98e8a364c92635c82084374d765b069759
7
- data.tar.gz: 9ac8835a36b9871c02981d64ee335fd8e7a1a390825e81f5536e57af0b4d5be5d5004236d40f45409294a73a739aa01d0a814d9a30d5e20643b3c6a725682faf
6
+ metadata.gz: 4f38820e6f6eafd5135f7d6788e9b0f31ff45b42e85afc0ffb14213e263bb951250f734b1473cf1ffbcc21a5b22d823aed16235ab06bf2f218c39ff9aa59a42f
7
+ data.tar.gz: 0f4b493d2cb3c06de1c2a7d68455f39a9e496d2ae95ed6ff845b8caf3367128ae0ca863a937b44ddb87147573b261178bd6573c4c6042de14a19c7c56d3e5ca1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 0.44.0
4
+
5
+ - Support Figma embedding scripts
6
+ - Fix bug of checkbox filter
7
+
3
8
  ## 0.43.0
4
9
 
5
10
  - Fix GitHub Actions can't be executed when public fork
@@ -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
@@ -97,8 +97,9 @@ module Qiita
97
97
  },
98
98
  css: {
99
99
  properties: [
100
- "text-align",
101
100
  "background-color",
101
+ "border",
102
+ "text-align",
102
103
  ],
103
104
  },
104
105
  elements: [
@@ -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,
@@ -10,6 +10,7 @@ module Qiita
10
10
  Embed::SlideShare::SCRIPT_HOST,
11
11
  Embed::GoogleSlide::SCRIPT_HOST,
12
12
  Embed::Docswell::SCRIPT_HOSTS,
13
+ Embed::Figma::SCRIPT_HOST,
13
14
  ].flatten.freeze
14
15
 
15
16
  def self.call(**args)
@@ -1,5 +1,5 @@
1
1
  module Qiita
2
2
  module Markdown
3
- VERSION = "0.43.0"
3
+ VERSION = "0.44.0"
4
4
  end
5
5
  end
@@ -15,6 +15,7 @@ require "qiita/markdown/embed/slide_share"
15
15
  require "qiita/markdown/embed/google_slide"
16
16
  require "qiita/markdown/embed/speeker_deck"
17
17
  require "qiita/markdown/embed/docswell"
18
+ require "qiita/markdown/embed/figma"
18
19
  require "qiita/markdown/transformers/filter_attributes"
19
20
  require "qiita/markdown/transformers/filter_script"
20
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
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.43.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-10-14 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: []
@@ -315,6 +315,7 @@ files:
315
315
  - lib/qiita/markdown/embed/asciinema.rb
316
316
  - lib/qiita/markdown/embed/code_pen.rb
317
317
  - lib/qiita/markdown/embed/docswell.rb
318
+ - lib/qiita/markdown/embed/figma.rb
318
319
  - lib/qiita/markdown/embed/google_slide.rb
319
320
  - lib/qiita/markdown/embed/slide_share.rb
320
321
  - lib/qiita/markdown/embed/speeker_deck.rb
@@ -348,6 +349,7 @@ files:
348
349
  - lib/qiita/markdown/transformers/strip_invalid_node.rb
349
350
  - lib/qiita/markdown/version.rb
350
351
  - qiita-markdown.gemspec
352
+ - spec/qiita/markdown/filters/checkbox_spec.rb
351
353
  - spec/qiita/markdown/filters/greenmat_spec.rb
352
354
  - spec/qiita/markdown/filters/inline_code_color_spec.rb
353
355
  - spec/qiita/markdown/greenmat/html_toc_renderer_spec.rb
@@ -358,7 +360,7 @@ homepage: https://github.com/increments/qiita-markdown
358
360
  licenses:
359
361
  - MIT
360
362
  metadata: {}
361
- post_install_message:
363
+ post_install_message:
362
364
  rdoc_options: []
363
365
  require_paths:
364
366
  - lib
@@ -374,10 +376,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
374
376
  version: '0'
375
377
  requirements: []
376
378
  rubygems_version: 3.1.4
377
- signing_key:
379
+ signing_key:
378
380
  specification_version: 4
379
381
  summary: Qiita-specified markdown processor.
380
382
  test_files:
383
+ - spec/qiita/markdown/filters/checkbox_spec.rb
381
384
  - spec/qiita/markdown/filters/greenmat_spec.rb
382
385
  - spec/qiita/markdown/filters/inline_code_color_spec.rb
383
386
  - spec/qiita/markdown/greenmat/html_toc_renderer_spec.rb