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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9344258d896f70f623b6297cd04a23d5f89dfd4c
4
- data.tar.gz: 21aecf4aee086196aac28d1ddb49b519e86d8375
3
+ metadata.gz: efa4d3efc0863de76d19919aac701aad63c74c46
4
+ data.tar.gz: e815643322bd2208cd170327ec11960ef4909653
5
5
  SHA512:
6
- metadata.gz: 0e99d47cfe441d711a6a3bf5de5214df354b3b1a291a902679acfb2ada90ecf59613fc72dac76588a16dded595bf36a2239c82f41f2719d3ad9e5dd38737b26b
7
- data.tar.gz: cfda1467a4bd799182cc7955420512fbe2d457716227fc52b740ce12fe5459ae12cc4e5cc9da3f4ca73a1d0d9dae8211e1d363683461d4a3a598767ba1e5b0f9
6
+ metadata.gz: 07f933c45cf47dc98c57d1582872c368f8f99698a6dcc91e2829add256b2aaa54f07e023677ff0f8b14ead0bdfbddfd61f9acfa1221f9b2330c43932f8412b35
7
+ data.tar.gz: bea355914ebb893f337a55f279d8f35c6baaf6eca3c5cc6ab1e2aeab447aee087a47622d22b26d73cc6f8b1fcc35ed3bcec2bcc4be202f08e5aacf991d1cc696
data/CHANGELOG.md CHANGED
@@ -1,7 +1,12 @@
1
+ # v0.2.1
2
+
3
+ - Don't skip a nested list
4
+ - But still flattened
5
+
1
6
  # v0.2.0
2
7
 
3
8
  - Use redcarpet as markdown parser
4
- - Support `*` list
9
+ - Support list starting with `*`
5
10
 
6
11
  # v0.1.2
7
12
 
@@ -38,13 +38,8 @@ module Md2key
38
38
  slides << slide
39
39
  slide.title = node.text
40
40
  when 'ul'
41
- node.children.each do |child_node|
42
- next unless child_node.is_a?(Oga::XML::Element)
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)
@@ -1,3 +1,3 @@
1
1
  module Md2key
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: md2key
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun