livetext 0.9.27 → 0.9.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.lt3 +3 -2
- data/imports/bookish.rb +1 -1
- data/lib/livetext/expansion.rb +108 -0
- data/lib/livetext/formatter.rb +223 -0
- data/lib/livetext/functions.rb +9 -0
- data/lib/livetext/helpers.rb +41 -29
- data/lib/livetext/html.rb +73 -0
- data/lib/livetext/more.rb +33 -13
- data/lib/livetext/parser/general.rb +1 -1
- data/lib/livetext/parser/set.rb +10 -3
- data/lib/livetext/processor.rb +5 -0
- data/lib/livetext/standard.rb +67 -67
- data/lib/livetext/userapi.rb +41 -19
- data/lib/livetext/version.rb +1 -1
- data/lib/livetext.rb +1 -1
- data/plugin/bookish.rb +1 -1
- data/plugin/bootstrap_menu.rb +140 -0
- data/plugin/misc/navbar.rb +162 -0
- data/test/extra/README.txt +149 -0
- data/test/extra/bracketed.rb +121 -0
- data/test/extra/bracketed.txt +44 -0
- data/test/extra/double.rb +121 -0
- data/test/extra/double.txt +44 -0
- data/test/extra/functions.rb +148 -0
- data/test/extra/functions.txt +58 -0
- data/test/extra/single.rb +139 -0
- data/test/extra/single.txt +52 -0
- data/test/extra/testgen.rb +104 -0
- data/test/extra/variables.rb +94 -0
- data/test/extra/variables.txt +35 -0
- data/test/snapshots/basic_formatting/expected-output.txt +2 -2
- data/test/snapshots/simple_vars/source.lt3 +1 -1
- data/test/snapshots/subset.txt +49 -49
- data/test/unit/all.rb +1 -2
- data/test/unit/parser/general.rb +2 -2
- data/test/unit/parser/set.rb +0 -9
- metadata +18 -34
- data/lib/livetext/funcall.rb +0 -87
- data/lib/livetext/lineparser.rb +0 -575
- data/test/snapshots/basic_formatting/actual-error.txt +0 -0
- data/test/snapshots/basic_formatting/actual-output.txt +0 -13
- data/test/snapshots/basic_formatting/err-sdiff.txt +0 -1
- data/test/snapshots/basic_formatting/out-sdiff.txt +0 -14
- data/test/snapshots/error_inc_line_num/README.txt +0 -20
- data/test/snapshots/error_invalid_name/foo +0 -5
- data/test/snapshots/functions/actual-error.txt +0 -19
- data/test/snapshots/functions/actual-output.txt +0 -0
- data/test/snapshots/functions/err-sdiff.txt +0 -20
- data/test/snapshots/more_complex_vars/actual-error.txt +0 -0
- data/test/snapshots/more_complex_vars/actual-output.txt +0 -4
- data/test/snapshots/more_complex_vars/err-sdiff.txt +0 -1
- data/test/snapshots/more_complex_vars/out-sdiff.txt +0 -5
- data/test/snapshots/more_functions/actual-error.txt +0 -19
- data/test/snapshots/more_functions/actual-output.txt +0 -0
- data/test/snapshots/more_functions/err-sdiff.txt +0 -20
- data/test/snapshots/raw_lines/actual-error.txt +0 -22
- data/test/snapshots/raw_lines/actual-output.txt +0 -0
- data/test/snapshots/raw_lines/err-sdiff.txt +0 -23
- data/test/snapshots/simple_vars/actual-error.txt +0 -0
- data/test/snapshots/simple_vars/actual-output.txt +0 -6
- data/test/snapshots/simple_vars/err-sdiff.txt +0 -1
- data/test/snapshots/simple_vars/out-sdiff.txt +0 -7
- data/test/snapshots/var_into_func/actual-error.txt +0 -19
- data/test/snapshots/var_into_func/actual-output.txt +0 -0
- data/test/snapshots/var_into_func/err-sdiff.txt +0 -20
- data/test/snapshots/var_into_func/out-sdiff.txt +0 -17
- data/test/unit/lineparser.rb +0 -359
- data/test/unit/new_lineparser.rb +0 -359
- data/test/unit/tokenizer.rb +0 -535
data/lib/livetext/parser/set.rb
CHANGED
@@ -53,8 +53,9 @@ class Livetext::ParseSet < StringParser
|
|
53
53
|
var = get_var
|
54
54
|
skip_equal
|
55
55
|
value = get_value
|
56
|
-
value = Livetext.interpolate(value)
|
56
|
+
# value = Livetext.interpolate(value)
|
57
57
|
pair = [var, value]
|
58
|
+
Livetext::Vars[var.to_sym] = value
|
58
59
|
pair
|
59
60
|
end
|
60
61
|
|
@@ -115,10 +116,11 @@ class Livetext::ParseSet < StringParser
|
|
115
116
|
end
|
116
117
|
|
117
118
|
def unquoted_value
|
118
|
-
char = nil
|
119
119
|
value = ""
|
120
|
+
char = nil
|
120
121
|
loop do
|
121
122
|
char = peek
|
123
|
+
break if char.nil?
|
122
124
|
break if eos?
|
123
125
|
break if char == " " || char == ","
|
124
126
|
value << char
|
@@ -133,7 +135,12 @@ class Livetext::ParseSet < StringParser
|
|
133
135
|
|
134
136
|
def get_value
|
135
137
|
char = peek
|
136
|
-
|
138
|
+
flag = quote?(char)
|
139
|
+
if flag
|
140
|
+
value = quoted_value
|
141
|
+
else
|
142
|
+
value = unquoted_value
|
143
|
+
end
|
137
144
|
value
|
138
145
|
end
|
139
146
|
end
|
data/lib/livetext/processor.rb
CHANGED
@@ -35,12 +35,17 @@ class Processor
|
|
35
35
|
@indentation = @parent.indentation
|
36
36
|
@_mixins = []
|
37
37
|
@_imports = []
|
38
|
+
@html = HTML.new(@parent.api)
|
38
39
|
end
|
39
40
|
|
40
41
|
def api
|
41
42
|
@parent.api # FIXME Is this weird??
|
42
43
|
end
|
43
44
|
|
45
|
+
def html
|
46
|
+
@html
|
47
|
+
end
|
48
|
+
|
44
49
|
def output=(io)
|
45
50
|
@output = io
|
46
51
|
end
|
data/lib/livetext/standard.rb
CHANGED
@@ -17,6 +17,8 @@ module Livetext::Standard
|
|
17
17
|
include HTMLHelper
|
18
18
|
include Livetext::Helpers
|
19
19
|
|
20
|
+
TTY = ::File.open("/dev/tty", "w")
|
21
|
+
|
20
22
|
SimpleFormats = # Move this?
|
21
23
|
{ b: %w[<b> </b>],
|
22
24
|
i: %w[<i> </i>],
|
@@ -25,18 +27,9 @@ module Livetext::Standard
|
|
25
27
|
|
26
28
|
attr_reader :data
|
27
29
|
|
28
|
-
def data=(val) # FIXME this is weird, let's remove it soonish and why are there two???
|
29
|
-
# api.tty ">>>> in #{__FILE__}: api id = #{api.object_id}"
|
30
|
-
val = val.chomp
|
31
|
-
api.data = val
|
32
|
-
api.args = format(val).split rescue []
|
33
|
-
@mixins = []
|
34
|
-
@imports = []
|
35
|
-
end
|
36
|
-
|
37
30
|
# dumb name - bold, italic, teletype, striketrough
|
38
31
|
|
39
|
-
def bits
|
32
|
+
def bits # FIXME umm what is this?
|
40
33
|
b0, b1, i0, i1, t0, t1, s0, s1 = *api.args
|
41
34
|
SimpleFormats[:b] = [b0, b1]
|
42
35
|
SimpleFormats[:i] = [i0, i1]
|
@@ -45,29 +38,35 @@ module Livetext::Standard
|
|
45
38
|
api.optional_blank_line
|
46
39
|
end
|
47
40
|
|
48
|
-
def
|
41
|
+
# def setvars(pairs)
|
42
|
+
# pairs.each do |var, value|
|
43
|
+
# api.setvar(var, value)
|
44
|
+
# end
|
45
|
+
# end
|
46
|
+
|
47
|
+
def backtrace
|
49
48
|
@backtrace = onoff(api.args.first)
|
50
49
|
api.optional_blank_line
|
51
50
|
end
|
52
51
|
|
53
|
-
def comment
|
52
|
+
def comment
|
54
53
|
api.body
|
55
54
|
api.optional_blank_line
|
56
55
|
end
|
57
56
|
|
58
|
-
def shell
|
57
|
+
def shell
|
59
58
|
cmd = api.data
|
60
59
|
system(cmd)
|
61
60
|
api.optional_blank_line
|
62
61
|
end
|
63
62
|
|
64
|
-
def func
|
63
|
+
def func
|
65
64
|
funcname = api.args[0]
|
66
65
|
# check_disallowed(funcname) # should any be invalid?
|
67
66
|
funcname = funcname.gsub(/\./, "__")
|
68
67
|
func_def = <<~EOS
|
69
68
|
def #{funcname}(param)
|
70
|
-
#{api.body.to_a.join("\n")}
|
69
|
+
#{api.body(true).to_a.join("\n")}
|
71
70
|
end
|
72
71
|
EOS
|
73
72
|
api.optional_blank_line
|
@@ -75,21 +74,21 @@ module Livetext::Standard
|
|
75
74
|
return true
|
76
75
|
end
|
77
76
|
|
78
|
-
def h1
|
79
|
-
def h2
|
80
|
-
def h3
|
81
|
-
def h4
|
82
|
-
def h5
|
83
|
-
def h6
|
77
|
+
def h1; api.out wrapped(api.data, :h1); return true; end
|
78
|
+
def h2; api.out wrapped(api.data, :h2); return true; end
|
79
|
+
def h3; api.out wrapped(api.data, :h3); return true; end
|
80
|
+
def h4; api.out wrapped(api.data, :h4); return true; end
|
81
|
+
def h5; api.out wrapped(api.data, :h5); return true; end
|
82
|
+
def h6; api.out wrapped(api.data, :h6); return true; end
|
84
83
|
|
85
|
-
def list
|
84
|
+
def list
|
86
85
|
wrap :ul do
|
87
86
|
api.body {|line| api.out wrapped(line, :li) }
|
88
87
|
end
|
89
88
|
api.optional_blank_line
|
90
89
|
end
|
91
90
|
|
92
|
-
def list!
|
91
|
+
def list!
|
93
92
|
wrap(:ul) do
|
94
93
|
lines = api.body.each # enumerator
|
95
94
|
loop do
|
@@ -102,40 +101,40 @@ module Livetext::Standard
|
|
102
101
|
api.optional_blank_line
|
103
102
|
end
|
104
103
|
|
105
|
-
def shell!
|
104
|
+
def shell!
|
106
105
|
cmd = api.data
|
107
106
|
system(cmd)
|
108
107
|
api.optional_blank_line
|
109
108
|
end
|
110
109
|
|
111
|
-
def errout
|
110
|
+
def errout
|
112
111
|
::STDERR.puts api.data
|
113
112
|
api.optional_blank_line
|
114
113
|
end
|
115
114
|
|
116
|
-
def ttyout
|
115
|
+
def ttyout
|
117
116
|
TTY.puts api.data
|
118
117
|
api.optional_blank_line
|
119
118
|
end
|
120
119
|
|
121
|
-
def say
|
120
|
+
def say
|
122
121
|
str = api.format(api.data)
|
123
122
|
TTY.puts str
|
124
123
|
api.optional_blank_line
|
125
124
|
end
|
126
125
|
|
127
|
-
def banner
|
126
|
+
def banner
|
128
127
|
str = api.format(api.data)
|
129
128
|
num = str.length
|
130
129
|
decor = "-"*num + "\n"
|
131
130
|
puts decor + str + "\n" + decor
|
132
131
|
end
|
133
132
|
|
134
|
-
def quit
|
133
|
+
def quit
|
135
134
|
@output.close
|
136
135
|
end
|
137
136
|
|
138
|
-
def cleanup
|
137
|
+
def cleanup
|
139
138
|
api.args.each do |item|
|
140
139
|
cmd = ::File.directory?(item) ? "rm -f #{item}/*" : "rm #{item}"
|
141
140
|
system(cmd)
|
@@ -143,13 +142,9 @@ module Livetext::Standard
|
|
143
142
|
api.optional_blank_line
|
144
143
|
end
|
145
144
|
|
146
|
-
def dot_def
|
147
|
-
# api.tty "in #{__FILE__}: api id = #{api.inspect}"
|
145
|
+
def dot_def
|
148
146
|
name = api.args[0]
|
149
|
-
# api.tty :dd1
|
150
|
-
# api.tty name.inspect
|
151
147
|
check_disallowed(name)
|
152
|
-
# api.tty :dd2
|
153
148
|
# Difficult to avoid eval here
|
154
149
|
str = "def #{name}\n"
|
155
150
|
str << api.body(true).join("\n")
|
@@ -158,16 +153,16 @@ module Livetext::Standard
|
|
158
153
|
api.optional_blank_line
|
159
154
|
end
|
160
155
|
|
161
|
-
def set
|
162
|
-
line = api.data.chomp
|
156
|
+
def set
|
157
|
+
line = api.args.join(" ") # data.chomp
|
163
158
|
pairs = Livetext::ParseSet.new(line).parse
|
164
|
-
|
159
|
+
api.setvars(pairs)
|
165
160
|
api.optional_blank_line
|
166
161
|
end
|
167
162
|
|
168
163
|
# FIXME really these should be one method...
|
169
164
|
|
170
|
-
def variables!
|
165
|
+
def variables! # cwd, not FileDir - weird, fix later
|
171
166
|
prefix = api.args[0]
|
172
167
|
file = api.args[1]
|
173
168
|
prefix = nil if prefix == "-" # FIXME dumb hack
|
@@ -178,11 +173,12 @@ module Livetext::Standard
|
|
178
173
|
lines = api.body
|
179
174
|
end
|
180
175
|
pairs = Livetext::ParseGeneral.parse_vars(lines, prefix: nil)
|
181
|
-
|
176
|
+
STDERR.puts "! pairs = #{pairs.inspect}"
|
177
|
+
api.setvars(pairs)
|
182
178
|
api.optional_blank_line
|
183
179
|
end
|
184
180
|
|
185
|
-
def variables
|
181
|
+
def variables
|
186
182
|
prefix = api.args[0]
|
187
183
|
file = api.args[1]
|
188
184
|
prefix = nil if prefix == "-" # FIXME dumb hack
|
@@ -193,11 +189,12 @@ module Livetext::Standard
|
|
193
189
|
lines = api.body
|
194
190
|
end
|
195
191
|
pairs = Livetext::ParseGeneral.parse_vars(lines, prefix: nil)
|
196
|
-
|
192
|
+
STDERR.puts "pairs = #{pairs.inspect}"
|
193
|
+
api.setvars(pairs)
|
197
194
|
api.optional_blank_line
|
198
195
|
end
|
199
196
|
|
200
|
-
def heredoc
|
197
|
+
def heredoc
|
201
198
|
var = api.args[0]
|
202
199
|
text = api.body.join("\n")
|
203
200
|
rhs = ""
|
@@ -211,7 +208,7 @@ module Livetext::Standard
|
|
211
208
|
api.optional_blank_line
|
212
209
|
end
|
213
210
|
|
214
|
-
def seek
|
211
|
+
def seek # like include, but search upward as needed
|
215
212
|
file = api.args.first
|
216
213
|
file = search_upward(file)
|
217
214
|
check_file_exists(file)
|
@@ -219,14 +216,14 @@ module Livetext::Standard
|
|
219
216
|
api.optional_blank_line
|
220
217
|
end
|
221
218
|
|
222
|
-
def dot_include
|
223
|
-
file = api.format(api.args.first) # allows for variables
|
219
|
+
def dot_include # dot command
|
220
|
+
file = api.args.first # api.format(api.args.first) # allows for variables
|
224
221
|
check_file_exists(file)
|
225
222
|
@parent.process_file(file)
|
226
223
|
api.optional_blank_line
|
227
224
|
end
|
228
225
|
|
229
|
-
def inherit
|
226
|
+
def inherit
|
230
227
|
file = api.args.first
|
231
228
|
upper = "../#{file}"
|
232
229
|
got_upper, got_file = File.exist?(upper), File.exist?(file)
|
@@ -238,8 +235,9 @@ module Livetext::Standard
|
|
238
235
|
api.optional_blank_line
|
239
236
|
end
|
240
237
|
|
241
|
-
def mixin
|
238
|
+
def mixin
|
242
239
|
name = api.args.first # Expect a module name
|
240
|
+
@mixins ||= []
|
243
241
|
return if @mixins.include?(name)
|
244
242
|
@mixins << name
|
245
243
|
mod = Livetext::Handler::Mixin.get_module(name, @parent)
|
@@ -249,8 +247,9 @@ module Livetext::Standard
|
|
249
247
|
api.optional_blank_line
|
250
248
|
end
|
251
249
|
|
252
|
-
def import
|
250
|
+
def import
|
253
251
|
name = api.args.first # Expect a module name
|
252
|
+
@imports ||= []
|
254
253
|
return if @imports.include?(name)
|
255
254
|
@imports << name
|
256
255
|
mod = Livetext::Handler::Import.get_module(name, @parent)
|
@@ -260,7 +259,7 @@ module Livetext::Standard
|
|
260
259
|
api.optional_blank_line
|
261
260
|
end
|
262
261
|
|
263
|
-
def copy
|
262
|
+
def copy
|
264
263
|
file = api.args.first
|
265
264
|
ok = check_file_exists(file)
|
266
265
|
|
@@ -270,65 +269,67 @@ module Livetext::Standard
|
|
270
269
|
[ok, file]
|
271
270
|
end
|
272
271
|
|
273
|
-
def r
|
274
|
-
|
272
|
+
def r
|
273
|
+
# FIXME api.data is broken
|
274
|
+
# api.out api.data # No processing at all
|
275
|
+
api.out api.args.join(" ")
|
275
276
|
api.optional_blank_line
|
276
277
|
end
|
277
278
|
|
278
|
-
def raw
|
279
|
+
def raw
|
279
280
|
# No processing at all (terminate with __EOF__)
|
280
281
|
api.raw_body {|line| api.out line } # no formatting
|
281
282
|
api.optional_blank_line
|
282
283
|
end
|
283
284
|
|
284
|
-
def debug
|
285
|
+
def debug
|
285
286
|
self._debug = onoff(api.args.first)
|
286
287
|
api.optional_blank_line
|
287
288
|
end
|
288
289
|
|
289
|
-
def passthru
|
290
|
+
def passthru
|
290
291
|
# FIXME - add check for args size? (helpers)
|
291
292
|
@nopass = ! onoff(api.args.first)
|
292
293
|
api.optional_blank_line
|
293
294
|
end
|
294
295
|
|
295
|
-
def nopass
|
296
|
+
def nopass
|
296
297
|
@nopass = true
|
297
298
|
api.optional_blank_line
|
298
299
|
end
|
299
300
|
|
300
|
-
def para
|
301
|
+
def para
|
301
302
|
# FIXME - add check for args size? (helpers)
|
302
303
|
@nopara = ! onoff(api.args.first)
|
303
304
|
api.optional_blank_line
|
304
305
|
end
|
305
306
|
|
306
|
-
def nopara
|
307
|
+
def nopara
|
307
308
|
@nopara = true
|
308
309
|
api.optional_blank_line
|
309
310
|
end
|
310
311
|
|
311
|
-
def heading
|
312
|
+
def heading
|
312
313
|
api.print "<center><font size=+1><b>"
|
313
314
|
api.print api.data
|
314
315
|
api.print "</b></font></center>"
|
315
316
|
api.optional_blank_line
|
316
317
|
end
|
317
318
|
|
318
|
-
def newpage
|
319
|
+
def newpage
|
319
320
|
api.out '<p style="page-break-after:always;"></p>'
|
320
321
|
api.out "<p/>"
|
321
322
|
api.optional_blank_line
|
322
323
|
end
|
323
324
|
|
324
|
-
def mono
|
325
|
+
def mono
|
325
326
|
wrap ":pre" do
|
326
327
|
api.body(true) {|line| api.out line }
|
327
328
|
end
|
328
329
|
api.optional_blank_line
|
329
330
|
end
|
330
331
|
|
331
|
-
def dlist
|
332
|
+
def dlist
|
332
333
|
delim = api.args.first
|
333
334
|
wrap(:dl) do
|
334
335
|
api.body do |line|
|
@@ -341,15 +342,14 @@ module Livetext::Standard
|
|
341
342
|
api.optional_blank_line
|
342
343
|
end
|
343
344
|
|
344
|
-
def link
|
345
|
+
def link
|
345
346
|
url = api.args.first
|
346
347
|
text = api.args[2..-1].join(" ")
|
347
348
|
api.out "<a style='text-decoration: none' href='#{url}'>#{text}</a>"
|
348
349
|
api.optional_blank_line
|
349
350
|
end
|
350
351
|
|
351
|
-
def xtable
|
352
|
-
# TTY.puts "=== #{__method__} #{__FILE__} #{__LINE__}"
|
352
|
+
def xtable # Borrowed from bookish - FIXME
|
353
353
|
title = api.data
|
354
354
|
delim = " :: "
|
355
355
|
api.out "<br><center><table width=90% cellpadding=5>"
|
@@ -379,13 +379,13 @@ module Livetext::Standard
|
|
379
379
|
api.optional_blank_line
|
380
380
|
end
|
381
381
|
|
382
|
-
def image
|
382
|
+
def image
|
383
383
|
name = api.args[0]
|
384
384
|
api.out "<img src='#{name}'></img>"
|
385
385
|
api.optional_blank_line
|
386
386
|
end
|
387
387
|
|
388
|
-
def br
|
388
|
+
def br
|
389
389
|
num = api.args.first || "1"
|
390
390
|
str = ""
|
391
391
|
num.to_i.times { str << "<br>" }
|
data/lib/livetext/userapi.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
require_relative '
|
1
|
+
require_relative 'expansion'
|
2
|
+
require_relative 'html'
|
3
3
|
|
4
4
|
# Encapsulate the UserAPI as a class
|
5
5
|
|
@@ -15,18 +15,31 @@ class Livetext::UserAPI
|
|
15
15
|
def initialize(live)
|
16
16
|
@live = live
|
17
17
|
@vars = live.vars
|
18
|
+
@html = HTML.new(self)
|
19
|
+
@expander = Livetext::Expansion.new(live)
|
18
20
|
end
|
19
21
|
|
20
22
|
def api
|
21
23
|
@live.api
|
22
24
|
end
|
23
25
|
|
26
|
+
def html
|
27
|
+
@html
|
28
|
+
end
|
29
|
+
|
24
30
|
def dot
|
25
31
|
@live
|
26
32
|
end
|
27
33
|
|
28
|
-
def setvar(var, val)
|
29
|
-
|
34
|
+
def setvar(var, val) # FIXME
|
35
|
+
@live.vars.set(var, val)
|
36
|
+
end
|
37
|
+
|
38
|
+
def setvars(pairs)
|
39
|
+
pairs = pairs.to_a if pairs.is_a?(Hash)
|
40
|
+
pairs.each do |var, value|
|
41
|
+
@live.vars.set(var, value)
|
42
|
+
end
|
30
43
|
end
|
31
44
|
|
32
45
|
def check_existence(file, msg)
|
@@ -34,9 +47,13 @@ class Livetext::UserAPI
|
|
34
47
|
end
|
35
48
|
|
36
49
|
def data=(value)
|
37
|
-
|
38
|
-
|
39
|
-
@
|
50
|
+
@data = value.dup
|
51
|
+
# @args = format(@data).chomp.split
|
52
|
+
@data
|
53
|
+
end
|
54
|
+
|
55
|
+
def data
|
56
|
+
@data
|
40
57
|
end
|
41
58
|
|
42
59
|
def args
|
@@ -44,9 +61,9 @@ class Livetext::UserAPI
|
|
44
61
|
@args.each {|arg| yield arg }
|
45
62
|
end
|
46
63
|
|
47
|
-
|
48
|
-
|
49
|
-
|
64
|
+
def vars
|
65
|
+
@vars
|
66
|
+
end
|
50
67
|
|
51
68
|
def optional_blank_line
|
52
69
|
peek = @live.peek_nextline # ???
|
@@ -93,7 +110,7 @@ class Livetext::UserAPI
|
|
93
110
|
break if end?(@line)
|
94
111
|
next if comment?(@line)
|
95
112
|
@line = format(@line) unless raw
|
96
|
-
lines << @line
|
113
|
+
lines << @line
|
97
114
|
end
|
98
115
|
raise "Expected .end, found end of file" unless end?(@line) # use custom exception
|
99
116
|
optional_blank_line # FIXME Delete this??
|
@@ -118,22 +135,27 @@ class Livetext::UserAPI
|
|
118
135
|
end
|
119
136
|
|
120
137
|
def format(line)
|
121
|
-
|
122
|
-
line2 = Livetext::LineParser.parse!(line)
|
138
|
+
line2 = @expander.format(line)
|
123
139
|
line2
|
124
140
|
end
|
125
141
|
|
126
142
|
def passthru(line)
|
127
143
|
return if @live.nopass
|
128
|
-
|
129
|
-
|
130
|
-
|
144
|
+
if line == "\n"
|
145
|
+
unless @live.nopara
|
146
|
+
out "<p>"
|
147
|
+
out
|
148
|
+
end
|
149
|
+
else
|
150
|
+
text = @expander.format(line.chomp)
|
151
|
+
out text
|
152
|
+
end
|
131
153
|
end
|
132
154
|
|
133
155
|
def out(str = "", file = nil)
|
134
156
|
return if str.nil?
|
135
157
|
return file.puts str unless file.nil?
|
136
|
-
@live.body << str
|
158
|
+
@live.body << str
|
137
159
|
@live.body << "\n" unless str.end_with?("\n")
|
138
160
|
end
|
139
161
|
|
@@ -150,11 +172,11 @@ class Livetext::UserAPI
|
|
150
172
|
end
|
151
173
|
|
152
174
|
def puts(*args)
|
153
|
-
@live.output.puts *args
|
175
|
+
@live.output.puts *args
|
154
176
|
end
|
155
177
|
|
156
178
|
def print(*args)
|
157
|
-
@live.output.print *args
|
179
|
+
@live.output.print *args
|
158
180
|
end
|
159
181
|
|
160
182
|
def debug=(val)
|
data/lib/livetext/version.rb
CHANGED
data/lib/livetext.rb
CHANGED
@@ -9,7 +9,7 @@ require_relative 'livetext/errors'
|
|
9
9
|
require_relative 'livetext/standard'
|
10
10
|
require_relative 'livetext/functions'
|
11
11
|
require_relative 'livetext/userapi'
|
12
|
-
require_relative 'livetext/
|
12
|
+
require_relative 'livetext/formatter'
|
13
13
|
require_relative 'livetext/processor'
|
14
14
|
require_relative 'livetext/helpers'
|
15
15
|
require_relative 'livetext/handler'
|
data/plugin/bookish.rb
CHANGED