himekami-markdown 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/himekami/markdown/filters/checkbox.rb +14 -4
- data/lib/himekami/markdown/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '094e47b827689d146bfd8eb9962fc69c15d287ac'
|
4
|
+
data.tar.gz: 3965a4adcf0060587375c15e9b8d242e73aadad5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5813f9714f8b3b1c35df4a9e022160d189970410e2422a8a3dc49c7b09e7bd2deeae910b9b02c77c08a9979a6c7cf318bad07f1c5f70d9f104e73be59ca785d6
|
7
|
+
data.tar.gz: 37d3ee27a32ae8b7dda9f94330fcbc432b8c04b531cdbe4e34058a29c653daf1322a9fd337c380e6448cb5a1f3f518e3d7458d5f2167ab8d40f6c16aae7707fb
|
@@ -4,7 +4,10 @@ module Himekami
|
|
4
4
|
class Checkbox < HTML::Pipeline::Filter
|
5
5
|
def call
|
6
6
|
doc.search("li").each do |li|
|
7
|
-
|
7
|
+
if List.has_checkbox?(li)
|
8
|
+
li = List.new(li)
|
9
|
+
li.convert!
|
10
|
+
end
|
8
11
|
end
|
9
12
|
doc
|
10
13
|
end
|
@@ -32,24 +35,31 @@ module Himekami
|
|
32
35
|
|
33
36
|
def convert!
|
34
37
|
add_css_class
|
38
|
+
text_node
|
35
39
|
add_checkbox_html
|
36
40
|
end
|
37
41
|
|
38
42
|
private
|
39
43
|
|
44
|
+
def text_node
|
45
|
+
return @node.children.find { |node| node.name == 'p' }.children.first if @node.children.any? { |node| node.name == 'p' }
|
46
|
+
|
47
|
+
@node.children.first
|
48
|
+
end
|
49
|
+
|
40
50
|
def add_css_class
|
41
51
|
@node['class'] = LI_ATTR_CLASS if @node['class'].nil? || !@node['class'].include?(LI_ATTR_CLASS)
|
42
52
|
end
|
43
53
|
|
44
54
|
def remove_md
|
45
|
-
|
55
|
+
text_node.content = text_node.content.sub(CHECKBOX_PATTERN, '').strip
|
46
56
|
end
|
47
57
|
|
48
58
|
def add_checkbox_html
|
49
59
|
html = open_checkbox? ? render_open_checkbox_html : render_closed_checkbox_html
|
50
60
|
|
51
61
|
remove_md
|
52
|
-
|
62
|
+
text_node.add_previous_sibling(html)
|
53
63
|
end
|
54
64
|
|
55
65
|
def render_open_checkbox_html
|
@@ -61,7 +71,7 @@ module Himekami
|
|
61
71
|
end
|
62
72
|
|
63
73
|
def open_checkbox?
|
64
|
-
|
74
|
+
text_node.content.include?(CHECKBOX_OPEN)
|
65
75
|
end
|
66
76
|
end
|
67
77
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: himekami-markdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- otukutun
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|