hlt 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/hlt.rb +42 -26
- metadata +6 -6
- metadata.gz.sig +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c84fd69fa082a907a0df5c140bd1cc3519dd0c7
|
4
|
+
data.tar.gz: ab6a2d8d68c17930659bb7326da904ce7c738ff5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e83dcfb9bfb9fc044fb463c7ccfedfd0b6d61756ac953be3f4a3867c12b7c793ec78e2f482550ec7b0680254a79de7989a8833af4833852e647428eb09ef8230
|
7
|
+
data.tar.gz: b8b5406e5838d29f87d0f06397328ed190f1c74cbf96aafd7a34ed4858257e3afb7a0be1b19c0bcb1c3de5255bb282e4e0c12ee7d23a8186d60b653e660eb7ec
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/hlt.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# file: hlt.rb
|
4
4
|
|
5
|
-
require '
|
5
|
+
require 'martile'
|
6
6
|
require 'line-tree'
|
7
7
|
require 'rexle-builder'
|
8
8
|
|
@@ -11,16 +11,16 @@ class Hlt
|
|
11
11
|
|
12
12
|
attr_reader :to_html, :to_doc
|
13
13
|
|
14
|
-
def initialize(raw_s,
|
14
|
+
def initialize(raw_s, pretty: true, declaration: true, style: true,
|
15
|
+
debug: false)
|
15
16
|
|
16
|
-
opt = {pretty: true, declaration: true, style: true}.merge(options)
|
17
17
|
|
18
18
|
# strip out lines which are blank or only contain a comment
|
19
19
|
#s = raw_s.lines.to_a.reject!{|x| x[/(^\s+\#\s)|(^\s*$)/] }
|
20
20
|
|
21
21
|
raw_s.strip!
|
22
22
|
|
23
|
-
s2,
|
23
|
+
s2, martile = fetch_martile raw_s
|
24
24
|
s, xml_list = filter_xml(s2)
|
25
25
|
|
26
26
|
#s = raw_s
|
@@ -72,11 +72,22 @@ class Hlt
|
|
72
72
|
"\n\n" + a_code[i].lines.map{|x| ' ' * 4 + x}.join + "\n"
|
73
73
|
end
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
|
75
|
+
martile.each.with_index do |x,i|
|
76
|
+
|
77
|
+
if @debug then
|
78
|
+
puts 'i: ' + i.inspect
|
79
|
+
puts 'x: ' + x.inspect
|
80
|
+
puts 'html: ' + html.inspect
|
81
|
+
end
|
82
|
+
|
83
|
+
html.sub!(/<mar(tile|kdown):#{i.to_s}\/>/, RDiscount.new(\
|
84
|
+
Martile.new(x).to_s).to_html\
|
85
|
+
.gsub(/<(\w+)>\s*{style:\s*['"]([^'"]+)[^\}]+\}/,\
|
86
|
+
'<\1 style=\'\2\'>'))
|
78
87
|
end
|
79
88
|
|
89
|
+
puts 'html_: ' + html.inspect if @debug
|
90
|
+
|
80
91
|
doc = Rexle.new(html)
|
81
92
|
|
82
93
|
xml_list.each.with_index do |xml,i|
|
@@ -85,7 +96,9 @@ class Hlt
|
|
85
96
|
e.delete
|
86
97
|
end
|
87
98
|
|
88
|
-
if
|
99
|
+
# remove the style attributes from the document if style == false
|
100
|
+
#
|
101
|
+
if style == false then
|
89
102
|
doc.root.xpath('//.[@style]').each do |e|
|
90
103
|
unless e.attributes[:style][/^clear:/] then
|
91
104
|
e.attributes.delete :style
|
@@ -94,9 +107,9 @@ class Hlt
|
|
94
107
|
end
|
95
108
|
|
96
109
|
|
97
|
-
#html = doc.xml opt
|
98
110
|
@doc = doc
|
99
|
-
|
111
|
+
h = {declaration: declaration, pretty: pretty, style: style}
|
112
|
+
html = doc.root.xpath('*'){|x| x.xml(h)}.join("\n")
|
100
113
|
|
101
114
|
time = Time.now
|
102
115
|
timestamp = time.strftime("#{ordinalize(time.day)} %B %Y @ %H:%M")
|
@@ -162,9 +175,9 @@ class Hlt
|
|
162
175
|
|
163
176
|
end
|
164
177
|
|
165
|
-
def
|
178
|
+
def fetch_martile(raw_s)
|
166
179
|
|
167
|
-
# any lines which are in the context of
|
180
|
+
# any lines which are in the context of martile which only contain
|
168
181
|
# a new line character will have spaces inserted into them
|
169
182
|
|
170
183
|
prev_line = ''
|
@@ -176,53 +189,56 @@ class Hlt
|
|
176
189
|
|
177
190
|
index, spaces, md_spaces = 0, 0, 0
|
178
191
|
state = :default
|
179
|
-
|
192
|
+
martile = []
|
180
193
|
|
181
194
|
s2 = s.lines.map do |line|
|
182
|
-
|
183
|
-
|
195
|
+
|
196
|
+
puts 'line: ' + line.inspect if @debug
|
197
|
+
|
198
|
+
if state == :martile then
|
184
199
|
|
185
200
|
spaces = line[/^\s+/].to_s.length
|
186
201
|
|
187
202
|
if spaces > md_spaces then
|
188
|
-
|
203
|
+
martile[index] << line[(md_spaces + 2)..-1]
|
189
204
|
line = ''
|
190
205
|
else
|
191
|
-
|
206
|
+
martile[index].strip!
|
192
207
|
index += 1
|
193
208
|
state = :default
|
194
209
|
|
195
|
-
r = line[/^(\s+)
|
210
|
+
r = line[/^(\s+)martile:/,1]
|
196
211
|
|
197
212
|
if r then
|
198
213
|
|
199
|
-
state = :
|
214
|
+
state = :martile
|
200
215
|
md_spaces = r.length
|
201
216
|
|
202
|
-
line.sub!(/
|
203
|
-
|
217
|
+
line.sub!(/mar(kdown|tile):/,'\0' + index.to_s)
|
218
|
+
martile[index] = ''
|
204
219
|
end
|
205
220
|
end
|
206
221
|
|
207
222
|
else
|
208
223
|
|
209
|
-
r = line[/^(\s+)
|
224
|
+
r = line[/^(\s+)mar(kdown|tile):/,1]
|
210
225
|
|
211
226
|
if r then
|
212
227
|
|
213
|
-
state = :
|
228
|
+
state = :martile
|
214
229
|
md_spaces = r.length
|
215
|
-
line.sub!(/
|
230
|
+
line.sub!(/mar(kdown|tile):/,'\0' + index.to_s)
|
216
231
|
|
217
|
-
|
232
|
+
martile[index] = ''
|
218
233
|
end
|
219
234
|
end
|
220
235
|
|
236
|
+
puts 'line: ' + line.inspect
|
221
237
|
line
|
222
238
|
|
223
239
|
end
|
224
240
|
|
225
|
-
[s2.join,
|
241
|
+
[s2.join, martile]
|
226
242
|
end
|
227
243
|
|
228
244
|
def ordinalize(n)
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -53,25 +53,25 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.6.4
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: martile
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0.8'
|
62
62
|
- - ">="
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version:
|
64
|
+
version: 0.8.3
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
69
|
- - "~>"
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version: '
|
71
|
+
version: '0.8'
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
74
|
+
version: 0.8.3
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: rexle-builder
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
�;��UQ��G��O���@�U���!�-61���B%?RE����k��/�Lj����7���,�T�$m�]�˨��iWςN�-+����(�}a�ۅ�H�����؇���Kw�U���'�Hw�c�ufM�Y��D��xö��}�D�x�@.T{���R��RSQI��أӜ �CV�n���)[7�_��|�m�K%v�gN�p?������ڨ��+
|
2
|
+
���Ù�����;!c�ѦiV������q�M
|