mindmapdoc 0.1.3 → 0.1.4
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/mindmapdoc.rb +56 -7
- metadata +2 -2
- metadata.gz.sig +1 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: becb7ef9f41a6dbda62acc91fa0bc8509d1f23fc
|
|
4
|
+
data.tar.gz: 873e1d6e96950cbf815c5fea5a6e3cf0e2f96087
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
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.
|
|
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-
|
|
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