qiita-markdown 0.42.0 → 0.43.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/.github/workflows/test.yml +24 -12
- data/CHANGELOG.md +6 -0
- data/lib/qiita/markdown/embed/docswell.rb +23 -0
- data/lib/qiita/markdown/filters/final_sanitizer.rb +1 -0
- data/lib/qiita/markdown/filters/user_input_sanitizer.rb +1 -1
- data/lib/qiita/markdown/transformers/filter_iframe.rb +1 -0
- data/lib/qiita/markdown/transformers/filter_script.rb +1 -0
- data/lib/qiita/markdown/version.rb +1 -1
- data/lib/qiita/markdown.rb +1 -0
- data/spec/qiita/markdown/processor_spec.rb +57 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 925ca9666fc91e263d0b8fb4d704900d52b92964d6d53d63730d84403304df3b
|
4
|
+
data.tar.gz: 47a27d59b58ced30484eadfc1dd59bfb94f96673a6e5e20fafc76f19c10065ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0613208602c957acd488a6050095a5ba79cc085fa08a8c18aa6ea98711e3ca61313cd68a9d166308b4d1cdd6efabe98e8a364c92635c82084374d765b069759
|
7
|
+
data.tar.gz: 9ac8835a36b9871c02981d64ee335fd8e7a1a390825e81f5536e57af0b4d5be5d5004236d40f45409294a73a739aa01d0a814d9a30d5e20643b3c6a725682faf
|
data/.github/workflows/test.yml
CHANGED
@@ -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
|
-
-
|
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
|
37
|
-
|
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
@@ -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
|
@@ -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
|
data/lib/qiita/markdown.rb
CHANGED
@@ -14,6 +14,7 @@ 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"
|
17
18
|
require "qiita/markdown/transformers/filter_attributes"
|
18
19
|
require "qiita/markdown/transformers/filter_script"
|
19
20
|
require "qiita/markdown/transformers/filter_iframe"
|
@@ -1642,6 +1642,63 @@ describe Qiita::Markdown::Processor do
|
|
1642
1642
|
end
|
1643
1643
|
end
|
1644
1644
|
|
1645
|
+
context "with HTML embed code for Docswell" do
|
1646
|
+
let(:markdown) do
|
1647
|
+
<<-MARKDOWN.strip_heredoc
|
1648
|
+
<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>
|
1649
|
+
MARKDOWN
|
1650
|
+
end
|
1651
|
+
|
1652
|
+
if allowed
|
1653
|
+
it "does not sanitize embed code" do
|
1654
|
+
should eq <<-HTML.strip_heredoc
|
1655
|
+
<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>
|
1656
|
+
HTML
|
1657
|
+
end
|
1658
|
+
else
|
1659
|
+
it "forces async attribute on script" do
|
1660
|
+
should eq <<-HTML.strip_heredoc
|
1661
|
+
<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>
|
1662
|
+
HTML
|
1663
|
+
end
|
1664
|
+
end
|
1665
|
+
|
1666
|
+
shared_examples "iframe code docswell example" do
|
1667
|
+
let(:markdown) do
|
1668
|
+
<<-MARKDOWN.strip_heredoc
|
1669
|
+
<iframe src="#{url}" allowfullscreen="true" width="620" height="405" style="width:100%"></iframe>
|
1670
|
+
MARKDOWN
|
1671
|
+
end
|
1672
|
+
let(:url) { "#{scheme}//www.docswell.com/slide/example/embed" }
|
1673
|
+
|
1674
|
+
if allowed
|
1675
|
+
it "does not sanitize embed code" do
|
1676
|
+
should eq <<-HTML.strip_heredoc
|
1677
|
+
<iframe src="#{url}" allowfullscreen="true" width="620" height="405"></iframe>
|
1678
|
+
HTML
|
1679
|
+
end
|
1680
|
+
else
|
1681
|
+
it "forces width attribute on iframe" do
|
1682
|
+
should eq <<-HTML.strip_heredoc
|
1683
|
+
<iframe src="#{url}" allowfullscreen="true" width="100%" height="405"></iframe>
|
1684
|
+
HTML
|
1685
|
+
end
|
1686
|
+
end
|
1687
|
+
end
|
1688
|
+
|
1689
|
+
context "with scheme" do
|
1690
|
+
let(:scheme) { "https:" }
|
1691
|
+
|
1692
|
+
include_examples "iframe code docswell example"
|
1693
|
+
end
|
1694
|
+
|
1695
|
+
context "without scheme" do
|
1696
|
+
let(:scheme) { "" }
|
1697
|
+
|
1698
|
+
include_examples "iframe code docswell example"
|
1699
|
+
end
|
1700
|
+
end
|
1701
|
+
|
1645
1702
|
context "with embed code for Tweet" do
|
1646
1703
|
let(:markdown) do
|
1647
1704
|
<<-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.43.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gemoji
|
@@ -314,6 +314,7 @@ 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
|
317
318
|
- lib/qiita/markdown/embed/google_slide.rb
|
318
319
|
- lib/qiita/markdown/embed/slide_share.rb
|
319
320
|
- lib/qiita/markdown/embed/speeker_deck.rb
|
@@ -372,7 +373,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
372
373
|
- !ruby/object:Gem::Version
|
373
374
|
version: '0'
|
374
375
|
requirements: []
|
375
|
-
rubygems_version: 3.1.
|
376
|
+
rubygems_version: 3.1.4
|
376
377
|
signing_key:
|
377
378
|
specification_version: 4
|
378
379
|
summary: Qiita-specified markdown processor.
|