qiita-markdown 0.41.0 → 0.43.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +25 -13
- data/.rubocop_todo.yml +69 -30
- data/CHANGELOG.md +11 -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/syntax_highlight.rb +2 -2
- data/lib/qiita/markdown/filters/user_input_sanitizer.rb +1 -1
- data/lib/qiita/markdown/transformers/filter_attributes.rb +2 -2
- data/lib/qiita/markdown/transformers/filter_iframe.rb +3 -2
- data/lib/qiita/markdown/transformers/filter_script.rb +3 -2
- data/lib/qiita/markdown/transformers/strip_invalid_node.rb +2 -2
- data/lib/qiita/markdown/version.rb +1 -1
- data/lib/qiita/markdown.rb +1 -0
- data/qiita-markdown.gemspec +3 -3
- data/spec/qiita/markdown/processor_spec.rb +57 -0
- metadata +14 -13
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,12 +11,33 @@ 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
|
17
38
|
matrix:
|
18
39
|
os: ['ubuntu-18.04', 'ubuntu-latest', 'macos-latest']
|
19
|
-
ruby: ['2.6', '2.7']
|
40
|
+
ruby: ['2.6', '2.7', '3.0', '3.1']
|
20
41
|
experimental: [false]
|
21
42
|
include:
|
22
43
|
- os: 'ubuntu-latest'
|
@@ -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/.rubocop_todo.yml
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config --exclude-limit 99999`
|
3
|
-
# on 2022-
|
3
|
+
# on 2022-04-15 03:12:24 UTC using RuboCop version 1.27.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
9
|
# Offense count: 3
|
10
|
-
#
|
10
|
+
# This cop supports safe auto-correction (--auto-correct).
|
11
11
|
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
|
12
12
|
# Include: **/*.gemspec
|
13
13
|
Gemspec/OrderedDependencies:
|
@@ -15,13 +15,28 @@ Gemspec/OrderedDependencies:
|
|
15
15
|
- 'qiita-markdown.gemspec'
|
16
16
|
|
17
17
|
# Offense count: 1
|
18
|
-
#
|
18
|
+
# This cop supports safe auto-correction (--auto-correct).
|
19
|
+
# Configuration parameters: Include.
|
20
|
+
# Include: **/*.gemspec
|
21
|
+
Gemspec/RequireMFA:
|
22
|
+
Exclude:
|
23
|
+
- 'qiita-markdown.gemspec'
|
24
|
+
|
25
|
+
# Offense count: 1
|
26
|
+
# Configuration parameters: Include.
|
27
|
+
# Include: **/*.gemspec
|
28
|
+
Gemspec/RequiredRubyVersion:
|
29
|
+
Exclude:
|
30
|
+
- 'qiita-markdown.gemspec'
|
31
|
+
|
32
|
+
# Offense count: 1
|
33
|
+
# This cop supports safe auto-correction (--auto-correct).
|
19
34
|
Layout/ClosingHeredocIndentation:
|
20
35
|
Exclude:
|
21
36
|
- 'spec/qiita/markdown/processor_spec.rb'
|
22
37
|
|
23
38
|
# Offense count: 9
|
24
|
-
#
|
39
|
+
# This cop supports safe auto-correction (--auto-correct).
|
25
40
|
Layout/EmptyLineAfterGuardClause:
|
26
41
|
Exclude:
|
27
42
|
- 'lib/qiita/markdown/filters/custom_block.rb'
|
@@ -32,7 +47,7 @@ Layout/EmptyLineAfterGuardClause:
|
|
32
47
|
- 'lib/qiita/markdown/transformers/filter_attributes.rb'
|
33
48
|
|
34
49
|
# Offense count: 22
|
35
|
-
#
|
50
|
+
# This cop supports safe auto-correction (--auto-correct).
|
36
51
|
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
|
37
52
|
# SupportedHashRocketStyles: key, separator, table
|
38
53
|
# SupportedColonStyles: key, separator, table
|
@@ -42,7 +57,7 @@ Layout/HashAlignment:
|
|
42
57
|
- 'lib/qiita/markdown/filters/user_input_sanitizer.rb'
|
43
58
|
|
44
59
|
# Offense count: 1
|
45
|
-
#
|
60
|
+
# This cop supports safe auto-correction (--auto-correct).
|
46
61
|
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
|
47
62
|
# SupportedStyles: space, no_space, compact
|
48
63
|
# SupportedStylesForEmptyBrackets: space, no_space
|
@@ -50,6 +65,12 @@ Layout/SpaceInsideArrayLiteralBrackets:
|
|
50
65
|
Exclude:
|
51
66
|
- 'lib/qiita/markdown/transformers/filter_iframe.rb'
|
52
67
|
|
68
|
+
# Offense count: 2
|
69
|
+
# This cop supports safe auto-correction (--auto-correct).
|
70
|
+
Lint/AmbiguousOperatorPrecedence:
|
71
|
+
Exclude:
|
72
|
+
- 'lib/qiita/markdown/filters/mention.rb'
|
73
|
+
|
53
74
|
# Offense count: 5
|
54
75
|
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
|
55
76
|
Metrics/AbcSize:
|
@@ -60,13 +81,22 @@ Metrics/AbcSize:
|
|
60
81
|
Metrics/MethodLength:
|
61
82
|
Max: 20
|
62
83
|
|
84
|
+
# Offense count: 2
|
85
|
+
# This cop supports safe auto-correction (--auto-correct).
|
86
|
+
# Configuration parameters: EnforcedStyle, BlockForwardingName.
|
87
|
+
# SupportedStyles: anonymous, explicit
|
88
|
+
Naming/BlockForwarding:
|
89
|
+
Exclude:
|
90
|
+
- 'lib/qiita/markdown/filters/truncate.rb'
|
91
|
+
|
63
92
|
# Offense count: 1
|
64
93
|
Naming/ConstantName:
|
65
94
|
Exclude:
|
66
95
|
- 'lib/qiita/markdown/filters/mention.rb'
|
67
96
|
|
68
97
|
# Offense count: 1
|
69
|
-
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
98
|
+
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
99
|
+
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
|
70
100
|
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
|
71
101
|
Naming/FileName:
|
72
102
|
Exclude:
|
@@ -97,7 +127,7 @@ Naming/MethodParameterName:
|
|
97
127
|
- 'lib/qiita/markdown/filters/footnote.rb'
|
98
128
|
|
99
129
|
# Offense count: 3
|
100
|
-
#
|
130
|
+
# This cop supports safe auto-correction (--auto-correct).
|
101
131
|
# Configuration parameters: EnforcedStyle.
|
102
132
|
# SupportedStyles: percent_q, bare_percent
|
103
133
|
Style/BarePercentLiterals:
|
@@ -105,13 +135,13 @@ Style/BarePercentLiterals:
|
|
105
135
|
- 'lib/qiita/markdown/filters/syntax_highlight.rb'
|
106
136
|
|
107
137
|
# Offense count: 1
|
108
|
-
#
|
138
|
+
# This cop supports safe auto-correction (--auto-correct).
|
109
139
|
Style/ExpandPathArguments:
|
110
140
|
Exclude:
|
111
141
|
- 'qiita-markdown.gemspec'
|
112
142
|
|
113
143
|
# Offense count: 47
|
114
|
-
#
|
144
|
+
# This cop supports safe auto-correction (--auto-correct).
|
115
145
|
# Configuration parameters: EnforcedStyle.
|
116
146
|
# SupportedStyles: always, always_true, never
|
117
147
|
Style/FrozenStringLiteralComment:
|
@@ -164,32 +194,41 @@ Style/FrozenStringLiteralComment:
|
|
164
194
|
- 'spec/qiita/markdown/summary_processor_spec.rb'
|
165
195
|
- 'spec/spec_helper.rb'
|
166
196
|
|
197
|
+
# Offense count: 6
|
198
|
+
# This cop supports safe auto-correction (--auto-correct).
|
199
|
+
# Configuration parameters: EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
200
|
+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
201
|
+
# SupportedShorthandSyntax: always, never, either
|
202
|
+
Style/HashSyntax:
|
203
|
+
EnforcedStyle: ruby19
|
204
|
+
EnforcedShorthandSyntax: never
|
205
|
+
|
167
206
|
# Offense count: 2
|
168
|
-
#
|
207
|
+
# This cop supports safe auto-correction (--auto-correct).
|
169
208
|
Style/IfUnlessModifier:
|
170
209
|
Exclude:
|
171
210
|
- 'lib/qiita/markdown/filters/truncate.rb'
|
172
211
|
- 'lib/qiita/markdown/transformers/strip_invalid_node.rb'
|
173
212
|
|
174
213
|
# Offense count: 17
|
175
|
-
#
|
214
|
+
# This cop supports safe auto-correction (--auto-correct).
|
176
215
|
# Configuration parameters: EnforcedStyle.
|
177
216
|
# SupportedStyles: literals, strict
|
178
217
|
Style/MutableConstant:
|
179
218
|
Exclude:
|
180
219
|
- 'lib/qiita/markdown/embed/code_pen.rb'
|
181
|
-
- 'lib/qiita/markdown/embed/tweet.rb'
|
182
|
-
- 'lib/qiita/markdown/filters/checkbox.rb'
|
183
|
-
- 'lib/qiita/markdown/filters/code_block.rb'
|
184
220
|
- 'lib/qiita/markdown/filters/group_mention.rb'
|
185
221
|
- 'lib/qiita/markdown/filters/inline_code_color.rb'
|
186
222
|
- 'lib/qiita/markdown/filters/mention.rb'
|
223
|
+
- 'lib/qiita/markdown/embed/tweet.rb'
|
224
|
+
- 'lib/qiita/markdown/filters/checkbox.rb'
|
225
|
+
- 'lib/qiita/markdown/filters/code_block.rb'
|
187
226
|
- 'lib/qiita/markdown/filters/simplify.rb'
|
188
227
|
- 'lib/qiita/markdown/filters/syntax_highlight.rb'
|
189
228
|
- 'lib/qiita/markdown/version.rb'
|
190
229
|
|
191
230
|
# Offense count: 2
|
192
|
-
#
|
231
|
+
# This cop supports safe auto-correction (--auto-correct).
|
193
232
|
# Configuration parameters: EnforcedStyle, MinBodyLength.
|
194
233
|
# SupportedStyles: skip_modifier_ifs, always
|
195
234
|
Style/Next:
|
@@ -198,7 +237,7 @@ Style/Next:
|
|
198
237
|
- 'lib/qiita/markdown/filters/image_link.rb'
|
199
238
|
|
200
239
|
# Offense count: 5
|
201
|
-
#
|
240
|
+
# This cop supports unsafe auto-correction (--auto-correct-all).
|
202
241
|
# Configuration parameters: EnforcedStyle, IgnoredMethods.
|
203
242
|
# SupportedStyles: predicate, comparison
|
204
243
|
Style/NumericPredicate:
|
@@ -216,13 +255,13 @@ Style/OptionalBooleanParameter:
|
|
216
255
|
- 'lib/qiita/markdown/greenmat/heading_rendering.rb'
|
217
256
|
|
218
257
|
# Offense count: 1
|
219
|
-
#
|
258
|
+
# This cop supports safe auto-correction (--auto-correct).
|
220
259
|
Style/OrAssignment:
|
221
260
|
Exclude:
|
222
261
|
- 'lib/qiita/markdown/greenmat/html_toc_renderer.rb'
|
223
262
|
|
224
263
|
# Offense count: 9
|
225
|
-
#
|
264
|
+
# This cop supports safe auto-correction (--auto-correct).
|
226
265
|
# Configuration parameters: PreferredDelimiters.
|
227
266
|
Style/PercentLiteralDelimiters:
|
228
267
|
Exclude:
|
@@ -233,33 +272,33 @@ Style/PercentLiteralDelimiters:
|
|
233
272
|
- 'spec/qiita/markdown/summary_processor_spec.rb'
|
234
273
|
|
235
274
|
# Offense count: 1
|
236
|
-
#
|
275
|
+
# This cop supports safe auto-correction (--auto-correct).
|
237
276
|
Style/PerlBackrefs:
|
238
277
|
Exclude:
|
239
278
|
- 'lib/qiita/markdown/filters/mention.rb'
|
240
279
|
|
241
280
|
# Offense count: 1
|
242
|
-
#
|
281
|
+
# This cop supports unsafe auto-correction (--auto-correct-all).
|
243
282
|
# Configuration parameters: Methods.
|
244
283
|
Style/RedundantArgument:
|
245
284
|
Exclude:
|
246
285
|
- 'lib/qiita/markdown/filters/custom_block.rb'
|
247
286
|
|
248
287
|
# Offense count: 1
|
249
|
-
#
|
288
|
+
# This cop supports safe auto-correction (--auto-correct).
|
250
289
|
Style/RedundantRegexpCharacterClass:
|
251
290
|
Exclude:
|
252
291
|
- 'lib/qiita/markdown/filters/mention.rb'
|
253
292
|
|
254
293
|
# Offense count: 9
|
255
|
-
#
|
294
|
+
# This cop supports safe auto-correction (--auto-correct).
|
256
295
|
Style/RedundantRegexpEscape:
|
257
296
|
Exclude:
|
258
297
|
- 'lib/qiita/markdown/filters/group_mention.rb'
|
259
298
|
- 'lib/qiita/markdown/filters/inline_code_color.rb'
|
260
299
|
|
261
300
|
# Offense count: 4
|
262
|
-
#
|
301
|
+
# This cop supports safe auto-correction (--auto-correct).
|
263
302
|
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
|
264
303
|
# SupportedStyles: slashes, percent_r, mixed
|
265
304
|
Style/RegexpLiteral:
|
@@ -268,7 +307,7 @@ Style/RegexpLiteral:
|
|
268
307
|
- 'lib/qiita/markdown/filters/mention.rb'
|
269
308
|
|
270
309
|
# Offense count: 1
|
271
|
-
#
|
310
|
+
# This cop supports safe auto-correction (--auto-correct).
|
272
311
|
# Configuration parameters: EnforcedStyle.
|
273
312
|
# SupportedStyles: implicit, explicit
|
274
313
|
Style/RescueStandardError:
|
@@ -276,8 +315,8 @@ Style/RescueStandardError:
|
|
276
315
|
- 'lib/qiita/markdown/filters/syntax_highlight.rb'
|
277
316
|
|
278
317
|
# Offense count: 2
|
279
|
-
#
|
280
|
-
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods.
|
318
|
+
# This cop supports safe auto-correction (--auto-correct).
|
319
|
+
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
|
281
320
|
# AllowedMethods: present?, blank?, presence, try, try!
|
282
321
|
Style/SafeNavigation:
|
283
322
|
Exclude:
|
@@ -285,7 +324,7 @@ Style/SafeNavigation:
|
|
285
324
|
- 'lib/qiita/markdown/filters/toc.rb'
|
286
325
|
|
287
326
|
# Offense count: 3
|
288
|
-
#
|
327
|
+
# This cop supports safe auto-correction (--auto-correct).
|
289
328
|
# Configuration parameters: EnforcedStyle.
|
290
329
|
# SupportedStyles: only_raise, only_fail, semantic
|
291
330
|
Style/SignalException:
|
@@ -294,7 +333,7 @@ Style/SignalException:
|
|
294
333
|
- 'spec/qiita/markdown/summary_processor_spec.rb'
|
295
334
|
|
296
335
|
# Offense count: 13
|
297
|
-
#
|
336
|
+
# This cop supports safe auto-correction (--auto-correct).
|
298
337
|
# Configuration parameters: EnforcedStyleForMultiline.
|
299
338
|
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
|
300
339
|
Style/TrailingCommaInArguments:
|
@@ -303,7 +342,7 @@ Style/TrailingCommaInArguments:
|
|
303
342
|
- 'spec/qiita/markdown/processor_spec.rb'
|
304
343
|
|
305
344
|
# Offense count: 12
|
306
|
-
#
|
345
|
+
# This cop supports safe auto-correction (--auto-correct).
|
307
346
|
# Configuration parameters: EnforcedStyle, MinSize, WordRegex.
|
308
347
|
# SupportedStyles: percent, brackets
|
309
348
|
Style/WordArray:
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
## Unreleased
|
2
2
|
|
3
|
+
## 0.43.0
|
4
|
+
|
5
|
+
- Fix GitHub Actions can't be executed when public fork
|
6
|
+
- Support new embed scripts and iframes
|
7
|
+
- Docswell
|
8
|
+
|
9
|
+
## 0.42.0
|
10
|
+
|
11
|
+
- Add for Ruby 3.0, 3.1 support
|
12
|
+
- Bump greenmat from 3.5.1.3 to 3.5.1.4
|
13
|
+
|
3
14
|
## 0.41.0
|
4
15
|
|
5
16
|
- Bump greenmat from 3.5.1.2 to 3.5.1.3
|
@@ -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
|
@@ -9,10 +9,11 @@ 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,
|
12
13
|
].flatten.freeze
|
13
14
|
|
14
|
-
def self.call(
|
15
|
-
new(
|
15
|
+
def self.call(**args)
|
16
|
+
new(**args).transform
|
16
17
|
end
|
17
18
|
|
18
19
|
def initialize(env)
|
@@ -6,14 +6,15 @@ 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 = [
|
12
13
|
Embed::Asciinema::SCRIPT_HOST,
|
13
14
|
].flatten.freeze
|
14
15
|
|
15
|
-
def self.call(
|
16
|
-
new(
|
16
|
+
def self.call(**args)
|
17
|
+
new(**args).transform
|
17
18
|
end
|
18
19
|
|
19
20
|
def initialize(env)
|
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"
|
data/qiita-markdown.gemspec
CHANGED
@@ -23,10 +23,10 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_dependency "html-pipeline", "~> 2.0"
|
24
24
|
spec.add_dependency "mem"
|
25
25
|
spec.add_dependency "rouge", "3.26.0"
|
26
|
-
spec.add_dependency "greenmat", "3.5.1.
|
26
|
+
spec.add_dependency "greenmat", "3.5.1.4"
|
27
27
|
spec.add_dependency "sanitize"
|
28
28
|
spec.add_dependency "addressable"
|
29
|
-
spec.add_development_dependency "activesupport", "
|
29
|
+
spec.add_development_dependency "activesupport", "~> 5.2.7"
|
30
30
|
spec.add_development_dependency "benchmark-ips", "~> 1.2"
|
31
31
|
spec.add_development_dependency "bundler"
|
32
32
|
spec.add_development_dependency "codeclimate-test-reporter", "0.4.4"
|
@@ -34,5 +34,5 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_development_dependency "pry"
|
35
35
|
spec.add_development_dependency "rake", "~> 10.0"
|
36
36
|
spec.add_development_dependency "rspec", "~> 3.1"
|
37
|
-
spec.add_development_dependency "rubocop", "1.
|
37
|
+
spec.add_development_dependency "rubocop", "~> 1.27.0"
|
38
38
|
end
|
@@ -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
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - '='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 3.5.1.
|
89
|
+
version: 3.5.1.4
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 3.5.1.
|
96
|
+
version: 3.5.1.4
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: sanitize
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,16 +126,16 @@ dependencies:
|
|
126
126
|
name: activesupport
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
131
|
+
version: 5.2.7
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
138
|
+
version: 5.2.7
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: benchmark-ips
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -280,16 +280,16 @@ dependencies:
|
|
280
280
|
name: rubocop
|
281
281
|
requirement: !ruby/object:Gem::Requirement
|
282
282
|
requirements:
|
283
|
-
- -
|
283
|
+
- - "~>"
|
284
284
|
- !ruby/object:Gem::Version
|
285
|
-
version: 1.
|
285
|
+
version: 1.27.0
|
286
286
|
type: :development
|
287
287
|
prerelease: false
|
288
288
|
version_requirements: !ruby/object:Gem::Requirement
|
289
289
|
requirements:
|
290
|
-
- -
|
290
|
+
- - "~>"
|
291
291
|
- !ruby/object:Gem::Version
|
292
|
-
version: 1.
|
292
|
+
version: 1.27.0
|
293
293
|
description:
|
294
294
|
email:
|
295
295
|
- r7kamura@gmail.com
|
@@ -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.
|
376
|
+
rubygems_version: 3.1.4
|
376
377
|
signing_key:
|
377
378
|
specification_version: 4
|
378
379
|
summary: Qiita-specified markdown processor.
|