wiki_md 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/wiki_md.rb +115 -8
- 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: 812073421ddfee0070fd6c340e54853949d4ba7cfbb5cd736a9b4ef54640efb1
|
4
|
+
data.tar.gz: bf512609589a4eb78fd2eeb9052fa4626052a4408621d32bd4417f9aaa461c31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8c2045c900695dd6eb122e1e869b34d2dd27aa79d62b2f64f746c924c668914003e92d94d3218358f5af0f80cd951782514b4cde6ef9df829a773a08515b0e6
|
7
|
+
data.tar.gz: 0c34abcedaf88c4cc771f6f9e66019f9ac684bd095afb2c7560e2a2b02a2a953754da3d3334b614463967192e2a3c46be49c0ab204a7eebddb6c32660c12f49b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/wiki_md.rb
CHANGED
@@ -68,7 +68,9 @@ class WikiMd
|
|
68
68
|
|
69
69
|
if wiki then
|
70
70
|
|
71
|
+
puts 'before rxfhelper wiki: ' + wiki.inspect if @debug
|
71
72
|
s, type = RXFHelper.read(wiki, auto: false)
|
73
|
+
puts 'after rxfhelper s: ' + s.inspect if @debug
|
72
74
|
|
73
75
|
puts ('type: ' + type.inspect).debug if debug
|
74
76
|
|
@@ -107,8 +109,8 @@ class WikiMd
|
|
107
109
|
raise WikiMdReadError, msg unless valid
|
108
110
|
|
109
111
|
puts ('s: ' + s.inspect).debug if @debug
|
110
|
-
|
111
|
-
|
112
|
+
|
113
|
+
@dxsx = read_raw_document s
|
112
114
|
|
113
115
|
@filepath = File.dirname @filename
|
114
116
|
|
@@ -120,7 +122,7 @@ class WikiMd
|
|
120
122
|
|
121
123
|
else
|
122
124
|
|
123
|
-
@dxsx =
|
125
|
+
@dxsx = read_raw_document s
|
124
126
|
|
125
127
|
end
|
126
128
|
|
@@ -195,7 +197,14 @@ class WikiMd
|
|
195
197
|
end
|
196
198
|
|
197
199
|
def entries()
|
198
|
-
|
200
|
+
|
201
|
+
@dxsx.dx.all.map do |x|
|
202
|
+
|
203
|
+
puts 'x: ' + x.inspect if @debug
|
204
|
+
Entry.new(x)
|
205
|
+
|
206
|
+
end
|
207
|
+
|
199
208
|
end
|
200
209
|
|
201
210
|
def find(q, exact_match: false)
|
@@ -252,7 +261,7 @@ EOF
|
|
252
261
|
|
253
262
|
end
|
254
263
|
|
255
|
-
alias import new_md
|
264
|
+
alias import new_md
|
256
265
|
|
257
266
|
def read_section(heading, exact_match: false)
|
258
267
|
|
@@ -331,7 +340,8 @@ EOF
|
|
331
340
|
|
332
341
|
@filename = filename
|
333
342
|
@filepath = File.dirname(@filename)
|
334
|
-
|
343
|
+
|
344
|
+
FileX.write @filename=filename, dx_to_wmd(@dxsx.to_s)
|
335
345
|
|
336
346
|
puts ('before @dxsx save').debug if @debug
|
337
347
|
@dxsx.save filename.sub(/\.md$/, '.xml')
|
@@ -370,7 +380,7 @@ EOF
|
|
370
380
|
|
371
381
|
e = Rexle::Element.new('panel')
|
372
382
|
e.add_attribute(title: x.heading)
|
373
|
-
|
383
|
+
puts 'x.body: ' + x.body.inspect if @debug
|
374
384
|
body = "<body>%s</body>" % Martile.new(x.body).to_html
|
375
385
|
Rexle.new(body).root.elements.each {|element| e.add element }
|
376
386
|
|
@@ -395,10 +405,14 @@ EOF
|
|
395
405
|
@dxsx.to_doc.xml(declaration: false, pretty: true)
|
396
406
|
end
|
397
407
|
|
398
|
-
def
|
408
|
+
def to_rawdx()
|
399
409
|
@dxsx.to_s
|
400
410
|
end
|
401
411
|
|
412
|
+
def to_s()
|
413
|
+
dx_to_wmd(@dxsx.to_dx)
|
414
|
+
end
|
415
|
+
|
402
416
|
def to_toc()
|
403
417
|
y = Yatoc.new(Kramdown::Document.new(self.to_sections).to_html)
|
404
418
|
puts y.to_html
|
@@ -521,8 +535,19 @@ EOF
|
|
521
535
|
|
522
536
|
end
|
523
537
|
|
538
|
+
def read_raw_document(s)
|
539
|
+
|
540
|
+
s2 = s.lines.first =~ /^<\?wikimd\b/ ? wmd_to_dx(s) : s
|
541
|
+
|
542
|
+
DxSectionX.new s2, debug: @debug, autosave: true,
|
543
|
+
order: @order
|
544
|
+
|
545
|
+
end
|
546
|
+
|
524
547
|
def validate(s)
|
525
548
|
|
549
|
+
puts 'validate s:' + s.inspect if @debug
|
550
|
+
|
526
551
|
a = s[/(?<=--#\n).*/m].split(/(?=\n# )/)
|
527
552
|
valid = a.all? {|x| x.lines.last[0] == '+'}
|
528
553
|
return true if valid
|
@@ -533,4 +558,86 @@ EOF
|
|
533
558
|
|
534
559
|
[false, 'Tagline missing from heading # ' + heading]
|
535
560
|
end
|
561
|
+
|
562
|
+
def wmd_to_dx(s)
|
563
|
+
|
564
|
+
puts 's: ' + s.inspect if @debug
|
565
|
+
|
566
|
+
header, body = s.split(/.*(?=^#)/,2)
|
567
|
+
|
568
|
+
puts 'body: ' + body.inspect if @debug
|
569
|
+
|
570
|
+
title = header[/title: +(.*)/,1]
|
571
|
+
|
572
|
+
raw_dx_header = "
|
573
|
+
<?dynarex schema='sections[title]/section(x)' format_mask='[!x]'?>
|
574
|
+
title: #{title}
|
575
|
+
|
576
|
+
--#\n\n"
|
577
|
+
|
578
|
+
puts 'raw_dx_header: ' + raw_dx_header.inspect if @debug#
|
579
|
+
|
580
|
+
rawdx = raw_dx_header + body
|
581
|
+
puts 'rawdx: ' + rawdx.inspect if @debug
|
582
|
+
|
583
|
+
dx = Dynarex.new(rawdx)
|
584
|
+
|
585
|
+
rows = dx.all.map do |record|
|
586
|
+
|
587
|
+
a = record.x.lines
|
588
|
+
puts 'a: ' + a.inspect if @debug
|
589
|
+
|
590
|
+
raw_heading = a.shift.chomp
|
591
|
+
puts 'raw_heading: ' + raw_heading.inspect if @debug
|
592
|
+
heading = raw_heading[/^#[^#]+/].rstrip
|
593
|
+
|
594
|
+
tags = raw_heading =~ /#/ ? raw_heading[/(?<=# ).*/].scan(/#(\w+)/).flatten : ''
|
595
|
+
puts ('tags: ' + tags.inspect).debug if @debug
|
596
|
+
|
597
|
+
if a.last =~ /^\+/ then
|
598
|
+
|
599
|
+
footer = a.pop
|
600
|
+
tags += footer[1..-1].strip.split
|
601
|
+
|
602
|
+
else
|
603
|
+
|
604
|
+
if tags.empty? then
|
605
|
+
tags = heading.downcase.gsub(/['\.\(\)]/,'').split
|
606
|
+
end
|
607
|
+
|
608
|
+
footer = '+ ' + tags.join(' ')
|
609
|
+
|
610
|
+
end
|
611
|
+
|
612
|
+
body = a.join.strip
|
613
|
+
|
614
|
+
[heading, body, footer].join("\n\n")
|
615
|
+
|
616
|
+
end
|
617
|
+
|
618
|
+
raw_dx_header + rows.join("\n\n")
|
619
|
+
|
620
|
+
end
|
621
|
+
|
622
|
+
def dx_to_wmd(dx)
|
623
|
+
|
624
|
+
rows = dx.all.map do |record|
|
625
|
+
|
626
|
+
a = record.x.lines
|
627
|
+
|
628
|
+
raw_heading = a.shift.chomp
|
629
|
+
footer = a.pop
|
630
|
+
body = a.join.strip
|
631
|
+
|
632
|
+
tags = footer[2..-1].split.map {|x| '#' + x }.join(' ')
|
633
|
+
heading = raw_heading + ' ' + tags
|
634
|
+
|
635
|
+
[heading, body].join("\n\n")
|
636
|
+
|
637
|
+
end
|
638
|
+
|
639
|
+
"<?wikimd version='1.0'?>
|
640
|
+
title: " + dx.title + "\n\n" + rows.join("\n\n")
|
641
|
+
|
642
|
+
end
|
536
643
|
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.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
N5hZmnA6M2h3NysLCPRtwS2vMJh8qq6OS5RjU9cc5V08vyIkQ7/YC/x+7kLm5Kn0
|
36
36
|
kvoWXxa8gpUBS+qMlSYFDHlq
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2020-01-
|
38
|
+
date: 2020-01-24 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: dxsectionx
|
metadata.gz.sig
CHANGED
Binary file
|