livetext 0.9.26 → 0.9.31

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