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 +4 -4
- checksums.yaml.gz.sig +4 -2
- data.tar.gz.sig +0 -0
- data/lib/mindmapdoc.rb +14 -8
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65ae773bf8d1435127643459920d2d86fb559797
|
4
|
+
data.tar.gz: 251f3aaeb26a40ddb1ae8792425f65dce15f0a8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ecabeaa5ca47d21059428f400e041013da62b445b0a3c6b6344bb485d3d78581f8258c146d97058ca8a2709d41b70a8d855315e3f3510966b130e0707f012ac
|
7
|
+
data.tar.gz: f7b124ec7769490a78c6c942791e509ba1601d75152c10b8d0cb4ba47448378522a20dd023f0da0fa982ba662804420d9437c38e633a605f6354e30082325d04
|
checksums.yaml.gz.sig
CHANGED
@@ -1,2 +1,4 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
��N�� ^ꋍx_�[m�YW�Š���V&
|
2
|
+
v���H��[�y���z�S?�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(
|
20
|
+
def import(raw_s)
|
21
21
|
|
22
|
-
|
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/)
|
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
|
-
|
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.
|
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:
|
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
|