bluedoc-sml 0.6.2 → 0.6.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 675ba78976901654e5dfc6edbd8e3a6432af52f1566bff7a9dfe1fcbd9f138ad
4
- data.tar.gz: 5d4d87f0db8127706450f765fd10a1f09ed632347e7be952bdd753a08f9cbd08
3
+ metadata.gz: 718c548205f36ea679cb8f4bebcc30dcffd866aa3a675d04cd3f6e96d88d820f
4
+ data.tar.gz: 386e5dd242af935307fc9ab42896dfc567598b1dc31a986049d41f67a0d1391b
5
5
  SHA512:
6
- metadata.gz: 810a4ec0f30c541eb7e7d66016004cd699ed62af72fc1a182bc489c061db48c05d28b69b45a60d6894080e24e0545f9908ee991357f8af20abb2bc0e914ed4cc
7
- data.tar.gz: 4e883a3d9fda0a022fd6f1047e8c222cc4a37a9b9be7dc33207a7b0a297ed4cc63eb392dbc841a1e043538b78f492ad6bb861d6b51702438d44686162bc5087a
6
+ metadata.gz: 3ec05e73f7f09af8fdfb15de922962c4bebbd0ea83a04ab43de76f866b51564ae0d0aa7706bf25d2ee5b3a6d67c4d4888eec3cac4049aacf203732ae17f73c55
7
+ data.tar.gz: ae0e430fd556bd20601cfc316f016f544b29b651fe63b9dfaf323405437b2606c164e6d26877373c15d7f9c50b4d283a49c2171425969a5c1b619db3c4c487c7
@@ -39,6 +39,10 @@ module BlueDoc::SML
39
39
  return node if node.is_a?(String)
40
40
 
41
41
  children = self.class.get_children(node)
42
+
43
+ parent_is_list = self.class.tag_name(node) == "list"
44
+ parent_attrs = self.class.attributes(node)
45
+
42
46
  children.each_with_index.map do |child, idx|
43
47
  prev_node = idx > 0 ? children[idx - 1] : nil
44
48
  next_node = idx < children.length ? children[idx + 1] : nil
@@ -46,10 +50,16 @@ module BlueDoc::SML
46
50
  list = self.list
47
51
  is_list = self.class.tag_name(child) == "list"
48
52
 
53
+ child_attrs = self.class.attributes(child)
54
+
49
55
  if is_list
50
- child_attrs = self.class.attributes(child)
51
56
  nid = child_attrs[:nid]
52
57
 
58
+ # BUG: ignore invlid nested list
59
+ if parent_is_list
60
+ return ""
61
+ end
62
+
53
63
  if list[nid]
54
64
  list[nid] << child
55
65
  else
@@ -57,9 +67,10 @@ module BlueDoc::SML
57
67
  end
58
68
  end
59
69
 
70
+ pre_node_attrs = self.class.attributes(prev_node)
60
71
  if (!is_list && self.class.tag_name(prev_node) == "list") ||
61
- (is_list && self.class.tag_name(prev_node) == "list" && self.class.attributes(child)[:nid] != self.class.attributes(prev_node)[:nid])
62
- nid = self.class.attributes(prev_node)[:nid]
72
+ (is_list && self.class.tag_name(prev_node) == "list" && child_attrs[:nid] != pre_node_attrs[:nid])
73
+ nid = pre_node_attrs[:nid]
63
74
  list.delete(nid)
64
75
  end
65
76
 
@@ -22,6 +22,7 @@ module BlueDoc::SML::Rules
22
22
 
23
23
  current.length.times do |i|
24
24
  current_node = current[i]
25
+
25
26
  prev_node = current[i - 1]
26
27
  next_node = current[i + 1]
27
28
 
@@ -37,6 +37,14 @@ module BlueDoc::SML
37
37
  attrs
38
38
  end
39
39
 
40
+ def set_attribute(node, key, val)
41
+ return if node.blank?
42
+ return unless element?(node)
43
+ return unless has_attributes?(node)
44
+
45
+ node[1][key] = val
46
+ end
47
+
40
48
  def has_attributes?(node)
41
49
  return false unless element?(node)
42
50
  attributes?(node[1])
@@ -2,6 +2,6 @@
2
2
 
3
3
  module BlueDoc
4
4
  module SML
5
- VERSION = "0.6.2"
5
+ VERSION = "0.6.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bluedoc-sml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-29 00:00:00.000000000 Z
11
+ date: 2019-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport