mindmapdoc 0.1.2 → 0.1.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
  SHA1:
3
- metadata.gz: 863ab82d02cfe924c84484e1a52d9ed4153f7e72
4
- data.tar.gz: 153a857b79c09a1abf8e7cd9dc9d79dac1a0788e
3
+ metadata.gz: 65ae773bf8d1435127643459920d2d86fb559797
4
+ data.tar.gz: 251f3aaeb26a40ddb1ae8792425f65dce15f0a8c
5
5
  SHA512:
6
- metadata.gz: 212dbc7a8c7ca359f1508cdf78bb93e335a0b4c9336ff22baa37a276a1114998653c92076e87a6d094240f3f4556e6741b110859f64c7e169025fe07de0f4c9a
7
- data.tar.gz: c724f5ebab95655e4c2fc634e821817f6023f51820718e208f8b41533ebefe91ad9f26ee953f480c64d41e5026bc674ab5ee73432a9ff21947ee22e270bb4b50
6
+ metadata.gz: 9ecabeaa5ca47d21059428f400e041013da62b445b0a3c6b6344bb485d3d78581f8258c146d97058ca8a2709d41b70a8d855315e3f3510966b130e0707f012ac
7
+ data.tar.gz: f7b124ec7769490a78c6c942791e509ba1601d75152c10b8d0cb4ba47448378522a20dd023f0da0fa982ba662804420d9437c38e633a605f6354e30082325d04
checksums.yaml.gz.sig CHANGED
@@ -1,2 +1,4 @@
1
- �� ��<kg��h�u7 G���#��VXS�f���Kbt�R��E_]'<�EF�Sv:CoO�K����6K�������:��Ly����?�`���:�|8Wra��?hy\ ���7��1���ڞ�z^�h���D�����y%�����;�OVP ���#)w�8��y��X?L��r���7�y]FĪ�A��~�+t#;�ӑ�� � �������%N
2
- <�!\�Y��M7�.�?���.��@\�u����
1
+ ��N՗�� ^ꋍx_�[mYW�Š���V&
2
+ v���H��[�y���zS?�TTB
3
+ 5N ��jA�V��m�r��0I-���iSsӾw*��܀7`eN| �����#��`3s�N�`2��pWlx�~u
4
+ $�;;�����K���f��Lگ���}@�&{�nk�b_��]���&W��p*A���
data.tar.gz.sig CHANGED
Binary file
data/lib/mindmapdoc.rb CHANGED
@@ -10,16 +10,18 @@ class MindmapDoc
10
10
 
11
11
  attr_accessor :root
12
12
 
13
- def initialize(s=nil, root: 'root')
13
+ def initialize(s=nil, root: 'root', debug: false)
14
14
 
15
- @root, @tree, @txtdoc, @svg = root, '', '', ''
15
+ @root, @tree, @txtdoc, @svg, @debug = root, '', '', '', debug
16
16
  import(s) if s
17
17
 
18
18
  end
19
19
 
20
- def import(s)
20
+ def import(raw_s)
21
21
 
22
- if s =~ /^# / then
22
+ s = raw_s.strip
23
+
24
+ if s =~ /^#+ / then
23
25
  @txtdoc = s.gsub(/\r/,'')
24
26
  @tree, @html = parse_doc s
25
27
  else
@@ -43,10 +45,11 @@ class MindmapDoc
43
45
  @svg
44
46
  end
45
47
 
46
- def to_tree()
48
+ def to_tree(rooted: false)
47
49
  lines = @tree.lines
48
50
  lines.shift
49
- lines.map! {|x| x[2..-1]}.join
51
+ r = lines.map! {|x| x[2..-1]}.join
52
+ @root + "\n" + r.lines.map {|x| ' ' + x}.join if rooted
50
53
  end
51
54
 
52
55
  alias to_s to_tree
@@ -78,13 +81,16 @@ class MindmapDoc
78
81
  # the rendered Markdown
79
82
  #
80
83
  def parse_doc(md)
84
+
85
+ puts 'inside parse_doc: ' + md if @debug
81
86
 
82
87
  s = RDiscount.new(md.gsub(/\r/,'')).to_html.gsub(/(?<=\<h)[^\<]+/) do |x|
83
88
  id = x[/(?<=\>).*/].downcase.gsub(/\s/,'')
84
89
  "#{ x[/\d/]} id='#{id}'>#{x[/(?<=\>).*/]}"
85
90
  end
86
91
 
87
- lines = md.scan(/#[^\n]+\n/).map {|x| (' ' * (x.scan(/#/).length - 1)) + x[/(?<=# ).*/]}
92
+ lines = md.scan(/#[^\n]+\n/)\
93
+ .map {|x| (' ' * (x.scan(/#/).length - 1)) + x[/(?<=# ).*/]}
88
94
  @root = lines.first
89
95
 
90
96
  [lines.join("\n"), s]
@@ -95,7 +101,7 @@ class MindmapDoc
95
101
  #
96
102
  def parse_tree(s)
97
103
 
98
- asrc = [@root + "\n"] + s.gsub(/\r/,'').strip.lines.map {|x| ' ' + x}
104
+ # asrc = [@root + "\n"] + s.gsub(/\r/,'').strip.lines.map {|x| ' ' + x}
99
105
 
100
106
  a2 = asrc.inject([]) do |r,x|
101
107
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mindmapdoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  MVgPwk1JjHwj6LchFY/zTEamSovovbrRFMSbfw5kdbPk/wmOGRYaEwTk7wm8u0Zm
32
32
  RRHYVIirxLY0zg==
33
33
  -----END CERTIFICATE-----
34
- date: 2017-12-13 00:00:00.000000000 Z
34
+ date: 2018-02-10 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rdiscount
metadata.gz.sig CHANGED
Binary file