martile 1.3.0 → 1.4.4
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.tar.gz.sig +0 -0
- data/lib/martile.rb +111 -10
- metadata +13 -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: 9c7e7a5129c34656f11828831a861f08e63fcc47767219d8657a56b484cdf7f0
|
4
|
+
data.tar.gz: 79988d64a4ae83816cd20c182c75b73549217cb5ddc060771483474faae04907
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02cbcdc557b6f9085881da520e6c3d12975937e9a9c599614b85c36f697099fab2bf752fd8b5ef57f9dfdffcd31e7d648439e833e5897bd92123cffd01c8c276
|
7
|
+
data.tar.gz: 9d1ce499b5ee42bd05e5c2741be92a274e4f90e25237439932790f469ebebc5ba9a2bddaaf9cbaf7d8551ed5b8bffbc7c1a32ce6ecd516697c0aeeb48b21a0de
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/martile.rb
CHANGED
@@ -12,8 +12,15 @@ require 'rqrcode'
|
|
12
12
|
require 'mindmapdoc'
|
13
13
|
require 'flowchartviz'
|
14
14
|
require 'jsmenubuilder'
|
15
|
+
require 'htmlcom'
|
15
16
|
|
16
17
|
|
18
|
+
# feature: 08-Aug-2020 Implemented #to_Webpage
|
19
|
+
# improvement: 23-Apr-2020 A self-closing sidenav tag is now valid
|
20
|
+
# feature: 01-Mar-2020 A src attribute can now be used in the sidenav tag
|
21
|
+
# feature: 29-Feb-2020 The sidenav tag can now contain a raw hierachical list
|
22
|
+
# feature: 22-Jan-2020 An HtmlCom::Accordion component can now be generated
|
23
|
+
# using the tag <accordion>
|
17
24
|
# feature: 16-Sep-2019 An HTML Tree component can now be generated when
|
18
25
|
# the tag <sidebar/> is used
|
19
26
|
# feature: 16-Jul-2019 An HTML Tabs component can now be created from XML
|
@@ -164,12 +171,14 @@ class Martile
|
|
164
171
|
s255 = tabs(s253)
|
165
172
|
puts ('s255 after tabs: ' + s255.inspect).debug if @debug
|
166
173
|
|
167
|
-
|
174
|
+
s257 = accordion(s255)
|
175
|
+
|
176
|
+
toc = false if s257 =~ /class=['"]sidenav['"]>/
|
168
177
|
|
169
178
|
s260 = if toc then
|
170
|
-
Yatoc.new(Kramdown::Document.new(
|
179
|
+
Yatoc.new(Kramdown::Document.new(s257).to_html, debug: debug).to_html
|
171
180
|
else
|
172
|
-
|
181
|
+
s257
|
173
182
|
end
|
174
183
|
|
175
184
|
puts ('s260: ' + s260.inspect).debug if debug
|
@@ -225,8 +234,67 @@ class Martile
|
|
225
234
|
@js.join("\n")
|
226
235
|
end
|
227
236
|
|
237
|
+
def to_webpage()
|
238
|
+
|
239
|
+
a = RexleBuilder.build do |xml|
|
240
|
+
xml.html do
|
241
|
+
xml.head do
|
242
|
+
xml.meta name: "viewport", content: \
|
243
|
+
"width=device-width, initial-scale=1"
|
244
|
+
xml.style "\nbody {font-family: Arial;}\n\n" + @css.join("\n")
|
245
|
+
end
|
246
|
+
xml.body to_html()
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
doc = Rexle.new(a)
|
251
|
+
|
252
|
+
doc.root.element('body').add \
|
253
|
+
Rexle::Element.new('script').add_text "\n" +
|
254
|
+
@js.join("\n").gsub(/^ +\/\/[^\n]+\n/,'')
|
255
|
+
|
256
|
+
"<!DOCTYPE html>\n" + doc.xml(pretty: true, declaration: false)\
|
257
|
+
.gsub(/<\/div>/,'\0' + "\n").gsub(/\n *<!--[^>]+>/,'')
|
258
|
+
|
259
|
+
end
|
260
|
+
|
228
261
|
private
|
229
262
|
|
263
|
+
def accordion(s1)
|
264
|
+
|
265
|
+
s = s1.clone
|
266
|
+
|
267
|
+
doc = Rexle.new("<root>#{s}</root>")
|
268
|
+
puts 'doc.root.xml: ' + doc.root.xml.inspect if @debug
|
269
|
+
a = doc.root.xpath('accordion').map.with_index do |e, i |
|
270
|
+
|
271
|
+
build = HtmlCom::Accordion.new(e.xml, debug: false)
|
272
|
+
|
273
|
+
if i < 1 then
|
274
|
+
@css << build.to_css
|
275
|
+
@js << build.to_js
|
276
|
+
end
|
277
|
+
|
278
|
+
build.to_html
|
279
|
+
|
280
|
+
|
281
|
+
end
|
282
|
+
puts 'accordion a:' + a.inspect if @debug
|
283
|
+
|
284
|
+
# replaces the <accordion> XML with HTML
|
285
|
+
a.each do |html|
|
286
|
+
|
287
|
+
istart = s =~ /^<accordion[^>]*>/
|
288
|
+
iend = s =~ /<\/accordion>/
|
289
|
+
s.slice!(istart, (iend - istart) + '</accordion>'.length + 1)
|
290
|
+
s.insert(istart, html)
|
291
|
+
|
292
|
+
end
|
293
|
+
|
294
|
+
return s
|
295
|
+
|
296
|
+
end
|
297
|
+
|
230
298
|
def audiotag(s)
|
231
299
|
|
232
300
|
s.gsub(/\B!a\[\]\((https?:\/\/[^\)]+)\)\B/) do |x|
|
@@ -305,7 +373,8 @@ class Martile
|
|
305
373
|
x[2..-1].sub(/(.*)[^\+]+\n\+/m) do |x2|
|
306
374
|
|
307
375
|
summary, detail = x2.split(/----+/,2)
|
308
|
-
"<details><summary>%s</summary>%s</details>" %
|
376
|
+
"<details><summary>%s</summary>%s</details>" % \
|
377
|
+
[summary, Martile.new(detail.chop).to_html]
|
309
378
|
|
310
379
|
end
|
311
380
|
|
@@ -735,13 +804,45 @@ class Martile
|
|
735
804
|
def sidenav(s1)
|
736
805
|
|
737
806
|
s = s1.clone
|
738
|
-
if s =~ /^<sidenav
|
807
|
+
if s =~ /^<sidenav/ then
|
808
|
+
|
809
|
+
content = s[/(<sidenav[^>]+\/>|<sidenav[^>]+>([^<]*<[^>]+>)?)/]
|
810
|
+
puts ('content: ' + content.inspect) if @debug
|
811
|
+
|
812
|
+
doc = if content then
|
813
|
+
|
814
|
+
s.sub!(content,'')
|
815
|
+
doc2 = Rexle.new(content)
|
816
|
+
|
817
|
+
h = doc2.root.attributes
|
818
|
+
target = h[:target] || 'pgview'
|
819
|
+
|
820
|
+
txt = if h[:src] then
|
821
|
+
RXFHelper.read(h[:src]).first.sub(/<\?links[^>]+>\n/,'')
|
822
|
+
else
|
823
|
+
doc2.root.text
|
824
|
+
end
|
825
|
+
|
826
|
+
puts 'txt: ' + txt.inspect if @debug
|
827
|
+
|
828
|
+
html = HtmlCom::Tree.new(txt).to_webpage
|
829
|
+
puts 'html: ' + html.inspect if @debug
|
830
|
+
|
831
|
+
doc2 = Rexle.new(html)
|
832
|
+
|
833
|
+
doc2.root.xpath('body/ul[@class="sidenav"]/li//a').each do |node|
|
834
|
+
node.attributes[:target] = target
|
835
|
+
end
|
836
|
+
|
837
|
+
doc2
|
838
|
+
|
839
|
+
else
|
840
|
+
s.sub!(/^<sidenav\/>/,'')
|
841
|
+
html = HtmlCom::Tree.new(s).to_webpage
|
842
|
+
Rexle.new(html)
|
843
|
+
end
|
844
|
+
|
739
845
|
|
740
|
-
s.sub!(/^<sidenav\/>/,'')
|
741
|
-
#jtb = JsTreeBuilder.new :tree, {src: tree, debug: true}
|
742
|
-
jtb = JsTreeBuilder.new(:sidebar, {src: s, hn: 2, debug: true})
|
743
|
-
html = jtb.to_webpage
|
744
|
-
doc = Rexle.new(html)
|
745
846
|
html2 = Kramdown::Document.new(Martile.new(s, toc: false).to_html)\
|
746
847
|
.to_html
|
747
848
|
div = Rexle.new("<div class='main'>%s</div>" % html2)
|
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.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
g0+rPDPUCWKVNHo7BG5zGRDcLsJO0QeIILy/AQaSAE3lQiHmC47nhsiBK0qNehWa
|
36
36
|
47XiKvz0ZVCGgrz4GEb723WC
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2020-08-08 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.0.0
|
67
64
|
- - "~>"
|
68
65
|
- !ruby/object:Gem::Version
|
69
|
-
version: '1.
|
66
|
+
version: '1.1'
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.1.2
|
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.0.0
|
77
74
|
- - "~>"
|
78
75
|
- !ruby/object:Gem::Version
|
79
|
-
version: '1.
|
76
|
+
version: '1.1'
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 1.1.2
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: mindmapdoc
|
82
82
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,27 +118,7 @@ dependencies:
|
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: 0.1.6
|
120
120
|
- !ruby/object:Gem::Dependency
|
121
|
-
name:
|
122
|
-
requirement: !ruby/object:Gem::Requirement
|
123
|
-
requirements:
|
124
|
-
- - "~>"
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
version: '0.2'
|
127
|
-
- - ">="
|
128
|
-
- !ruby/object:Gem::Version
|
129
|
-
version: 0.2.3
|
130
|
-
type: :runtime
|
131
|
-
prerelease: false
|
132
|
-
version_requirements: !ruby/object:Gem::Requirement
|
133
|
-
requirements:
|
134
|
-
- - "~>"
|
135
|
-
- !ruby/object:Gem::Version
|
136
|
-
version: '0.2'
|
137
|
-
- - ">="
|
138
|
-
- !ruby/object:Gem::Version
|
139
|
-
version: 0.2.3
|
140
|
-
- !ruby/object:Gem::Dependency
|
141
|
-
name: jstreebuilder
|
121
|
+
name: htmlcom
|
142
122
|
requirement: !ruby/object:Gem::Requirement
|
143
123
|
requirements:
|
144
124
|
- - "~>"
|
@@ -146,7 +126,7 @@ dependencies:
|
|
146
126
|
version: '0.2'
|
147
127
|
- - ">="
|
148
128
|
- !ruby/object:Gem::Version
|
149
|
-
version: 0.2.
|
129
|
+
version: 0.2.4
|
150
130
|
type: :runtime
|
151
131
|
prerelease: false
|
152
132
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -156,7 +136,7 @@ dependencies:
|
|
156
136
|
version: '0.2'
|
157
137
|
- - ">="
|
158
138
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.2.
|
139
|
+
version: 0.2.4
|
160
140
|
description:
|
161
141
|
email: james@jamesrobertson.eu
|
162
142
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|