mindmapdoc 0.3.2 → 0.3.3

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
  SHA256:
3
- metadata.gz: c7acb85a928b9e839e2b923b07d19803ed1a7f0790767754cc713ccb1f07ad46
4
- data.tar.gz: 453baffafe77af8da4bea2109a7e20ec604e6f91f75bc1981f2dc39909312adc
3
+ metadata.gz: 704a5376607e57cd65f125c18a86ac1beb864d93b9045ef35ee57f122db3fe39
4
+ data.tar.gz: 021531a0205bf396fd26eec46ab741913f455b1c833bba2a541077f7714fd4c4
5
5
  SHA512:
6
- metadata.gz: b3c97a751908ee9a29c3d6dff058f1279a9a9dc6d5e9a523ef473b34269a080c3c3a87a6571a537744a6d885d59a384dcbe112cad0cc33935a2401c06ebb6615
7
- data.tar.gz: 5307b4b09ed629599b80b085dfb8510ae5cf11d413e116dfa87f879ec1e43f0c83da3b289b0ed97cf33ab961ae9ff0fe7a94b260cfa3a03d372855c218229c7e
6
+ metadata.gz: aa420e04dee040c99e457618b7e9a9143d54d8e219dce0f5e8f02d658d692c98007703bc18803393765bc7854231b2d73caccb551bc21a596e9f79f351c4eaeb
7
+ data.tar.gz: 5e393c56073ef4f265824755e19834c1c5c520e955fccfb69faf5470f2831599eca98420c2f6e9637fe13a0a17177e849418a8992ca14707a63c0d1b44bb6189
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/mindmapdoc.rb CHANGED
@@ -17,6 +17,7 @@ class MindmapDoc
17
17
  def initialize(s=nil, root: nil, debug: false)
18
18
 
19
19
  @root, @tree, @txtdoc, @svg, @debug = root, '', '', '', debug
20
+ puts '@root' + @root.inspect if @debug
20
21
  import(s) if s
21
22
 
22
23
  end
@@ -76,10 +77,10 @@ class MindmapDoc
76
77
  ' raw_md: ' + raw_md.inspect).debug
77
78
  end
78
79
 
79
- mm1 = MindmapDoc.new raw_tree
80
+ mm1 = MindmapDoc.new raw_tree, debug: @debug
80
81
 
81
82
  if raw_md then
82
- mm2 = MindmapDoc.new raw_md
83
+ mm2 = MindmapDoc.new raw_md, debug: @debug
83
84
  data << mm2.to_mmv(id: count)
84
85
  end
85
86
 
@@ -115,6 +116,32 @@ class MindmapDoc
115
116
  @html
116
117
  end
117
118
 
119
+ def to_mindmapdoc(s)
120
+
121
+ s2 = s.split(/(?=-mm-+)/).map do |raw_s|
122
+
123
+ if raw_s =~ /^-mm--/ then
124
+
125
+ a2 = raw_s[/.*(?=^-{10,})/m].lines
126
+ remaining = ($').lines[1..-1].join
127
+ a2.shift
128
+ content = a2.join
129
+ rooted = content =~ /^# / ? true : false
130
+ puts ('content: ' + content.inspect).debug if @debug
131
+ tree = MindmapDoc.new(content, debug: @debug).to_tree(rooted: rooted)
132
+ "<mindmap>\n%s\n\n----------\n\n%s</mindmap>\n\n%s" \
133
+ % [tree, content, remaining]
134
+
135
+ else
136
+ raw_s
137
+ end
138
+
139
+ end.join()
140
+
141
+ end
142
+
143
+ alias to_mmd to_mindmapdoc
144
+
118
145
  def to_mindmapviz(id: '')
119
146
 
120
147
  lines = to_tree().lines.map do |raw_label|
@@ -123,7 +150,7 @@ class MindmapDoc
123
150
  "%s # #%s" % [label, label.lstrip.downcase.gsub(' ', '-')]
124
151
  end
125
152
 
126
- "<?mindmapviz root='#{root}' fields='label, url' delimiter=' # ' " \
153
+ "<?mindmapviz root=\"#{root}\" fields='label, url' delimiter=' # ' " \
127
154
  + "id='mindmap#{id}'?>
128
155
 
129
156
  #{lines.join("\n")}
@@ -202,11 +229,18 @@ overflow-y: auto; height: 70vh; "
202
229
 
203
230
  puts ('inside parse_doc: ' + md).debug if @debug
204
231
 
205
- s = Kramdown::Document.new(md.gsub(/\r/,'')).to_html
232
+ s = Kramdown::Document.new(md.gsub(/\r/,'')
233
+ .gsub(/\b'\b/,"{::nomarkdown}'{:/}")).to_html
206
234
 
207
235
  lines = md.scan(/#[^\n]+\n/)\
208
236
  .map {|x| (' ' * (x.scan(/#/).length - 1)) + x[/(?<=# ).*/]}
209
- @root = lines.first if lines.first
237
+ #@root = lines.first if lines.first
238
+ @root = if lines.first[/^[^#\s]/] then
239
+ lines.shift.chomp
240
+ elsif @root.nil?
241
+ 'root'
242
+ end
243
+
210
244
  puts ('lines: ' + lines.inspect).debug if @debug
211
245
  [lines.join("\n"), s]
212
246
  end
@@ -216,15 +250,17 @@ overflow-y: auto; height: 70vh; "
216
250
  #
217
251
  def parse_tree(s)
218
252
 
219
- puts ('inside parse_tree').debug if @debug
253
+ puts ('inside parse_tree').info if @debug
220
254
 
221
255
  lines = s.gsub(/\r/,'').strip.lines
256
+ puts ('lines: ' + lines.inspect) if @debug
222
257
 
223
258
  @root = if lines.first[/^[^#\s]/] then
224
259
  lines.shift.chomp
225
260
  elsif @root.nil?
226
261
  'root'
227
262
  end
263
+ puts ('@root:' + @root.inspect).debug if @debug
228
264
 
229
265
  asrc = [@root + "\n"] + lines.map {|x| ' ' + x}
230
266
 
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.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  B6lHIpiAVH9Sx621FqXBHf0fkcUSiXCWW1BpBLGqPsRAcA19KUIPOOn9D011To8+
36
36
  kf4RzXeKdszyRSi+lsn0EdIK
37
37
  -----END CERTIFICATE-----
38
- date: 2019-02-06 00:00:00.000000000 Z
38
+ date: 2019-03-03 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: c32
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  requirements: []
126
- rubygems_version: 3.0.2
126
+ rubygems_version: 3.0.1
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: Transforms a markdown document into a mindmap or a mindmap into a markdown
metadata.gz.sig CHANGED
Binary file