wiki_md 0.1.0 → 0.1.1
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/lib/wiki_md.rb +48 -9
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c95067964e86163eae1475a060654f1bd517410f71f2fe6a02d80e37b1c85ffa
|
4
|
+
data.tar.gz: 3e7e8058cebf0018cd9968dac70c8fa06c3aaaab7f021530eb002cdf82fce09b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2891b0a0c4436df45336f42cc21e19bd16b208790a3eb33c1761cdbeeeb79a63cbb5044f7af84b5ba6e61973e2b35d35dd250fac5588af94a6f064e31ce248ff
|
7
|
+
data.tar.gz: 9a8b5212b36a698ba751d5eac14fc7763d7fb74068877de1ce3a847703276a7612780957627c18196845825d5b288f6807ae178d4ded0c40fb467812d909403b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/wiki_md.rb
CHANGED
@@ -7,24 +7,35 @@ require 'dxsectionx'
|
|
7
7
|
|
8
8
|
|
9
9
|
class WikiMd
|
10
|
+
include RXFHelperModule
|
10
11
|
|
11
|
-
|
12
|
+
attr_reader :active_heading
|
13
|
+
|
14
|
+
def initialize(wiki=nil, debug: false)
|
15
|
+
|
16
|
+
@debug = debug
|
12
17
|
|
13
18
|
if wiki then
|
14
|
-
s,
|
15
|
-
@
|
19
|
+
s, type = RXFHelper.read(wiki, auto: false)
|
20
|
+
@filename = wiki if type == :file or type == :dfs
|
21
|
+
puts 's: ' + s.inspect if @debug
|
22
|
+
@dxsx = DxSectionX.new s, debug: debug
|
16
23
|
else
|
17
24
|
|
18
25
|
new_md()
|
19
26
|
|
20
|
-
end
|
21
|
-
|
27
|
+
end
|
28
|
+
|
22
29
|
end
|
23
30
|
|
31
|
+
|
24
32
|
def create_section(s)
|
33
|
+
@active_heading = s[/(?<=^# ).*/]
|
25
34
|
@dxsx.create(x: s)
|
26
35
|
end
|
27
36
|
|
37
|
+
alias add_section create_section
|
38
|
+
|
28
39
|
def delete_section(q)
|
29
40
|
|
30
41
|
r = find()
|
@@ -37,11 +48,22 @@ class WikiMd
|
|
37
48
|
|
38
49
|
def find(q)
|
39
50
|
|
51
|
+
puts 'WikiMd::find q: ' + q.inspect if @debug
|
40
52
|
return @dxsx.dx.find q if q =~ /^\d+$/
|
41
53
|
regex = q.is_a?(String) ? /#{q}/i : q
|
42
|
-
@dxsx.dx.all.find {|section| section.x =~ regex }
|
54
|
+
r = @dxsx.dx.all.find {|section| section.x.lines.first =~ regex }
|
55
|
+
puts ' r: ' + r.inspect if @debug
|
56
|
+
return unless r
|
57
|
+
|
58
|
+
heading2 = r.x.lines.last[/(?<=redirect ).*/]
|
59
|
+
heading2 ? find(heading2) : r
|
60
|
+
|
43
61
|
end
|
44
62
|
|
63
|
+
def headings()
|
64
|
+
@dxsx.dx.all.map {|section| section.x.lines.first.chomp[/(?<=# ).*/] }
|
65
|
+
end
|
66
|
+
|
45
67
|
def new_md(x=nil)
|
46
68
|
|
47
69
|
s = nil
|
@@ -62,6 +84,15 @@ EOF
|
|
62
84
|
|
63
85
|
alias import new_md
|
64
86
|
|
87
|
+
def read_section(heading)
|
88
|
+
section = find heading
|
89
|
+
section.x if section
|
90
|
+
end
|
91
|
+
|
92
|
+
def save(filename=@filename)
|
93
|
+
FileX.write filename, @dxsx.to_s
|
94
|
+
end
|
95
|
+
|
65
96
|
def title()
|
66
97
|
@dxsx.dx.title()
|
67
98
|
end
|
@@ -89,12 +120,20 @@ EOF
|
|
89
120
|
|
90
121
|
def update_section(*args)
|
91
122
|
|
123
|
+
puts 'inside update_section' if @debug
|
124
|
+
|
92
125
|
val, raw_q = args.reverse
|
126
|
+
puts ' val: ' + val.inspect if @debug
|
127
|
+
puts ' raw_q: ' + raw_q.inspect if @debug
|
128
|
+
q = raw_q ? raw_q : val.lines.first[/(?<=^# ).*/]
|
93
129
|
|
94
|
-
q
|
130
|
+
puts ' q: ' + q.inspect if @debug
|
131
|
+
@section = r = find(q)
|
132
|
+
return false unless r
|
95
133
|
|
96
|
-
|
97
|
-
|
134
|
+
content = val =~ /# / ? val : r.x.lines.first + "\n" + val
|
135
|
+
@active_heading = content[/(?<=^# ).*/]
|
136
|
+
r.x = content
|
98
137
|
end
|
99
138
|
|
100
139
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wiki_md
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
nEQURKgvgTAqVg9tuqcjEE861mSCPc+12rmUHVBZDxMDQF6CQbnOxrYRIS+7fnia
|
36
36
|
kikBQtN17cUMyGOrZTVRhVGR
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2018-09-
|
38
|
+
date: 2018-09-16 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: dxsectionx
|
metadata.gz.sig
CHANGED
Binary file
|