qiita-markdown 0.43.0 → 0.44.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +14 -200
  3. data/CHANGELOG.md +10 -0
  4. data/README.md +2 -2
  5. data/benchmark/heading_anchor_rendering.rb +1 -1
  6. data/lib/qiita/markdown/embed/figma.rb +11 -0
  7. data/lib/qiita/markdown/filters/checkbox.rb +1 -1
  8. data/lib/qiita/markdown/filters/code_block.rb +13 -13
  9. data/lib/qiita/markdown/filters/custom_block.rb +1 -0
  10. data/lib/qiita/markdown/filters/external_link.rb +2 -0
  11. data/lib/qiita/markdown/filters/final_sanitizer.rb +118 -117
  12. data/lib/qiita/markdown/filters/footnote.rb +2 -0
  13. data/lib/qiita/markdown/filters/group_mention.rb +2 -2
  14. data/lib/qiita/markdown/filters/image_link.rb +6 -6
  15. data/lib/qiita/markdown/filters/inline_code_color.rb +8 -8
  16. data/lib/qiita/markdown/filters/mention.rb +11 -9
  17. data/lib/qiita/markdown/filters/simplify.rb +1 -0
  18. data/lib/qiita/markdown/filters/syntax_highlight.rb +4 -4
  19. data/lib/qiita/markdown/filters/truncate.rb +1 -3
  20. data/lib/qiita/markdown/filters/user_input_sanitizer.rb +26 -23
  21. data/lib/qiita/markdown/greenmat/heading_rendering.rb +2 -2
  22. data/lib/qiita/markdown/greenmat/html_toc_renderer.rb +1 -1
  23. data/lib/qiita/markdown/transformers/filter_attributes.rb +1 -0
  24. data/lib/qiita/markdown/transformers/filter_iframe.rb +2 -2
  25. data/lib/qiita/markdown/transformers/filter_script.rb +1 -1
  26. data/lib/qiita/markdown/transformers/strip_invalid_node.rb +1 -3
  27. data/lib/qiita/markdown/version.rb +1 -1
  28. data/lib/qiita/markdown.rb +1 -0
  29. data/qiita-markdown.gemspec +6 -6
  30. data/spec/qiita/markdown/filters/checkbox_spec.rb +42 -0
  31. data/spec/qiita/markdown/processor_spec.rb +54 -16
  32. data/spec/qiita/markdown/summary_processor_spec.rb +2 -2
  33. metadata +96 -99
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 925ca9666fc91e263d0b8fb4d704900d52b92964d6d53d63730d84403304df3b
4
- data.tar.gz: 47a27d59b58ced30484eadfc1dd59bfb94f96673a6e5e20fafc76f19c10065ea
3
+ metadata.gz: 15a4f04515ad1a13dca22d1cdb61272ddb7fca2066dbc5bc82b7ccfa3db06b74
4
+ data.tar.gz: 4fd57bd43763ee38486898592e63ddd2c945f54450557c08a4d66ea95b2a00ee
5
5
  SHA512:
6
- metadata.gz: d0613208602c957acd488a6050095a5ba79cc085fa08a8c18aa6ea98711e3ca61313cd68a9d166308b4d1cdd6efabe98e8a364c92635c82084374d765b069759
7
- data.tar.gz: 9ac8835a36b9871c02981d64ee335fd8e7a1a390825e81f5536e57af0b4d5be5d5004236d40f45409294a73a739aa01d0a814d9a30d5e20643b3c6a725682faf
6
+ metadata.gz: e648c8b60f7457028a3aaa89c891815fa5b283f553a02c1f6e516d658de480b2626508039fc41247a86b3d8ea931366a108f6bd8a119983906622596a5cb129b
7
+ data.tar.gz: 9f291ae053a36028df40a665d83a7e3acf1a82d5496c2cb1ead5a54e9369b71d2a43276d7ac5ccd6449e5e52bd9b29df13e3da1371d9531da53ba042c2d66ad4
data/.rubocop_todo.yml CHANGED
@@ -1,27 +1,11 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config --exclude-limit 99999`
3
- # on 2022-04-15 03:12:24 UTC using RuboCop version 1.27.0.
3
+ # on 2022-11-14 07:37:46 UTC using RuboCop version 1.39.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
- # Offense count: 3
10
- # This cop supports safe auto-correction (--auto-correct).
11
- # Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
12
- # Include: **/*.gemspec
13
- Gemspec/OrderedDependencies:
14
- Exclude:
15
- - 'qiita-markdown.gemspec'
16
-
17
- # Offense count: 1
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
9
  # Offense count: 1
26
10
  # Configuration parameters: Include.
27
11
  # Include: **/*.gemspec
@@ -29,66 +13,16 @@ Gemspec/RequiredRubyVersion:
29
13
  Exclude:
30
14
  - 'qiita-markdown.gemspec'
31
15
 
32
- # Offense count: 1
33
- # This cop supports safe auto-correction (--auto-correct).
34
- Layout/ClosingHeredocIndentation:
35
- Exclude:
36
- - 'spec/qiita/markdown/processor_spec.rb'
37
-
38
- # Offense count: 9
39
- # This cop supports safe auto-correction (--auto-correct).
40
- Layout/EmptyLineAfterGuardClause:
41
- Exclude:
42
- - 'lib/qiita/markdown/filters/custom_block.rb'
43
- - 'lib/qiita/markdown/filters/external_link.rb'
44
- - 'lib/qiita/markdown/filters/footnote.rb'
45
- - 'lib/qiita/markdown/filters/mention.rb'
46
- - 'lib/qiita/markdown/filters/simplify.rb'
47
- - 'lib/qiita/markdown/transformers/filter_attributes.rb'
48
-
49
- # Offense count: 22
50
- # This cop supports safe auto-correction (--auto-correct).
51
- # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
52
- # SupportedHashRocketStyles: key, separator, table
53
- # SupportedColonStyles: key, separator, table
54
- # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
55
- Layout/HashAlignment:
56
- Exclude:
57
- - 'lib/qiita/markdown/filters/user_input_sanitizer.rb'
58
-
59
- # Offense count: 1
60
- # This cop supports safe auto-correction (--auto-correct).
61
- # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
62
- # SupportedStyles: space, no_space, compact
63
- # SupportedStylesForEmptyBrackets: space, no_space
64
- Layout/SpaceInsideArrayLiteralBrackets:
65
- Exclude:
66
- - 'lib/qiita/markdown/transformers/filter_iframe.rb'
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
-
74
16
  # Offense count: 5
75
- # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
17
+ # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
76
18
  Metrics/AbcSize:
77
19
  Max: 22
78
20
 
79
- # Offense count: 10
80
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
21
+ # Offense count: 9
22
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
81
23
  Metrics/MethodLength:
82
24
  Max: 20
83
25
 
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
-
92
26
  # Offense count: 1
93
27
  Naming/ConstantName:
94
28
  Exclude:
@@ -121,27 +55,13 @@ Naming/MemoizedInstanceVariableName:
121
55
 
122
56
  # Offense count: 1
123
57
  # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
124
- # AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to
58
+ # AllowedNames: as, at, by, db, id, if, in, io, ip, of, on, os, pp, to
125
59
  Naming/MethodParameterName:
126
60
  Exclude:
127
61
  - 'lib/qiita/markdown/filters/footnote.rb'
128
62
 
129
- # Offense count: 3
130
- # This cop supports safe auto-correction (--auto-correct).
131
- # Configuration parameters: EnforcedStyle.
132
- # SupportedStyles: percent_q, bare_percent
133
- Style/BarePercentLiterals:
134
- Exclude:
135
- - 'lib/qiita/markdown/filters/syntax_highlight.rb'
136
-
137
- # Offense count: 1
138
- # This cop supports safe auto-correction (--auto-correct).
139
- Style/ExpandPathArguments:
140
- Exclude:
141
- - 'qiita-markdown.gemspec'
142
-
143
63
  # Offense count: 47
144
- # This cop supports safe auto-correction (--auto-correct).
64
+ # This cop supports unsafe autocorrection (--autocorrect-all).
145
65
  # Configuration parameters: EnforcedStyle.
146
66
  # SupportedStyles: always, always_true, never
147
67
  Style/FrozenStringLiteralComment:
@@ -194,51 +114,26 @@ Style/FrozenStringLiteralComment:
194
114
  - 'spec/qiita/markdown/summary_processor_spec.rb'
195
115
  - 'spec/spec_helper.rb'
196
116
 
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
-
206
- # Offense count: 2
207
- # This cop supports safe auto-correction (--auto-correct).
208
- Style/IfUnlessModifier:
209
- Exclude:
210
- - 'lib/qiita/markdown/filters/truncate.rb'
211
- - 'lib/qiita/markdown/transformers/strip_invalid_node.rb'
212
-
213
117
  # Offense count: 17
214
- # This cop supports safe auto-correction (--auto-correct).
118
+ # This cop supports unsafe autocorrection (--autocorrect-all).
215
119
  # Configuration parameters: EnforcedStyle.
216
120
  # SupportedStyles: literals, strict
217
121
  Style/MutableConstant:
218
122
  Exclude:
219
123
  - 'lib/qiita/markdown/embed/code_pen.rb'
220
- - 'lib/qiita/markdown/filters/group_mention.rb'
221
- - 'lib/qiita/markdown/filters/inline_code_color.rb'
222
- - 'lib/qiita/markdown/filters/mention.rb'
223
124
  - 'lib/qiita/markdown/embed/tweet.rb'
224
125
  - 'lib/qiita/markdown/filters/checkbox.rb'
225
126
  - 'lib/qiita/markdown/filters/code_block.rb'
127
+ - 'lib/qiita/markdown/filters/group_mention.rb'
128
+ - 'lib/qiita/markdown/filters/inline_code_color.rb'
129
+ - 'lib/qiita/markdown/filters/mention.rb'
226
130
  - 'lib/qiita/markdown/filters/simplify.rb'
227
131
  - 'lib/qiita/markdown/filters/syntax_highlight.rb'
228
132
  - 'lib/qiita/markdown/version.rb'
229
133
 
230
- # Offense count: 2
231
- # This cop supports safe auto-correction (--auto-correct).
232
- # Configuration parameters: EnforcedStyle, MinBodyLength.
233
- # SupportedStyles: skip_modifier_ifs, always
234
- Style/Next:
235
- Exclude:
236
- - 'lib/qiita/markdown/filters/code_block.rb'
237
- - 'lib/qiita/markdown/filters/image_link.rb'
238
-
239
134
  # Offense count: 5
240
- # This cop supports unsafe auto-correction (--auto-correct-all).
241
- # Configuration parameters: EnforcedStyle, IgnoredMethods.
135
+ # This cop supports unsafe autocorrection (--autocorrect-all).
136
+ # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns, IgnoredMethods.
242
137
  # SupportedStyles: predicate, comparison
243
138
  Style/NumericPredicate:
244
139
  Exclude:
@@ -255,98 +150,17 @@ Style/OptionalBooleanParameter:
255
150
  - 'lib/qiita/markdown/greenmat/heading_rendering.rb'
256
151
 
257
152
  # Offense count: 1
258
- # This cop supports safe auto-correction (--auto-correct).
259
- Style/OrAssignment:
260
- Exclude:
261
- - 'lib/qiita/markdown/greenmat/html_toc_renderer.rb'
262
-
263
- # Offense count: 9
264
- # This cop supports safe auto-correction (--auto-correct).
265
- # Configuration parameters: PreferredDelimiters.
266
- Style/PercentLiteralDelimiters:
267
- Exclude:
268
- - 'benchmark/heading_anchor_rendering.rb'
269
- - 'lib/qiita/markdown/filters/mention.rb'
270
- - 'lib/qiita/markdown/filters/syntax_highlight.rb'
271
- - 'spec/qiita/markdown/processor_spec.rb'
272
- - 'spec/qiita/markdown/summary_processor_spec.rb'
273
-
274
- # Offense count: 1
275
- # This cop supports safe auto-correction (--auto-correct).
276
- Style/PerlBackrefs:
277
- Exclude:
278
- - 'lib/qiita/markdown/filters/mention.rb'
279
-
280
- # Offense count: 1
281
- # This cop supports unsafe auto-correction (--auto-correct-all).
153
+ # This cop supports unsafe autocorrection (--autocorrect-all).
282
154
  # Configuration parameters: Methods.
283
155
  Style/RedundantArgument:
284
156
  Exclude:
285
157
  - 'lib/qiita/markdown/filters/custom_block.rb'
286
158
 
287
- # Offense count: 1
288
- # This cop supports safe auto-correction (--auto-correct).
289
- Style/RedundantRegexpCharacterClass:
290
- Exclude:
291
- - 'lib/qiita/markdown/filters/mention.rb'
292
-
293
- # Offense count: 9
294
- # This cop supports safe auto-correction (--auto-correct).
295
- Style/RedundantRegexpEscape:
296
- Exclude:
297
- - 'lib/qiita/markdown/filters/group_mention.rb'
298
- - 'lib/qiita/markdown/filters/inline_code_color.rb'
299
-
300
- # Offense count: 4
301
- # This cop supports safe auto-correction (--auto-correct).
302
- # Configuration parameters: EnforcedStyle, AllowInnerSlashes.
303
- # SupportedStyles: slashes, percent_r, mixed
304
- Style/RegexpLiteral:
305
- Exclude:
306
- - 'lib/qiita/markdown/filters/inline_code_color.rb'
307
- - 'lib/qiita/markdown/filters/mention.rb'
308
-
309
- # Offense count: 1
310
- # This cop supports safe auto-correction (--auto-correct).
311
- # Configuration parameters: EnforcedStyle.
312
- # SupportedStyles: implicit, explicit
313
- Style/RescueStandardError:
314
- Exclude:
315
- - 'lib/qiita/markdown/filters/syntax_highlight.rb'
316
-
317
159
  # Offense count: 2
318
- # This cop supports safe auto-correction (--auto-correct).
160
+ # This cop supports unsafe autocorrection (--autocorrect-all).
319
161
  # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
320
162
  # AllowedMethods: present?, blank?, presence, try, try!
321
163
  Style/SafeNavigation:
322
164
  Exclude:
323
165
  - 'lib/qiita/markdown/filters/custom_block.rb'
324
166
  - 'lib/qiita/markdown/filters/toc.rb'
325
-
326
- # Offense count: 3
327
- # This cop supports safe auto-correction (--auto-correct).
328
- # Configuration parameters: EnforcedStyle.
329
- # SupportedStyles: only_raise, only_fail, semantic
330
- Style/SignalException:
331
- Exclude:
332
- - 'lib/qiita/markdown/greenmat/heading_rendering.rb'
333
- - 'spec/qiita/markdown/summary_processor_spec.rb'
334
-
335
- # Offense count: 13
336
- # This cop supports safe auto-correction (--auto-correct).
337
- # Configuration parameters: EnforcedStyleForMultiline.
338
- # SupportedStylesForMultiline: comma, consistent_comma, no_comma
339
- Style/TrailingCommaInArguments:
340
- Exclude:
341
- - 'lib/qiita/markdown/filters/mention.rb'
342
- - 'spec/qiita/markdown/processor_spec.rb'
343
-
344
- # Offense count: 12
345
- # This cop supports safe auto-correction (--auto-correct).
346
- # Configuration parameters: EnforcedStyle, MinSize, WordRegex.
347
- # SupportedStyles: percent, brackets
348
- Style/WordArray:
349
- Exclude:
350
- - 'lib/qiita/markdown/filters/final_sanitizer.rb'
351
- - 'lib/qiita/markdown/transformers/filter_script.rb'
352
- - 'spec/qiita/markdown/processor_spec.rb'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 0.44.1
4
+
5
+ - Rename package name from `Qiita::Markdown` to `Qiita Markdown` in README
6
+ - Bump rubocop from 1.27.0 to 1.39.0 and apply rubocop auto correct
7
+
8
+ ## 0.44.0
9
+
10
+ - Support Figma embedding scripts
11
+ - Fix bug of checkbox filter
12
+
3
13
  ## 0.43.0
4
14
 
5
15
  - Fix GitHub Actions can't be executed when public fork
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Qiita::Markdown
1
+ # Qiita Markdown
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/qiita-markdown.svg)](https://badge.fury.io/rb/qiita-markdown)
4
4
  [![Build Status](https://travis-ci.org/increments/qiita-markdown.svg)](https://travis-ci.org/increments/qiita-markdown)
@@ -42,7 +42,7 @@ processor.call(markdown)
42
42
 
43
43
  ### Filters
44
44
 
45
- Qiita::Markdown is built on [jch/html-pipeline](https://github.com/jch/html-pipeline).
45
+ Qiita Markdown is built on [jch/html-pipeline](https://github.com/jch/html-pipeline).
46
46
  Add your favorite html-pipeline-compatible filters.
47
47
 
48
48
  ```ruby
@@ -61,7 +61,7 @@ module PostProcess
61
61
  end
62
62
 
63
63
  def anchor_element
64
- %[<span id="#{suffixed_id}" class="fragment"></span><a href="##{suffixed_id}"><i class="fa fa-link"></i></a>]
64
+ %(<span id="#{suffixed_id}" class="fragment"></span><a href="##{suffixed_id}"><i class="fa fa-link"></i></a>)
65
65
  end
66
66
 
67
67
  def content
@@ -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
@@ -16,19 +16,19 @@ module Qiita
16
16
  def call
17
17
  result[:codes] ||= []
18
18
  doc.search("pre").each do |pre|
19
- if (code = pre.at("code"))
20
- metadata = Metadata.new(code["data-metadata"])
21
- filename = metadata.filename
22
- language = metadata.language
23
- language = language_aliases[language] || language
24
- pre["filename"] = filename if filename
25
- pre["lang"] = language if language
26
- result[:codes] << {
27
- code: pre.text,
28
- filename: filename,
29
- language: language,
30
- }
31
- end
19
+ next unless (code = pre.at("code"))
20
+
21
+ metadata = Metadata.new(code["data-metadata"])
22
+ filename = metadata.filename
23
+ language = metadata.language
24
+ language = language_aliases[language] || language
25
+ pre["filename"] = filename if filename
26
+ pre["lang"] = language if language
27
+ result[:codes] << {
28
+ code: pre.text,
29
+ filename: filename,
30
+ language: language,
31
+ }
32
32
  end
33
33
  doc
34
34
  end
@@ -8,6 +8,7 @@ module Qiita
8
8
  doc.search('div[data-type="customblock"]').each do |div|
9
9
  metadata = Metadata.new(div["data-metadata"])
10
10
  next unless ALLOWED_TYPES.include?(metadata.type)
11
+
11
12
  klass = Object.const_get("#{self.class}::#{metadata.type.capitalize}")
12
13
  klass.new(div, metadata.subtype).convert
13
14
  end
@@ -7,9 +7,11 @@ module Qiita
7
7
  def call
8
8
  doc.search("a").each do |anchor|
9
9
  next unless anchor["href"]
10
+
10
11
  href = anchor["href"].strip
11
12
  href_host = host_of(href)
12
13
  next unless href_host
14
+
13
15
  if href_host != hostname
14
16
  anchor["rel"] = "nofollow noopener"
15
17
  anchor["target"] = "_blank"