mindmapdoc 0.1.5 → 0.1.6

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: 3bb7f980be65d7fbdeb609465376a069ab6c237f
4
- data.tar.gz: e914a6107ddf93116bfd393b5ab2f0a62ad7d74c
3
+ metadata.gz: 48fb6a5690a698712730434dd6f79af2b53436d4
4
+ data.tar.gz: b25a696b53ad6bc8d9078e7ff57ecf8daa8eb97f
5
5
  SHA512:
6
- metadata.gz: ed18f72c6f70d1460c9db993b57819aa08cb2318ad0727f3c93349323a21eb68f88605c6cca40ddf707c744375ddacbc80daf6dd0705cc14ea90e4e3dcbd5a8a
7
- data.tar.gz: af89280edf4cb70a598afee008834198ceaf0b0d191e4fabfcdb0c9071a7539b665441056bd28df809af19a885571e5a3697a689a06e5a720f6c7903267d3f45
6
+ metadata.gz: 4ebc4c07a9db4b3a400311e8afe93f0a40514dd16352ef26e4e383a84412a2dff0c1eea24d3255a235890ec6d472b45a2b74462aea4bdce2962bf1362c6fbd53
7
+ data.tar.gz: e15a756bc2075ba3403d49384633d3a2e7fc4fe9137ea8a55c235106caad5d810e328e5cc94264a5cea6c18903bd593e2eb670e7cc190462cfd8fffd4343bfed
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/mindmapdoc.rb CHANGED
@@ -6,11 +6,12 @@ require 'rdiscount'
6
6
  require 'mindmapviz'
7
7
 
8
8
 
9
+
9
10
  class MindmapDoc
10
11
 
11
12
  attr_accessor :root
12
13
 
13
- def initialize(s=nil, root: 'root', debug: false)
14
+ def initialize(s=nil, root: nil, debug: false)
14
15
 
15
16
  @root, @tree, @txtdoc, @svg, @debug = root, '', '', '', debug
16
17
  import(s) if s
@@ -42,22 +43,24 @@ class MindmapDoc
42
43
  #
43
44
  def transform(s)
44
45
 
45
- a = s.split(/(?=<mindmap>)/)
46
+ a = s.split(/(?=^<mindmap[^>]*>)/)
46
47
  puts 'transform: a: ' + a.inspect if @debug
47
48
 
48
49
  count = 0
49
50
 
50
51
  a2 = a.map do |x|
51
52
 
52
- if x =~ /^<mindmap>/ then
53
+ if x =~ /^<mindmap/ then
53
54
 
54
55
  count += 1
55
56
 
56
- mm, remaining = x[/<mindmap>(.*)/m,1].split(/<\/mindmap>/,2)
57
+ mm, remaining = x[/<mindmap[^>]*>(.*)/m,1].split(/<\/mindmap>/,2)
57
58
  raw_tree, raw_md = mm.split(/-{10,}/,2)
58
59
  mm1, mm2 = [raw_tree, raw_md].map {|x| MindmapDoc.new x}
60
+ docwidth = x[/<mindmap +docwidth=['"]([^'"]+)/,1]
61
+ puts 'docwidth: ' + docwidth.inspect if @debug
59
62
 
60
- mm_template(mm1.to_svg, mm2.to_doc, count)
63
+ mm_template(mm1.to_svg, mm2.to_doc, count, docwidth) + remaining
61
64
 
62
65
  else
63
66
  x
@@ -116,9 +119,10 @@ class MindmapDoc
116
119
 
117
120
  # used by public method transform()
118
121
  #
119
- def mm_template(svg, doc, count)
122
+ def mm_template(svg, doc, count, docwidth='50%')
120
123
 
121
- style = 'float: right; width: 50%; overflow-y: auto; height: 70vh'
124
+ style = "float: right; width: #{docwidth || '50%'}; \
125
+ overflow-y: auto; height: 70vh; "
122
126
 
123
127
  "<div id='mindmap#{count}'>
124
128
  #{svg}
@@ -154,7 +158,17 @@ class MindmapDoc
154
158
  #
155
159
  def parse_tree(s)
156
160
 
157
- asrc = [@root + "\n"] + s.gsub(/\r/,'').strip.lines.map {|x| ' ' + x}
161
+ puts 'inside parse_tree' if @debug
162
+
163
+ lines = s.gsub(/\r/,'').strip.lines
164
+
165
+ @root = if lines.first[/^[^#\s]/] then
166
+ lines.shift.chomp
167
+ elsif @root.nil?
168
+ 'root'
169
+ end
170
+
171
+ asrc = [@root + "\n"] + lines.map {|x| ' ' + x}
158
172
 
159
173
  a2 = asrc.inject([]) do |r,x|
160
174
 
data.tar.gz.sig CHANGED
Binary file
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.5
4
+ version: 0.1.6
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-12 00:00:00.000000000 Z
34
+ date: 2018-02-17 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rdiscount
metadata.gz.sig CHANGED
Binary file