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