qiita-markdown 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of qiita-markdown might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +0 -1
- data/lib/qiita/markdown/filters/checkbox.rb +3 -8
- data/lib/qiita/markdown/version.rb +1 -1
- data/spec/qiita/markdown/processor_spec.rb +7 -31
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9017a4c3b8f333bbd46769e73282dc5ade827b3
|
4
|
+
data.tar.gz: b12d3ec85b24c2e19e727e187f74b4b471bf4078
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7f9b5e259c48094d8fc84c117cfc18d8be58f75bb33ec720f082424615c5817ebb98a30d966e8ff4f12b63111e9eae9298c4675b71806df71393f664658ad25
|
7
|
+
data.tar.gz: 7b36281b31d80ae7b2e01a8d4c4c9376720bc3857eebcefdcf79a63d042351495dfa26e70c24f4103628a671835d933b8a724855c6e65617dbfe85e198d0b9f9
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -51,7 +51,6 @@ processor.call(text)
|
|
51
51
|
:asset_path - URL path to link to emoji sprite. (String)
|
52
52
|
:asset_root - Base URL to link to emoji sprite. (String)
|
53
53
|
:base_url - Used to construct links to user profile pages for each. (String)
|
54
|
-
:checkbox_disabled - Pass true to add `disabled` attribute to input element/ (Boolean)
|
55
54
|
:default_language - Default language used if no language detected from code. (String)
|
56
55
|
:language_aliases - Alias table for some language names. (Hash)
|
57
56
|
:rule - Sanitization rule table. (Hash)
|
@@ -7,14 +7,10 @@ module Qiita
|
|
7
7
|
# * [ ] Bar
|
8
8
|
# * [ ] Baz
|
9
9
|
#
|
10
|
-
# Takes following context options:
|
11
|
-
#
|
12
|
-
# * :checkbox_disabled - Pass true to add `disabled` attribute to input element
|
13
|
-
#
|
14
10
|
class Checkbox < HTML::Pipeline::Filter
|
15
11
|
def call
|
16
12
|
doc.search("li").each_with_index do |li, index|
|
17
|
-
list = List.new(
|
13
|
+
list = List.new(index: index, node: li)
|
18
14
|
list.convert if list.has_checkbox?
|
19
15
|
end
|
20
16
|
doc
|
@@ -26,8 +22,7 @@ module Qiita
|
|
26
22
|
CHECKBOX_CLOSE_MARK = "[x] "
|
27
23
|
CHECKBOX_OPEN_MARK = "[ ] "
|
28
24
|
|
29
|
-
def initialize(
|
30
|
-
@disabled = disabled
|
25
|
+
def initialize(index: nil, node: nil)
|
31
26
|
@index = index
|
32
27
|
@node = node
|
33
28
|
end
|
@@ -57,7 +52,7 @@ module Qiita
|
|
57
52
|
node = Nokogiri::HTML.fragment('<input type="checkbox" class="task-list-item-checkbox">')
|
58
53
|
node.children.first["data-checkbox-index"] = @index
|
59
54
|
node.children.first["checked"] = true if has_close_checkbox?
|
60
|
-
node.children.first["disabled"] = true
|
55
|
+
node.children.first["disabled"] = true
|
61
56
|
node
|
62
57
|
end
|
63
58
|
|
@@ -388,9 +388,9 @@ describe Qiita::Markdown::Processor do
|
|
388
388
|
should eq <<-EOS.strip_heredoc
|
389
389
|
<ul>
|
390
390
|
<li class="task-list-item">
|
391
|
-
<input type="checkbox" class="task-list-item-checkbox" data-checkbox-index="0">a</li>
|
391
|
+
<input type="checkbox" class="task-list-item-checkbox" data-checkbox-index="0" disabled>a</li>
|
392
392
|
<li class="task-list-item">
|
393
|
-
<input type="checkbox" class="task-list-item-checkbox" data-checkbox-index="1" checked>b</li>
|
393
|
+
<input type="checkbox" class="task-list-item-checkbox" data-checkbox-index="1" checked disabled>b</li>
|
394
394
|
</ul>
|
395
395
|
EOS
|
396
396
|
end
|
@@ -408,11 +408,11 @@ describe Qiita::Markdown::Processor do
|
|
408
408
|
should eq <<-EOS.strip_heredoc
|
409
409
|
<ul>
|
410
410
|
<li class="task-list-item">
|
411
|
-
<input type="checkbox" class="task-list-item-checkbox" data-checkbox-index="0">a
|
411
|
+
<input type="checkbox" class="task-list-item-checkbox" data-checkbox-index="0" disabled>a
|
412
412
|
|
413
413
|
<ul>
|
414
414
|
<li class="task-list-item">
|
415
|
-
<input type="checkbox" class="task-list-item-checkbox" data-checkbox-index="1">b</li>
|
415
|
+
<input type="checkbox" class="task-list-item-checkbox" data-checkbox-index="1" disabled>b</li>
|
416
416
|
</ul>
|
417
417
|
</li>
|
418
418
|
</ul>
|
@@ -439,30 +439,6 @@ describe Qiita::Markdown::Processor do
|
|
439
439
|
end
|
440
440
|
end
|
441
441
|
|
442
|
-
context "with task list and :checkbox_disabled context" do
|
443
|
-
before do
|
444
|
-
context[:checkbox_disabled] = true
|
445
|
-
end
|
446
|
-
|
447
|
-
let(:markdown) do
|
448
|
-
<<-EOS.strip_heredoc
|
449
|
-
- [ ] a
|
450
|
-
- [x] b
|
451
|
-
EOS
|
452
|
-
end
|
453
|
-
|
454
|
-
it "inserts checkbox with disabled attribute" do
|
455
|
-
should eq <<-EOS.strip_heredoc
|
456
|
-
<ul>
|
457
|
-
<li class="task-list-item">
|
458
|
-
<input type="checkbox" class="task-list-item-checkbox" data-checkbox-index="0" disabled>a</li>
|
459
|
-
<li class="task-list-item">
|
460
|
-
<input type="checkbox" class="task-list-item-checkbox" data-checkbox-index="1" checked disabled>b</li>
|
461
|
-
</ul>
|
462
|
-
EOS
|
463
|
-
end
|
464
|
-
end
|
465
|
-
|
466
442
|
context 'with empty line between task list' do
|
467
443
|
let(:markdown) do
|
468
444
|
<<-EOS.strip_heredoc
|
@@ -472,11 +448,11 @@ describe Qiita::Markdown::Processor do
|
|
472
448
|
EOS
|
473
449
|
end
|
474
450
|
|
475
|
-
it "inserts checkbox
|
451
|
+
it "inserts checkbox" do
|
476
452
|
should eq <<-EOS.strip_heredoc
|
477
453
|
<ul>
|
478
|
-
<li class="task-list-item"><p><input type="checkbox" class="task-list-item-checkbox" data-checkbox-index="0">a</p></li>
|
479
|
-
<li class="task-list-item"><p><input type="checkbox" class="task-list-item-checkbox" data-checkbox-index="1" checked>b</p></li>
|
454
|
+
<li class="task-list-item"><p><input type="checkbox" class="task-list-item-checkbox" data-checkbox-index="0" disabled>a</p></li>
|
455
|
+
<li class="task-list-item"><p><input type="checkbox" class="task-list-item-checkbox" data-checkbox-index="1" checked disabled>b</p></li>
|
480
456
|
</ul>
|
481
457
|
EOS
|
482
458
|
end
|