md2key 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/lib/md2key/markdown.rb +25 -7
- data/lib/md2key/version.rb +1 -1
- 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: efa4d3efc0863de76d19919aac701aad63c74c46
|
4
|
+
data.tar.gz: e815643322bd2208cd170327ec11960ef4909653
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07f933c45cf47dc98c57d1582872c368f8f99698a6dcc91e2829add256b2aaa54f07e023677ff0f8b14ead0bdfbddfd61f9acfa1221f9b2330c43932f8412b35
|
7
|
+
data.tar.gz: bea355914ebb893f337a55f279d8f35c6baaf6eca3c5cc6ab1e2aeab447aee087a47622d22b26d73cc6f8b1fcc35ed3bcec2bcc4be202f08e5aacf991d1cc696
|
data/CHANGELOG.md
CHANGED
data/lib/md2key/markdown.rb
CHANGED
@@ -38,13 +38,8 @@ module Md2key
|
|
38
38
|
slides << slide
|
39
39
|
slide.title = node.text
|
40
40
|
when 'ul'
|
41
|
-
|
42
|
-
|
43
|
-
next if child_node.name != 'li'
|
44
|
-
|
45
|
-
# TODO: implement nested list
|
46
|
-
slide.lines << child_node.inner_text.strip
|
47
|
-
end
|
41
|
+
# FIXME: support nested list
|
42
|
+
slide.lines += li_texts(node).flatten
|
48
43
|
when 'p'
|
49
44
|
slide.lines << node.text
|
50
45
|
when 'hr'
|
@@ -54,6 +49,29 @@ module Md2key
|
|
54
49
|
slides
|
55
50
|
end
|
56
51
|
|
52
|
+
def li_texts(ul_node)
|
53
|
+
return [] unless ul_node.is_a?(Oga::XML::Element)
|
54
|
+
return [] if ul_node.name != 'ul'
|
55
|
+
|
56
|
+
texts = []
|
57
|
+
ul_node.children.each do |li_node|
|
58
|
+
next unless li_node.is_a?(Oga::XML::Element)
|
59
|
+
next if li_node.name != 'li'
|
60
|
+
|
61
|
+
li_node.children.each do |node|
|
62
|
+
case node
|
63
|
+
when Oga::XML::Text
|
64
|
+
text = node.text.strip
|
65
|
+
texts << text unless text.empty?
|
66
|
+
when Oga::XML::Element
|
67
|
+
next if node.name != 'ul'
|
68
|
+
texts << li_texts(node)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
texts
|
73
|
+
end
|
74
|
+
|
57
75
|
def to_xhtml(markdown)
|
58
76
|
redcarpet = Redcarpet::Markdown.new(Redcarpet::Render::XHTML)
|
59
77
|
redcarpet.render(markdown)
|
data/lib/md2key/version.rb
CHANGED