hlt 0.6.3 → 0.6.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/lib/hlt.rb +62 -59
- data.tar.gz.sig +0 -0
- metadata +30 -30
- 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: 48ef4fe61faa5abb7df415fe54610141405c880325c0ab12e63cdf0d5d82887b
|
4
|
+
data.tar.gz: 27b5664cc8436b75db26e926c626e3da1c9727346e73e3cf9d8e6bc56c482ffe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ceb3873c51582d0b17bd87dbeaa0059ccb7659dc1c0d843690e52937c348d095fcc926363dcedebcb217e9b6b1446db9a513a2ff2af02bbde3ed17ca4dabe4a
|
7
|
+
data.tar.gz: 2a05a52b8e1b4be7108595396f5719824f9263bfbdda48c8a50cfe1a18b74610a1405e9059acc296fdd71e3e60702ce710f1b62e8e9806f453c61c5ae38fb501
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/hlt.rb
CHANGED
@@ -12,16 +12,16 @@ class Hlt
|
|
12
12
|
|
13
13
|
attr_reader :to_html, :to_doc
|
14
14
|
|
15
|
-
def initialize(raw_s, pretty: true, declaration: true, style: true,
|
16
|
-
debug: false)
|
17
|
-
|
18
|
-
|
15
|
+
def initialize(raw_s, pretty: true, declaration: true, style: true,
|
16
|
+
nocomment: true, debug: false)
|
17
|
+
|
18
|
+
|
19
19
|
@debug = debug
|
20
20
|
# strip out lines which are blank or only contain a comment
|
21
21
|
#s = raw_s.lines.to_a.reject!{|x| x[/(^\s+\#\s)|(^\s*$)/] }
|
22
|
-
|
22
|
+
|
23
23
|
raw_s.strip!
|
24
|
-
|
24
|
+
|
25
25
|
s2, martile = fetch_martile raw_s
|
26
26
|
puts 'martile: ' + martile.inspect if @debug
|
27
27
|
s, xml_list = filter_xml(s2)
|
@@ -34,16 +34,16 @@ class Hlt
|
|
34
34
|
puts ('a_code: ' + a_code.inspect).debug if @debug
|
35
35
|
s.gsub!(/\n\[[^\]]+\]\B/, " !CODE\n")
|
36
36
|
|
37
|
-
s2 = s.lines.to_a.map!{|line|
|
37
|
+
s2 = s.lines.to_a.map!{|line|
|
38
38
|
|
39
39
|
hash = "(\s*\{[^\}]+\})?"
|
40
|
-
|
40
|
+
|
41
41
|
line.prepend ' '
|
42
42
|
|
43
43
|
line.sub!(/^(\s*)\w+: /,'\0' + "\n" + '\1')
|
44
|
-
|
45
|
-
r = line.sub(/^\s*(\w+)?(?:[\.#]\w+){1,}#{hash}/) do |x|
|
46
|
-
|
44
|
+
|
45
|
+
r = line.sub(/^\s*(\w+)?(?:[\.#]\w+){1,}#{hash}/) do |x|
|
46
|
+
|
47
47
|
raw_attrs = x.slice!(/\{.*\}/)
|
48
48
|
attrs = raw_attrs[1..-2] if raw_attrs
|
49
49
|
|
@@ -51,7 +51,7 @@ class Hlt
|
|
51
51
|
tag = x[/(^\s*\w*)[#\.]/,1] || 'div'
|
52
52
|
tag += 'div' if tag.strip.empty?
|
53
53
|
|
54
|
-
x.sub(/(?:\.\w+){1,}/) do |x2|
|
54
|
+
x.sub(/(?:\.\w+){1,}/) do |x2|
|
55
55
|
a = x2[/(?:\.\w+){1,}/].split('.')
|
56
56
|
a.shift
|
57
57
|
a2 << "class: '%s'" % a.join(' ')
|
@@ -66,68 +66,71 @@ class Hlt
|
|
66
66
|
|
67
67
|
r
|
68
68
|
}
|
69
|
-
|
69
|
+
|
70
70
|
s2.unshift "root\n"
|
71
71
|
s3 = s2.join.gsub(/^(\s*)-\s+/,'\1templatecode ').\
|
72
72
|
gsub(/^(\s*)=\s+/,'\1templateoutput ')
|
73
73
|
|
74
74
|
puts ('s3: ' + s3.inspect).debug if @debug
|
75
|
-
|
75
|
+
|
76
76
|
raw_html = LineTree.new(*s3, ignore_non_element: false, debug: debug).to_xml
|
77
77
|
puts ('raw_html: ' + raw_html.inspect).debug if @debug
|
78
78
|
|
79
|
-
html = raw_html.gsub('!CODE').with_index do |x,i|
|
79
|
+
html = raw_html.gsub('!CODE').with_index do |x,i|
|
80
80
|
"\n\n" + a_code[i].lines.map{|x| ' ' * 4 + x}.join + "\n"
|
81
81
|
end
|
82
82
|
|
83
83
|
martile.each.with_index do |x,i|
|
84
|
-
|
84
|
+
|
85
85
|
if @debug then
|
86
86
|
puts ('i: ' + i.inspect).debug
|
87
87
|
puts ('x: ' + x.inspect).debug
|
88
88
|
puts ('html: ' + html.inspect).debug
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
html.sub!(/<mar(tile|kdown):#{i.to_s}\/>/, RDiscount.new(\
|
92
92
|
Martile.new(x).to_s).to_html\
|
93
93
|
.gsub(/<(\w+)>\s*{style:\s*['"]([^'"]+)[^\}]+\}/,\
|
94
94
|
'<\1 style=\'\2\'>'))
|
95
95
|
end
|
96
|
-
|
96
|
+
|
97
97
|
puts ('html_: ' + html.inspect).debug if @debug
|
98
|
-
|
98
|
+
|
99
99
|
doc = Rexle.new(html)
|
100
|
-
|
100
|
+
|
101
101
|
xml_list.each.with_index do |xml,i|
|
102
102
|
e = doc.root.element('//xml:' + i.to_s)
|
103
103
|
e.insert_before Rexle.new(xml).root
|
104
104
|
e.delete
|
105
105
|
end
|
106
|
-
|
106
|
+
|
107
107
|
# remove the style attributes from the document if style == false
|
108
108
|
#
|
109
109
|
if style == false then
|
110
|
-
doc.root.xpath('//.[@style]').each do |e|
|
110
|
+
doc.root.xpath('//.[@style]').each do |e|
|
111
111
|
unless e.attributes[:style][/^clear:/] then
|
112
|
-
e.attributes.delete :style
|
112
|
+
e.attributes.delete :style
|
113
113
|
end
|
114
114
|
end
|
115
|
-
end
|
116
|
-
|
117
|
-
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
118
|
@doc = doc
|
119
119
|
h = {declaration: declaration, pretty: pretty, style: style}
|
120
120
|
html = doc.root.xpath('*'){|x| x.xml(h)}.join("\n")
|
121
|
-
|
121
|
+
|
122
122
|
time = Time.now
|
123
123
|
timestamp = time.strftime("#{ordinalize(time.day)} %B %Y @ %H:%M")
|
124
|
-
comment = "\n <!-- Generated by Hlt-site_builder on the %s -->\n" % timestamp
|
125
124
|
|
126
|
-
|
125
|
+
unless nocomment
|
126
|
+
comment = "\n <!-- Generated by Hlt-site_builder on the %s -->\n" % timestamp
|
127
|
+
html.sub!(/(?=<\/html>)/, comment)
|
128
|
+
end
|
129
|
+
|
127
130
|
@to_html = html
|
128
131
|
|
129
132
|
end
|
130
|
-
|
133
|
+
|
131
134
|
def render(locals: {})
|
132
135
|
|
133
136
|
variables = locals.map do |key, value|
|
@@ -138,24 +141,24 @@ class Hlt
|
|
138
141
|
s << scanbuild(@doc.to_a)
|
139
142
|
|
140
143
|
a = eval variables.join("\n") + "\n" + s
|
141
|
-
|
144
|
+
|
142
145
|
Rexle.new(a).element('root/.')
|
143
146
|
|
144
147
|
end
|
145
|
-
|
148
|
+
|
146
149
|
def to_doc()
|
147
150
|
@doc
|
148
151
|
end
|
149
|
-
|
152
|
+
|
150
153
|
private
|
151
|
-
|
154
|
+
|
152
155
|
def filter_xml(s)
|
153
|
-
|
156
|
+
|
154
157
|
n = s =~ /</
|
155
158
|
return [s,[]] unless n
|
156
|
-
|
159
|
+
|
157
160
|
end_pos = s.length - (s =~ />[^>]+$/)
|
158
|
-
|
161
|
+
|
159
162
|
|
160
163
|
i = 0
|
161
164
|
xml = []
|
@@ -178,9 +181,9 @@ class Hlt
|
|
178
181
|
|
179
182
|
n = s =~ /</
|
180
183
|
end
|
181
|
-
|
184
|
+
|
182
185
|
[s, xml]
|
183
|
-
|
186
|
+
|
184
187
|
end
|
185
188
|
|
186
189
|
def fetch_martile(raw_s)
|
@@ -200,13 +203,13 @@ class Hlt
|
|
200
203
|
martile = []
|
201
204
|
|
202
205
|
s2 = s.lines.map do |line|
|
203
|
-
|
206
|
+
|
204
207
|
puts ('line: ' + line.inspect).debug if @debug
|
205
|
-
|
208
|
+
|
206
209
|
if state == :martile then
|
207
|
-
|
210
|
+
|
208
211
|
spaces = line[/^\s+/].to_s.length
|
209
|
-
|
212
|
+
|
210
213
|
if spaces > md_spaces then
|
211
214
|
martile[index] << line[(md_spaces + 2)..-1]
|
212
215
|
line = ''
|
@@ -214,27 +217,27 @@ class Hlt
|
|
214
217
|
martile[index].strip!
|
215
218
|
index += 1
|
216
219
|
state = :default
|
217
|
-
|
220
|
+
|
218
221
|
r = line[/^(\s+)martile:/,1]
|
219
222
|
|
220
|
-
if r then
|
223
|
+
if r then
|
221
224
|
|
222
|
-
state = :martile
|
223
|
-
md_spaces = r.length
|
225
|
+
state = :martile
|
226
|
+
md_spaces = r.length
|
224
227
|
|
225
228
|
line.sub!(/mar(kdown|tile):/,'\0' + index.to_s)
|
226
229
|
martile[index] = ''
|
227
230
|
end
|
228
|
-
end
|
231
|
+
end
|
229
232
|
|
230
233
|
else
|
231
234
|
|
232
235
|
r = line[/^(\s+)mar(kdown|tile):/,1]
|
233
236
|
|
234
|
-
if r then
|
237
|
+
if r then
|
235
238
|
|
236
|
-
state = :martile
|
237
|
-
md_spaces = r.length
|
239
|
+
state = :martile
|
240
|
+
md_spaces = r.length
|
238
241
|
line.sub!(/mar(kdown|tile):/,'\0' + index.to_s)
|
239
242
|
|
240
243
|
martile[index] = ''
|
@@ -248,20 +251,20 @@ class Hlt
|
|
248
251
|
|
249
252
|
[s2.join, martile]
|
250
253
|
end
|
251
|
-
|
254
|
+
|
252
255
|
def ordinalize(n)
|
253
|
-
n.to_s + ( (10...20).include?(n) ? 'th' :
|
256
|
+
n.to_s + ( (10...20).include?(n) ? 'th' :
|
254
257
|
%w{ th st nd rd th th th th th th }[n % 10] )
|
255
258
|
end
|
256
|
-
|
257
|
-
|
259
|
+
|
260
|
+
|
258
261
|
def v(x)
|
259
262
|
|
260
263
|
if x then
|
261
264
|
var = x[/^=\s+(.*)/,1]
|
262
265
|
var ? var : x.inspect
|
263
266
|
end
|
264
|
-
|
267
|
+
|
265
268
|
end
|
266
269
|
|
267
270
|
def scanbuild(x, indent=0)
|
@@ -271,9 +274,9 @@ class Hlt
|
|
271
274
|
children = remaining.shift
|
272
275
|
text = ''
|
273
276
|
|
274
|
-
|
277
|
+
|
275
278
|
if children.is_a? Array then
|
276
|
-
nested = scanbuild(children, indent+1)
|
279
|
+
nested = scanbuild(children, indent+1)
|
277
280
|
elsif children
|
278
281
|
text = children
|
279
282
|
end
|
@@ -299,7 +302,7 @@ class Hlt
|
|
299
302
|
while remaining.any? do
|
300
303
|
children = remaining.shift
|
301
304
|
if children and children.is_a? Array then
|
302
|
-
s2 << "\n" + scanbuild(children, indent+1)
|
305
|
+
s2 << "\n" + scanbuild(children, indent+1)
|
303
306
|
end
|
304
307
|
end
|
305
308
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hlt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
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
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjIwNDA2MTUyODQ3WhcN
|
15
|
+
MjMwNDA2MTUyODQ3WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2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ik5t98lFDjkhqPuPph7oYJw5T06Z7FJAdudS68fh
|
30
|
+
G4qZ0Nh1A6HcQe9yGV0lYxr3rR6Fumk5nkb7Srq9pK8j8Vpkyjy4spIuks8egG2R
|
31
|
+
fU33f4/smPNubEk6m4qWSS+eE6p88uLC0nb0CzUfxPkn9LHO3dm692YZYLrZVHD9
|
32
|
+
y6hv9n0PgEpfRrvCFhCUoEQY6v7+49KEaQcHPzJXXgOUKZZUFy7ywxWgVMGvJpr1
|
33
|
+
edBjqd6rMwug+FAgXReYkqer0BRUIkbc6p9RWavsfV07JUcbYbO+dzZ27L9GXLmV
|
34
|
+
3oMnD+s3/Xvg8QBWtznvsPA4UmwNRK7iyjUGcT8rDIl2GZx3kM2I2DAgQ6kLKOKp
|
35
|
+
siUpSxLYLAnXUjn6nTDDJSkzsajG/UPWQCTPUsvEnJK6oyzAdcb83xZ56B05bA1e
|
36
|
+
PpVYUtAiq8MU2gnelzudj7EY
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2022-04-06 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: martile
|
@@ -43,22 +43,22 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '1.
|
46
|
+
version: '1.5'
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 1.
|
49
|
+
version: 1.5.0
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '1.
|
56
|
+
version: '1.5'
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 1.
|
59
|
+
version: 1.5.0
|
60
60
|
description:
|
61
|
-
email:
|
61
|
+
email: digital.robertson@gmail.com
|
62
62
|
executables: []
|
63
63
|
extensions: []
|
64
64
|
extra_rdoc_files: []
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
|
-
rubygems_version: 3.
|
86
|
+
rubygems_version: 3.2.22
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: Intended for building HTML from a kind of Slim template.
|
metadata.gz.sig
CHANGED
Binary file
|