qiita-markdown 0.24.0 → 0.25.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.

Potentially problematic release.


This version of qiita-markdown might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ebf4b7bf3373510614a5718e5f679f8b811e799
4
- data.tar.gz: e8c155ed67938804d750f6dbf19ee2dbde25f68f
3
+ metadata.gz: 89534a166cf79eb437e025498219b56ad7f62ec2
4
+ data.tar.gz: 8e4d0c3fe57c5876dbc3467a1a523fb2b96f7174
5
5
  SHA512:
6
- metadata.gz: 0b9770f4cc579ccbb39b7e6b3b4d624937f7e12572bbdaa8db7e2d634439441c4f87b9a5a314a52d10647dd19279d2e5589c6781d161e1368993849590753ba2
7
- data.tar.gz: 9ee149a5fc1470e7d7a3e8dca59b2a4cc9fc8765f7494f8703e33222a24811275be35d544fdc520bd092c1607f7951ca6fd1befd3c19919d2dfe9c0187906254
6
+ metadata.gz: a7b791b1d6ee445d539b1f6576d17f00e70370f3a723efcf614c85ea1277a49d43848570202955fdf016ff11965657a3feb8395887ea11de8c37510da60949c3
7
+ data.tar.gz: a31faf66fcd5e3d5509adeb1b4726e6b76f9184efdf6831f451048e5fbb9d187b7b62846f888ff5691a9b8f338ec1c7664579aad58e40e26008cddc90588fab4
@@ -1,5 +1,9 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 0.25.0
4
+
5
+ - Accept new codepen script url (static.codepen.io)
6
+
3
7
  ## 0.24.0
4
8
 
5
9
  - Fix to strip HTML tags in ToC
@@ -2,7 +2,10 @@ module Qiita
2
2
  module Markdown
3
3
  module Embed
4
4
  module CodePen
5
- SCRIPT_URL = "https://production-assets.codepen.io/assets/embed/ei.js"
5
+ SCRIPT_URLS = [
6
+ "https://production-assets.codepen.io/assets/embed/ei.js",
7
+ "https://static.codepen.io/assets/embed/ei.js",
8
+ ]
6
9
  CLASS_NAME = %w[codepen]
7
10
  DATA_ATTRIBUTES = %w[
8
11
  data-active-link-color data-active-tab-color data-animations data-border
@@ -3,9 +3,9 @@ module Qiita
3
3
  module Transformers
4
4
  class FilterScript
5
5
  WHITE_LIST = [
6
- Embed::CodePen::SCRIPT_URL,
6
+ Embed::CodePen::SCRIPT_URLS,
7
7
  Embed::Tweet::SCRIPT_URL,
8
- ].freeze
8
+ ].flatten.freeze
9
9
 
10
10
  def self.call(*args)
11
11
  new(*args).transform
@@ -1,5 +1,5 @@
1
1
  module Qiita
2
2
  module Markdown
3
- VERSION = "0.24.0"
3
+ VERSION = "0.25.0"
4
4
  end
5
5
  end
@@ -21,9 +21,9 @@ describe Qiita::Markdown::Processor do
21
21
  shared_examples_for "basic markdown syntax" do
22
22
  context "with valid condition" do
23
23
  let(:markdown) do
24
- <<-EOS.strip_heredoc
24
+ <<-MARKDOWN.strip_heredoc
25
25
  example
26
- EOS
26
+ MARKDOWN
27
27
  end
28
28
 
29
29
  it "returns a Hash with HTML output and other metadata" do
@@ -39,9 +39,9 @@ describe Qiita::Markdown::Processor do
39
39
  end
40
40
 
41
41
  it "sanitizes them" do
42
- should eq <<-EOS.strip_heredoc
42
+ should eq <<-HTML.strip_heredoc
43
43
  <p>&lt;&gt;&amp;</p>
44
- EOS
44
+ HTML
45
45
  end
46
46
  end
47
47
 
@@ -51,24 +51,24 @@ describe Qiita::Markdown::Processor do
51
51
  end
52
52
 
53
53
  it "replaces with mailto link" do
54
- should eq <<-EOS.strip_heredoc
54
+ should eq <<-HTML.strip_heredoc
55
55
  <p><a href="mailto:test@example.com" class="autolink">test@example.com</a></p>
56
- EOS
56
+ HTML
57
57
  end
58
58
  end
59
59
 
60
60
  context "with headings" do
61
61
  let(:markdown) do
62
- <<-EOS.strip_heredoc
62
+ <<-MARKDOWN.strip_heredoc
63
63
  # a
64
64
  ## a
65
65
  ### a
66
66
  ### a
67
- EOS
67
+ MARKDOWN
68
68
  end
69
69
 
70
70
  it "adds ID for ToC" do
71
- should eq <<-EOS.strip_heredoc
71
+ should eq <<-HTML.strip_heredoc
72
72
 
73
73
  <h1>
74
74
  <span id="a" class="fragment"></span><a href="#a"><i class="fa fa-link"></i></a>a</h1>
@@ -81,48 +81,48 @@ describe Qiita::Markdown::Processor do
81
81
 
82
82
  <h3>
83
83
  <span id="a-3" class="fragment"></span><a href="#a-3"><i class="fa fa-link"></i></a>a</h3>
84
- EOS
84
+ HTML
85
85
  end
86
86
  end
87
87
 
88
88
  context "with heading whose title includes special HTML characters" do
89
89
  let(:markdown) do
90
- <<-EOS.strip_heredoc
90
+ <<-MARKDOWN.strip_heredoc
91
91
  # <b>R&amp;B</b>
92
- EOS
92
+ MARKDOWN
93
93
  end
94
94
 
95
95
  it "generates fragment identifier by sanitizing the special characters in the title" do
96
- should eq <<-EOS.strip_heredoc
96
+ should eq <<-HTML.strip_heredoc
97
97
 
98
98
  <h1>
99
99
  <span id="rb" class="fragment"></span><a href="#rb"><i class="fa fa-link"></i></a><b>R&amp;B</b>
100
100
  </h1>
101
- EOS
101
+ HTML
102
102
  end
103
103
  end
104
104
 
105
105
  context "with manually inputted heading HTML tags without id attribute" do
106
106
  let(:markdown) do
107
- <<-EOS.strip_heredoc
107
+ <<-MARKDOWN.strip_heredoc
108
108
  <h1>foo</h1>
109
- EOS
109
+ MARKDOWN
110
110
  end
111
111
 
112
112
  it "does nothing" do
113
- should eq <<-EOS.strip_heredoc
113
+ should eq <<-HTML.strip_heredoc
114
114
  <h1>foo</h1>
115
- EOS
115
+ HTML
116
116
  end
117
117
  end
118
118
 
119
119
  context "with code" do
120
120
  let(:markdown) do
121
- <<-EOS.strip_heredoc
121
+ <<-MARKDOWN.strip_heredoc
122
122
  ```foo.rb
123
123
  puts 'hello world'
124
124
  ```
125
- EOS
125
+ MARKDOWN
126
126
  end
127
127
 
128
128
  it "returns detected codes" do
@@ -138,68 +138,68 @@ describe Qiita::Markdown::Processor do
138
138
 
139
139
  context "with code & filename" do
140
140
  let(:markdown) do
141
- <<-EOS.strip_heredoc
141
+ <<-MARKDOWN.strip_heredoc
142
142
  ```example.rb
143
143
  1
144
144
  ```
145
- EOS
145
+ MARKDOWN
146
146
  end
147
147
 
148
148
  it "returns code-frame, code-lang, and highlighted pre element" do
149
- should eq <<-EOS.strip_heredoc
149
+ should eq <<-HTML.strip_heredoc
150
150
  <div class="code-frame" data-lang="ruby">
151
151
  <div class="code-lang"><span class="bold">example.rb</span></div>
152
152
  <div class="highlight"><pre><span></span><span class="mi">1</span>
153
153
  </pre></div>
154
154
  </div>
155
- EOS
155
+ HTML
156
156
  end
157
157
  end
158
158
 
159
159
  context "with code & filename with .php" do
160
160
  let(:markdown) do
161
- <<-EOS.strip_heredoc
161
+ <<-MARKDOWN.strip_heredoc
162
162
  ```example.php
163
163
  1
164
164
  ```
165
- EOS
165
+ MARKDOWN
166
166
  end
167
167
 
168
168
  it "returns PHP code-frame" do
169
- should eq <<-EOS.strip_heredoc
169
+ should eq <<-HTML.strip_heredoc
170
170
  <div class="code-frame" data-lang="php">
171
171
  <div class="code-lang"><span class="bold">example.php</span></div>
172
172
  <div class="highlight"><pre><span></span><span class="mi">1</span>
173
173
  </pre></div>
174
174
  </div>
175
- EOS
175
+ HTML
176
176
  end
177
177
  end
178
178
 
179
179
  context "with code & no filename" do
180
180
  let(:markdown) do
181
- <<-EOS.strip_heredoc
181
+ <<-MARKDOWN.strip_heredoc
182
182
  ```ruby
183
183
  1
184
184
  ```
185
- EOS
185
+ MARKDOWN
186
186
  end
187
187
 
188
188
  it "returns code-frame and highlighted pre element" do
189
- should eq <<-EOS.strip_heredoc
189
+ should eq <<-HTML.strip_heredoc
190
190
  <div class="code-frame" data-lang="ruby"><div class="highlight"><pre><span></span><span class="mi">1</span>
191
191
  </pre></div></div>
192
- EOS
192
+ HTML
193
193
  end
194
194
  end
195
195
 
196
196
  context "with undefined but aliased language" do
197
197
  let(:markdown) do
198
- <<-EOS.strip_heredoc
198
+ <<-MARKDOWN.strip_heredoc
199
199
  ```zsh
200
200
  true
201
201
  ```
202
- EOS
202
+ MARKDOWN
203
203
  end
204
204
 
205
205
  it "returns aliased language name" do
@@ -215,22 +215,22 @@ describe Qiita::Markdown::Processor do
215
215
 
216
216
  context "with code with leading and trailing newlines" do
217
217
  let(:markdown) do
218
- <<-EOS.strip_heredoc
218
+ <<-MARKDOWN.strip_heredoc
219
219
  ```
220
220
 
221
221
  foo
222
222
 
223
223
  ```
224
- EOS
224
+ MARKDOWN
225
225
  end
226
226
 
227
227
  it "does not strip the newlines" do
228
- should eq <<-EOS.strip_heredoc
228
+ should eq <<-HTML.strip_heredoc
229
229
  <div class="code-frame" data-lang="text"><div class="highlight"><pre><span></span>
230
230
  foo
231
231
 
232
232
  </pre></div></div>
233
- EOS
233
+ HTML
234
234
  end
235
235
  end
236
236
 
@@ -240,9 +240,9 @@ describe Qiita::Markdown::Processor do
240
240
  end
241
241
 
242
242
  it "replaces mention with link" do
243
- should include(<<-EOS.strip_heredoc.rstrip)
243
+ should include(<<-HTML.strip_heredoc.rstrip)
244
244
  <a href="/alice" class="user-mention js-hovercard" title="alice" data-hovercard-target-type="user" data-hovercard-target-name="alice">@alice</a>
245
- EOS
245
+ HTML
246
246
  end
247
247
  end
248
248
 
@@ -252,15 +252,15 @@ describe Qiita::Markdown::Processor do
252
252
  end
253
253
 
254
254
  it "replaces mention with link" do
255
- should include(<<-EOS.strip_heredoc.rstrip)
255
+ should include(<<-HTML.strip_heredoc.rstrip)
256
256
  <a href="/al" class="user-mention js-hovercard" title="al" data-hovercard-target-type="user" data-hovercard-target-name="al">@al</a>
257
- EOS
257
+ HTML
258
258
  end
259
259
  end
260
260
 
261
261
  context "with mentions in complex patterns" do
262
262
  let(:markdown) do
263
- <<-EOS.strip_heredoc
263
+ <<-MARKDOWN.strip_heredoc
264
264
  @alice
265
265
 
266
266
  ```
@@ -280,7 +280,7 @@ describe Qiita::Markdown::Processor do
280
280
  @-o
281
281
  @o_
282
282
  @_o
283
- EOS
283
+ MARKDOWN
284
284
  end
285
285
 
286
286
  it "extracts mentions correctly" do
@@ -300,21 +300,21 @@ describe Qiita::Markdown::Processor do
300
300
 
301
301
  context "with mention-like filename on code block" do
302
302
  let(:markdown) do
303
- <<-EOS.strip_heredoc
303
+ <<-MARKDOWN.strip_heredoc
304
304
  ```ruby:@alice
305
305
  1
306
306
  ```
307
- EOS
307
+ MARKDOWN
308
308
  end
309
309
 
310
310
  it "does not treat it as mention" do
311
- should include(<<-EOS.strip_heredoc.rstrip)
311
+ should include(<<-HTML.strip_heredoc.rstrip)
312
312
  <div class="code-frame" data-lang="ruby">
313
313
  <div class="code-lang"><span class="bold">@alice</span></div>
314
314
  <div class="highlight"><pre><span></span><span class="mi">1</span>
315
315
  </pre></div>
316
316
  </div>
317
- EOS
317
+ HTML
318
318
  end
319
319
  end
320
320
 
@@ -324,11 +324,11 @@ describe Qiita::Markdown::Processor do
324
324
  end
325
325
 
326
326
  it "does not replace mention with link" do
327
- should include(<<-EOS.strip_heredoc.rstrip)
327
+ should include(<<-HTML.strip_heredoc.rstrip)
328
328
  <blockquote>
329
329
  <p>@alice</p>
330
330
  </blockquote>
331
- EOS
331
+ HTML
332
332
  end
333
333
  end
334
334
 
@@ -338,9 +338,9 @@ describe Qiita::Markdown::Processor do
338
338
  end
339
339
 
340
340
  it "does not emphasize the name" do
341
- should include(<<-EOS.strip_heredoc.rstrip)
341
+ should include(<<-HTML.strip_heredoc.rstrip)
342
342
  <a href="/_alice_" class="user-mention js-hovercard" title="_alice_" data-hovercard-target-type="user" data-hovercard-target-name="_alice_">@_alice_</a>
343
- EOS
343
+ HTML
344
344
  end
345
345
  end
346
346
 
@@ -350,10 +350,10 @@ describe Qiita::Markdown::Processor do
350
350
  end
351
351
 
352
352
  let(:markdown) do
353
- <<-EOS.strip_heredoc
353
+ <<-MARKDOWN.strip_heredoc
354
354
  @alice
355
355
  @bob
356
- EOS
356
+ MARKDOWN
357
357
  end
358
358
 
359
359
  it "limits mentions to allowed usernames" do
@@ -371,9 +371,9 @@ describe Qiita::Markdown::Processor do
371
371
  end
372
372
 
373
373
  it "links it and reports all allowed users as mentioned user names" do
374
- should include(<<-EOS.strip_heredoc.rstrip)
374
+ should include(<<-HTML.strip_heredoc.rstrip)
375
375
  <a href="/" class="user-mention" title="all">@all</a>
376
- EOS
376
+ HTML
377
377
  expect(result[:mentioned_usernames]).to eq context[:allowed_usernames]
378
378
  end
379
379
  end
@@ -409,9 +409,9 @@ describe Qiita::Markdown::Processor do
409
409
  end
410
410
 
411
411
  it "does not replace it" do
412
- is_expected.to eq <<-EOS.strip_heredoc
412
+ is_expected.to eq <<-HTML.strip_heredoc
413
413
  <p>@alice/bob</p>
414
- EOS
414
+ HTML
415
415
  end
416
416
  end
417
417
 
@@ -427,9 +427,9 @@ describe Qiita::Markdown::Processor do
427
427
  end
428
428
 
429
429
  it "replaces it with preferred link and updates :mentioned_groups" do
430
- is_expected.to eq <<-EOS.strip_heredoc
430
+ is_expected.to eq <<-HTML.strip_heredoc
431
431
  <p><a href="https://alice.example.com/groups/bob" rel="nofollow noopener" target="_blank">@alice/bob</a></p>
432
- EOS
432
+ HTML
433
433
  expect(result[:mentioned_groups]).to eq [{
434
434
  group_url_name: "bob",
435
435
  team_url_name: "alice",
@@ -459,9 +459,9 @@ describe Qiita::Markdown::Processor do
459
459
  end
460
460
 
461
461
  it "creates link for that" do
462
- should eq <<-EOS.strip_heredoc
462
+ should eq <<-HTML.strip_heredoc
463
463
  <p><a href="/example"></a></p>
464
- EOS
464
+ HTML
465
465
  end
466
466
  end
467
467
 
@@ -471,9 +471,9 @@ describe Qiita::Markdown::Processor do
471
471
  end
472
472
 
473
473
  it "creates link for that" do
474
- should eq <<-EOS.strip_heredoc
474
+ should eq <<-HTML.strip_heredoc
475
475
  <p><a href="#example"></a></p>
476
- EOS
476
+ HTML
477
477
  end
478
478
  end
479
479
 
@@ -483,9 +483,9 @@ describe Qiita::Markdown::Processor do
483
483
  end
484
484
 
485
485
  it "creates link for that with the title" do
486
- should eq <<-EOS.strip_heredoc
486
+ should eq <<-HTML.strip_heredoc
487
487
  <p><a href="/example" title="Title"></a></p>
488
- EOS
488
+ HTML
489
489
  end
490
490
  end
491
491
 
@@ -508,9 +508,9 @@ describe Qiita::Markdown::Processor do
508
508
  end
509
509
 
510
510
  it "removes that link by creating empty a element" do
511
- should eq <<-EOS.strip_heredoc
511
+ should eq <<-HTML.strip_heredoc
512
512
  <p><a></a></p>
513
- EOS
513
+ HTML
514
514
  end
515
515
  end
516
516
 
@@ -526,11 +526,11 @@ describe Qiita::Markdown::Processor do
526
526
 
527
527
  context "with emoji in pre or code element" do
528
528
  let(:markdown) do
529
- <<-EOS.strip_heredoc
529
+ <<-MARKDOWN.strip_heredoc
530
530
  ```
531
531
  :+1:
532
532
  ```
533
- EOS
533
+ MARKDOWN
534
534
  end
535
535
 
536
536
  it "does not replace it" do
@@ -573,11 +573,11 @@ describe Qiita::Markdown::Processor do
573
573
 
574
574
  context "with colon-only label" do
575
575
  let(:markdown) do
576
- <<-EOS.strip_heredoc
576
+ <<-MARKDOWN.strip_heredoc
577
577
  ```:
578
578
  1
579
579
  ```
580
- EOS
580
+ MARKDOWN
581
581
  end
582
582
 
583
583
  it "does not replace it" do
@@ -597,42 +597,42 @@ describe Qiita::Markdown::Processor do
597
597
  end
598
598
 
599
599
  it "allows font element with color attribute" do
600
- should eq <<-EOS.strip_heredoc
600
+ should eq <<-HTML.strip_heredoc
601
601
  <p>#{markdown}</p>
602
- EOS
602
+ HTML
603
603
  end
604
604
  end
605
605
 
606
606
  context "with task list" do
607
607
  let(:markdown) do
608
- <<-EOS.strip_heredoc
608
+ <<-MARKDOWN.strip_heredoc
609
609
  - [ ] a
610
610
  - [x] b
611
- EOS
611
+ MARKDOWN
612
612
  end
613
613
 
614
614
  it "inserts checkbox" do
615
- should eq <<-EOS.strip_heredoc
615
+ should eq <<-HTML.strip_heredoc
616
616
  <ul>
617
617
  <li class="task-list-item">
618
618
  <input type="checkbox" class="task-list-item-checkbox" disabled>a</li>
619
619
  <li class="task-list-item">
620
620
  <input type="checkbox" class="task-list-item-checkbox" checked disabled>b</li>
621
621
  </ul>
622
- EOS
622
+ HTML
623
623
  end
624
624
  end
625
625
 
626
626
  context "with nested task list" do
627
627
  let(:markdown) do
628
- <<-EOS.strip_heredoc
628
+ <<-MARKDOWN.strip_heredoc
629
629
  - [ ] a
630
630
  - [ ] b
631
- EOS
631
+ MARKDOWN
632
632
  end
633
633
 
634
634
  it "inserts checkbox" do
635
- should eq <<-EOS.strip_heredoc
635
+ should eq <<-HTML.strip_heredoc
636
636
  <ul>
637
637
  <li class="task-list-item">
638
638
  <input type="checkbox" class="task-list-item-checkbox" disabled>a
@@ -643,45 +643,45 @@ describe Qiita::Markdown::Processor do
643
643
  </ul>
644
644
  </li>
645
645
  </ul>
646
- EOS
646
+ HTML
647
647
  end
648
648
  end
649
649
 
650
650
  context "with task list in code block" do
651
651
  let(:markdown) do
652
- <<-EOS.strip_heredoc
652
+ <<-MARKDOWN.strip_heredoc
653
653
  ```
654
654
  - [ ] a
655
655
  - [x] b
656
656
  ```
657
- EOS
657
+ MARKDOWN
658
658
  end
659
659
 
660
660
  it "does not replace checkbox" do
661
- should eq <<-EOS.strip_heredoc
661
+ should eq <<-HTML.strip_heredoc
662
662
  <div class="code-frame" data-lang="text"><div class="highlight"><pre><span></span>- [ ] a
663
663
  - [x] b
664
664
  </pre></div></div>
665
- EOS
665
+ HTML
666
666
  end
667
667
  end
668
668
 
669
669
  context "with empty line between task list" do
670
670
  let(:markdown) do
671
- <<-EOS.strip_heredoc
671
+ <<-MARKDOWN.strip_heredoc
672
672
  - [ ] a
673
673
 
674
674
  - [x] b
675
- EOS
675
+ MARKDOWN
676
676
  end
677
677
 
678
678
  it "inserts checkbox" do
679
- should eq <<-EOS.strip_heredoc
679
+ should eq <<-HTML.strip_heredoc
680
680
  <ul>
681
681
  <li class="task-list-item"><p><input type="checkbox" class="task-list-item-checkbox" disabled>a</p></li>
682
682
  <li class="task-list-item"><p><input type="checkbox" class="task-list-item-checkbox" checked disabled>b</p></li>
683
683
  </ul>
684
- EOS
684
+ HTML
685
685
  end
686
686
  end
687
687
 
@@ -691,25 +691,25 @@ describe Qiita::Markdown::Processor do
691
691
  end
692
692
 
693
693
  it "inserts checkbox" do
694
- should eq <<-EOS.strip_heredoc
694
+ should eq <<-HTML.strip_heredoc
695
695
  <ul>
696
696
  <li>
697
697
  </ul>
698
- EOS
698
+ HTML
699
699
  end
700
700
  end
701
701
 
702
702
  context "with text-aligned table" do
703
703
  let(:markdown) do
704
- <<-EOS.strip_heredoc
704
+ <<-MARKDOWN.strip_heredoc
705
705
  | a | b | c |
706
706
  |:---|---:|:---:|
707
707
  | a | b | c |
708
- EOS
708
+ MARKDOWN
709
709
  end
710
710
 
711
711
  it "creates table element with text-align style" do
712
- should eq <<-EOS.strip_heredoc
712
+ should eq <<-HTML.strip_heredoc
713
713
  <table>
714
714
  <thead>
715
715
  <tr>
@@ -726,20 +726,20 @@ describe Qiita::Markdown::Processor do
726
726
  </tr>
727
727
  </tbody>
728
728
  </table>
729
- EOS
729
+ HTML
730
730
  end
731
731
  end
732
732
 
733
733
  context "with footenotes syntax" do
734
734
  let(:markdown) do
735
- <<-EOS.strip_heredoc
735
+ <<-MARKDOWN.strip_heredoc
736
736
  [^1]
737
737
  [^1]: test
738
- EOS
738
+ MARKDOWN
739
739
  end
740
740
 
741
741
  it "generates footnotes elements" do
742
- should eq <<-EOS.strip_heredoc
742
+ should eq <<-HTML.strip_heredoc
743
743
  <p><sup id="fnref1"><a href="#fn1" rel="footnote" title="test">1</a></sup></p>
744
744
 
745
745
  <div class="footnotes">
@@ -752,35 +752,35 @@ describe Qiita::Markdown::Processor do
752
752
 
753
753
  </ol>
754
754
  </div>
755
- EOS
755
+ HTML
756
756
  end
757
757
  end
758
758
 
759
759
  context "with manually written link inside of <sup> tag" do
760
760
  let(:markdown) do
761
- <<-EOS.strip_heredoc
761
+ <<-MARKDOWN.strip_heredoc
762
762
  <sup>[Example](http://example.com/)</sup>
763
- EOS
763
+ MARKDOWN
764
764
  end
765
765
 
766
766
  it "does not confuse the structure with automatically generated footnote reference" do
767
- should eq <<-EOS.strip_heredoc
767
+ should eq <<-HTML.strip_heredoc
768
768
  <p><sup><a href="http://example.com/">Example</a></sup></p>
769
- EOS
769
+ HTML
770
770
  end
771
771
  end
772
772
 
773
773
  context "with manually written <a> tag with strange href inside of <sup> tag" do
774
774
  let(:markdown) do
775
- <<-EOS.strip_heredoc
775
+ <<-MARKDOWN.strip_heredoc
776
776
  <sup><a href="#foo.1">Link</a></sup>
777
- EOS
777
+ MARKDOWN
778
778
  end
779
779
 
780
780
  it "does not confuse the structure with automatically generated footnote reference" do
781
- should eq <<-EOS.strip_heredoc
781
+ should eq <<-HTML.strip_heredoc
782
782
  <p><sup><a href="#foo.1">Link</a></sup></p>
783
- EOS
783
+ HTML
784
784
  end
785
785
  end
786
786
 
@@ -790,16 +790,16 @@ describe Qiita::Markdown::Processor do
790
790
  end
791
791
 
792
792
  let(:markdown) do
793
- <<-EOS.strip_heredoc
793
+ <<-MARKDOWN.strip_heredoc
794
794
  [^1]
795
795
  [^1]: test
796
- EOS
796
+ MARKDOWN
797
797
  end
798
798
 
799
799
  it "does not generate footnote elements" do
800
- should eq <<-EOS.strip_heredoc
800
+ should eq <<-HTML.strip_heredoc
801
801
  <p><a href="test">^1</a></p>
802
- EOS
802
+ HTML
803
803
  end
804
804
  end
805
805
 
@@ -813,9 +813,9 @@ describe Qiita::Markdown::Processor do
813
813
  end
814
814
 
815
815
  let(:markdown) do
816
- <<-EOS.strip_heredoc
816
+ <<-MARKDOWN.strip_heredoc
817
817
  :foo: :o: :x:
818
- EOS
818
+ MARKDOWN
819
819
  end
820
820
 
821
821
  it "replaces only the specified emoji names with img elements with custom URL" do
@@ -1036,9 +1036,9 @@ describe Qiita::Markdown::Processor do
1036
1036
  shared_examples_for "script element" do |allowed:|
1037
1037
  context "with script element" do
1038
1038
  let(:markdown) do
1039
- <<-EOS.strip_heredoc
1039
+ <<-MARKDOWN.strip_heredoc
1040
1040
  <script>alert(1)</script>
1041
- EOS
1041
+ MARKDOWN
1042
1042
  end
1043
1043
 
1044
1044
  if allowed
@@ -1048,9 +1048,9 @@ describe Qiita::Markdown::Processor do
1048
1048
 
1049
1049
  context "and allowed attributes" do
1050
1050
  let(:markdown) do
1051
- <<-EOS.strip_heredoc
1051
+ <<-MARKDOWN.strip_heredoc
1052
1052
  <p><script async data-a="b" type="text/javascript">alert(1)</script></p>
1053
- EOS
1053
+ MARKDOWN
1054
1054
  end
1055
1055
 
1056
1056
  it "allows data-attributes" do
@@ -1068,32 +1068,32 @@ describe Qiita::Markdown::Processor do
1068
1068
  shared_examples_for "malicious script in filename" do |allowed:|
1069
1069
  context "with malicious script in filename" do
1070
1070
  let(:markdown) do
1071
- <<-EOS.strip_heredoc
1071
+ <<-MARKDOWN.strip_heredoc
1072
1072
  ```js:test<script>alert(1)</script>
1073
1073
  1
1074
1074
  ```
1075
- EOS
1075
+ MARKDOWN
1076
1076
  end
1077
1077
 
1078
1078
  if allowed
1079
1079
  it "does not sanitize script element" do
1080
- should eq <<-EOS.strip_heredoc
1080
+ should eq <<-HTML.strip_heredoc
1081
1081
  <div class="code-frame" data-lang="js">
1082
1082
  <div class="code-lang"><span class="bold">test<script>alert(1)</script></span></div>
1083
1083
  <div class="highlight"><pre><span></span><span class="mi">1</span>
1084
1084
  </pre></div>
1085
1085
  </div>
1086
- EOS
1086
+ HTML
1087
1087
  end
1088
1088
  else
1089
1089
  it "sanitizes script element" do
1090
- should eq <<-EOS.strip_heredoc
1090
+ should eq <<-HTML.strip_heredoc
1091
1091
  <div class="code-frame" data-lang="js">
1092
1092
  <div class="code-lang"><span class="bold">test</span></div>
1093
1093
  <div class="highlight"><pre><span></span><span class="mi">1</span>
1094
1094
  </pre></div>
1095
1095
  </div>
1096
- EOS
1096
+ HTML
1097
1097
  end
1098
1098
  end
1099
1099
  end
@@ -1102,9 +1102,9 @@ describe Qiita::Markdown::Processor do
1102
1102
  shared_examples_for "iframe element" do |allowed:|
1103
1103
  context "with iframe" do
1104
1104
  let(:markdown) do
1105
- <<-EOS.strip_heredoc
1105
+ <<-MARKDOWN.strip_heredoc
1106
1106
  <iframe width="1" height="2" src="//example.com" frameborder="0" allowfullscreen></iframe>
1107
- EOS
1107
+ MARKDOWN
1108
1108
  end
1109
1109
 
1110
1110
  if allowed
@@ -1122,9 +1122,9 @@ describe Qiita::Markdown::Processor do
1122
1122
  shared_examples_for "input element" do |allowed:|
1123
1123
  context "with input" do
1124
1124
  let(:markdown) do
1125
- <<-EOS.strip_heredoc
1125
+ <<-MARKDOWN.strip_heredoc
1126
1126
  <input type="checkbox"> foo
1127
- EOS
1127
+ MARKDOWN
1128
1128
  end
1129
1129
 
1130
1130
  if allowed
@@ -1142,66 +1142,66 @@ describe Qiita::Markdown::Processor do
1142
1142
  shared_examples_for "data-attributes" do |allowed:|
1143
1143
  context "with data-attributes for general tags" do
1144
1144
  let(:markdown) do
1145
- <<-EOS.strip_heredoc
1145
+ <<-MARKDOWN.strip_heredoc
1146
1146
  <div data-a="b"></div>
1147
- EOS
1147
+ MARKDOWN
1148
1148
  end
1149
1149
 
1150
1150
  if allowed
1151
1151
  it "does not sanitize data-attributes" do
1152
- should eq <<-EOS.strip_heredoc
1152
+ should eq <<-HTML.strip_heredoc
1153
1153
  <div data-a="b"></div>
1154
- EOS
1154
+ HTML
1155
1155
  end
1156
1156
  else
1157
1157
  it "sanitizes data-attributes" do
1158
- should eq <<-EOS.strip_heredoc
1158
+ should eq <<-HTML.strip_heredoc
1159
1159
  <div></div>
1160
- EOS
1160
+ HTML
1161
1161
  end
1162
1162
  end
1163
1163
  end
1164
1164
 
1165
1165
  context "with data-attributes for <blockquote> tag" do
1166
1166
  let(:markdown) do
1167
- <<-EOS.strip_heredoc
1167
+ <<-MARKDOWN.strip_heredoc
1168
1168
  <blockquote data-theme="a" data-malicious="b"></blockquote>
1169
- EOS
1169
+ MARKDOWN
1170
1170
  end
1171
1171
 
1172
1172
  if allowed
1173
1173
  it "does not sanitize data-attributes" do
1174
- should eq <<-EOS.strip_heredoc
1174
+ should eq <<-HTML.strip_heredoc
1175
1175
  <blockquote data-theme="a" data-malicious="b"></blockquote>
1176
- EOS
1176
+ HTML
1177
1177
  end
1178
1178
  else
1179
1179
  it "sanitizes data-attributes except the attributes used by tweet" do
1180
- should eq <<-EOS.strip_heredoc
1180
+ should eq <<-HTML.strip_heredoc
1181
1181
  <blockquote data-theme="a"></blockquote>
1182
- EOS
1182
+ HTML
1183
1183
  end
1184
1184
  end
1185
1185
  end
1186
1186
 
1187
1187
  context "with data-attributes for <p> tag" do
1188
1188
  let(:markdown) do
1189
- <<-EOS.strip_heredoc
1189
+ <<-MARKDOWN.strip_heredoc
1190
1190
  <p data-slug-hash="a" data-malicious="b"></p>
1191
- EOS
1191
+ MARKDOWN
1192
1192
  end
1193
1193
 
1194
1194
  if allowed
1195
1195
  it "does not sanitize data-attributes" do
1196
- should eq <<-EOS.strip_heredoc
1196
+ should eq <<-HTML.strip_heredoc
1197
1197
  <p data-slug-hash="a" data-malicious="b"></p>
1198
- EOS
1198
+ HTML
1199
1199
  end
1200
1200
  else
1201
1201
  it "sanitizes data-attributes except the attributes used by codepen" do
1202
- should eq <<-EOS.strip_heredoc
1202
+ should eq <<-HTML.strip_heredoc
1203
1203
  <p data-slug-hash="a"></p>
1204
- EOS
1204
+ HTML
1205
1205
  end
1206
1206
  end
1207
1207
  end
@@ -1226,91 +1226,91 @@ describe Qiita::Markdown::Processor do
1226
1226
 
1227
1227
  context "with class attribute for <a> tag" do
1228
1228
  let(:markdown) do
1229
- <<-EOS.strip_heredoc
1229
+ <<-MARKDOWN.strip_heredoc
1230
1230
  <a href="foo" class="malicious-class">foo</a>
1231
1231
  http://qiita.com/
1232
- EOS
1232
+ MARKDOWN
1233
1233
  end
1234
1234
 
1235
1235
  if allowed
1236
1236
  it "does not sanitize the classes" do
1237
- should eq <<-EOS.strip_heredoc
1237
+ should eq <<-HTML.strip_heredoc
1238
1238
  <p><a href="foo" class="malicious-class">foo</a><br>
1239
1239
  <a href="http://qiita.com/" class="autolink" rel="nofollow noopener" target="_blank">http://qiita.com/</a></p>
1240
- EOS
1240
+ HTML
1241
1241
  end
1242
1242
  else
1243
1243
  it "sanitizes classes except `autolink`" do
1244
- should eq <<-EOS.strip_heredoc
1244
+ should eq <<-HTML.strip_heredoc
1245
1245
  <p><a href="foo" class="">foo</a><br>
1246
1246
  <a href="http://qiita.com/" class="autolink" rel="nofollow noopener" target="_blank">http://qiita.com/</a></p>
1247
- EOS
1247
+ HTML
1248
1248
  end
1249
1249
  end
1250
1250
  end
1251
1251
 
1252
1252
  context "with class attribute for <blockquote> tag" do
1253
1253
  let(:markdown) do
1254
- <<-EOS.strip_heredoc
1254
+ <<-MARKDOWN.strip_heredoc
1255
1255
  <blockquote class="twitter-tweet malicious-class">foo</blockquote>
1256
- EOS
1256
+ MARKDOWN
1257
1257
  end
1258
1258
 
1259
1259
  if allowed
1260
1260
  it "does not sanitize the classes" do
1261
- should eq <<-EOS.strip_heredoc
1261
+ should eq <<-HTML.strip_heredoc
1262
1262
  <blockquote class="twitter-tweet malicious-class">foo</blockquote>
1263
- EOS
1263
+ HTML
1264
1264
  end
1265
1265
  else
1266
1266
  it "sanitizes classes except `twitter-tweet`" do
1267
- should eq <<-EOS.strip_heredoc
1267
+ should eq <<-HTML.strip_heredoc
1268
1268
  <blockquote class="twitter-tweet">foo</blockquote>
1269
- EOS
1269
+ HTML
1270
1270
  end
1271
1271
  end
1272
1272
  end
1273
1273
 
1274
1274
  context "with class attribute for <div> tag" do
1275
1275
  let(:markdown) do
1276
- <<-EOS.strip_heredoc
1276
+ <<-MARKDOWN.strip_heredoc
1277
1277
  <div class="footnotes malicious-class">foo</div>
1278
- EOS
1278
+ MARKDOWN
1279
1279
  end
1280
1280
 
1281
1281
  if allowed
1282
1282
  it "does not sanitize the classes" do
1283
- should eq <<-EOS.strip_heredoc
1283
+ should eq <<-HTML.strip_heredoc
1284
1284
  <div class="footnotes malicious-class">foo</div>
1285
- EOS
1285
+ HTML
1286
1286
  end
1287
1287
  else
1288
1288
  it "sanitizes classes except `footnotes`" do
1289
- should eq <<-EOS.strip_heredoc
1289
+ should eq <<-HTML.strip_heredoc
1290
1290
  <div class="footnotes">foo</div>
1291
- EOS
1291
+ HTML
1292
1292
  end
1293
1293
  end
1294
1294
  end
1295
1295
 
1296
1296
  context "with class attribute for <p> tag" do
1297
1297
  let(:markdown) do
1298
- <<-EOS.strip_heredoc
1298
+ <<-MARKDOWN.strip_heredoc
1299
1299
  <p class="codepen malicious-class">foo</p>
1300
- EOS
1300
+ MARKDOWN
1301
1301
  end
1302
1302
 
1303
1303
  if allowed
1304
1304
  it "does not sanitize the classes" do
1305
- should eq <<-EOS.strip_heredoc
1305
+ should eq <<-HTML.strip_heredoc
1306
1306
  <p class="codepen malicious-class">foo</p>
1307
- EOS
1307
+ HTML
1308
1308
  end
1309
1309
  else
1310
1310
  it "sanitizes classes except `codepen`" do
1311
- should eq <<-EOS.strip_heredoc
1311
+ should eq <<-HTML.strip_heredoc
1312
1312
  <p class="codepen">foo</p>
1313
- EOS
1313
+ HTML
1314
1314
  end
1315
1315
  end
1316
1316
  end
@@ -1335,44 +1335,69 @@ describe Qiita::Markdown::Processor do
1335
1335
  end
1336
1336
 
1337
1337
  shared_examples_for "override embed code attributes" do |allowed:|
1338
- context "with HTML embed code for CodePen" do
1338
+ context "with HTML embed code for CodePen using old script url" do
1339
1339
  let(:markdown) do
1340
- <<-EOS.strip_heredoc
1340
+ <<-MARKDOWN.strip_heredoc
1341
1341
  <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p>
1342
1342
  <script src="https://production-assets.codepen.io/assets/embed/ei.js"></script>
1343
- EOS
1343
+ MARKDOWN
1344
1344
  end
1345
1345
 
1346
1346
  if allowed
1347
1347
  it "does not sanitize embed code" do
1348
- should eq <<-EOS.strip_heredoc
1348
+ should eq <<-HTML.strip_heredoc
1349
1349
  <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p>\n
1350
1350
  <script src="https://production-assets.codepen.io/assets/embed/ei.js"></script>
1351
- EOS
1351
+ HTML
1352
1352
  end
1353
1353
  else
1354
1354
  it "forces async attribute on script" do
1355
- should eq <<-EOS.strip_heredoc
1355
+ should eq <<-HTML.strip_heredoc
1356
1356
  <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p>\n
1357
1357
  <script src="https://production-assets.codepen.io/assets/embed/ei.js" async="async"></script>
1358
- EOS
1358
+ HTML
1359
+ end
1360
+ end
1361
+ end
1362
+
1363
+ context "with HTML embed code for CodePen" do
1364
+ let(:markdown) do
1365
+ <<-MARKDOWN.strip_heredoc
1366
+ <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p>
1367
+ <script src="https://static.codepen.io/assets/embed/ei.js"></script>
1368
+ MARKDOWN
1369
+ end
1370
+
1371
+ if allowed
1372
+ it "does not sanitize embed code" do
1373
+ should eq <<-HTML.strip_heredoc
1374
+ <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p>\n
1375
+ <script src="https://static.codepen.io/assets/embed/ei.js"></script>
1376
+ HTML
1377
+ end
1378
+ else
1379
+ it "forces async attribute on script" do
1380
+ should eq <<-HTML.strip_heredoc
1381
+ <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p>\n
1382
+ <script src="https://static.codepen.io/assets/embed/ei.js" async="async"></script>
1383
+ HTML
1359
1384
  end
1360
1385
  end
1361
1386
  end
1362
1387
 
1363
1388
  context "with embed code for Tweet" do
1364
1389
  let(:markdown) do
1365
- <<-EOS.strip_heredoc
1390
+ <<-MARKDOWN.strip_heredoc
1366
1391
  <blockquote class="twitter-tweet" data-lang="es" data-cards="hidden" data-conversation="none">foo</blockquote>
1367
1392
  <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
1368
- EOS
1393
+ MARKDOWN
1369
1394
  end
1370
1395
 
1371
1396
  it "does not sanitize embed code" do
1372
- should eq <<-EOS.strip_heredoc
1397
+ should eq <<-HTML.strip_heredoc
1373
1398
  <blockquote class="twitter-tweet" data-lang="es" data-cards="hidden" data-conversation="none">foo</blockquote>\n
1374
1399
  <script async src="https://platform.twitter.com/widgets.js"></script>
1375
- EOS
1400
+ HTML
1376
1401
  end
1377
1402
  end
1378
1403
  end
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.24.0
4
+ version: 0.25.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: 2017-12-21 00:00:00.000000000 Z
11
+ date: 2018-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gemoji