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 +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/qiita/markdown/embed/figma.rb +11 -0
- data/lib/qiita/markdown/filters/checkbox.rb +1 -1
- data/lib/qiita/markdown/filters/final_sanitizer.rb +2 -1
- data/lib/qiita/markdown/filters/user_input_sanitizer.rb +4 -1
- data/lib/qiita/markdown/transformers/filter_iframe.rb +1 -0
- data/lib/qiita/markdown/version.rb +1 -1
- data/lib/qiita/markdown.rb +1 -0
- data/spec/qiita/markdown/filters/checkbox_spec.rb +42 -0
- data/spec/qiita/markdown/processor_spec.rb +38 -0
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb18cd9f37329069980cc0322cff454cb1dcbd57ad3fe6836f40b3d8e968e304
|
4
|
+
data.tar.gz: ad7d5e7d89eeb283616d04e2fbdc8a1bb2b090897bf1538f6033d061cbe8d958
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f38820e6f6eafd5135f7d6788e9b0f31ff45b42e85afc0ffb14213e263bb951250f734b1473cf1ffbcc21a5b22d823aed16235ab06bf2f218c39ff9aa59a42f
|
7
|
+
data.tar.gz: 0f4b493d2cb3c06de1c2a7d68455f39a9e496d2ae95ed6ff845b8caf3367128ae0ca863a937b44ddb87147573b261178bd6573c4c6042de14a19c7c56d3e5ca1
|
data/CHANGELOG.md
CHANGED
@@ -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
|
data/lib/qiita/markdown.rb
CHANGED
@@ -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.
|
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-
|
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
|