livetext 0.9.02 → 0.9.07
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/livetext.rb +31 -80
- data/lib/processor.rb +1 -1
- data/lib/standard.rb +46 -13
- data/lib/userapi.rb +9 -3
- data/plugin/bookish.rb +45 -39
- data/plugin/calibre.rb +1 -1
- data/test/data/basic_formatting/expected-output.txt +1 -1
- data/test/data/error_invalid_name/expected-err-line1match.txt +1 -0
- data/test/data/error_line_num/expected-err-line1match.txt +1 -0
- data/test/data/example_alpha2/source.lt3 +1 -1
- data/test/data/lines.txt +2 -2
- data/test/test.rb +35 -3
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb9d448129a6a48466dee41a2775829697a98a99126b934a2a2836c83a078363
|
4
|
+
data.tar.gz: 42ff4b5f39db113b4e4abf9c4c2d57d1210cf4fe4bf93e582c2f9725f93ef53c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14d559a7f7f1856300d47c2a6e0d1ba820d5b1bf45c40629547187670442f520a8b111aa2136b638ab4ae4c0a02ed42bcf2e3f040e1f1564685041108822a81c
|
7
|
+
data.tar.gz: 9f74fe5f520c98e562159f7616ab8bb75582ee580fa0192c2841dfc893a34e2ef199bff80248bd18dbb25531f297ff3176f3fc138ccbe9dc312e56091999bc75
|
data/lib/livetext.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Livetext
|
2
|
-
VERSION = "0.9.
|
2
|
+
VERSION = "0.9.07"
|
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)
|
@@ -166,50 +169,13 @@ end
|
|
166
169
|
self.body
|
167
170
|
end
|
168
171
|
|
169
|
-
def xform_file(file, vars: {})
|
172
|
+
def xform_file(file) # , vars: {})
|
170
173
|
Livetext::Vars.replace(vars) unless vars.nil?
|
174
|
+
@_vars.replace(vars) unless vars.nil?
|
171
175
|
self.process_file(file)
|
172
176
|
self.body
|
173
177
|
end
|
174
178
|
|
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
179
|
## FIXME process_file[!] should call process[_text]
|
214
180
|
|
215
181
|
def process_file(fname, btrace=false)
|
@@ -231,21 +197,6 @@ end
|
|
231
197
|
@body = ""
|
232
198
|
end
|
233
199
|
|
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
200
|
def handle_scomment(line)
|
250
201
|
end
|
251
202
|
|
@@ -265,13 +216,13 @@ end
|
|
265
216
|
|
266
217
|
def handle_dotcmd(line, indent = 0)
|
267
218
|
indent = @indentation.last # top of stack
|
268
|
-
line = line.sub(/# .*$/, "")
|
219
|
+
line = line.sub(/# .*$/, "")
|
269
220
|
name = _get_name(line).to_sym
|
270
221
|
result = nil
|
271
222
|
if @main.respond_to?(name)
|
272
223
|
result = @main.send(name)
|
273
224
|
else
|
274
|
-
@main._error! "Name '#{name}' is unknown
|
225
|
+
@main._error! "Name '#{name}' is unknown"
|
275
226
|
return
|
276
227
|
end
|
277
228
|
result
|
data/lib/processor.rb
CHANGED
@@ -35,7 +35,7 @@ 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} (at #{where[1]} line #{where[2]})"
|
38
|
+
STDERR.puts "Error: #{err} " # (at #{where[1]} line #{where[2]})"
|
39
39
|
STDERR.puts err.backtrace if err.respond_to?(:backtrace) # && trace
|
40
40
|
exit if abort
|
41
41
|
end
|
data/lib/standard.rb
CHANGED
@@ -9,7 +9,7 @@ module Livetext::Standard
|
|
9
9
|
attr_reader :_data
|
10
10
|
|
11
11
|
def data=(val)
|
12
|
-
@_data = val
|
12
|
+
@_data = val.chomp
|
13
13
|
@_args = val.split rescue []
|
14
14
|
@_mixins = []
|
15
15
|
end
|
@@ -33,7 +33,7 @@ module Livetext::Standard
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def shell
|
36
|
-
cmd = @_data
|
36
|
+
cmd = @_data.chomp
|
37
37
|
# _errout("Running: #{cmd}")
|
38
38
|
system(cmd)
|
39
39
|
end
|
@@ -49,23 +49,51 @@ EOS
|
|
49
49
|
Livetext::Functions.class_eval func_def
|
50
50
|
end
|
51
51
|
|
52
|
+
def h1; _out "<h1>#{@_data}</h1>"; end
|
53
|
+
def h2; _out "<h2>#{@_data}</h2>"; end
|
54
|
+
def h3; _out "<h3>#{@_data}</h3>"; end
|
55
|
+
def h4; _out "<h4>#{@_data}</h4>"; end
|
56
|
+
def h5; _out "<h5>#{@_data}</h5>"; end
|
57
|
+
def h6; _out "<h6>#{@_data}</h6>"; end
|
58
|
+
|
59
|
+
def list
|
60
|
+
_out "<ul>"
|
61
|
+
_body {|line| _out "<li>#{line}</li>" }
|
62
|
+
_out "</ul>"
|
63
|
+
end
|
64
|
+
|
65
|
+
def list!
|
66
|
+
_out "<ul>"
|
67
|
+
lines = _body.each # {|line| _out "<li>#{line}</li>" }
|
68
|
+
loop do
|
69
|
+
line = lines.next
|
70
|
+
line = _format(line)
|
71
|
+
if line[0] == " "
|
72
|
+
_out line
|
73
|
+
else
|
74
|
+
_out "<li>#{line}</li>"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
_out "</ul>"
|
78
|
+
end
|
79
|
+
|
52
80
|
def shell!
|
53
|
-
cmd = @_data
|
81
|
+
cmd = @_data.chomp
|
54
82
|
system(cmd)
|
55
83
|
end
|
56
84
|
|
57
85
|
def errout
|
58
|
-
TTY.puts @_data
|
86
|
+
TTY.puts @_data.chomp
|
59
87
|
end
|
60
88
|
|
61
89
|
def say
|
62
|
-
str = _format(@_data)
|
90
|
+
str = _format(@_data.chomp)
|
63
91
|
TTY.puts str
|
64
92
|
_optional_blank_line
|
65
93
|
end
|
66
94
|
|
67
95
|
def banner
|
68
|
-
str = _format(@_data)
|
96
|
+
str = _format(@_data.chomp)
|
69
97
|
n = str.length - 1
|
70
98
|
puts "-"*n
|
71
99
|
puts str
|
@@ -94,7 +122,7 @@ EOS
|
|
94
122
|
name = @_args[0]
|
95
123
|
str = "def #{name}\n"
|
96
124
|
raise "Illegal name '#{name}'" if _disallowed?(name)
|
97
|
-
str +=
|
125
|
+
str += _body(true).join("\n")
|
98
126
|
str += "\nend\n"
|
99
127
|
eval str
|
100
128
|
rescue => err
|
@@ -179,7 +207,7 @@ EOS
|
|
179
207
|
end
|
180
208
|
|
181
209
|
def set_NEW
|
182
|
-
line = _data.
|
210
|
+
line = _data.chomp
|
183
211
|
e = line.each_char # enum
|
184
212
|
loop do
|
185
213
|
c = e.next
|
@@ -216,12 +244,12 @@ EOS
|
|
216
244
|
end
|
217
245
|
|
218
246
|
def reval
|
219
|
-
eval _data
|
247
|
+
eval _data.chomp
|
220
248
|
end
|
221
249
|
|
222
250
|
def heredoc
|
223
251
|
var = @_args[0]
|
224
|
-
str =
|
252
|
+
str = _body.join("\n")
|
225
253
|
s2 = ""
|
226
254
|
str.each_line do |s|
|
227
255
|
str = FormatLine.var_func_parse(s.chomp)
|
@@ -347,7 +375,7 @@ EOS
|
|
347
375
|
end
|
348
376
|
|
349
377
|
def r
|
350
|
-
_out @_data # No processing at all
|
378
|
+
_out @_data.chomp # No processing at all
|
351
379
|
end
|
352
380
|
|
353
381
|
def raw
|
@@ -393,7 +421,7 @@ EOS
|
|
393
421
|
|
394
422
|
def heading
|
395
423
|
_print "<center><font size=+1><b>"
|
396
|
-
_print @_data
|
424
|
+
_print @_data.chomp
|
397
425
|
_print "</b></font></center>"
|
398
426
|
end
|
399
427
|
|
@@ -444,7 +472,7 @@ EOS
|
|
444
472
|
end
|
445
473
|
|
446
474
|
def xtable # Borrowed from bookish - FIXME
|
447
|
-
title = @_data
|
475
|
+
title = @_data.chomp
|
448
476
|
delim = " :: "
|
449
477
|
_out "<br><center><table width=90% cellpadding=5>"
|
450
478
|
lines = _body(true)
|
@@ -472,6 +500,11 @@ EOS
|
|
472
500
|
_out "</table></center>"
|
473
501
|
end
|
474
502
|
|
503
|
+
def image
|
504
|
+
name = @_args[0]
|
505
|
+
_out "<img src='#{name}'></img>"
|
506
|
+
end
|
507
|
+
|
475
508
|
def br
|
476
509
|
n = _args.first || "1"
|
477
510
|
out = ""
|
data/lib/userapi.rb
CHANGED
@@ -19,6 +19,7 @@ module Livetext::UserAPI
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def _args
|
22
|
+
@_args = _format(@_data).chomp.split
|
22
23
|
if block_given?
|
23
24
|
@_args.each {|arg| yield arg }
|
24
25
|
else
|
@@ -26,6 +27,10 @@ module Livetext::UserAPI
|
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
30
|
+
def _vars
|
31
|
+
@_vars.dup
|
32
|
+
end
|
33
|
+
|
29
34
|
def _optional_blank_line
|
30
35
|
peek = peek_nextline
|
31
36
|
return if peek.nil?
|
@@ -80,6 +85,8 @@ module Livetext::UserAPI
|
|
80
85
|
lines << @line
|
81
86
|
end
|
82
87
|
|
88
|
+
raise "Expected .end, found end of file" unless _end?(@line)
|
89
|
+
|
83
90
|
_optional_blank_line
|
84
91
|
if block_given?
|
85
92
|
lines.each {|line| yield line } # FIXME what about $. ?
|
@@ -87,14 +94,13 @@ module Livetext::UserAPI
|
|
87
94
|
lines
|
88
95
|
end
|
89
96
|
rescue => err
|
90
|
-
str =
|
91
|
-
str << err.inspect + "\n"
|
97
|
+
str = err.inspect + "\n"
|
92
98
|
str << err.backtrace.map {|x| " " + x }.join("\n")
|
93
99
|
_error!(str)
|
94
100
|
end
|
95
101
|
|
96
102
|
def _body_text(raw=false)
|
97
|
-
|
103
|
+
_raw_body.join("\n")
|
98
104
|
end
|
99
105
|
|
100
106
|
def _raw_body!
|
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>"
|
@@ -88,10 +68,11 @@ def chapter
|
|
88
68
|
@sec = @sec2 = 0
|
89
69
|
title = @_data.split(" ",2)[1]
|
90
70
|
@toc << "<br><b>#@chapter</b> #{title}<br>"
|
91
|
-
|
71
|
+
@_data = _slug(title)
|
72
|
+
next_output
|
92
73
|
_out "<title>#{@chapter}. #{title}</title>"
|
93
74
|
_out <<-HTML
|
94
|
-
<h2>Chapter #{@chapter}</
|
75
|
+
<h2>Chapter #{@chapter}</h2>
|
95
76
|
<h1>#{title}</h1>
|
96
77
|
|
97
78
|
HTML
|
@@ -103,10 +84,11 @@ def chapterN
|
|
103
84
|
title = @_data # .split(" ",2)[1]
|
104
85
|
_errout("Chapter #@chapter: #{title}")
|
105
86
|
@toc << "<br><b>#@chapter</b> #{title}<br>"
|
106
|
-
|
87
|
+
@_data = _slug(title)
|
88
|
+
next_output
|
107
89
|
_out "<title>#{@chapter}. #{title}</title>"
|
108
90
|
_out <<-HTML
|
109
|
-
<h2>Chapter #{@chapter}</
|
91
|
+
<h2>Chapter #{@chapter}</h2>
|
110
92
|
<h1>#{title}</h1>
|
111
93
|
|
112
94
|
HTML
|
@@ -116,10 +98,11 @@ def sec
|
|
116
98
|
@sec += 1
|
117
99
|
@sec2 = 0
|
118
100
|
@section = "#@chapter.#@sec"
|
119
|
-
|
120
|
-
@toc << "#{_nbsp(3)}<b>#@section</b>
|
121
|
-
|
122
|
-
|
101
|
+
title = @_data.dup
|
102
|
+
@toc << "#{_nbsp(3)}<b>#@section</b> #{title}<br>"
|
103
|
+
@_data = _slug(@_data)
|
104
|
+
next_output
|
105
|
+
_out "<h3>#@section #{title}</h3>\n"
|
123
106
|
rescue => err
|
124
107
|
STDERR.puts "#{err}\n#{err.backtrace}"
|
125
108
|
exit
|
@@ -128,10 +111,33 @@ end
|
|
128
111
|
def subsec
|
129
112
|
@sec2 += 1
|
130
113
|
@subsec = "#@chapter.#@sec.#@sec2"
|
131
|
-
|
132
|
-
#
|
133
|
-
|
134
|
-
|
114
|
+
title = @_data.dup
|
115
|
+
@toc << "#{_nbsp(6)}<b>#@subsec</b> #{title}<br>"
|
116
|
+
@_data = _slug(@_data)
|
117
|
+
next_output
|
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
|
135
141
|
end
|
136
142
|
|
137
143
|
def table2
|
@@ -139,7 +145,7 @@ def table2
|
|
139
145
|
wide = "90"
|
140
146
|
extra = _args[2]
|
141
147
|
delim = " :: "
|
142
|
-
_out "<br><center><table
|
148
|
+
_out "<br><center><table width=#{wide}% cellpadding=5>"
|
143
149
|
lines = _body(true)
|
144
150
|
lines.map! {|line| _format(line) }
|
145
151
|
|
@@ -192,7 +198,7 @@ def table
|
|
192
198
|
@table_num += 1
|
193
199
|
title = @_data
|
194
200
|
delim = " :: "
|
195
|
-
_out "<br><center><table
|
201
|
+
_out "<br><center><table width=90% cellpadding=5>"
|
196
202
|
lines = _body(true)
|
197
203
|
maxw = nil
|
198
204
|
lines.each do |line|
|
@@ -200,7 +206,7 @@ def table
|
|
200
206
|
cells = line.split(delim)
|
201
207
|
wide = cells.map {|x| x.length }
|
202
208
|
maxw = [0] * cells.size
|
203
|
-
maxw = maxw.map.with_index {|x, i| [x, wide[i]].max }
|
209
|
+
maxw = maxw.map.with_index {|x, i| [x, wide[i]+2].max }
|
204
210
|
end
|
205
211
|
|
206
212
|
sum = maxw.inject(0, :+)
|
@@ -246,12 +252,12 @@ end
|
|
246
252
|
def missing
|
247
253
|
@toc << "#{_nbsp(8)}<font color=red>TBD: #@_data</font><br>"
|
248
254
|
stuff = @_data.empty? ? "" : ": #@_data"
|
249
|
-
|
255
|
+
_out "<br><font color=red><i>[Material missing#{stuff}]</i></font><br>\n "
|
250
256
|
end
|
251
257
|
|
252
258
|
def TBC
|
253
259
|
@toc << "#{_nbsp(8)}<font color=red>To be continued...</font><br>"
|
254
|
-
|
260
|
+
_out "<br><font color=red><i>To be continued...</i></font><br>"
|
255
261
|
end
|
256
262
|
|
257
263
|
def note
|
data/plugin/calibre.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
Error: Illegal name 'to_s' (at source.lt3 line 5)
|
@@ -0,0 +1 @@
|
|
1
|
+
Error: Name 'foobar' is unknown
|
data/test/data/lines.txt
CHANGED
@@ -104,7 +104,7 @@ _This for example
|
|
104
104
|
|
105
105
|
Line starts with double underscore
|
106
106
|
__This, for example
|
107
|
-
<i>This
|
107
|
+
<i>This</i>, for example
|
108
108
|
|
109
109
|
Line has embedded underscores
|
110
110
|
This has some_embedded_underscores
|
@@ -116,5 +116,5 @@ This has some_escaped_underscores
|
|
116
116
|
|
117
117
|
Doubled underscore, midline
|
118
118
|
This is __doubled, it seems
|
119
|
-
This is <i>doubled
|
119
|
+
This is <i>doubled</i>, it seems
|
120
120
|
|
data/test/test.rb
CHANGED
@@ -71,12 +71,44 @@ class TestingLivetext < MiniTest::Test
|
|
71
71
|
Dir.chdir(base) do
|
72
72
|
src, out, exp = "source.lt3", "/tmp/#{base}--actual-output.txt", "expected-output.txt"
|
73
73
|
err, erx = "/tmp/#{base}--actual-error.txt", "expected-error.txt"
|
74
|
+
|
75
|
+
# New features - match out/err by regex
|
76
|
+
expout_regex = "expected-out-line1match.txt"
|
77
|
+
experr_regex = "expected-err-line1match.txt"
|
78
|
+
|
74
79
|
cmd = "livetext #{src} >#{out} 2>#{err}"
|
75
80
|
system(cmd)
|
76
|
-
output, expected, errors, errexp = File.read(out), File.read(exp), File.read(err), File.read(erx)
|
77
81
|
|
78
|
-
|
79
|
-
|
82
|
+
output = File.read(out)
|
83
|
+
errors = File.read(err)
|
84
|
+
rx_out = rx_err = nil
|
85
|
+
|
86
|
+
if File.exist?(expout_regex)
|
87
|
+
rx_out = /#{Regexp.escape(File.read(expout_regex).chomp)}/
|
88
|
+
expected = "(match test)"
|
89
|
+
else
|
90
|
+
expected = File.read(exp)
|
91
|
+
end
|
92
|
+
|
93
|
+
if File.exist?(experr_regex)
|
94
|
+
rx_err = /#{Regexp.escape(File.read(experr_regex).chomp)}/
|
95
|
+
errexp = "(match test)"
|
96
|
+
else
|
97
|
+
errexp = File.read(erx)
|
98
|
+
end
|
99
|
+
|
100
|
+
if rx_out
|
101
|
+
out_ok = output =~ rx_out
|
102
|
+
else
|
103
|
+
out_ok = output == expected
|
104
|
+
end
|
105
|
+
|
106
|
+
if rx_err
|
107
|
+
err_ok = errors =~ rx_err
|
108
|
+
else
|
109
|
+
err_ok = errors == errexp
|
110
|
+
end
|
111
|
+
|
80
112
|
nout = output.split("\n").size
|
81
113
|
nexp = expected.split("\n").size
|
82
114
|
bad_out = "--- Expected (#{nexp} lines): \n#{green(expected)}\n--- Output (#{nout} lines): \n#{red(output)}\n"
|
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.07
|
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-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A smart text processor extensible in Ruby
|
14
14
|
email: rubyhacker@gmail.com
|
@@ -57,9 +57,11 @@ files:
|
|
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
|
+
- test/data/error_invalid_name/expected-err-line1match.txt
|
60
61
|
- test/data/error_invalid_name/expected-error.txt
|
61
62
|
- test/data/error_invalid_name/expected-output.txt
|
62
63
|
- test/data/error_invalid_name/source.lt3
|
64
|
+
- test/data/error_line_num/expected-err-line1match.txt
|
63
65
|
- test/data/error_line_num/expected-error.txt
|
64
66
|
- test/data/error_line_num/expected-output.txt
|
65
67
|
- test/data/error_line_num/source.lt3
|
@@ -137,7 +139,7 @@ homepage: https://github.com/Hal9000/livetext
|
|
137
139
|
licenses:
|
138
140
|
- Ruby
|
139
141
|
metadata: {}
|
140
|
-
post_install_message:
|
142
|
+
post_install_message:
|
141
143
|
rdoc_options: []
|
142
144
|
require_paths:
|
143
145
|
- lib
|
@@ -152,8 +154,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
154
|
- !ruby/object:Gem::Version
|
153
155
|
version: '0'
|
154
156
|
requirements: []
|
155
|
-
rubygems_version: 3.
|
156
|
-
signing_key:
|
157
|
+
rubygems_version: 3.1.2
|
158
|
+
signing_key:
|
157
159
|
specification_version: 4
|
158
160
|
summary: A smart processor for text
|
159
161
|
test_files: []
|