livetext 0.9.36 → 0.9.37

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2dceb322a5f44e776bab9ed9113c7c7a4adf29eff271be81a613c72a081a2d51
4
- data.tar.gz: 70576d3a39fccbe7f3285ddca930f79400b8d770ef600d043e2b3690f173ba23
3
+ metadata.gz: 784ac1767694b1d098d3e289082070ef3e3df0aab15766cf42105e854da31730
4
+ data.tar.gz: b6f62f1164873ec613b16067c53abc0e1b8906cacaeaae033bd5e862ca6b4bd5
5
5
  SHA512:
6
- metadata.gz: 8d91e26a1721ce60ca41ff49a323df2e4ef0a365b0b4eec9b224cbef8381e48b6ab4f3c0bb63e74ada905efb101c69a33e021f521420abe56927b16a46e02091
7
- data.tar.gz: fa718856dcbb75bb4f60f49f31638041158b815335ba9df3680c2ca0b117a2584d66921e06dae30b266f3104a465f826904a797e3e1a546960d75d6dc79d9d4b
6
+ metadata.gz: 795730de451f27c2ffccf326fcc976e170ae884fef45d3bc732bb59826cc40bbff0e877d3ee3ed051fa3f20e0836ccede6668c42ba7a21ec1bf51910ebfc7a99
7
+ data.tar.gz: 1db7dfbb839a6787872df65d591b49fb36db69f9d3ddc86805d981f19266c98abcac4a8bbe8efebdf1137ec674201a3b3f4e0f09d849116acb56f390eefd8cbd
@@ -127,7 +127,7 @@ module Livetext::Helpers
127
127
  retval = @main.send(name) # , *args) # was 125
128
128
  retval
129
129
  rescue => err
130
- graceful_error(err)
130
+ graceful_error(err) # , "#{__method__}: name = #{name}")
131
131
  end
132
132
 
133
133
  def handle_dotcmd(line, indent = 0)
data/lib/livetext/more.rb CHANGED
@@ -91,8 +91,9 @@ class Livetext
91
91
  TTY.puts "#dump had an error: #{err.inspect}"
92
92
  end
93
93
 
94
- def graceful_error(err)
94
+ def graceful_error(err, msg = nil)
95
95
  dump
96
+ STDERR.puts msg if msg
96
97
  raise err
97
98
  end
98
99
 
@@ -44,23 +44,23 @@ module Livetext::Standard
44
44
  # end
45
45
  # end
46
46
 
47
- def backtrace
47
+ def backtrace(args = nil, body = nil)
48
48
  @backtrace = onoff(api.args.first)
49
49
  api.optional_blank_line
50
50
  end
51
51
 
52
- def comment
52
+ def comment(args = nil, body = nil)
53
53
  api.body
54
54
  api.optional_blank_line
55
55
  end
56
56
 
57
- def shell
57
+ def shell(args = nil, body = nil)
58
58
  cmd = api.data
59
59
  system(cmd)
60
60
  api.optional_blank_line
61
61
  end
62
62
 
63
- def func
63
+ def func(args = nil, body = nil)
64
64
  funcname = api.args[0]
65
65
  # check_disallowed(funcname) # should any be invalid?
66
66
  funcname = funcname.gsub(/\./, "__")
@@ -74,21 +74,21 @@ module Livetext::Standard
74
74
  return true
75
75
  end
76
76
 
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
77
+ def h1(args = nil, body = nil); api.out html.tag(:h1, api.data); return true; end
78
+ def h2(args = nil, body = nil); api.out html.tag(:h2, api.data); return true; end
79
+ def h3(args = nil, body = nil); api.out html.tag(:h3, api.data); return true; end
80
+ def h4(args = nil, body = nil); api.out html.tag(:h4, api.data); return true; end
81
+ def h5(args = nil, body = nil); api.out html.tag(:h5, api.data); return true; end
82
+ def h6(args = nil, body = nil); api.out html.tag(:h6, api.data); return true; end
83
83
 
84
- def list
84
+ def list(args = nil, body = nil)
85
85
  html.wrap :ul do
86
- api.body {|line| api.out wrapped(line, :li) }
86
+ api.body {|line| api.out html.tag(:li, line) }
87
87
  end
88
88
  api.optional_blank_line
89
89
  end
90
90
 
91
- def list!
91
+ def list!(args = nil, body = nil)
92
92
  html.wrap(:ul) do
93
93
  lines = api.body.each # enumerator
94
94
  loop do
@@ -101,41 +101,41 @@ module Livetext::Standard
101
101
  api.optional_blank_line
102
102
  end
103
103
 
104
- def shell!
104
+ def shell!(args = nil, body = nil)
105
105
  cmd = api.data
106
106
  system(cmd)
107
107
  api.optional_blank_line
108
108
  end
109
109
 
110
- def errout
110
+ def errout(args = nil, body = nil)
111
111
  ::STDERR.puts api.data
112
112
  api.optional_blank_line
113
113
  end
114
114
 
115
- def ttyout
115
+ def ttyout(args = nil, body = nil)
116
116
  TTY.puts api.data
117
117
  api.optional_blank_line
118
118
  end
119
119
 
120
- def say(arg=nil)
121
- data = arg || api.args.join(" ")
120
+ def say(args = nil, body = nil)
121
+ data = args || api.args.join(" ")
122
122
  str = api.format(data)
123
123
  TTY.puts "(say) #{str}"
124
124
  api.optional_blank_line
125
125
  end
126
126
 
127
- def banner
127
+ def banner(args = nil, body = nil)
128
128
  str = api.format(api.data)
129
129
  num = str.length
130
130
  decor = "-"*num + "\n"
131
131
  puts decor + str + "\n" + decor
132
132
  end
133
133
 
134
- def quit
134
+ def quit(args = nil, body = nil)
135
135
  @output.close
136
136
  end
137
137
 
138
- def cleanup
138
+ def cleanup(args = nil, body = nil)
139
139
  api.args.each do |item|
140
140
  cmd = ::File.directory?(item) ? "rm -f #{item}/*" : "rm #{item}"
141
141
  system(cmd)
@@ -143,7 +143,7 @@ module Livetext::Standard
143
143
  api.optional_blank_line
144
144
  end
145
145
 
146
- def dot_def
146
+ def dot_def(args = nil, body = nil)
147
147
  name = api.args[0]
148
148
  check_disallowed(name)
149
149
  # Difficult to avoid eval here
@@ -154,7 +154,7 @@ module Livetext::Standard
154
154
  api.optional_blank_line
155
155
  end
156
156
 
157
- def set
157
+ def set(args = nil, body = nil)
158
158
  line = api.args.join(" ") # data.chomp
159
159
  pairs = Livetext::ParseSet.new(line).parse
160
160
  api.setvars(pairs)
@@ -163,7 +163,7 @@ module Livetext::Standard
163
163
 
164
164
  # FIXME really these should be one method...
165
165
 
166
- def variables! # cwd, not FileDir - weird, fix later
166
+ def variables!(args = nil, body = nil) # cwd, not FileDir - weird, fix later
167
167
  prefix = api.args[0]
168
168
  file = api.args[1]
169
169
  prefix = nil if prefix == "-" # FIXME dumb hack
@@ -178,7 +178,7 @@ module Livetext::Standard
178
178
  api.optional_blank_line
179
179
  end
180
180
 
181
- def variables
181
+ def variables(args = nil, body = nil)
182
182
  prefix = api.args[0]
183
183
  file = api.args[1]
184
184
  prefix = nil if prefix == "-" # FIXME dumb hack
@@ -193,7 +193,7 @@ module Livetext::Standard
193
193
  api.optional_blank_line
194
194
  end
195
195
 
196
- def heredoc
196
+ def heredoc(args = nil, body = nil)
197
197
  var = api.args[0]
198
198
  text = api.body.join("\n")
199
199
  rhs = ""
@@ -207,7 +207,7 @@ module Livetext::Standard
207
207
  api.optional_blank_line
208
208
  end
209
209
 
210
- def seek # like include, but search upward as needed
210
+ def seek(args = nil, body = nil) # like include, but search upward as needed
211
211
  file = api.args.first
212
212
  file = search_upward(file)
213
213
  check_file_exists(file)
@@ -215,14 +215,14 @@ module Livetext::Standard
215
215
  api.optional_blank_line
216
216
  end
217
217
 
218
- def dot_include # dot command
218
+ def dot_include(args = nil, body = nil) # dot command
219
219
  file = api.expand_variables(api.args.first) # allows for variables
220
220
  check_file_exists(file)
221
221
  @parent.process_file(file)
222
222
  api.optional_blank_line
223
223
  end
224
224
 
225
- def inherit
225
+ def inherit(args = nil, body = nil)
226
226
  file = api.args.first
227
227
  upper = "../#{file}"
228
228
  got_upper, got_file = File.exist?(upper), File.exist?(file)
@@ -234,7 +234,7 @@ module Livetext::Standard
234
234
  api.optional_blank_line
235
235
  end
236
236
 
237
- def mixin
237
+ def mixin(args = nil, body = nil)
238
238
  name = api.args.first # Expect a module name
239
239
  @mixins ||= []
240
240
  return if @mixins.include?(name)
@@ -246,7 +246,7 @@ module Livetext::Standard
246
246
  api.optional_blank_line
247
247
  end
248
248
 
249
- def import
249
+ def import(args = nil, body = nil)
250
250
  name = api.args.first # Expect a module name
251
251
  @imports ||= []
252
252
  return if @imports.include?(name)
@@ -258,7 +258,7 @@ module Livetext::Standard
258
258
  api.optional_blank_line
259
259
  end
260
260
 
261
- def copy
261
+ def copy(args = nil, body = nil)
262
262
  file = api.args.first
263
263
  ok = check_file_exists(file)
264
264
 
@@ -268,67 +268,67 @@ module Livetext::Standard
268
268
  [ok, file]
269
269
  end
270
270
 
271
- def r
271
+ def r(args = nil, body = nil)
272
272
  # FIXME api.data is broken
273
273
  # api.out api.data # No processing at all
274
274
  api.out api.args.join(" ")
275
275
  api.optional_blank_line
276
276
  end
277
277
 
278
- def raw
278
+ def raw(args = nil, body = nil)
279
279
  # No processing at all (terminate with __EOF__)
280
280
  api.raw_body {|line| api.out line } # no formatting
281
281
  api.optional_blank_line
282
282
  end
283
283
 
284
- def debug
284
+ def debug(args = nil, body = nil)
285
285
  @debug = onoff(api.args.first)
286
286
  api.optional_blank_line
287
287
  end
288
288
 
289
- def passthru
289
+ def passthru(args = nil, body = nil)
290
290
  # FIXME - add check for args size? (helpers)
291
291
  @nopass = ! onoff(api.args.first)
292
292
  api.optional_blank_line
293
293
  end
294
294
 
295
- def nopass
295
+ def nopass(args = nil, body = nil)
296
296
  @nopass = true
297
297
  api.optional_blank_line
298
298
  end
299
299
 
300
- def para
300
+ def para(args = nil, body = nil)
301
301
  # FIXME - add check for args size? (helpers)
302
302
  @nopara = ! onoff(api.args.first)
303
303
  api.optional_blank_line
304
304
  end
305
305
 
306
- def nopara
306
+ def nopara(args = nil, body = nil)
307
307
  @nopara = true
308
308
  api.optional_blank_line
309
309
  end
310
310
 
311
- def heading
311
+ def heading(args = nil, body = nil)
312
312
  api.print "<center><font size=+1><b>"
313
313
  api.print api.data
314
314
  api.print "</b></font></center>"
315
315
  api.optional_blank_line
316
316
  end
317
317
 
318
- def newpage
318
+ def newpage(args = nil, body = nil)
319
319
  api.out '<p style="page-break-after:always;"></p>'
320
320
  api.out "<p/>"
321
321
  api.optional_blank_line
322
322
  end
323
323
 
324
- def mono
324
+ def mono(args = nil, body = nil)
325
325
  html.wrap ":pre" do
326
326
  api.body(true) {|line| api.out line }
327
327
  end
328
328
  api.optional_blank_line
329
329
  end
330
330
 
331
- def dlist
331
+ def dlist(args = nil, body = nil)
332
332
  delim = api.args.first
333
333
  html.wrap(:dl) do
334
334
  api.body do |line|
@@ -341,14 +341,14 @@ module Livetext::Standard
341
341
  api.optional_blank_line
342
342
  end
343
343
 
344
- def link
344
+ def link(args = nil, body = nil)
345
345
  url = api.args.first
346
346
  text = api.args[2..-1].join(" ")
347
347
  api.out "<a style='text-decoration: none' href='#{url}'>#{text}</a>"
348
348
  api.optional_blank_line
349
349
  end
350
350
 
351
- def xtable # Borrowed from bookish - FIXME
351
+ def xtable(args = nil, body = nil) # Borrowed from bookish - FIXME
352
352
  title = api.data
353
353
  delim = " :: "
354
354
  api.out "<br><center><table width=90% cellpadding=5>"
@@ -378,7 +378,7 @@ module Livetext::Standard
378
378
  api.optional_blank_line
379
379
  end
380
380
 
381
- def image
381
+ def image(args = nil, body = nil)
382
382
  name, wide, high = api.args
383
383
  geom = ""
384
384
  geom = "width=#{wide} height=#{high}" if wide || high
@@ -386,7 +386,7 @@ module Livetext::Standard
386
386
  api.optional_blank_line
387
387
  end
388
388
 
389
- def br
389
+ def br(args = nil, body = nil)
390
390
  num = api.args.first || "1"
391
391
  str = ""
392
392
  num.to_i.times { str << "<br>" }
@@ -394,7 +394,7 @@ module Livetext::Standard
394
394
  api.optional_blank_line
395
395
  end
396
396
 
397
- def reflection # strictly experimental!
397
+ def reflection(args = nil, body = nil) # strictly experimental!
398
398
  list = self.methods
399
399
  obj = Object.instance_methods
400
400
  diff = (list - obj).sort
@@ -2,5 +2,5 @@
2
2
  # Defining VERSION
3
3
 
4
4
  class Livetext
5
- VERSION = "0.9.36"
5
+ VERSION = "0.9.37"
6
6
  end
data/plugin/bookish.rb CHANGED
@@ -15,9 +15,12 @@ end
15
15
 
16
16
  # These are duplicated. Remove safely
17
17
 
18
- def h1; api.out "<h1>#{api.data}</h1>"; api.optional_blank_line; end
19
- def h2; api.out "<h2>#{api.data}</h2>"; api.optional_blank_line; end
20
- def h3; api.out "<h3>#{api.data}</h3>"; api.optional_blank_line; end
18
+ def h1(args = nil, body = nil); api.out html.tag(:h1, api.data); return true; end
19
+ def h2(args = nil, body = nil); api.out html.tag(:h2, api.data); return true; end
20
+ def h3(args = nil, body = nil); api.out html.tag(:h3, api.data); return true; end
21
+ def h4(args = nil, body = nil); api.out html.tag(:h4, api.data); return true; end
22
+ def h5(args = nil, body = nil); api.out html.tag(:h5, api.data); return true; end
23
+ def h6(args = nil, body = nil); api.out html.tag(:h6, api.data); return true; end
21
24
 
22
25
  def alpha_columns(args = nil, body = nil)
23
26
  n = api.args.first.to_i # FIXME: what if it's missing?
@@ -71,7 +74,7 @@ def figure(args = nil, body = nil)
71
74
  api.optional_blank_line
72
75
  end
73
76
 
74
- def chapter(args = nil, body = nil)
77
+ def xchapterN(args = nil, body = nil)
75
78
  @chapter = api.args.first.to_i
76
79
  @sec = @sec2 = 0
77
80
  title = api.data.split(" ",2)[1]
@@ -81,13 +84,12 @@ def chapter(args = nil, body = nil)
81
84
  api.out "<title>#{@chapter}. #{title}</title>"
82
85
  api.out <<-HTML
83
86
  <h2>Chapter #{@chapter}</h2>
84
- <h1>#{title}</h1>
85
-
87
+ <h1>#{title}</h1>\n
86
88
  HTML
87
89
  api.optional_blank_line
88
90
  end
89
91
 
90
- def chapterN(args = nil, body = nil)
92
+ def chapter(args = nil, body = nil)
91
93
  @chapter += 1
92
94
  @sec = @sec2 = 0
93
95
  title = api.data # .split(" ",2)[1]
@@ -98,8 +100,7 @@ def chapterN(args = nil, body = nil)
98
100
  api.out "<title>#{@chapter}. #{title}</title>"
99
101
  api.out <<-HTML
100
102
  <h2>Chapter #{@chapter}</h2>
101
- <h1>#{title}</h1>
102
-
103
+ <h1>#{title}</h1>\n
103
104
  HTML
104
105
  api.optional_blank_line
105
106
  end
@@ -115,8 +116,8 @@ def sec(args = nil, body = nil)
115
116
  api.out "<h3>#@section #{title}</h3>\n"
116
117
  api.optional_blank_line
117
118
  rescue => err
118
- api.tty "#{err}\n#{err.backtrace}"
119
- ::STDERR.puts "#{err}\n#{err.backtrace}"
119
+ api.tty "#{err}\n#{err.backtrace.join("\n")}"
120
+ ::STDERR.puts "#{err}\n#{err.backtrace.join("\n")}"
120
121
  exit
121
122
  end
122
123
 
@@ -296,22 +297,22 @@ rescue => err
296
297
  end
297
298
 
298
299
  def init_bookish
300
+ @_file_num = 0
299
301
  @toc_file = "toc.tmp"
300
302
  @toc = ::File.new(@toc_file, "w")
301
303
  @chapter = -1
302
304
  end
303
305
 
304
- ################### custom.rb
306
+ ###########
305
307
 
306
-
307
- def outdir
308
+ def outdir(args = nil, body = nil)
308
309
  @_outdir = api.args.first
309
310
  # @output = STDOUT
310
311
  @output = nil
311
312
  api.optional_blank_line
312
313
  end
313
314
 
314
- def outdir! # FIXME ?
315
+ def outdir!(args = nil, body = nil) # FIXME ?
315
316
  @_outdir = api.args.first
316
317
  raise "No output directory specified" if @_outdir.nil?
317
318
  raise "No output directory specified" if @_outdir.empty?
@@ -327,12 +328,12 @@ def _append(name)
327
328
  end
328
329
 
329
330
 
330
- def append
331
+ def append(args = nil, body = nil)
331
332
  file = api.args[0]
332
333
  _append(file)
333
334
  end
334
335
 
335
- def close_output
336
+ def close_output(args = nil, body = nil)
336
337
  return if @output == STDOUT
337
338
  @_outdir ||= "."
338
339
  @output.puts "<meta charset='UTF-8'>\n\n"
@@ -343,16 +344,19 @@ def close_output
343
344
  end
344
345
 
345
346
  def _prep_next_output(args)
346
- tag, num = args # _next_output(tag, num)
347
- @_file_num = num ? num : @_file_num + 1
348
- @_file_num = @_file_num.to_i
349
- name = "#{'%03d' % @_file_num}-#{tag}.html"
350
- api.tty "tag, num, name= #{[tag, num, name].inspect}"
351
- name
352
- end
353
-
354
- def next_output
355
- name = _prep_next_output(api.args)
347
+ *title = args # _next_output(tag, num)
348
+ title = title.join(" ")
349
+ slug = _slug(title)
350
+ api.tty "title = #{title.inspect}"
351
+ @_file_num += 1
352
+ fname = "#{'%03d' % @_file_num}-#{slug}.html"
353
+ api.tty "slug, fnum, fname= #{[slug, @_file_num, fname].inspect}"
354
+ fname
355
+ end
356
+
357
+ def next_output(args = nil, body = nil)
358
+ args ||= api.args
359
+ fname = _prep_next_output(args)
356
360
  @_outdir ||= "."
357
361
  unless @output.nil?
358
362
  @output.puts "<meta charset='UTF-8'>\n\n"
@@ -360,12 +364,12 @@ def next_output
360
364
  @parent.body = ""
361
365
  @output.close unless @output == STDOUT
362
366
  end
363
- fname = @_outdir + "/" + name
367
+ fname = @_outdir + "/" + fname
364
368
  @output = File.open(fname, "w")
365
369
  api.optional_blank_line
366
370
  end
367
371
 
368
- def output
372
+ def output(args = nil, body = nil)
369
373
  name = api.args.first
370
374
  _debug "Redirecting output to: #{name}"
371
375
  # _output(name)
@@ -378,7 +382,7 @@ def output
378
382
  @output = File.open(fname, "w") #; STDERR.puts "---- @out = #{@output.inspect}"
379
383
  end
380
384
 
381
- def columns
385
+ def columns(args = nil, body = nil)
382
386
  api.out "<table border=1><tr><td valign=top><br>\n"
383
387
  api.body.to_a.each do |line|
384
388
  if line.start_with?("##col")
@@ -392,7 +396,7 @@ def columns
392
396
  api.out "<br>\n</td></tr></table>"
393
397
  end
394
398
 
395
- def quote
399
+ def quote(args = nil, body = nil)
396
400
  api.out "<blockquote>"
397
401
  lines = api.body.to_a
398
402
  # STDERR.puts "-----------------------------------------------------"
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.36
4
+ version: 0.9.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-08 00:00:00.000000000 Z
11
+ date: 2023-03-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A smart text processor extensible in Ruby
14
14
  email: rubyhacker@gmail.com