livetext 0.9.03 → 0.9.08
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
- data/lib/livetext.rb +36 -80
- data/lib/processor.rb +2 -1
- data/lib/standard.rb +75 -6
- data/lib/userapi.rb +6 -2
- data/plugin/bookish.rb +35 -33
- data/plugin/calibre.rb +1 -1
- data/test/data/block_comment/source.lt3 +2 -2
- data/test/data/error_inc_line_num/expected-err-line1match.txt +1 -0
- data/test/data/error_invalid_name/expected-err-line1match.txt +1 -1
- data/test/data/error_mismatched_end/expected-err-line1match.txt +1 -0
- data/test/data/error_missing_end/expected-err-line1match.txt +1 -0
- data/test/data/error_name_not_permitted/expected-error.txt +1 -1
- data/test/data/error_no_such_copy/expected-err-line1match.txt +1 -0
- data/test/data/error_no_such_inc/expected-err-line1match.txt +1 -0
- data/test/data/error_no_such_mixin/expected-err-line1match.txt +1 -0
- data/test/data/error_no_such_mixin/expected-output.txt +0 -6
- data/test/data/functions/source.lt3 +1 -1
- data/test/test.rb +6 -8
- metadata +12 -14
- data/test/data/error_inc_line_num/expected-error.txt +0 -1
- data/test/data/error_invalid_name/expected-error.txt +0 -1
- data/test/data/error_line_num/expected-error.txt +0 -1
- data/test/data/error_mismatched_end/expected-error.txt +0 -1
- data/test/data/error_missing_end/expected-error.txt +0 -1
- data/test/data/error_no_such_copy/expected-error.txt +0 -1
- data/test/data/error_no_such_inc/expected-error.txt +0 -1
- data/test/data/error_no_such_mixin/expected-error.txt +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f983f97d1e649079c9ae7b8c059c099eb3fb4b70b3df8afa026aefad4009f83e
|
|
4
|
+
data.tar.gz: 5efeb66838ae1b36dff234d548e0835f6617af739c653d9e6af8888c68b09c02
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 957fccd4430db4bd5dfcaa889829e753b180ee9a48635ba88769dd6e2645768cbff293c887d6202dcfc58474deaa56bc03ce18973f612ec138b85db636909988
|
|
7
|
+
data.tar.gz: 18c66b6647b1bd78c75b5bf4c7d0b7b5649fc2f403b1013dedec8a7e0203fa0758ef17f5fd7f731705a9428ac993e8a449b6092b551a4708d84bf13848bdfd1b
|
data/lib/livetext.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
class Livetext
|
|
2
|
-
VERSION = "0.9.
|
|
2
|
+
VERSION = "0.9.08"
|
|
3
3
|
Path = File.expand_path(File.join(File.dirname(__FILE__)))
|
|
4
4
|
end
|
|
5
5
|
|
|
@@ -31,6 +31,10 @@ class Livetext
|
|
|
31
31
|
attr_accessor :output # both bad solutions?
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
def vars
|
|
35
|
+
Livetext::Vars.dup
|
|
36
|
+
end
|
|
37
|
+
|
|
34
38
|
def self.customize(mix: [], call: [], vars: {})
|
|
35
39
|
obj = self.new
|
|
36
40
|
mix = Array(mix)
|
|
@@ -50,10 +54,6 @@ class Livetext
|
|
|
50
54
|
self
|
|
51
55
|
end
|
|
52
56
|
|
|
53
|
-
def vars
|
|
54
|
-
Livetext::Vars.dup
|
|
55
|
-
end
|
|
56
|
-
|
|
57
57
|
Space = " "
|
|
58
58
|
Sigil = "." # Can't change yet
|
|
59
59
|
|
|
@@ -73,29 +73,30 @@ class Livetext
|
|
|
73
73
|
@body = ""
|
|
74
74
|
@main = Processor.new(self, output)
|
|
75
75
|
@indentation = [0]
|
|
76
|
+
@_vars = Livetext::Vars
|
|
76
77
|
end
|
|
77
78
|
|
|
78
|
-
def _parse_colon_args(args, hash) # really belongs in livetext
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
def _parse_colon_args(args, hash) # really belongs in livetext
|
|
80
|
+
h2 = hash.dup
|
|
81
|
+
e = args.each
|
|
82
|
+
loop do
|
|
83
|
+
arg = e.next.chop.to_sym
|
|
84
|
+
raise "_parse_args: #{arg} is unknown" unless hash.keys.include?(arg)
|
|
85
|
+
h2[arg] = e.next
|
|
86
|
+
end
|
|
87
|
+
h2 = h2.reject {|k,v| v.nil? }
|
|
88
|
+
h2.each_pair {|k, v| raise "#{k} has no value" if v.empty? }
|
|
89
|
+
h2
|
|
85
90
|
end
|
|
86
|
-
h2 = h2.reject {|k,v| v.nil? }
|
|
87
|
-
h2.each_pair {|k, v| raise "#{k} has no value" if v.empty? }
|
|
88
|
-
h2
|
|
89
|
-
end
|
|
90
91
|
|
|
91
|
-
def _get_arg(name, args) # really belongs in livetext
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
end
|
|
92
|
+
def _get_arg(name, args) # really belongs in livetext
|
|
93
|
+
raise "(#{name}) Expected an array" unless args.is_a? Array
|
|
94
|
+
raise "(#{name}) Expected an arg" if args.empty?
|
|
95
|
+
raise "(#{name}) Too many args: #{args.inspect}" if args.size > 1
|
|
96
|
+
val = args[0]
|
|
97
|
+
raise "Expected an argument '#{name}'" if val.nil?
|
|
98
|
+
val
|
|
99
|
+
end
|
|
99
100
|
|
|
100
101
|
def mixin(mod)
|
|
101
102
|
@main._mixin(mod)
|
|
@@ -105,6 +106,8 @@ end
|
|
|
105
106
|
str, sym = var.to_s, var.to_sym
|
|
106
107
|
Livetext::Vars[str] = val
|
|
107
108
|
Livetext::Vars[sym] = val
|
|
109
|
+
@_vars[str] = val
|
|
110
|
+
@_vars[sym] = val
|
|
108
111
|
end
|
|
109
112
|
|
|
110
113
|
def _setfile(file)
|
|
@@ -123,6 +126,7 @@ end
|
|
|
123
126
|
when Comment
|
|
124
127
|
handle_scomment(line)
|
|
125
128
|
when Dotcmd
|
|
129
|
+
STDERR.puts "line = #{line.inspect}"
|
|
126
130
|
handle_dotcmd(line)
|
|
127
131
|
when Ddotcmd
|
|
128
132
|
indent = line.index("$") + 1
|
|
@@ -166,50 +170,13 @@ end
|
|
|
166
170
|
self.body
|
|
167
171
|
end
|
|
168
172
|
|
|
169
|
-
def xform_file(file, vars: {})
|
|
173
|
+
def xform_file(file) # , vars: {})
|
|
170
174
|
Livetext::Vars.replace(vars) unless vars.nil?
|
|
175
|
+
@_vars.replace(vars) unless vars.nil?
|
|
171
176
|
self.process_file(file)
|
|
172
177
|
self.body
|
|
173
178
|
end
|
|
174
179
|
|
|
175
|
-
# def transform(text)
|
|
176
|
-
# _setfile!("(string)")
|
|
177
|
-
# @output = ::Livetext.output
|
|
178
|
-
# enum = text.each_line
|
|
179
|
-
# front = text.match(/.*?\n/).to_a.first.chomp rescue "..."
|
|
180
|
-
# @main.source(enum, "STDIN: '#{front}...'", 0)
|
|
181
|
-
# loop do
|
|
182
|
-
# line = @main.nextline
|
|
183
|
-
# break if line.nil?
|
|
184
|
-
# process_line(line) # transform_line ???
|
|
185
|
-
# end
|
|
186
|
-
# @body
|
|
187
|
-
# end
|
|
188
|
-
|
|
189
|
-
## FIXME don't need process *and* process_text
|
|
190
|
-
|
|
191
|
-
# def process_text(text)
|
|
192
|
-
# _setfile!("(string)")
|
|
193
|
-
# text = text.split("\n") if text.is_a? String
|
|
194
|
-
# enum = text.each
|
|
195
|
-
# @backtrace = false
|
|
196
|
-
# front = text[0].chomp
|
|
197
|
-
# @main.source(enum, "(text): '#{front}...'", 0)
|
|
198
|
-
# loop do
|
|
199
|
-
# line = @main.nextline
|
|
200
|
-
# break if line.nil?
|
|
201
|
-
# process_line(line)
|
|
202
|
-
# end
|
|
203
|
-
# val = @main.finalize if @main.respond_to? :finalize
|
|
204
|
-
# val
|
|
205
|
-
# rescue => err
|
|
206
|
-
# puts "process_text: err = #{err}"
|
|
207
|
-
## puts err.backtrace.join("\n")
|
|
208
|
-
# puts @body
|
|
209
|
-
# @body = ""
|
|
210
|
-
# return @body
|
|
211
|
-
# end
|
|
212
|
-
|
|
213
180
|
## FIXME process_file[!] should call process[_text]
|
|
214
181
|
|
|
215
182
|
def process_file(fname, btrace=false)
|
|
@@ -218,6 +185,7 @@ end
|
|
|
218
185
|
enum = text.each
|
|
219
186
|
@backtrace = btrace
|
|
220
187
|
@main.source(enum, fname, 0)
|
|
188
|
+
line = nil
|
|
221
189
|
loop do
|
|
222
190
|
line = @main.nextline
|
|
223
191
|
break if line.nil?
|
|
@@ -226,26 +194,12 @@ end
|
|
|
226
194
|
val = @main.finalize if @main.respond_to? :finalize
|
|
227
195
|
@body
|
|
228
196
|
rescue => err
|
|
197
|
+
STDERR.puts "[process_file] fname = #{fname.inspect}\n line = #{line.inspect}"
|
|
229
198
|
STDERR.puts "ERROR #{err} in process_file"
|
|
230
199
|
err.backtrace.each {|x| STDERR.puts " " + x }
|
|
231
200
|
@body = ""
|
|
232
201
|
end
|
|
233
202
|
|
|
234
|
-
# def process_file!(fname, backtrace=false)
|
|
235
|
-
# _setfile(fname)
|
|
236
|
-
# raise "No such file '#{fname}' to process" unless File.exist?(fname)
|
|
237
|
-
# @main.output = StringIO.new
|
|
238
|
-
# enum = File.readlines(fname).each
|
|
239
|
-
# @backtrace = backtrace
|
|
240
|
-
# @main.source(enum, fname, 0)
|
|
241
|
-
# loop do
|
|
242
|
-
# line = @main.nextline
|
|
243
|
-
# break if line.nil?
|
|
244
|
-
# process_line(line)
|
|
245
|
-
# end
|
|
246
|
-
# @main.finalize if @main.respond_to? :finalize
|
|
247
|
-
# end
|
|
248
|
-
|
|
249
203
|
def handle_scomment(line)
|
|
250
204
|
end
|
|
251
205
|
|
|
@@ -265,7 +219,7 @@ end
|
|
|
265
219
|
|
|
266
220
|
def handle_dotcmd(line, indent = 0)
|
|
267
221
|
indent = @indentation.last # top of stack
|
|
268
|
-
line = line.sub(/# .*$/, "")
|
|
222
|
+
line = line.sub(/# .*$/, "")
|
|
269
223
|
name = _get_name(line).to_sym
|
|
270
224
|
result = nil
|
|
271
225
|
if @main.respond_to?(name)
|
|
@@ -276,8 +230,10 @@ line = line.sub(/# .*$/, "")
|
|
|
276
230
|
end
|
|
277
231
|
result
|
|
278
232
|
rescue => err
|
|
233
|
+
STDERR.puts "Error was: #{err.inspect} (calling @main._error!)"
|
|
234
|
+
STDERR.puts err.backtrace
|
|
279
235
|
@main._error!(err)
|
|
280
|
-
puts @body
|
|
236
|
+
# puts @body
|
|
281
237
|
@body = ""
|
|
282
238
|
return @body
|
|
283
239
|
end
|
data/lib/processor.rb
CHANGED
|
@@ -35,7 +35,8 @@ class Livetext
|
|
|
35
35
|
def _error!(err, abort=true, trace=false)
|
|
36
36
|
where = @sources.last || @save_location
|
|
37
37
|
puts @parent.body
|
|
38
|
-
STDERR.puts "Error: #{err}
|
|
38
|
+
STDERR.puts "[lib/processor] Error: #{err}" # (at #{where[1]} line #{where[2]})"
|
|
39
|
+
raise "lib/processor error!"
|
|
39
40
|
STDERR.puts err.backtrace if err.respond_to?(:backtrace) # && trace
|
|
40
41
|
exit if abort
|
|
41
42
|
end
|
data/lib/standard.rb
CHANGED
|
@@ -43,12 +43,42 @@ module Livetext::Standard
|
|
|
43
43
|
_error! "Illegal name '#{funcname}'" if _disallowed?(funcname)
|
|
44
44
|
func_def = <<-EOS
|
|
45
45
|
def #{funcname}(param)
|
|
46
|
-
#{
|
|
46
|
+
#{_body.to_a.join("\n")}
|
|
47
47
|
end
|
|
48
48
|
EOS
|
|
49
|
+
_optional_blank_line
|
|
50
|
+
|
|
49
51
|
Livetext::Functions.class_eval func_def
|
|
50
52
|
end
|
|
51
53
|
|
|
54
|
+
def h1; _out "<h1>#{@_data}</h1>"; end
|
|
55
|
+
def h2; _out "<h2>#{@_data}</h2>"; end
|
|
56
|
+
def h3; _out "<h3>#{@_data}</h3>"; end
|
|
57
|
+
def h4; _out "<h4>#{@_data}</h4>"; end
|
|
58
|
+
def h5; _out "<h5>#{@_data}</h5>"; end
|
|
59
|
+
def h6; _out "<h6>#{@_data}</h6>"; end
|
|
60
|
+
|
|
61
|
+
def list
|
|
62
|
+
_out "<ul>"
|
|
63
|
+
_body {|line| _out "<li>#{line}</li>" }
|
|
64
|
+
_out "</ul>"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def list!
|
|
68
|
+
_out "<ul>"
|
|
69
|
+
lines = _body.each # {|line| _out "<li>#{line}</li>" }
|
|
70
|
+
loop do
|
|
71
|
+
line = lines.next
|
|
72
|
+
line = _format(line)
|
|
73
|
+
if line[0] == " "
|
|
74
|
+
_out line
|
|
75
|
+
else
|
|
76
|
+
_out "<li>#{line}</li>"
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
_out "</ul>"
|
|
80
|
+
end
|
|
81
|
+
|
|
52
82
|
def shell!
|
|
53
83
|
cmd = @_data.chomp
|
|
54
84
|
system(cmd)
|
|
@@ -195,6 +225,26 @@ EOS
|
|
|
195
225
|
end
|
|
196
226
|
end
|
|
197
227
|
|
|
228
|
+
def variables! # cwd, not FileDir - weird, fix later
|
|
229
|
+
prefix = _args[0]
|
|
230
|
+
file = _args[1]
|
|
231
|
+
prefix = nil if prefix == "-" # FIXME dumb hack
|
|
232
|
+
if file
|
|
233
|
+
here = "" # different for ! version
|
|
234
|
+
lines = File.readlines(here + file)
|
|
235
|
+
else
|
|
236
|
+
lines = _body
|
|
237
|
+
end
|
|
238
|
+
lines.map! {|x| x.sub(/# .*/, "").strip } # strip comments
|
|
239
|
+
lines.each do |line|
|
|
240
|
+
next if line.strip.empty?
|
|
241
|
+
var, val = line.split(" ", 2)
|
|
242
|
+
val = FormatLine.var_func_parse(val)
|
|
243
|
+
var = prefix + "." + var if prefix
|
|
244
|
+
@parent._setvar(var, val)
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
|
|
198
248
|
def variables
|
|
199
249
|
prefix = _args[0]
|
|
200
250
|
file = _args[1]
|
|
@@ -219,13 +269,21 @@ EOS
|
|
|
219
269
|
eval _data.chomp
|
|
220
270
|
end
|
|
221
271
|
|
|
272
|
+
def heredoc! # adds <br>...
|
|
273
|
+
_heredoc(true)
|
|
274
|
+
end
|
|
275
|
+
|
|
222
276
|
def heredoc
|
|
277
|
+
_heredoc
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
def _heredoc(bang=false)
|
|
223
281
|
var = @_args[0]
|
|
224
282
|
str = _body.join("\n")
|
|
225
283
|
s2 = ""
|
|
226
284
|
str.each_line do |s|
|
|
227
285
|
str = FormatLine.var_func_parse(s.chomp)
|
|
228
|
-
s2 << str
|
|
286
|
+
s2 << str + "<br>"
|
|
229
287
|
end
|
|
230
288
|
indent = @parent.indentation.last
|
|
231
289
|
indented = " " * indent
|
|
@@ -250,8 +308,10 @@ EOS
|
|
|
250
308
|
break if value
|
|
251
309
|
end
|
|
252
310
|
end
|
|
311
|
+
STDERR.puts "Cannot find #{file.inspect} from #{Dir.pwd}" unless value
|
|
253
312
|
return value
|
|
254
313
|
rescue
|
|
314
|
+
STDERR.puts "Can't find #{file.inspect} from #{Dir.pwd}"
|
|
255
315
|
return nil
|
|
256
316
|
end
|
|
257
317
|
|
|
@@ -259,21 +319,25 @@ EOS
|
|
|
259
319
|
# like include, but search upward as needed
|
|
260
320
|
file = @_args.first
|
|
261
321
|
file = _seek(file)
|
|
262
|
-
_error!(
|
|
322
|
+
_error!("No such include file #{file.inspect}") unless file
|
|
263
323
|
@parent.process_file(file)
|
|
264
324
|
_optional_blank_line
|
|
325
|
+
rescue => err
|
|
326
|
+
STDERR.puts ".seek error - #{err}"
|
|
327
|
+
STDERR.puts err.inspect
|
|
328
|
+
return nil
|
|
265
329
|
end
|
|
266
330
|
|
|
267
331
|
def in_out # FIXME dumb name!
|
|
268
332
|
file, dest = *@_args
|
|
269
|
-
_check_existence(file, "No such include file
|
|
333
|
+
_check_existence(file, "No such include file #{file.inspect}")
|
|
270
334
|
@parent.process_file(file, dest)
|
|
271
335
|
_optional_blank_line
|
|
272
336
|
end
|
|
273
337
|
|
|
274
338
|
def _include
|
|
275
339
|
file = @_args.first
|
|
276
|
-
_check_existence(file, "No such include file
|
|
340
|
+
_check_existence(file, "No such include file #{file.inspect}")
|
|
277
341
|
@parent.process_file(file)
|
|
278
342
|
_optional_blank_line
|
|
279
343
|
end
|
|
@@ -320,7 +384,7 @@ EOS
|
|
|
320
384
|
Dir.chdir("..") { mixin }
|
|
321
385
|
return
|
|
322
386
|
else
|
|
323
|
-
STDERR.puts "No such mixin '#{name}"
|
|
387
|
+
STDERR.puts "No such mixin '#{name}'"
|
|
324
388
|
puts @body
|
|
325
389
|
exit!
|
|
326
390
|
end
|
|
@@ -472,6 +536,11 @@ EOS
|
|
|
472
536
|
_out "</table></center>"
|
|
473
537
|
end
|
|
474
538
|
|
|
539
|
+
def image
|
|
540
|
+
name = @_args[0]
|
|
541
|
+
_out "<img src='#{name}'></img>"
|
|
542
|
+
end
|
|
543
|
+
|
|
475
544
|
def br
|
|
476
545
|
n = _args.first || "1"
|
|
477
546
|
out = ""
|
data/lib/userapi.rb
CHANGED
|
@@ -19,7 +19,7 @@ module Livetext::UserAPI
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def _args
|
|
22
|
-
@_args = @_data.chomp.split
|
|
22
|
+
@_args = _format(@_data).chomp.split
|
|
23
23
|
if block_given?
|
|
24
24
|
@_args.each {|arg| yield arg }
|
|
25
25
|
else
|
|
@@ -27,6 +27,10 @@ module Livetext::UserAPI
|
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
def _vars
|
|
31
|
+
@_vars.dup
|
|
32
|
+
end
|
|
33
|
+
|
|
30
34
|
def _optional_blank_line
|
|
31
35
|
peek = peek_nextline
|
|
32
36
|
return if peek.nil?
|
|
@@ -90,7 +94,7 @@ module Livetext::UserAPI
|
|
|
90
94
|
lines
|
|
91
95
|
end
|
|
92
96
|
rescue => err
|
|
93
|
-
str
|
|
97
|
+
str = err.inspect + "\n"
|
|
94
98
|
str << err.backtrace.map {|x| " " + x }.join("\n")
|
|
95
99
|
_error!(str)
|
|
96
100
|
end
|
data/plugin/bookish.rb
CHANGED
|
@@ -12,29 +12,9 @@ def credit
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def h1; _out "<h1>#{@_data}</h1>"; end
|
|
15
|
+
def h2; _out "<h2>#{@_data}</h2>"; end
|
|
15
16
|
def h3; _out "<h3>#{@_data}</h3>"; end
|
|
16
17
|
|
|
17
|
-
def list
|
|
18
|
-
_out "<ul>"
|
|
19
|
-
_body {|line| _out "<li>#{line}</li>" }
|
|
20
|
-
_out "</ul>"
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def list!
|
|
24
|
-
_out "<ul>"
|
|
25
|
-
lines = _body.each # {|line| _out "<li>#{line}</li>" }
|
|
26
|
-
loop do
|
|
27
|
-
line = lines.next
|
|
28
|
-
line = _format(line)
|
|
29
|
-
if line[0] == " "
|
|
30
|
-
_out line
|
|
31
|
-
else
|
|
32
|
-
_out "<li>#{line}</li>"
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
_out "</ul>"
|
|
36
|
-
end
|
|
37
|
-
|
|
38
18
|
def alpha_columns
|
|
39
19
|
n = @_args.first.to_i # FIXME: what if missing?
|
|
40
20
|
words = []
|
|
@@ -42,7 +22,7 @@ def alpha_columns
|
|
|
42
22
|
words << line.chomp
|
|
43
23
|
end
|
|
44
24
|
words.sort!
|
|
45
|
-
_out "<table cellpadding=
|
|
25
|
+
_out "<table cellpadding=2>"
|
|
46
26
|
words.each_slice(n) do |w|
|
|
47
27
|
items = w.map {|x| "<tt>#{x}</tt>" }
|
|
48
28
|
_out "<tr><td width=5% valign=top></td><td>" + items.join("</td><td>") + "</td></tr>"
|
|
@@ -92,7 +72,7 @@ def chapter
|
|
|
92
72
|
next_output
|
|
93
73
|
_out "<title>#{@chapter}. #{title}</title>"
|
|
94
74
|
_out <<-HTML
|
|
95
|
-
<h2>Chapter #{@chapter}</
|
|
75
|
+
<h2>Chapter #{@chapter}</h2>
|
|
96
76
|
<h1>#{title}</h1>
|
|
97
77
|
|
|
98
78
|
HTML
|
|
@@ -108,7 +88,7 @@ def chapterN
|
|
|
108
88
|
next_output
|
|
109
89
|
_out "<title>#{@chapter}. #{title}</title>"
|
|
110
90
|
_out <<-HTML
|
|
111
|
-
<h2>Chapter #{@chapter}</
|
|
91
|
+
<h2>Chapter #{@chapter}</h2>
|
|
112
92
|
<h1>#{title}</h1>
|
|
113
93
|
|
|
114
94
|
HTML
|
|
@@ -118,11 +98,11 @@ def sec
|
|
|
118
98
|
@sec += 1
|
|
119
99
|
@sec2 = 0
|
|
120
100
|
@section = "#@chapter.#@sec"
|
|
121
|
-
|
|
122
|
-
@toc << "#{_nbsp(3)}<b>#@section</b>
|
|
101
|
+
title = @_data.dup
|
|
102
|
+
@toc << "#{_nbsp(3)}<b>#@section</b> #{title}<br>"
|
|
123
103
|
@_data = _slug(@_data)
|
|
124
104
|
next_output
|
|
125
|
-
_out "<h3>#@section #{
|
|
105
|
+
_out "<h3>#@section #{title}</h3>\n"
|
|
126
106
|
rescue => err
|
|
127
107
|
STDERR.puts "#{err}\n#{err.backtrace}"
|
|
128
108
|
exit
|
|
@@ -131,11 +111,33 @@ end
|
|
|
131
111
|
def subsec
|
|
132
112
|
@sec2 += 1
|
|
133
113
|
@subsec = "#@chapter.#@sec.#@sec2"
|
|
134
|
-
|
|
135
|
-
#
|
|
114
|
+
title = @_data.dup
|
|
115
|
+
@toc << "#{_nbsp(6)}<b>#@subsec</b> #{title}<br>"
|
|
136
116
|
@_data = _slug(@_data)
|
|
137
117
|
next_output
|
|
138
|
-
_out "<h3>#@subsec #{
|
|
118
|
+
_out "<h3>#@subsec #{title}</h3>\n"
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def definition_table
|
|
122
|
+
title = @_data
|
|
123
|
+
wide = "95"
|
|
124
|
+
delim = " :: "
|
|
125
|
+
_out "<br><center><table width=#{wide}% cellpadding=5>"
|
|
126
|
+
lines = _body(true)
|
|
127
|
+
lines.map! {|line| _format(line) }
|
|
128
|
+
|
|
129
|
+
lines.each do |line|
|
|
130
|
+
cells = line.split(delim)
|
|
131
|
+
_out "<tr>"
|
|
132
|
+
cells.each.with_index do |cell, i|
|
|
133
|
+
width = (i == 0) ? "width=15%" : ""
|
|
134
|
+
_out " <td #{width} valign=top>#{cell}</td>"
|
|
135
|
+
end
|
|
136
|
+
_out "</tr>"
|
|
137
|
+
end
|
|
138
|
+
_out "</table></center><br><br>"
|
|
139
|
+
|
|
140
|
+
_optional_blank_line
|
|
139
141
|
end
|
|
140
142
|
|
|
141
143
|
def table2
|
|
@@ -143,7 +145,7 @@ def table2
|
|
|
143
145
|
wide = "90"
|
|
144
146
|
extra = _args[2]
|
|
145
147
|
delim = " :: "
|
|
146
|
-
_out "<br><center><table
|
|
148
|
+
_out "<br><center><table width=#{wide}% cellpadding=5>"
|
|
147
149
|
lines = _body(true)
|
|
148
150
|
lines.map! {|line| _format(line) }
|
|
149
151
|
|
|
@@ -196,7 +198,7 @@ def table
|
|
|
196
198
|
@table_num += 1
|
|
197
199
|
title = @_data
|
|
198
200
|
delim = " :: "
|
|
199
|
-
_out "<br><center><table
|
|
201
|
+
_out "<br><center><table width=90% cellpadding=5>"
|
|
200
202
|
lines = _body(true)
|
|
201
203
|
maxw = nil
|
|
202
204
|
lines.each do |line|
|
|
@@ -204,7 +206,7 @@ def table
|
|
|
204
206
|
cells = line.split(delim)
|
|
205
207
|
wide = cells.map {|x| x.length }
|
|
206
208
|
maxw = [0] * cells.size
|
|
207
|
-
maxw = maxw.map.with_index {|x, i| [x, wide[i]].max }
|
|
209
|
+
maxw = maxw.map.with_index {|x, i| [x, wide[i]+2].max }
|
|
208
210
|
end
|
|
209
211
|
|
|
210
212
|
sum = maxw.inject(0, :+)
|
data/plugin/calibre.rb
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Error: Name 'foobar' is unknown
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Error: Illegal name 'to_s'
|
|
1
|
+
Error: Illegal name 'to_s'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Error: Mismatched 'end'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Error: #<RuntimeError: Expected .end, found end of file>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Error: Name 'class' is not permitted
|
|
1
|
+
Error: Name 'class' is not permitted
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Error: No such file 'nosuchfile.txt' to copy
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Error: No such include file 'nosuchinc.lt3'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
No such mixin 'nosuchthing'
|
data/test/test.rb
CHANGED
|
@@ -18,7 +18,7 @@ class TestingLivetext < MiniTest::Test
|
|
|
18
18
|
|
|
19
19
|
TestLines = []
|
|
20
20
|
|
|
21
|
-
Dir.chdir `livetext --path`.chomp if ARGV.first == "cmdline"
|
|
21
|
+
Dir.chdir `livetext --path`.chomp.chomp if ARGV.first == "cmdline"
|
|
22
22
|
|
|
23
23
|
Dir.chdir(Data)
|
|
24
24
|
|
|
@@ -31,7 +31,7 @@ class TestingLivetext < MiniTest::Test
|
|
|
31
31
|
break if f.eof?
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
if File.size("subset.txt")
|
|
34
|
+
if File.size("subset.txt") == 0
|
|
35
35
|
puts "Defining via TestLines"
|
|
36
36
|
TestLines.each.with_index do |item, i|
|
|
37
37
|
msg, src, exp, blank = *item
|
|
@@ -51,8 +51,6 @@ class TestingLivetext < MiniTest::Test
|
|
|
51
51
|
selected = File.readlines("subset.txt").map(&:chomp)
|
|
52
52
|
Subset = selected.empty? ? TestDirs : selected
|
|
53
53
|
|
|
54
|
-
# puts "Subset = #{Subset.inspect}"
|
|
55
|
-
|
|
56
54
|
Subset.each do |tdir|
|
|
57
55
|
define_method("test_#{tdir}") do
|
|
58
56
|
external_files(tdir)
|
|
@@ -60,11 +58,11 @@ class TestingLivetext < MiniTest::Test
|
|
|
60
58
|
end
|
|
61
59
|
|
|
62
60
|
def green(str)
|
|
63
|
-
"[32m" + str + "[0m"
|
|
61
|
+
"[32m" + str.to_s + "[0m"
|
|
64
62
|
end
|
|
65
63
|
|
|
66
64
|
def red(str)
|
|
67
|
-
"[31m" + str + "[0m"
|
|
65
|
+
"[31m" + str.to_s + "[0m"
|
|
68
66
|
end
|
|
69
67
|
|
|
70
68
|
def external_files(base)
|
|
@@ -85,14 +83,14 @@ class TestingLivetext < MiniTest::Test
|
|
|
85
83
|
|
|
86
84
|
if File.exist?(expout_regex)
|
|
87
85
|
rx_out = /#{Regexp.escape(File.read(expout_regex).chomp)}/
|
|
88
|
-
expected = "(match test)"
|
|
86
|
+
expected = rx_out # "(match test)"
|
|
89
87
|
else
|
|
90
88
|
expected = File.read(exp)
|
|
91
89
|
end
|
|
92
90
|
|
|
93
91
|
if File.exist?(experr_regex)
|
|
94
92
|
rx_err = /#{Regexp.escape(File.read(experr_regex).chomp)}/
|
|
95
|
-
errexp = "(match test)"
|
|
93
|
+
errexp = rx_err # "(match test)"
|
|
96
94
|
else
|
|
97
95
|
errexp = File.read(erx)
|
|
98
96
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: livetext
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.08
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hal Fulton
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-11-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A smart text processor extensible in Ruby
|
|
14
14
|
email: rubyhacker@gmail.com
|
|
@@ -53,34 +53,32 @@ files:
|
|
|
53
53
|
- test/data/def_method/expected-error.txt
|
|
54
54
|
- test/data/def_method/expected-output.txt
|
|
55
55
|
- test/data/def_method/source.lt3
|
|
56
|
-
- test/data/error_inc_line_num/expected-
|
|
56
|
+
- test/data/error_inc_line_num/expected-err-line1match.txt
|
|
57
57
|
- test/data/error_inc_line_num/expected-output.txt
|
|
58
58
|
- test/data/error_inc_line_num/file2.lt3
|
|
59
59
|
- test/data/error_inc_line_num/source.lt3
|
|
60
60
|
- test/data/error_invalid_name/expected-err-line1match.txt
|
|
61
|
-
- test/data/error_invalid_name/expected-error.txt
|
|
62
61
|
- test/data/error_invalid_name/expected-output.txt
|
|
63
62
|
- test/data/error_invalid_name/source.lt3
|
|
64
63
|
- test/data/error_line_num/expected-err-line1match.txt
|
|
65
|
-
- test/data/error_line_num/expected-error.txt
|
|
66
64
|
- test/data/error_line_num/expected-output.txt
|
|
67
65
|
- test/data/error_line_num/source.lt3
|
|
68
|
-
- test/data/error_mismatched_end/expected-
|
|
66
|
+
- test/data/error_mismatched_end/expected-err-line1match.txt
|
|
69
67
|
- test/data/error_mismatched_end/expected-output.txt
|
|
70
68
|
- test/data/error_mismatched_end/source.lt3
|
|
71
|
-
- test/data/error_missing_end/expected-
|
|
69
|
+
- test/data/error_missing_end/expected-err-line1match.txt
|
|
72
70
|
- test/data/error_missing_end/expected-output.txt
|
|
73
71
|
- test/data/error_missing_end/source.lt3
|
|
74
72
|
- test/data/error_name_not_permitted/expected-error.txt
|
|
75
73
|
- test/data/error_name_not_permitted/expected-output.txt
|
|
76
74
|
- test/data/error_name_not_permitted/source.lt3
|
|
77
|
-
- test/data/error_no_such_copy/expected-
|
|
75
|
+
- test/data/error_no_such_copy/expected-err-line1match.txt
|
|
78
76
|
- test/data/error_no_such_copy/expected-output.txt
|
|
79
77
|
- test/data/error_no_such_copy/source.lt3
|
|
80
|
-
- test/data/error_no_such_inc/expected-
|
|
78
|
+
- test/data/error_no_such_inc/expected-err-line1match.txt
|
|
81
79
|
- test/data/error_no_such_inc/expected-output.txt
|
|
82
80
|
- test/data/error_no_such_inc/source.lt3
|
|
83
|
-
- test/data/error_no_such_mixin/expected-
|
|
81
|
+
- test/data/error_no_such_mixin/expected-err-line1match.txt
|
|
84
82
|
- test/data/error_no_such_mixin/expected-output.txt
|
|
85
83
|
- test/data/error_no_such_mixin/source.lt3
|
|
86
84
|
- test/data/example_alpha/expected-error.txt
|
|
@@ -139,7 +137,7 @@ homepage: https://github.com/Hal9000/livetext
|
|
|
139
137
|
licenses:
|
|
140
138
|
- Ruby
|
|
141
139
|
metadata: {}
|
|
142
|
-
post_install_message:
|
|
140
|
+
post_install_message:
|
|
143
141
|
rdoc_options: []
|
|
144
142
|
require_paths:
|
|
145
143
|
- lib
|
|
@@ -154,8 +152,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
154
152
|
- !ruby/object:Gem::Version
|
|
155
153
|
version: '0'
|
|
156
154
|
requirements: []
|
|
157
|
-
rubygems_version: 3.
|
|
158
|
-
signing_key:
|
|
155
|
+
rubygems_version: 3.1.2
|
|
156
|
+
signing_key:
|
|
159
157
|
specification_version: 4
|
|
160
158
|
summary: A smart processor for text
|
|
161
159
|
test_files: []
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Error: Name 'foobar' is unknown (at file2.lt3 line 5)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Error: Illegal name 'to_s' (at source.lt3 line 5)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Error: Name 'foobar' is unknown (at source.lt3 line 4)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Error: Mismatched 'end' (at source.lt3 line 6)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Error: Expecting .end, found end of file (at source.lt3 line 6)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Error: No such file 'nosuchfile.txt' to copy (at source.lt3 line 5)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Error: No such include file 'nosuchinc.lt3' (at source.lt3 line 5)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Error: No such mixin 'nosuchthing' (at source.lt3 line 6)
|