martile 1.6.2 → 1.7.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/martile.rb +309 -270
- data.tar.gz.sig +0 -0
- metadata +34 -33
- 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: 6cf601753597fa04c7e12d03c01580d931e797c06550e711016eabd9792d84de
|
|
4
|
+
data.tar.gz: b8e55247e68d7ae1bc1f553d5e407c6ad26af23bf827781df1408ce484ebe8c3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d44dabfbc8642c8ff44fbacc6934bffc80fdee5b5f2efa127c90577edbc61b3cb1eb8d52fbe6065dabd825fad081b1f4722f733e2f53381fbf1590b36a58d042
|
|
7
|
+
data.tar.gz: ab8c4bb5ff400b54bbe8b8509fb7643f841c452b35606df18e323e244f56823c78d5123a014f9c67d471f210594348f988458556f6c7e336bcfb880f031095dc
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/lib/martile.rb
CHANGED
|
@@ -17,13 +17,14 @@ require 'rxfhelper'
|
|
|
17
17
|
require 'mindwords'
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
# feature: 24-Feb-2023 Plugins are now supported
|
|
20
21
|
# feature: 08-Apr-2022 A <mindwords> tag an now be embedded
|
|
21
22
|
# bug fix: 01-Feb-2022 When a Martile document has nomarkdown2 tags applied,
|
|
22
23
|
# they will no longer be applied from a
|
|
23
24
|
# nested Martile statement
|
|
24
25
|
# feature: 01-Sep-2020 Introduced the nomarkdown tag and nomarkdown2 tag.
|
|
25
|
-
# The nomarkdown2 tag has the advantage of being used
|
|
26
|
-
# inside tags which other Markdown parse don't read.
|
|
26
|
+
# The nomarkdown2 tag has the advantage of being used
|
|
27
|
+
# inside tags which other Markdown parse don't read.
|
|
27
28
|
# The tag will remove itself before completion to_s.
|
|
28
29
|
# feature: 08-Aug-2020 Implemented #to_Webpage
|
|
29
30
|
# improvement: 23-Apr-2020 A self-closing sidenav tag is now valid
|
|
@@ -31,61 +32,61 @@ require 'mindwords'
|
|
|
31
32
|
# feature: 29-Feb-2020 The sidenav tag can now contain a raw hierachical list
|
|
32
33
|
# feature: 22-Jan-2020 An HtmlCom::Accordion component can now be generated
|
|
33
34
|
# using the tag <accordion>
|
|
34
|
-
# feature: 16-Sep-2019 An HTML Tree component can now be generated when
|
|
35
|
+
# feature: 16-Sep-2019 An HTML Tree component can now be generated when
|
|
35
36
|
# the tag <sidebar/> is used
|
|
36
37
|
# feature: 16-Jul-2019 An HTML Tabs component can now be created from XML
|
|
37
38
|
# XML can now be created using !tag notation e.g. !tabs
|
|
38
39
|
# feature: 05-May-2019 Dimensions can now be supplied for an iframe
|
|
39
40
|
# improvment: 06-Mar-2019 Checks for mindmap tags outside of other tags
|
|
40
|
-
# feature: 03-Mar-2019 A high level mindmap with associated doc can now be
|
|
41
|
+
# feature: 03-Mar-2019 A high level mindmap with associated doc can now be
|
|
41
42
|
# easily created using the -mm---identifier
|
|
42
|
-
# bug fix: 25-Feb-2019 The section content is now rendered using to_s
|
|
43
|
+
# bug fix: 25-Feb-2019 The section content is now rendered using to_s
|
|
43
44
|
# instead of to_html
|
|
44
|
-
# feature: 16-Feb-2019 A hidden field cam now be rendered using
|
|
45
|
-
# the syntax [? name: value]
|
|
46
|
-
# feature: 11-Feb-2019 An apostrophe used between words is now preserved
|
|
45
|
+
# feature: 16-Feb-2019 A hidden field cam now be rendered using
|
|
46
|
+
# the syntax [? name: value]
|
|
47
|
+
# feature: 11-Feb-2019 An apostrophe used between words is now preserved
|
|
47
48
|
# from Kramdown HTML rendering
|
|
48
|
-
# feature: 23-Dec-2018 A SectionX or KVX object can now be referenced
|
|
49
|
+
# feature: 23-Dec-2018 A SectionX or KVX object can now be referenced
|
|
49
50
|
# from interpolated variables
|
|
50
|
-
# feature: 17-Dec-2018 Now automatically generates a toc when there are 3
|
|
51
|
+
# feature: 17-Dec-2018 Now automatically generates a toc when there are 3
|
|
51
52
|
# sections or more
|
|
52
53
|
# feature: 3-Oct-2018 An embed tag can now be used to dynamically load content
|
|
53
|
-
# bug fix: 26-Sep-2018 An extra new line is added after a code block to
|
|
54
|
-
# ensure the line directly below it is transformed to
|
|
54
|
+
# bug fix: 26-Sep-2018 An extra new line is added after a code block to
|
|
55
|
+
# ensure the line directly below it is transformed to
|
|
55
56
|
# HTML correctly.
|
|
56
|
-
# bug fix: 23-Sep-2018 mindmap tag is now properly
|
|
57
|
+
# bug fix: 23-Sep-2018 mindmap tag is now properly
|
|
57
58
|
# transformed before parse__data__
|
|
58
59
|
# feature: 23-Jul-2018 An HTML form can now be generated
|
|
59
|
-
# feature: 12-Feb-2018 Transforms <mindmap> tags into a
|
|
60
|
+
# feature: 12-Feb-2018 Transforms <mindmap> tags into a
|
|
60
61
|
# mindmap + related headings
|
|
61
62
|
# feature: 8-Feb-2018 A section attribute id can now include a dash (-).
|
|
62
|
-
# Markdown inside a section element is no longer
|
|
63
|
+
# Markdown inside a section element is no longer
|
|
63
64
|
# rendered by RDiscount
|
|
64
|
-
# minor improvement: 29-Sep-2017 A Markdownviz or Flowchartviz embedded
|
|
65
|
+
# minor improvement: 29-Sep-2017 A Markdownviz or Flowchartviz embedded
|
|
65
66
|
# document can now be declared without the word viz at the end.
|
|
66
|
-
# feature: 21-Sep-2017 A qrcode can now be rendered
|
|
67
|
+
# feature: 21-Sep-2017 A qrcode can now be rendered
|
|
67
68
|
# e.g. !q[](http://github.com)
|
|
68
69
|
# feature: 16-Sep-2017 A Flowchartviz raw document can now be embedded
|
|
69
70
|
# feature: 9-Sep-2017 A Mindmapviz raw document can now be embedded
|
|
70
71
|
# feature: 8-Sep-2017 An SVG doc can now be embedded from !s[]()
|
|
71
|
-
# feature: 6-Sep-2017 The preparation of a Dynarex table in Markdown is now
|
|
72
|
+
# feature: 6-Sep-2017 The preparation of a Dynarex table in Markdown is now
|
|
72
73
|
# done from the Dynarex object
|
|
73
|
-
# bug fix: 13-Aug-2017 bug fixes: A markdown table is no longer interpreted
|
|
74
|
-
# as <code> and a string containig a caret is no longer
|
|
75
|
-
# interpreted as <nark> if it contains non
|
|
74
|
+
# bug fix: 13-Aug-2017 bug fixes: A markdown table is no longer interpreted
|
|
75
|
+
# as <code> and a string containig a caret is no longer
|
|
76
|
+
# interpreted as <nark> if it contains non
|
|
76
77
|
# alphanumerical characters.
|
|
77
|
-
# feature: 28-May-2017 Within the context of an embedded Dynarex table,
|
|
78
|
+
# feature: 28-May-2017 Within the context of an embedded Dynarex table,
|
|
78
79
|
# the nomarkdown extension was wrapped around the inner HTML for each column
|
|
79
|
-
#
|
|
80
|
+
#
|
|
80
81
|
# Return characters are now stripped out.
|
|
81
82
|
#
|
|
82
|
-
# An embeded Dynarex table contents are now rendered to
|
|
83
|
+
# An embeded Dynarex table contents are now rendered to
|
|
83
84
|
# Markdown by default
|
|
84
|
-
# feature: 11-Mar-2017 A details and summary tag can now be generated from +>
|
|
85
|
+
# feature: 11-Mar-2017 A details and summary tag can now be generated from +>
|
|
85
86
|
# e.g.
|
|
86
87
|
# !+
|
|
87
88
|
# This a paragraph
|
|
88
|
-
#
|
|
89
|
+
#
|
|
89
90
|
# ----------------
|
|
90
91
|
#
|
|
91
92
|
# * something
|
|
@@ -103,27 +104,30 @@ class Martile
|
|
|
103
104
|
# embedded: Is the Martile object being run inside another Martile object?
|
|
104
105
|
#
|
|
105
106
|
def initialize(raw_s='', ignore_domainlabel: nil, toc: true,
|
|
106
|
-
embedded: false, debug: false, log: nil)
|
|
107
|
+
embedded: false, debug: false, log: nil, plugins: {})
|
|
107
108
|
|
|
108
109
|
|
|
109
110
|
@debug = debug
|
|
110
111
|
@data_source = {}
|
|
111
|
-
|
|
112
|
+
|
|
112
113
|
@ignore_domainlabel, @log = ignore_domainlabel, log
|
|
113
|
-
|
|
114
|
+
|
|
114
115
|
@css, @js = [], []
|
|
116
|
+
|
|
117
|
+
@plugins = initialize_plugins(plugins || [])
|
|
115
118
|
|
|
116
119
|
raw_s.gsub!("\r",'')
|
|
117
|
-
|
|
120
|
+
|
|
118
121
|
mmd = MindmapDoc.new(debug: debug)
|
|
119
122
|
s5 = apply_filter(raw_s) {|x| mmd.to_mmd(x) }
|
|
120
123
|
s10 = apply_filter(s5) {|x| mmd.transform(s5) }
|
|
121
124
|
#puts 's10: ' + s10.inspect if debug
|
|
122
125
|
#s10 = raw_s
|
|
123
126
|
s20 = s10 =~ /^__DATA__$/ ? parse__data__(s10) : s10
|
|
124
|
-
puts ('s20: ' + s20.inspect).debug if debug
|
|
127
|
+
puts ('s20: ' + s20.inspect).debug if debug
|
|
128
|
+
s25 = apply_filter(s20) {|x| commentout x }
|
|
125
129
|
|
|
126
|
-
s30 = apply_filter(
|
|
130
|
+
s30 = apply_filter(s25) {|x| slashpre x }
|
|
127
131
|
puts ('s30: ' + s30.inspect).debug if @debug
|
|
128
132
|
|
|
129
133
|
#puts 's1 : ' + s1.inspect
|
|
@@ -157,7 +161,7 @@ class Martile
|
|
|
157
161
|
|
|
158
162
|
s100 = apply_filter(s90) {|x| section x }
|
|
159
163
|
puts ('s100: ' + s100.inspect).debug if @debug
|
|
160
|
-
|
|
164
|
+
|
|
161
165
|
s110 = apply_filter(s100) {|x| smartlink x }
|
|
162
166
|
|
|
163
167
|
puts 's110: ' + s110.inspect if @debug
|
|
@@ -195,8 +199,14 @@ class Martile
|
|
|
195
199
|
s245 = s240.gsub(/\{::nomarkdown2\}/,'').gsub(/\{:2\/\}/,'')
|
|
196
200
|
puts 's245 : ' + s245.inspect if @debug
|
|
197
201
|
s246 = mindwords(s245)
|
|
198
|
-
|
|
199
|
-
|
|
202
|
+
|
|
203
|
+
s248 = @plugins.inject(s246) do |r, x|
|
|
204
|
+
puts 'plugin x: ' + x.inspect if @debug
|
|
205
|
+
x.apply(r) if x.respond_to? :apply
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
@to_s = s248.to_s
|
|
209
|
+
|
|
200
210
|
s250 = apply_filter(s246) {|x| nomarkdown x }
|
|
201
211
|
puts 's250 : ' + s250.inspect if @debug
|
|
202
212
|
s252 = sidenav(s250)
|
|
@@ -210,38 +220,38 @@ class Martile
|
|
|
210
220
|
s257 = accordion(s255)
|
|
211
221
|
puts 's257 : ' + s257.inspect if @debug
|
|
212
222
|
|
|
213
|
-
toc = false if s257 =~ /class=['"]sidenav['"]>/
|
|
214
|
-
|
|
223
|
+
toc = false if s257 =~ /class=['"]sidenav['"]>/
|
|
224
|
+
|
|
215
225
|
s260 = if toc then
|
|
216
226
|
Yatoc.new(Kramdown::Document.new(s257).to_html, debug: debug).to_html
|
|
217
227
|
else
|
|
218
228
|
s257
|
|
219
229
|
end
|
|
220
|
-
|
|
221
|
-
puts ('s260: ' + s260.inspect).debug if debug
|
|
230
|
+
|
|
231
|
+
puts ('s260: ' + s260.inspect).debug if debug
|
|
222
232
|
#puts 's17 : ' + s17.inspect
|
|
223
233
|
|
|
224
234
|
@to_html = s260
|
|
225
|
-
|
|
235
|
+
|
|
226
236
|
end
|
|
227
|
-
|
|
237
|
+
|
|
228
238
|
def create_form(s)
|
|
229
239
|
|
|
230
240
|
a = LineTree.new(s, ignore_blank_lines: true).to_a
|
|
231
|
-
|
|
241
|
+
|
|
232
242
|
def create_form_input(raw_name)
|
|
233
243
|
|
|
234
244
|
name = raw_name.downcase[/\w+/]
|
|
235
245
|
type = name =~ /password/ ? :password : :text
|
|
236
246
|
|
|
237
|
-
['div', {},
|
|
238
|
-
['label', {for: name}, raw_name],
|
|
247
|
+
['div', {},
|
|
248
|
+
['label', {for: name}, raw_name],
|
|
239
249
|
['input', {type: type, id: name, name: name}]
|
|
240
250
|
]
|
|
241
251
|
end
|
|
242
|
-
|
|
252
|
+
|
|
243
253
|
a2 = a[0][1..-1].select {|x| x[0] =~ /[^:]+\:/}.map do |items|
|
|
244
|
-
|
|
254
|
+
|
|
245
255
|
line = items[0]
|
|
246
256
|
case line
|
|
247
257
|
when /^\w/
|
|
@@ -260,21 +270,21 @@ class Martile
|
|
|
260
270
|
doc = Rexle.new(a2)
|
|
261
271
|
doc.root.element('div/input').attributes['autofocus'] = 'true'
|
|
262
272
|
doc.xml pretty: true, declaration: false
|
|
263
|
-
|
|
273
|
+
|
|
264
274
|
end
|
|
265
|
-
|
|
275
|
+
|
|
266
276
|
def to_css()
|
|
267
277
|
@css.join("\n")
|
|
268
278
|
end
|
|
269
|
-
|
|
279
|
+
|
|
270
280
|
def to_js()
|
|
271
281
|
@js.join("\n")
|
|
272
282
|
end
|
|
273
|
-
|
|
283
|
+
|
|
274
284
|
def to_webpage()
|
|
275
285
|
|
|
276
286
|
a = RexleBuilder.build do |xml|
|
|
277
|
-
xml.html do
|
|
287
|
+
xml.html do
|
|
278
288
|
xml.head do
|
|
279
289
|
xml.meta name: "viewport", content: \
|
|
280
290
|
"width=device-width, initial-scale=1"
|
|
@@ -284,58 +294,58 @@ class Martile
|
|
|
284
294
|
end
|
|
285
295
|
end
|
|
286
296
|
|
|
287
|
-
doc = Rexle.new(a)
|
|
288
|
-
|
|
297
|
+
doc = Rexle.new(a)
|
|
298
|
+
|
|
289
299
|
doc.root.element('body').add \
|
|
290
|
-
Rexle::Element.new('script').add_text "\n" +
|
|
300
|
+
Rexle::Element.new('script').add_text "\n" +
|
|
291
301
|
@js.join("\n").gsub(/^ +\/\/[^\n]+\n/,'')
|
|
292
|
-
|
|
302
|
+
|
|
293
303
|
"<!DOCTYPE html>\n" + doc.xml(pretty: true, declaration: false)\
|
|
294
304
|
.gsub(/<\/div>/,'\0' + "\n").gsub(/\n *<!--[^>]+>/,'')
|
|
295
|
-
|
|
305
|
+
|
|
296
306
|
end
|
|
297
|
-
|
|
307
|
+
|
|
298
308
|
private
|
|
299
|
-
|
|
309
|
+
|
|
300
310
|
def accordion(s1)
|
|
301
|
-
|
|
311
|
+
|
|
302
312
|
s = s1.clone
|
|
303
|
-
|
|
313
|
+
|
|
304
314
|
doc = Rexle.new("<root>#{s}</root>")
|
|
305
315
|
puts 'doc.root.xml: ' + doc.root.xml.inspect if @debug
|
|
306
316
|
a = doc.root.xpath('accordion').map.with_index do |e, i |
|
|
307
|
-
|
|
317
|
+
|
|
308
318
|
build = HtmlCom::Accordion.new(e.xml, debug: false)
|
|
309
|
-
|
|
319
|
+
|
|
310
320
|
if i < 1 then
|
|
311
|
-
@css << build.to_css
|
|
321
|
+
@css << build.to_css
|
|
312
322
|
@js << build.to_js
|
|
313
323
|
end
|
|
314
|
-
|
|
324
|
+
|
|
315
325
|
build.to_html
|
|
316
|
-
|
|
317
|
-
|
|
326
|
+
|
|
327
|
+
|
|
318
328
|
end
|
|
319
329
|
puts 'accordion a:' + a.inspect if @debug
|
|
320
330
|
|
|
321
331
|
# replaces the <accordion> XML with HTML
|
|
322
332
|
a.each do |html|
|
|
323
|
-
|
|
333
|
+
|
|
324
334
|
istart = s =~ /^<accordion[^>]*>/
|
|
325
335
|
iend = s =~ /<\/accordion>/
|
|
326
336
|
s.slice!(istart, (iend - istart) + '</accordion>'.length + 1)
|
|
327
337
|
s.insert(istart, html)
|
|
328
|
-
|
|
338
|
+
|
|
329
339
|
end
|
|
330
|
-
|
|
340
|
+
|
|
331
341
|
return s
|
|
332
|
-
|
|
333
|
-
end
|
|
334
|
-
|
|
342
|
+
|
|
343
|
+
end
|
|
344
|
+
|
|
335
345
|
def audiotag(s)
|
|
336
|
-
|
|
346
|
+
|
|
337
347
|
s.gsub(/\B!a\[\]\((https?:\/\/[^\)]+)\)\B/) do |x|
|
|
338
|
-
|
|
348
|
+
|
|
339
349
|
files = ($1).split
|
|
340
350
|
|
|
341
351
|
h = {/\.ogg$/ => 'ogg', /\.wav$/ => 'wav', /\.mp3$/ => 'mp3' }
|
|
@@ -346,17 +356,17 @@ class Martile
|
|
|
346
356
|
end
|
|
347
357
|
|
|
348
358
|
"<audio controls='controls'>\n%s\n</audio>" % [sources.join("\n")]
|
|
349
|
-
end
|
|
359
|
+
end
|
|
350
360
|
|
|
351
361
|
end
|
|
352
|
-
|
|
362
|
+
|
|
353
363
|
def bang_xml(s)
|
|
354
364
|
|
|
355
|
-
indent = -> (line) { ' ' + line }
|
|
365
|
+
indent = -> (line) { ' ' + line }
|
|
356
366
|
a = s.split(/(?=^\![a-zA-Z]+)/)
|
|
357
|
-
|
|
367
|
+
|
|
358
368
|
a.map do |s|
|
|
359
|
-
|
|
369
|
+
|
|
360
370
|
if s =~ /^!!/ then
|
|
361
371
|
|
|
362
372
|
parent, children = s.split(/^!!/,2)
|
|
@@ -369,17 +379,17 @@ class Martile
|
|
|
369
379
|
else
|
|
370
380
|
s
|
|
371
381
|
end
|
|
372
|
-
|
|
382
|
+
|
|
373
383
|
end.join
|
|
374
384
|
end
|
|
375
385
|
|
|
376
386
|
def code_block_to_html(s)
|
|
377
387
|
|
|
378
|
-
|
|
379
|
-
s.split(/(?=<pre>)/).map do |s2|
|
|
380
|
-
|
|
388
|
+
|
|
389
|
+
s.split(/(?=<pre>)/).map do |s2|
|
|
390
|
+
|
|
381
391
|
if s2[0] != '<' then
|
|
382
|
-
|
|
392
|
+
|
|
383
393
|
s2.lines.chunk {|x| x =~ /^\n|^ |\n/ }.map do |_, x|
|
|
384
394
|
|
|
385
395
|
if x.join.lstrip[/^ /] then
|
|
@@ -393,18 +403,26 @@ class Martile
|
|
|
393
403
|
else
|
|
394
404
|
s2
|
|
395
405
|
end
|
|
396
|
-
|
|
406
|
+
|
|
397
407
|
end.join
|
|
408
|
+
|
|
398
409
|
|
|
410
|
+
end
|
|
411
|
+
|
|
412
|
+
# comments out blocks of text using the XML comment style tags.
|
|
413
|
+
#
|
|
414
|
+
def commentout(s1)
|
|
415
|
+
|
|
416
|
+
return s1.clone.split(/\n(?=<!--)/).map {|x| x.sub(/<!--.*-->/m,'') }.join
|
|
399
417
|
|
|
400
418
|
end
|
|
401
419
|
|
|
402
420
|
def details(s)
|
|
403
|
-
|
|
421
|
+
|
|
404
422
|
puts ('inside details: ' + s.inspect).debug if @debug
|
|
405
|
-
|
|
423
|
+
|
|
406
424
|
s.split(/(?=\!\+)/).map do |x|
|
|
407
|
-
|
|
425
|
+
|
|
408
426
|
if x =~ /\!\+/ then
|
|
409
427
|
|
|
410
428
|
x[2..-1].sub(/(.*)[^\+]+\n\+/m) do |x2|
|
|
@@ -414,23 +432,23 @@ class Martile
|
|
|
414
432
|
[summary, Martile.new(detail.chop).to_html]
|
|
415
433
|
|
|
416
434
|
end
|
|
417
|
-
|
|
435
|
+
|
|
418
436
|
else
|
|
419
437
|
x
|
|
420
438
|
end
|
|
421
439
|
end.join
|
|
422
440
|
|
|
423
441
|
end
|
|
424
|
-
|
|
442
|
+
|
|
425
443
|
def dynarex_to_markdown(s)
|
|
426
|
-
|
|
444
|
+
|
|
427
445
|
s.gsub(/!d\[\]\(((#\w+|https?:\/\/)?[\w\/\.\-]+)\)(\{[^\}]+\})?/) do |match|
|
|
428
446
|
|
|
429
447
|
source = ($1)
|
|
430
448
|
raw_select = ($3)
|
|
431
449
|
|
|
432
450
|
dx = if source =~ /^http/ then
|
|
433
|
-
Dynarex.new(source)
|
|
451
|
+
Dynarex.new(source)
|
|
434
452
|
else
|
|
435
453
|
@data_source[source[/\w+/]]
|
|
436
454
|
end
|
|
@@ -458,43 +476,43 @@ class Martile
|
|
|
458
476
|
end
|
|
459
477
|
|
|
460
478
|
end
|
|
461
|
-
|
|
479
|
+
|
|
462
480
|
def embedtag(s)
|
|
463
|
-
|
|
464
|
-
s.gsub(/\B!\(((?:https?|rse|dfs):\/\/[^\)]+)\)/) do
|
|
481
|
+
|
|
482
|
+
s.gsub(/\B!\(((?:https?|rse|dfs):\/\/[^\)]+)\)/) do
|
|
465
483
|
RXFReader.read(source=($1) ).first
|
|
466
484
|
end
|
|
467
485
|
|
|
468
486
|
end
|
|
469
|
-
|
|
470
|
-
|
|
487
|
+
|
|
488
|
+
|
|
471
489
|
def escape(s)
|
|
472
490
|
s.gsub('<','<').gsub('>','>')
|
|
473
491
|
end
|
|
474
|
-
|
|
492
|
+
|
|
475
493
|
def formify(s)
|
|
476
|
-
|
|
494
|
+
|
|
477
495
|
s.split(/(?=\n\w+)/).map do |s|
|
|
478
|
-
|
|
496
|
+
|
|
479
497
|
if s =~ /(?=\w+\n\n* \w+: +\[ +\])/ then
|
|
480
498
|
create_form(s)
|
|
481
499
|
else
|
|
482
500
|
s
|
|
483
501
|
end
|
|
484
|
-
|
|
502
|
+
|
|
485
503
|
end.join
|
|
486
|
-
|
|
504
|
+
|
|
487
505
|
end
|
|
488
|
-
|
|
506
|
+
|
|
489
507
|
def iframetag(s)
|
|
490
|
-
|
|
508
|
+
|
|
491
509
|
s.gsub(/\B!i\[\]\((https?:\/\/[^\)]+)\)(\{[^\}]+\})?/) do |x|
|
|
492
|
-
|
|
510
|
+
|
|
493
511
|
url = ($1)
|
|
494
512
|
attr = ($2)
|
|
495
513
|
|
|
496
514
|
h = attr ? attr.scan(/(\w+):\s+['"]?(\w+)?/).to_h : {}
|
|
497
|
-
attributes = h.any? ? (' ' +
|
|
515
|
+
attributes = h.any? ? (' ' +
|
|
498
516
|
h.map {|k,v| "%s='%s'" % [k,v]}.join(' ')) : ''
|
|
499
517
|
|
|
500
518
|
"<iframe src='%s'%s></iframe>" % [url, attributes]
|
|
@@ -502,8 +520,8 @@ class Martile
|
|
|
502
520
|
|
|
503
521
|
|
|
504
522
|
end
|
|
505
|
-
|
|
506
|
-
|
|
523
|
+
|
|
524
|
+
|
|
507
525
|
|
|
508
526
|
def list_to_html(s,symbol='#')
|
|
509
527
|
|
|
@@ -511,11 +529,11 @@ class Martile
|
|
|
511
529
|
tag = {'#' => 'ol', '\*' => 'ul'}[symbol]
|
|
512
530
|
|
|
513
531
|
s.split(/(?=\[#{symbol}|^#{symbol*2})/).map do |x|
|
|
514
|
-
|
|
532
|
+
|
|
515
533
|
if x.strip.length > 0 then
|
|
516
534
|
s2, remainder = [x[/\[#{symbol}.*#{symbol}[^\]]+\]/m], ($').to_s]
|
|
517
535
|
end
|
|
518
|
-
|
|
536
|
+
|
|
519
537
|
if s2 then
|
|
520
538
|
|
|
521
539
|
raw_list = s2[1..-2].split(/^#{symbol}/).reject(&:empty?).map(&:strip)
|
|
@@ -524,17 +542,17 @@ class Martile
|
|
|
524
542
|
ignore_domainlabel: @ignore_domainlabel).to_html)\
|
|
525
543
|
.to_html[/<p>(.*)<\/p>/,1]}.join
|
|
526
544
|
list + remainder.to_s
|
|
527
|
-
|
|
545
|
+
|
|
528
546
|
else
|
|
529
|
-
|
|
547
|
+
|
|
530
548
|
x
|
|
531
|
-
|
|
549
|
+
|
|
532
550
|
end
|
|
533
|
-
|
|
551
|
+
|
|
534
552
|
end.join
|
|
535
553
|
|
|
536
554
|
end
|
|
537
|
-
|
|
555
|
+
|
|
538
556
|
def filter_on(s)
|
|
539
557
|
|
|
540
558
|
@filter = []
|
|
@@ -562,14 +580,14 @@ class Martile
|
|
|
562
580
|
end
|
|
563
581
|
|
|
564
582
|
def apply_filter(s)
|
|
565
|
-
|
|
583
|
+
|
|
566
584
|
s1 = filter_on(s)
|
|
567
585
|
s2 = yield s1
|
|
568
586
|
s3 = filter_off s2
|
|
569
|
-
|
|
587
|
+
|
|
570
588
|
return s3
|
|
571
589
|
end
|
|
572
|
-
|
|
590
|
+
|
|
573
591
|
|
|
574
592
|
def explicit_list_to_html(s)
|
|
575
593
|
|
|
@@ -594,25 +612,25 @@ class Martile
|
|
|
594
612
|
else
|
|
595
613
|
s
|
|
596
614
|
end
|
|
597
|
-
|
|
615
|
+
|
|
598
616
|
end
|
|
599
|
-
|
|
617
|
+
|
|
600
618
|
def hyperlinkify(s)
|
|
601
|
-
|
|
619
|
+
|
|
602
620
|
s.gsub(/\[([^\[]+)\]\(([^\)]+\)\)?\))/) do |x|
|
|
603
621
|
"<a href='#{$2.chop}'>#{$1}</a>"
|
|
604
622
|
end
|
|
605
623
|
|
|
606
624
|
end
|
|
607
|
-
|
|
608
|
-
|
|
625
|
+
|
|
626
|
+
|
|
609
627
|
def mtlite_utils(s)
|
|
610
|
-
|
|
628
|
+
|
|
611
629
|
# convert square brackets to unicode check boxes
|
|
612
|
-
# replaces a [] with a unicode checkbox,
|
|
630
|
+
# replaces a [] with a unicode checkbox,
|
|
613
631
|
# and [x] with a unicode checked checkbox
|
|
614
632
|
s2 = s.gsub(/\s\[ {0,1}\]\s/,' ☐ ').gsub(/\s\[x\]\s/,' ☑ ')
|
|
615
|
-
|
|
633
|
+
|
|
616
634
|
# create domain labels for hyperlinks
|
|
617
635
|
#
|
|
618
636
|
s3 = s2.gsub(/(?:^\[|\s\[)[^\]]+\]\((https?:\/\/[^\s]+)/) do |x|
|
|
@@ -628,60 +646,60 @@ class Martile
|
|
|
628
646
|
# e.g. -milk cow- becomes <del>milk cow</del>
|
|
629
647
|
s3.gsub(/\s-[^-]+-?[^-]+-[\s\]]/) do |x|
|
|
630
648
|
x.sub(/-([&\w]+.*\w+)-/,'<del>\1</del>')
|
|
631
|
-
end
|
|
649
|
+
end
|
|
632
650
|
|
|
633
651
|
end
|
|
634
|
-
|
|
652
|
+
|
|
635
653
|
def nomarkdown(s)
|
|
636
654
|
s.gsub(/\b'\b/,"{::nomarkdown}'{:/}")
|
|
637
655
|
end
|
|
638
|
-
|
|
656
|
+
|
|
639
657
|
def qrcodetag(s)
|
|
640
|
-
|
|
641
|
-
s.gsub(/\B!q\[\]\((https?:\/\/[^\)]+)\)/) do
|
|
642
|
-
|
|
643
|
-
svg = RQRCode::QRCode.new($1).as_svg
|
|
658
|
+
|
|
659
|
+
s.gsub(/\B!q\[\]\((https?:\/\/[^\)]+)\)/) do
|
|
660
|
+
|
|
661
|
+
svg = RQRCode::QRCode.new($1).as_svg
|
|
644
662
|
svg.slice!(/.*(?=<svg)/m)
|
|
645
|
-
|
|
663
|
+
|
|
646
664
|
svg
|
|
647
665
|
end
|
|
648
666
|
|
|
649
|
-
end
|
|
650
|
-
|
|
667
|
+
end
|
|
668
|
+
|
|
651
669
|
def ordered_list_to_html(s)
|
|
652
670
|
list_to_html s, '#'
|
|
653
671
|
end
|
|
654
|
-
|
|
672
|
+
|
|
655
673
|
def dx_render_table(dx, raw_select)
|
|
656
|
-
|
|
674
|
+
|
|
657
675
|
fields, markdown, heading, inner = nil, true, true, true
|
|
658
|
-
|
|
676
|
+
|
|
659
677
|
if raw_select then
|
|
660
678
|
|
|
661
679
|
raw_fields = raw_select[/select:\s*["']([^"']+)/,1]
|
|
662
|
-
|
|
680
|
+
|
|
663
681
|
fields = raw_fields.split(/\s*,\s*/) if raw_fields
|
|
664
682
|
inner = false if raw_select[/\bmarkdown:\s*false\b/]
|
|
665
683
|
heading = false if raw_select[/\bheading:\s*false\b/]
|
|
666
684
|
|
|
667
685
|
end
|
|
686
|
+
|
|
668
687
|
|
|
669
|
-
|
|
670
|
-
dx.to_table(markdown: true, fields: fields, innermarkdown: inner,
|
|
688
|
+
dx.to_table(markdown: true, fields: fields, innermarkdown: inner,
|
|
671
689
|
heading: heading)
|
|
672
|
-
end
|
|
673
|
-
|
|
690
|
+
end
|
|
691
|
+
|
|
674
692
|
def dx_render_table2(dx, raw_select)
|
|
675
|
-
|
|
693
|
+
|
|
676
694
|
markdown, heading = true, true
|
|
677
|
-
|
|
695
|
+
|
|
678
696
|
if raw_select then
|
|
679
697
|
raw_fields = raw_select[/select:\s*["']([^"']+)/,1]
|
|
680
698
|
fields = raw_fields.split(/\s*,\s*/) if raw_fields
|
|
681
699
|
markdown = false if raw_select[/\bmarkdown:\s*false\b/]
|
|
682
700
|
heading = false if raw_select[/\bheading:\s*false\b/]
|
|
683
701
|
end
|
|
684
|
-
|
|
702
|
+
|
|
685
703
|
print_row = -> (row, widths) do
|
|
686
704
|
'| ' + row.map\
|
|
687
705
|
.with_index {|y,i| y.to_s.ljust(widths[i])}.join(' | ') + " |\n"
|
|
@@ -699,12 +717,12 @@ class Martile
|
|
|
699
717
|
|
|
700
718
|
|
|
701
719
|
flat_records = raw_select ? dx.to_a(select: fields) : dx.to_a
|
|
702
|
-
|
|
720
|
+
|
|
703
721
|
keys = flat_records.map(&:keys).first
|
|
704
722
|
raw_vals = flat_records.map(&:values)
|
|
705
|
-
|
|
723
|
+
|
|
706
724
|
# create Markdown hyperlinks for any URLs
|
|
707
|
-
|
|
725
|
+
|
|
708
726
|
vals = raw_vals.map do |row|
|
|
709
727
|
|
|
710
728
|
row.map do |col|
|
|
@@ -720,35 +738,35 @@ class Martile
|
|
|
720
738
|
url_title = (a.join('.') + path)[0..39] + '...'
|
|
721
739
|
|
|
722
740
|
"[%s](%s)" % [url_title, col]
|
|
723
|
-
|
|
741
|
+
|
|
724
742
|
else
|
|
725
|
-
|
|
726
|
-
if markdown then
|
|
727
|
-
"{::nomarkdown}" +
|
|
743
|
+
|
|
744
|
+
if markdown then
|
|
745
|
+
"{::nomarkdown}" +
|
|
728
746
|
RDiscount.new(col).to_html.strip.gsub("\n",'') + "{:/}"
|
|
729
747
|
else
|
|
730
748
|
|
|
731
749
|
col
|
|
732
|
-
|
|
750
|
+
|
|
733
751
|
end
|
|
734
|
-
|
|
752
|
+
|
|
735
753
|
end
|
|
736
|
-
|
|
754
|
+
|
|
737
755
|
r
|
|
738
756
|
end
|
|
739
|
-
end
|
|
757
|
+
end
|
|
740
758
|
|
|
741
759
|
widths = ([keys] + vals).transpose.map{|x| x.max_by(&:length).length}
|
|
742
|
-
|
|
743
|
-
|
|
760
|
+
|
|
761
|
+
|
|
744
762
|
th = heading ? print_row.call(keys, widths) : ''
|
|
745
|
-
th_line = print_thline.call widths.map {|x| '-' * (x+1)}, widths
|
|
746
|
-
tb = print_rows.call(vals, widths)
|
|
747
|
-
|
|
763
|
+
th_line = print_thline.call widths.map {|x| '-' * (x+1)}, widths
|
|
764
|
+
tb = print_rows.call(vals, widths)
|
|
765
|
+
|
|
748
766
|
table = th + th_line + tb
|
|
749
|
-
|
|
767
|
+
|
|
750
768
|
end
|
|
751
|
-
|
|
769
|
+
|
|
752
770
|
|
|
753
771
|
def mindwords(s1)
|
|
754
772
|
|
|
@@ -785,131 +803,131 @@ class Martile
|
|
|
785
803
|
def parse__data__(s)
|
|
786
804
|
|
|
787
805
|
puts 'inside parse__data__'.info if @debug
|
|
788
|
-
|
|
806
|
+
|
|
789
807
|
a = s.split(/^__DATA__$/,2)
|
|
790
808
|
|
|
791
809
|
data = a[-1]
|
|
792
|
-
|
|
810
|
+
|
|
793
811
|
links, locals = data.split(/(?=<)/, 2)
|
|
794
|
-
|
|
812
|
+
|
|
795
813
|
links.strip.split("\n").each do |line|
|
|
796
|
-
|
|
814
|
+
|
|
797
815
|
puts ('line:' + line.inspect).debug if @debug
|
|
798
816
|
next if line.nil?
|
|
799
|
-
|
|
817
|
+
|
|
800
818
|
id, url = line.split(/:\s+/,2)
|
|
801
819
|
puts 'id: ' + id.inspect if @debug
|
|
802
820
|
puts 'url: ' + url.inspect if @debug
|
|
803
|
-
|
|
821
|
+
|
|
804
822
|
obj, _ = RXFHelper.read(url, auto: true)
|
|
805
823
|
define_singleton_method(id.to_sym) { @data_source[id] }
|
|
806
|
-
@data_source[id] = obj
|
|
807
|
-
|
|
824
|
+
@data_source[id] = obj
|
|
825
|
+
|
|
808
826
|
end
|
|
809
|
-
|
|
827
|
+
|
|
810
828
|
puts 'before locals' if @debug
|
|
811
|
-
|
|
829
|
+
|
|
812
830
|
locals ||= ''
|
|
813
|
-
|
|
831
|
+
|
|
814
832
|
locals.split(/(?=<\?)/).each do |x|
|
|
815
833
|
|
|
816
834
|
puts ('__data__ x: ' + x.inspect).debug if @debug
|
|
817
|
-
|
|
835
|
+
|
|
818
836
|
s2 = x.strip
|
|
819
837
|
next if s2.empty?
|
|
820
|
-
|
|
838
|
+
|
|
821
839
|
id = s2.lines.first[/id=["']([^"']+)/,1]
|
|
822
|
-
|
|
823
|
-
@data_source[id] = case s2
|
|
840
|
+
|
|
841
|
+
@data_source[id] = case s2
|
|
824
842
|
when /^<\?dynarex /
|
|
825
|
-
|
|
843
|
+
|
|
826
844
|
dx = Dynarex.new
|
|
827
845
|
dx.import s2
|
|
828
846
|
dx
|
|
829
|
-
|
|
847
|
+
|
|
830
848
|
when /^<\?mindmap(?:viz)? /
|
|
831
849
|
puts 's2: ' + s2.inspect if @debug
|
|
832
850
|
Mindmapviz.new s2
|
|
833
|
-
|
|
851
|
+
|
|
834
852
|
when /^<\?flowchart(?:viz)? /
|
|
835
|
-
|
|
836
|
-
Flowchartviz.new s2
|
|
837
|
-
|
|
853
|
+
|
|
854
|
+
Flowchartviz.new s2
|
|
855
|
+
|
|
838
856
|
when /^<\?graphvizml /
|
|
839
|
-
|
|
840
|
-
GraphVizML.new s2
|
|
841
|
-
|
|
857
|
+
|
|
858
|
+
GraphVizML.new s2
|
|
859
|
+
|
|
842
860
|
when /^<\?pxgraphviz /
|
|
843
861
|
puts 'before PxGraphViz.new'.info if @debug
|
|
844
|
-
PxGraphViz.new s2, debug: @debug
|
|
845
|
-
|
|
862
|
+
PxGraphViz.new s2, debug: @debug
|
|
863
|
+
|
|
846
864
|
when /^<\?depviz /
|
|
847
|
-
|
|
848
|
-
DepViz.new s2
|
|
849
|
-
|
|
865
|
+
|
|
866
|
+
DepViz.new s2
|
|
867
|
+
|
|
850
868
|
when /^<\?sectionx /
|
|
851
|
-
|
|
869
|
+
|
|
852
870
|
sx = SectionX.new
|
|
853
871
|
sx.import s2
|
|
854
872
|
define_singleton_method(id.to_sym) { @data_source[id] }
|
|
855
873
|
sx
|
|
856
|
-
|
|
874
|
+
|
|
857
875
|
when /^<\?kvx /
|
|
858
|
-
|
|
876
|
+
|
|
859
877
|
kvx = Kvx.new s2
|
|
860
878
|
|
|
861
879
|
define_singleton_method(id.to_sym) { @data_source[id] }
|
|
862
|
-
kvx
|
|
863
|
-
|
|
864
|
-
end
|
|
880
|
+
kvx
|
|
881
|
+
|
|
882
|
+
end
|
|
865
883
|
end
|
|
866
|
-
|
|
884
|
+
|
|
867
885
|
a[0..-2].join
|
|
868
|
-
|
|
886
|
+
|
|
869
887
|
end
|
|
870
|
-
|
|
888
|
+
|
|
871
889
|
def sidenav(s1)
|
|
872
|
-
|
|
890
|
+
|
|
873
891
|
s = s1.clone
|
|
874
892
|
if s =~ /^<sidenav/ then
|
|
875
|
-
|
|
893
|
+
|
|
876
894
|
content = s[/(<sidenav[^>]+\/>|<sidenav[^>]+>([^<]*<[^>]+>)?)/]
|
|
877
895
|
puts ('content: ' + content.inspect) if @debug
|
|
878
|
-
|
|
896
|
+
|
|
879
897
|
doc = if content then
|
|
880
|
-
|
|
898
|
+
|
|
881
899
|
s.sub!(content,'')
|
|
882
900
|
doc2 = Rexle.new(content)
|
|
883
|
-
|
|
901
|
+
|
|
884
902
|
h = doc2.root.attributes
|
|
885
903
|
target = h[:target] || 'pgview'
|
|
886
|
-
|
|
904
|
+
|
|
887
905
|
txt = if h[:src] then
|
|
888
906
|
RXFReader.read(h[:src]).first.sub(/<\?links[^>]+>\n/,'')
|
|
889
907
|
else
|
|
890
908
|
doc2.root.text
|
|
891
909
|
end
|
|
892
|
-
|
|
910
|
+
|
|
893
911
|
puts 'txt: ' + txt.inspect if @debug
|
|
894
|
-
|
|
912
|
+
|
|
895
913
|
html = HtmlCom::Tree.new(txt).to_webpage
|
|
896
|
-
puts 'html: ' + html.inspect if @debug
|
|
897
|
-
|
|
914
|
+
puts 'html: ' + html.inspect if @debug
|
|
915
|
+
|
|
898
916
|
doc2 = Rexle.new(html)
|
|
899
|
-
|
|
917
|
+
|
|
900
918
|
doc2.root.xpath('body/ul[@class="sidenav"]/li//a').each do |node|
|
|
901
919
|
node.attributes[:target] = target
|
|
902
920
|
end
|
|
903
|
-
|
|
921
|
+
|
|
904
922
|
doc2
|
|
905
|
-
|
|
923
|
+
|
|
906
924
|
else
|
|
907
925
|
s.sub!(/^<sidenav\/>/,'')
|
|
908
926
|
html = HtmlCom::Tree.new(s).to_webpage
|
|
909
927
|
Rexle.new(html)
|
|
910
928
|
end
|
|
911
|
-
|
|
912
|
-
|
|
929
|
+
|
|
930
|
+
|
|
913
931
|
html2 = Kramdown::Document.new(Martile.new(s, toc: false).to_html)\
|
|
914
932
|
.to_html
|
|
915
933
|
div = Rexle.new("<div class='main'>%s</div>" % html2)
|
|
@@ -923,7 +941,7 @@ class Martile
|
|
|
923
941
|
end
|
|
924
942
|
|
|
925
943
|
def table_to_html(s)
|
|
926
|
-
|
|
944
|
+
|
|
927
945
|
# create any tables
|
|
928
946
|
s.gsub!(/^\[[^|]+\|[^\n]+\n\|[^\]]+\]/) do |x|
|
|
929
947
|
|
|
@@ -945,50 +963,50 @@ class Martile
|
|
|
945
963
|
end
|
|
946
964
|
return s
|
|
947
965
|
end
|
|
948
|
-
|
|
966
|
+
|
|
949
967
|
def tabs(s1)
|
|
950
|
-
|
|
968
|
+
|
|
951
969
|
s = s1.clone
|
|
952
|
-
|
|
970
|
+
|
|
953
971
|
doc = Rexle.new("<root>#{s}</root>")
|
|
954
972
|
puts 'doc.root.xml: ' + doc.root.xml.inspect if @debug
|
|
955
973
|
a = doc.root.xpath('tabs').map.with_index do |e, i |
|
|
956
|
-
|
|
974
|
+
|
|
957
975
|
build = JsMenuBuilder.new()
|
|
958
976
|
build.import(e.xml)
|
|
959
|
-
|
|
977
|
+
|
|
960
978
|
if i < 1 then
|
|
961
|
-
@css << build.to_css
|
|
979
|
+
@css << build.to_css
|
|
962
980
|
@js << build.to_js
|
|
963
981
|
end
|
|
964
|
-
|
|
982
|
+
|
|
965
983
|
build.to_html
|
|
966
|
-
|
|
984
|
+
|
|
967
985
|
end
|
|
968
986
|
puts 'tabs a:' + a.inspect if @debug
|
|
969
987
|
|
|
970
988
|
# replaces the <tabs> XML with HTML
|
|
971
989
|
a.each do |html|
|
|
972
|
-
|
|
990
|
+
|
|
973
991
|
istart = s =~ /^<tabs[^>]*>/
|
|
974
992
|
iend = s =~ /<\/tabs>/
|
|
975
993
|
s.slice!(istart, (iend - istart) + '</tab>'.length + 1)
|
|
976
994
|
s.insert(istart, html)
|
|
977
|
-
|
|
995
|
+
|
|
978
996
|
end
|
|
979
|
-
|
|
997
|
+
|
|
980
998
|
return s
|
|
981
|
-
|
|
999
|
+
|
|
982
1000
|
end
|
|
983
1001
|
|
|
984
1002
|
def underline(s)
|
|
985
1003
|
|
|
986
|
-
s.gsub(/_[^_\(\)\n]+_\b/) do |x|
|
|
1004
|
+
s.gsub(/_[^_\(\)\n]+_\b/) do |x|
|
|
987
1005
|
"<span class='underline'>%s</span>" % x[1..-2]
|
|
988
1006
|
end
|
|
989
1007
|
|
|
990
1008
|
end
|
|
991
|
-
|
|
1009
|
+
|
|
992
1010
|
def highlight(s)
|
|
993
1011
|
|
|
994
1012
|
s.gsub(/\^[\w ]+\^/) {|x| "<mark>%s</mark>" % x[1..-2] }
|
|
@@ -998,41 +1016,41 @@ class Martile
|
|
|
998
1016
|
def script_out(s)
|
|
999
1017
|
s.gsub(/({!)[^}]+\}/) {|x| eval(x[/(?<={!)[^}]+/]) }
|
|
1000
1018
|
end
|
|
1001
|
-
|
|
1019
|
+
|
|
1002
1020
|
def smartlink(s)
|
|
1003
|
-
|
|
1021
|
+
|
|
1004
1022
|
s.split(/(?= \?)/).inject('') do |r, substring|
|
|
1005
1023
|
|
|
1006
1024
|
r << substring.gsub(/\B\?([^\n]+) +(https?:\/\/.[^\?]+\?)(?=\B)/) do |x|
|
|
1007
|
-
|
|
1025
|
+
|
|
1008
1026
|
content, link = $1, ($2).chop
|
|
1009
|
-
|
|
1027
|
+
|
|
1010
1028
|
if (link)[/\)$/] then
|
|
1011
1029
|
"<a href='%s'>%s</a>" % [link, content]
|
|
1012
1030
|
else
|
|
1013
1031
|
"[%s](%s)" % [content, link]
|
|
1014
1032
|
end
|
|
1015
1033
|
end
|
|
1034
|
+
|
|
1035
|
+
end
|
|
1016
1036
|
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
end
|
|
1020
|
-
|
|
1037
|
+
end
|
|
1038
|
+
|
|
1021
1039
|
def slashpre(s)
|
|
1022
1040
|
s.gsub(/^\/\/([^\/]+)^\/\//) do |x|
|
|
1023
1041
|
"<pre>#{($1).lines.map{|y| y.sub(/^ +/,'')}.join}</pre>"
|
|
1024
1042
|
end
|
|
1025
|
-
|
|
1043
|
+
|
|
1026
1044
|
end
|
|
1027
|
-
|
|
1028
|
-
# makes HTML sections out of string blocks which start with an
|
|
1045
|
+
|
|
1046
|
+
# makes HTML sections out of string blocks which start with an
|
|
1029
1047
|
# equals sign and end with an equals sign
|
|
1030
1048
|
def section(s)
|
|
1031
1049
|
|
|
1032
1050
|
a = s.lines
|
|
1033
1051
|
|
|
1034
1052
|
a2 = a.inject([[]]) do |r,x|
|
|
1035
|
-
|
|
1053
|
+
|
|
1036
1054
|
match = x.match(/^={1}(?:#)?([\w-]+)?$/)
|
|
1037
1055
|
|
|
1038
1056
|
if match then
|
|
@@ -1042,7 +1060,7 @@ class Martile
|
|
|
1042
1060
|
list = r.pop
|
|
1043
1061
|
puts ('section | list: ' + list.inspect).debug if @debug
|
|
1044
1062
|
|
|
1045
|
-
r << ["%s%s</section>" %
|
|
1063
|
+
r << ["%s%s</section>" %
|
|
1046
1064
|
[list[0], \
|
|
1047
1065
|
Martile.new(list[1..-1].join, \
|
|
1048
1066
|
ignore_domainlabel: @ignore_domainlabel, embedded: true).to_s
|
|
@@ -1053,10 +1071,10 @@ class Martile
|
|
|
1053
1071
|
else
|
|
1054
1072
|
|
|
1055
1073
|
raw_id = match.captures.first
|
|
1056
|
-
id = raw_id ? (" id='%s'" % raw_id) : ''
|
|
1074
|
+
id = raw_id ? (" id='%s'" % raw_id) : ''
|
|
1057
1075
|
r << ["<section#{id} markdown='1'>"]
|
|
1058
1076
|
end
|
|
1059
|
-
|
|
1077
|
+
|
|
1060
1078
|
else
|
|
1061
1079
|
|
|
1062
1080
|
r.last << x
|
|
@@ -1067,44 +1085,44 @@ class Martile
|
|
|
1067
1085
|
|
|
1068
1086
|
a2.join
|
|
1069
1087
|
end
|
|
1070
|
-
|
|
1088
|
+
|
|
1071
1089
|
def svgtag(s)
|
|
1072
|
-
|
|
1073
|
-
s.gsub(/\B!s\[\]\((#\w+|https?:\/\/[^\)]+)\)/) do
|
|
1074
|
-
|
|
1075
|
-
source = ($1)
|
|
1076
|
-
|
|
1090
|
+
|
|
1091
|
+
s.gsub(/\B!s\[\]\((#\w+|https?:\/\/[^\)]+)\)/) do
|
|
1092
|
+
|
|
1093
|
+
source = ($1)
|
|
1094
|
+
|
|
1077
1095
|
svg = if source =~ /^http/ then
|
|
1078
|
-
|
|
1096
|
+
|
|
1079
1097
|
RXFReader.read(source).first
|
|
1080
|
-
|
|
1098
|
+
|
|
1081
1099
|
else
|
|
1082
|
-
|
|
1100
|
+
|
|
1083
1101
|
@data_source[source[/\w+/]].to_svg
|
|
1084
|
-
|
|
1085
|
-
end
|
|
1086
|
-
|
|
1102
|
+
|
|
1103
|
+
end
|
|
1104
|
+
|
|
1087
1105
|
svg.slice!(/.*(?=<svg)/m)
|
|
1088
1106
|
svg
|
|
1089
1107
|
end
|
|
1090
1108
|
|
|
1091
1109
|
end
|
|
1092
|
-
|
|
1093
|
-
|
|
1110
|
+
|
|
1111
|
+
|
|
1094
1112
|
def videotag(s)
|
|
1095
|
-
|
|
1113
|
+
|
|
1096
1114
|
s.gsub(/\B!v\[\]\((https?:\/\/[^\)]+)\)(\{[^\}]+\})?/) do |match|
|
|
1097
1115
|
|
|
1098
1116
|
files = ($1).split
|
|
1099
1117
|
attr = ($2)
|
|
1100
1118
|
|
|
1101
1119
|
h = attr ? attr.scan(/(\w+):\s+(\w+)/).to_h : {}
|
|
1102
|
-
attributes = h.any? ? (' ' +
|
|
1120
|
+
attributes = h.any? ? (' ' +
|
|
1103
1121
|
h.map {|k,v| "%s='%s'" % [k,v]}.join(' ')) : ''
|
|
1104
1122
|
|
|
1105
1123
|
h2 = {
|
|
1106
|
-
/\.og[gv]$/ => 'ogg', /\.mp4$/ => 'mp4', /\.mov$/ => 'mov',
|
|
1107
|
-
/\.webm$/ => 'webm'
|
|
1124
|
+
/\.og[gv]$/ => 'ogg', /\.mp4$/ => 'mp4', /\.mov$/ => 'mov',
|
|
1125
|
+
/\.webm$/ => 'webm'
|
|
1108
1126
|
}
|
|
1109
1127
|
|
|
1110
1128
|
sources = files.map do |file|
|
|
@@ -1114,13 +1132,34 @@ class Martile
|
|
|
1114
1132
|
end
|
|
1115
1133
|
|
|
1116
1134
|
"<video controls='controls'%s>\n%s\n</video>" % [attributes, sources.join("\n")]
|
|
1117
|
-
end
|
|
1118
|
-
|
|
1135
|
+
end
|
|
1136
|
+
|
|
1119
1137
|
end
|
|
1120
|
-
|
|
1138
|
+
|
|
1121
1139
|
def list_item_to_hyperlink(s)
|
|
1122
|
-
|
|
1140
|
+
|
|
1123
1141
|
s.gsub(/\B(\* +)([^\n]+)\s+(https?:\/\/.*)/,'\1[\2](\3)')
|
|
1124
1142
|
|
|
1125
1143
|
end
|
|
1144
|
+
|
|
1145
|
+
private
|
|
1146
|
+
|
|
1147
|
+
def initialize_plugins(plugins)
|
|
1148
|
+
|
|
1149
|
+
@plugins = plugins.inject([]) do |r, plugin|
|
|
1150
|
+
|
|
1151
|
+
name, settings = plugin
|
|
1152
|
+
return r if settings[:active] == false and !settings[:active]
|
|
1153
|
+
|
|
1154
|
+
klass_name = 'MartilePlugin' + name.to_s
|
|
1155
|
+
|
|
1156
|
+
r << Kernel.const_get(klass_name).new(settings: settings)
|
|
1157
|
+
|
|
1158
|
+
def r.to_s()
|
|
1159
|
+
klass_name
|
|
1160
|
+
end
|
|
1161
|
+
|
|
1162
|
+
r
|
|
1163
|
+
end
|
|
1164
|
+
end
|
|
1126
1165
|
end
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: martile
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- James Robertson
|
|
@@ -10,32 +10,33 @@ bindir: bin
|
|
|
10
10
|
cert_chain:
|
|
11
11
|
- |
|
|
12
12
|
-----BEGIN CERTIFICATE-----
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
13
|
+
MIIEljCCAv6gAwIBAgIBATANBgkqhkiG9w0BAQsFADBIMRIwEAYDVQQDDAlnZW1t
|
|
14
|
+
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
|
15
|
+
8ixkARkWAmV1MB4XDTIzMDIyNDE4MzkwMloXDTI0MDIyNDE4MzkwMlowSDESMBAG
|
|
16
|
+
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
|
17
|
+
EjAQBgoJkiaJk/IsZAEZFgJldTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoC
|
|
18
|
+
ggGBAKdnCMCqodBviJiJ+iHla0eSwAoepZX+aCBNBe9PEvRsZ8ZWrx3p+UIcFr1d
|
|
19
|
+
Aksax46nVc8/xcNBXkz1hIPgcE0h0eVtr14sLjDqRO8eRWX9Hm0bjWgx9ra7sglo
|
|
20
|
+
r9YJUd/xQxKDGxYwh4BKlODKJOJMfFNmy1dOSzykVzlMQxtSL2ArS60sT3x4NGR2
|
|
21
|
+
8ZPf4D88jTNgdSJS82joZd/NLE/EJ+rqBbTJ+XU0WbN+KBqS886lIz4R7+1dp4Np
|
|
22
|
+
ASbv5z7MUxJrt18vpg7eEUyJKgSuQ8F3l9rFmNtBW6Lls9oq7D7mjaS75BQ6WWDL
|
|
23
|
+
W9bbJ1z1y3qQuvUixnHEIBlTJ6yhcmDo5oha+8LZmEOmHYpUuypWQ/JpYVCelyre
|
|
24
|
+
Arha9IC4BIR4i0fE1OYrc2wJMMohIpBB4GMWFqP5t4vFg6IjiaPK74GHjQtgzPEP
|
|
25
|
+
kzSvQuy3m4lj7zpgfLM4FEwwUJv2leLVxyv4zhubJvWxYJbBnhTEtagopeLC7ckj
|
|
26
|
+
MDYp3QIDAQABo4GKMIGHMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
|
|
27
|
+
BBRA5uvB6AJ629OfHMqHJNIrAXYjeTAmBgNVHREEHzAdgRtnZW1tYXN0ZXJAamFt
|
|
28
|
+
ZXNyb2JlcnRzb24uZXUwJgYDVR0SBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
|
|
29
|
+
c29uLmV1MA0GCSqGSIb3DQEBCwUAA4IBgQCOV68wjRVU9FGvagTo5Ejps0wBKvA6
|
|
30
|
+
IDppCnwP6388HVPm56f1Euepjjzbtfx+4YZ272n1/WFRtlqf9OuVQpYklNfDW+HY
|
|
31
|
+
TNtbMJpSW1hXCCn9XV8gijwzvoMxNAj6Yu0LxfDYBv1V9mgcEs5hlE5oxwWGGWYN
|
|
32
|
+
NYlV79pQN8GXBCauc2F4xjUxYk6M0zesyG+dhb2e0PuvtyKLtm/3Qqnw52TTUGEw
|
|
33
|
+
Rr58U2WoKLLN57V7T4FmAgKhisAvw7gF+uBDTeNkoh/RGaUILb46X0bV4esooIW8
|
|
34
|
+
svgC8LV9M+Ro2AX4R2XNV1FnQMcKm+a2jjcNZts9deug87r2EjpDWHhEyxWc2pNK
|
|
35
|
+
umCVGRPZGlB4N4m3pisZhS3wG1irYeonBsp38ozgfgo8RkRT41E632ANftiX+9v2
|
|
36
|
+
Kb0GddGEXoUej3rtoU1RzVB8qUstVA1iH2IqOi5iOBSBKDNWDvOSQ0X6HEbhCX8t
|
|
37
|
+
xfEqNtXh6NJ5yCPsubFzX2w7ssExXhtY9CQ=
|
|
37
38
|
-----END CERTIFICATE-----
|
|
38
|
-
date:
|
|
39
|
+
date: 2023-02-24 00:00:00.000000000 Z
|
|
39
40
|
dependencies:
|
|
40
41
|
- !ruby/object:Gem::Dependency
|
|
41
42
|
name: yatoc
|
|
@@ -66,7 +67,7 @@ dependencies:
|
|
|
66
67
|
version: '2.1'
|
|
67
68
|
- - ">="
|
|
68
69
|
- !ruby/object:Gem::Version
|
|
69
|
-
version: 2.1.
|
|
70
|
+
version: 2.1.2
|
|
70
71
|
type: :runtime
|
|
71
72
|
prerelease: false
|
|
72
73
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -76,7 +77,7 @@ dependencies:
|
|
|
76
77
|
version: '2.1'
|
|
77
78
|
- - ">="
|
|
78
79
|
- !ruby/object:Gem::Version
|
|
79
|
-
version: 2.1.
|
|
80
|
+
version: 2.1.2
|
|
80
81
|
- !ruby/object:Gem::Dependency
|
|
81
82
|
name: mindmapdoc
|
|
82
83
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -123,20 +124,20 @@ dependencies:
|
|
|
123
124
|
requirements:
|
|
124
125
|
- - "~>"
|
|
125
126
|
- !ruby/object:Gem::Version
|
|
126
|
-
version: '0.
|
|
127
|
+
version: '0.3'
|
|
127
128
|
- - ">="
|
|
128
129
|
- !ruby/object:Gem::Version
|
|
129
|
-
version: 0.
|
|
130
|
+
version: 0.3.4
|
|
130
131
|
type: :runtime
|
|
131
132
|
prerelease: false
|
|
132
133
|
version_requirements: !ruby/object:Gem::Requirement
|
|
133
134
|
requirements:
|
|
134
135
|
- - "~>"
|
|
135
136
|
- !ruby/object:Gem::Version
|
|
136
|
-
version: '0.
|
|
137
|
+
version: '0.3'
|
|
137
138
|
- - ">="
|
|
138
139
|
- !ruby/object:Gem::Version
|
|
139
|
-
version: 0.
|
|
140
|
+
version: 0.3.4
|
|
140
141
|
- !ruby/object:Gem::Dependency
|
|
141
142
|
name: mindwords
|
|
142
143
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -183,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
183
184
|
- !ruby/object:Gem::Version
|
|
184
185
|
version: '0'
|
|
185
186
|
requirements: []
|
|
186
|
-
rubygems_version: 3.
|
|
187
|
+
rubygems_version: 3.4.4
|
|
187
188
|
signing_key:
|
|
188
189
|
specification_version: 4
|
|
189
190
|
summary: Martile is a Markdown pre formatter which is designed to format custom Markdown
|
metadata.gz.sig
CHANGED
|
Binary file
|