wiki_md 0.2.1 → 0.3.0
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 +73 -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: 4b60a7007c10767ee1798adb195e34cfffc69c384697428120dbd379f6fb315e
|
4
|
+
data.tar.gz: cd50df1dc362a16e0babe375154d29519a21bc60b715eb4df44d9d8fb2969645
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1b9e4275ff9cc4c6d323bfc4faa4e681a2abab6922cc459ad1231dc5e77f62b21e9ef7e654e5728c9a60e5ab37eeaa042b280c78474e0edb4977a9c92928286
|
7
|
+
data.tar.gz: 8a1b78aa69fe3c3f02c13ba9a94345a1d2e53b010909807b1a1ceaec88192ccd52c861025248195a284b5dca109391b80090b43e33b9a8a5cd0519c8a31abf83
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/wiki_md.rb
CHANGED
@@ -8,9 +8,9 @@ require 'dxsectionx'
|
|
8
8
|
class WikiMd
|
9
9
|
include RXFHelperModule
|
10
10
|
|
11
|
-
attr_reader :active_heading, :filename
|
11
|
+
attr_reader :active_heading, :filename, :dx
|
12
12
|
|
13
|
-
def initialize(wiki=nil, domain: nil, debug: false, base_url: '
|
13
|
+
def initialize(wiki=nil, domain: nil, debug: false, base_url: '',
|
14
14
|
tag_base_url: '/tag')
|
15
15
|
|
16
16
|
@domain, @debug, @base_url, @tag_base_url = domain, debug, base_url,
|
@@ -35,20 +35,48 @@ class WikiMd
|
|
35
35
|
new_md()
|
36
36
|
|
37
37
|
end
|
38
|
+
|
39
|
+
save()
|
38
40
|
|
39
41
|
end
|
40
|
-
|
41
|
-
|
42
|
+
|
42
43
|
def create_section(s)
|
44
|
+
|
45
|
+
@active_heading = title = s[/(?<=^# ).*/]
|
46
|
+
url = [@base_url, File.basename(@filename)[/.*(?=\.\w+)/],
|
47
|
+
URI.escape(title)].join('/')
|
43
48
|
|
49
|
+
if s.rstrip.lines.last =~ /^\+\s+/ then
|
50
|
+
|
51
|
+
@dxsx.create(x: s, url: url)
|
52
|
+
|
53
|
+
else
|
54
|
+
|
55
|
+
a = title.split(/ +/)
|
56
|
+
tag = a.length > 1 ? a.map(&:capitalize).join : a.first
|
57
|
+
|
58
|
+
@dxsx.create(x: s + "\n\n+ " + tag, url: url)
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
FileX.write @filename, @dxsx.to_s if @filename
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
def create_section(s)
|
67
|
+
|
44
68
|
@active_heading = title = s[/(?<=^# ).*/]
|
45
|
-
tag = title.split(/ +/).map(&:capitalize).join
|
46
69
|
|
47
|
-
|
48
|
-
|
49
|
-
|
70
|
+
s2 = s.rstrip.lines.last =~ /^\+\s+/ ? s : s + "\n\n+ " + tag
|
71
|
+
|
72
|
+
@dxsx.create(x: s2)
|
73
|
+
|
74
|
+
tag = s.rstrip.lines.last[/(?<=^\+\s).*/]
|
75
|
+
@dx.create title: title + ' #' + tag.lstrip,
|
76
|
+
url: [@base_url, File.basename(@filename)[/.*(?=\.\w+)/],
|
50
77
|
URI.escape(title)].join('/')
|
51
78
|
FileX.write @filename, @dxsx.to_s if @filename
|
79
|
+
|
52
80
|
end
|
53
81
|
|
54
82
|
alias add_section create_section
|
@@ -143,7 +171,7 @@ EOF
|
|
143
171
|
end
|
144
172
|
end
|
145
173
|
|
146
|
-
def save(filename=@filename)
|
174
|
+
def save(filename=@filename || 'mywiki.md')
|
147
175
|
|
148
176
|
@filename = filename
|
149
177
|
@filepath = File.dirname(@filename)
|
@@ -202,6 +230,42 @@ EOF
|
|
202
230
|
content = val =~ /# / ? val : r.x.lines.first + "\n" + val
|
203
231
|
@active_heading = content[/(?<=^# ).*/]
|
204
232
|
r.x = content
|
233
|
+
|
234
|
+
rx = @dx.all.find {|x| x.title =~ /#{q}/}
|
235
|
+
tagline1 = content.lines.last[/^\+\s+(.*)/,1]
|
236
|
+
|
237
|
+
if rx then
|
238
|
+
|
239
|
+
# update the index entry if the title or tags have been modified
|
240
|
+
|
241
|
+
title, tagline2 = rx.title.split(/\s+#/)
|
242
|
+
|
243
|
+
|
244
|
+
if title != @active_heading or tagline2 != tagline1 then
|
245
|
+
|
246
|
+
rx.update title: @active_heading + ' #' + tagline1.split.join(' #'),
|
247
|
+
url: [@base_url, File.basename(@filename)[/.*(?=\.\w+)/],
|
248
|
+
URI.escape(title)].join('/')
|
249
|
+
|
250
|
+
end
|
251
|
+
|
252
|
+
|
253
|
+
else
|
254
|
+
|
255
|
+
# create a new index entry
|
256
|
+
|
257
|
+
newtagline = if tagline1 then
|
258
|
+
tagline1.split.join(' #')
|
259
|
+
else
|
260
|
+
a = @active_heading.split(/ +/)
|
261
|
+
a.length > 1 ? a.map(&:capitalize).join : a.first
|
262
|
+
end
|
263
|
+
|
264
|
+
@dx.create title: @active_heading + ' #' + newtagline,
|
265
|
+
url: [@base_url, File.basename(@filename),
|
266
|
+
URI.escape(@active_heading)].join('/')
|
267
|
+
end
|
268
|
+
|
205
269
|
end
|
206
270
|
|
207
271
|
private
|
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.
|
4
|
+
version: 0.3.0
|
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-11-
|
38
|
+
date: 2018-11-02 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: dxsectionx
|
metadata.gz.sig
CHANGED
Binary file
|