mindmapdoc 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65ae773bf8d1435127643459920d2d86fb559797
4
- data.tar.gz: 251f3aaeb26a40ddb1ae8792425f65dce15f0a8c
3
+ metadata.gz: becb7ef9f41a6dbda62acc91fa0bc8509d1f23fc
4
+ data.tar.gz: 873e1d6e96950cbf815c5fea5a6e3cf0e2f96087
5
5
  SHA512:
6
- metadata.gz: 9ecabeaa5ca47d21059428f400e041013da62b445b0a3c6b6344bb485d3d78581f8258c146d97058ca8a2709d41b70a8d855315e3f3510966b130e0707f012ac
7
- data.tar.gz: f7b124ec7769490a78c6c942791e509ba1601d75152c10b8d0cb4ba47448378522a20dd023f0da0fa982ba662804420d9437c38e633a605f6354e30082325d04
6
+ metadata.gz: 6fecc50f14a966571fcf0cd29202474ac6680fb00aefc6e35b3046245640c2658aab3b7c10f45a5cec8911fba0983d43ba632e158f728984ac9c5043ed69e50e
7
+ data.tar.gz: c1fb835bc72bdd160caec7c19030d0b1fe4d2c895cdfd0cb985f689373e05067ea9c6f85e39382fd0800951a65186e07f5ac3db759912fd2d2559f4b2fec6dad
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/mindmapdoc.rb CHANGED
@@ -36,7 +36,36 @@ class MindmapDoc
36
36
  buffer = File.read(s)
37
37
  import(buffer)
38
38
  end
39
+
40
+ # parses a string containing 1 or more embedded <mindmap> elements and
41
+ # outputs the SVG and associated doc
42
+ #
43
+ def transform(s)
44
+
45
+ a = s.split(/(?=<mindmap>)/)
39
46
 
47
+ count = 0
48
+
49
+ a2 = a.map do |x|
50
+
51
+ if x =~ /^<mindmap>/ then
52
+
53
+ count += 1
54
+
55
+ mm, remaining = x[/<mindmap>(.*)/m,1].split(/<\/mindmap>/,2)
56
+ raw_tree, raw_md = mm.split(/-{10,}/,2)
57
+ mm1, mm2 = [raw_tree, raw_md].map {|x| MindmapDoc.new x}
58
+
59
+ mm_template(mm1.to_svg, mm2.to_doc, count)
60
+
61
+ else
62
+ x
63
+ end
64
+
65
+ end.join
66
+
67
+ end
68
+
40
69
  def to_html()
41
70
  @html
42
71
  end
@@ -46,10 +75,16 @@ class MindmapDoc
46
75
  end
47
76
 
48
77
  def to_tree(rooted: false)
49
- lines = @tree.lines
50
- lines.shift
51
- r = lines.map! {|x| x[2..-1]}.join
52
- @root + "\n" + r.lines.map {|x| ' ' + x}.join if rooted
78
+
79
+ if rooted then
80
+ @root + "\n" + @tree
81
+ else
82
+
83
+ lines = @tree.lines
84
+ lines.shift if lines.first[/^\S/]
85
+ lines.map! {|x| x[2..-1]}.join
86
+ end
87
+
53
88
  end
54
89
 
55
90
  alias to_s to_tree
@@ -77,6 +112,20 @@ class MindmapDoc
77
112
 
78
113
  end
79
114
 
115
+ # used by public method transform()
116
+ #
117
+ def mm_template(svg, doc, count)
118
+
119
+ "<div id='mindmap#{count}'>
120
+ #{svg}
121
+ <div markdown='1'>
122
+ #{doc}
123
+ </div>
124
+ </div>
125
+ "
126
+ end
127
+
128
+
80
129
  # returns a indented string representation of the mindmap and HTML from
81
130
  # the rendered Markdown
82
131
  #
@@ -91,17 +140,17 @@ class MindmapDoc
91
140
 
92
141
  lines = md.scan(/#[^\n]+\n/)\
93
142
  .map {|x| (' ' * (x.scan(/#/).length - 1)) + x[/(?<=# ).*/]}
94
- @root = lines.first
143
+ @root = lines.first if lines.first[/^# /]
95
144
 
96
145
  [lines.join("\n"), s]
97
146
  end
98
-
147
+
99
148
 
100
149
  # returns a markdown document
101
150
  #
102
151
  def parse_tree(s)
103
152
 
104
- # asrc = [@root + "\n"] + s.gsub(/\r/,'').strip.lines.map {|x| ' ' + x}
153
+ asrc = [@root + "\n"] + s.gsub(/\r/,'').strip.lines.map {|x| ' ' + x}
105
154
 
106
155
  a2 = asrc.inject([]) do |r,x|
107
156
 
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.3
4
+ version: 0.1.4
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: 2018-02-10 00:00:00.000000000 Z
34
+ date: 2018-02-12 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rdiscount
metadata.gz.sig CHANGED
@@ -1,5 +1 @@
1
- �������
2
- :ϛ|��%w����0*���3����ોp��k�:�Ð�������v7ު��#��a
3
- �=R?�;�ܠ(��^e�O��;�ԑ�V�m��cF�F%���n$>�M�G�g� ,#CZ������s܇I� .�H��C
4
- +|
5
- T�Z6?�h��
1
+ .O�Y0 �{���2j8RTVr���d�x�Ӄm�<c�AM�$M�P M�0