livetext 0.9.33 → 0.9.35
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/imports/bookish.rb +5 -1
- data/lib/livetext/html.rb +37 -35
- data/lib/livetext/more.rb +4 -0
- data/lib/livetext/processor.rb +2 -0
- data/lib/livetext/standard.rb +11 -9
- data/lib/livetext/userapi.rb +4 -0
- data/lib/livetext/version.rb +1 -1
- data/plugin/bookish.rb +118 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb4392b3c99d41bf20385de2f5cbb25846fb9193ab303072075d0baf904912d2
|
4
|
+
data.tar.gz: b7fb45dd41a63f9c2cf39afa6e8973f53a8828c1063a341ad8ecd78eb4468f96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06e2d46af57bb812baecb5afcc30147abc862df4c4a0619f0151b3b2e6db3c78d7ef7f05eb8cab1e388a7efd73d7ca67ac2143fb5fb901f0b5abcf233b9dcb86
|
7
|
+
data.tar.gz: 0575eaf1bcf527c19ba6ea7ecf7d28b36c6f4dab8b4b81a57185bb9454452af4127bf60dea9a8d15039f29a7919ad7930a99e8aacf6f74ad4f55554bb9ade072
|
data/imports/bookish.rb
CHANGED
@@ -98,14 +98,18 @@ module Bookish
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def sec(args = nil, body = nil)
|
101
|
+
api.tty "## sec: cp 1"
|
101
102
|
@sec += 1
|
102
103
|
@sec2 = 0
|
103
104
|
@section = "#@chapter.#@sec"
|
105
|
+
api.tty "## sec: cp 2"
|
104
106
|
title = api.data.dup
|
105
107
|
@toc << "#{_nbsp(3)}<b>#@section</b> #{title}<br>"
|
106
|
-
api.data = _slug(
|
108
|
+
api.data = _slug(title)
|
109
|
+
api.tty "## sec: cp 3"
|
107
110
|
next_output
|
108
111
|
api.out "<h3>#@section #{title}</h3>\n"
|
112
|
+
api.tty "## sec: cp 4"
|
109
113
|
rescue => err
|
110
114
|
::STDERR.puts "#{err}\n#{err.backtrace}"
|
111
115
|
exit
|
data/lib/livetext/html.rb
CHANGED
@@ -1,43 +1,48 @@
|
|
1
1
|
|
2
|
-
module HTMLHelper
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
2
|
+
# module HTMLHelper
|
3
|
+
#
|
4
|
+
# def wrapped(str, *tags) # helper
|
5
|
+
# open, close = open_close_tags(*tags)
|
6
|
+
# open + str + close
|
7
|
+
# end
|
8
|
+
#
|
9
|
+
# def wrapped!(str, tag, **extras) # helper
|
10
|
+
# open, close = open_close_tags(tag)
|
11
|
+
# extras.each_pair do |name, value|
|
12
|
+
# open.sub!(">", " #{name}='#{value}'>")
|
13
|
+
# end
|
14
|
+
# open + str + close
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# def wrap(*tags) # helper
|
18
|
+
# open, close = open_close_tags(*tags)
|
19
|
+
# api.out open
|
20
|
+
# yield
|
21
|
+
# api.out close
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# def open_close_tags(*tags)
|
25
|
+
# open, close = "", ""
|
26
|
+
# tags.each do |tag|
|
27
|
+
# open << "<#{tag}>"
|
28
|
+
# close.prepend("</#{tag}>")
|
29
|
+
# end
|
30
|
+
# [open, close]
|
31
|
+
# end
|
32
|
+
# end
|
33
33
|
|
34
34
|
class HTML
|
35
35
|
|
36
36
|
def initialize(api)
|
37
|
+
raise "API is nil!" unless api
|
37
38
|
@api = api
|
38
39
|
@indent = 0
|
39
40
|
end
|
40
41
|
|
42
|
+
def api
|
43
|
+
@api
|
44
|
+
end
|
45
|
+
|
41
46
|
def indented
|
42
47
|
" "*@indent
|
43
48
|
end
|
@@ -69,10 +74,6 @@ class HTML
|
|
69
74
|
wrap(:li, **details, &block)
|
70
75
|
end
|
71
76
|
|
72
|
-
def api
|
73
|
-
@api
|
74
|
-
end
|
75
|
-
|
76
77
|
def open_close_tags(*tags)
|
77
78
|
open, close = "", ""
|
78
79
|
tags.each do |tag|
|
@@ -87,6 +88,7 @@ class HTML
|
|
87
88
|
extras.each_pair do |name, value|
|
88
89
|
open.sub!(">", " #{name}='#{value}'>")
|
89
90
|
end
|
91
|
+
# STDERR.puts "#wrap - @api = #{@api.inspect}\n-----------"
|
90
92
|
api.out indented + open
|
91
93
|
indent(:in)
|
92
94
|
yield
|
data/lib/livetext/more.rb
CHANGED
data/lib/livetext/processor.rb
CHANGED
data/lib/livetext/standard.rb
CHANGED
@@ -14,7 +14,7 @@ make_exception(:FileNotFound, "Error: file '%1' not found")
|
|
14
14
|
|
15
15
|
module Livetext::Standard
|
16
16
|
|
17
|
-
|
17
|
+
# include HTMLHelper
|
18
18
|
include Livetext::Helpers
|
19
19
|
|
20
20
|
TTY = ::File.open("/dev/tty", "w")
|
@@ -82,14 +82,14 @@ module Livetext::Standard
|
|
82
82
|
def h6; api.out wrapped(api.data, :h6); return true; end
|
83
83
|
|
84
84
|
def list
|
85
|
-
wrap :ul do
|
85
|
+
html.wrap :ul do
|
86
86
|
api.body {|line| api.out wrapped(line, :li) }
|
87
87
|
end
|
88
88
|
api.optional_blank_line
|
89
89
|
end
|
90
90
|
|
91
91
|
def list!
|
92
|
-
wrap(:ul) do
|
92
|
+
html.wrap(:ul) do
|
93
93
|
lines = api.body.each # enumerator
|
94
94
|
loop do
|
95
95
|
line = lines.next
|
@@ -281,7 +281,7 @@ module Livetext::Standard
|
|
281
281
|
end
|
282
282
|
|
283
283
|
def debug
|
284
|
-
self.
|
284
|
+
self.debug = onoff(api.args.first)
|
285
285
|
api.optional_blank_line
|
286
286
|
end
|
287
287
|
|
@@ -321,7 +321,7 @@ module Livetext::Standard
|
|
321
321
|
end
|
322
322
|
|
323
323
|
def mono
|
324
|
-
wrap ":pre" do
|
324
|
+
html.wrap ":pre" do
|
325
325
|
api.body(true) {|line| api.out line }
|
326
326
|
end
|
327
327
|
api.optional_blank_line
|
@@ -329,7 +329,7 @@ module Livetext::Standard
|
|
329
329
|
|
330
330
|
def dlist
|
331
331
|
delim = api.args.first
|
332
|
-
wrap(:dl) do
|
332
|
+
html.wrap(:dl) do
|
333
333
|
api.body do |line|
|
334
334
|
line = api.format(line)
|
335
335
|
term, defn = line.split(delim)
|
@@ -369,7 +369,7 @@ module Livetext::Standard
|
|
369
369
|
|
370
370
|
processed.each do |line|
|
371
371
|
cells = line.split(delim)
|
372
|
-
wrap :tr do
|
372
|
+
html.wrap :tr do
|
373
373
|
cells.each {|cell| api.out " <td valign=top>#{cell}</td>" }
|
374
374
|
end
|
375
375
|
end
|
@@ -378,8 +378,10 @@ module Livetext::Standard
|
|
378
378
|
end
|
379
379
|
|
380
380
|
def image
|
381
|
-
name = api.args
|
382
|
-
|
381
|
+
name, wide, high = api.args
|
382
|
+
geom = ""
|
383
|
+
geom = "width=#{wide} height=#{high}" if wide || high
|
384
|
+
api.out "<img src='#{name} #{geom}'></img>"
|
383
385
|
api.optional_blank_line
|
384
386
|
end
|
385
387
|
|
data/lib/livetext/userapi.rb
CHANGED
@@ -5,6 +5,8 @@ require_relative 'html'
|
|
5
5
|
|
6
6
|
class Livetext::UserAPI
|
7
7
|
|
8
|
+
include ::Livetext::Standard
|
9
|
+
|
8
10
|
KBD = File.new("/dev/tty", "r")
|
9
11
|
TTY = File.new("/dev/tty", "w")
|
10
12
|
|
@@ -33,6 +35,8 @@ class Livetext::UserAPI
|
|
33
35
|
|
34
36
|
def include_file(file)
|
35
37
|
api.data = file
|
38
|
+
api.args = [file]
|
39
|
+
STDERR.puts "incfile: #{api.methods.sort.inspect}\n "
|
36
40
|
api.dot_include
|
37
41
|
end
|
38
42
|
|
data/lib/livetext/version.rb
CHANGED
data/plugin/bookish.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
def hardbreaks(args = nil, body = nil)
|
2
2
|
@hard = false
|
3
3
|
@hard = true unless api.args.first == "off"
|
4
|
+
api.optional_blank_line
|
4
5
|
end
|
5
6
|
|
6
7
|
def hardbreaks?
|
@@ -9,13 +10,14 @@ end
|
|
9
10
|
|
10
11
|
def credit(args = nil, body = nil)
|
11
12
|
# really just a place marker in source
|
13
|
+
api.optional_blank_line
|
12
14
|
end
|
13
15
|
|
14
16
|
# These are duplicated. Remove safely
|
15
17
|
|
16
|
-
def h1; api.out "<h1>#{api.data}</h1>"; end
|
17
|
-
def h2; api.out "<h2>#{api.data}</h2>"; end
|
18
|
-
def h3; api.out "<h3>#{api.data}</h3>"; end
|
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
|
19
21
|
|
20
22
|
def alpha_columns(args = nil, body = nil)
|
21
23
|
n = api.args.first.to_i # FIXME: what if it's missing?
|
@@ -30,6 +32,7 @@ def alpha_columns(args = nil, body = nil)
|
|
30
32
|
api.out "<tr><td width=5% valign=top></td><td>" + items.join("</td><td>") + "</td></tr>"
|
31
33
|
end
|
32
34
|
api.out "</table>"
|
35
|
+
api.optional_blank_line
|
33
36
|
end
|
34
37
|
|
35
38
|
# def comment
|
@@ -55,6 +58,7 @@ end
|
|
55
58
|
def image(args = nil, body = nil)
|
56
59
|
name = api.args[0]
|
57
60
|
api.out "<img src='#{name}'></img>"
|
61
|
+
api.optional_blank_line
|
58
62
|
end
|
59
63
|
|
60
64
|
def figure(args = nil, body = nil)
|
@@ -64,6 +68,7 @@ def figure(args = nil, body = nil)
|
|
64
68
|
title = api.format(title)
|
65
69
|
api.out "<img src='#{name}'></img>"
|
66
70
|
api.out "<center><b>Figure #{num}</b> #{title}</center>"
|
71
|
+
api.optional_blank_line
|
67
72
|
end
|
68
73
|
|
69
74
|
def chapter(args = nil, body = nil)
|
@@ -79,6 +84,7 @@ def chapter(args = nil, body = nil)
|
|
79
84
|
<h1>#{title}</h1>
|
80
85
|
|
81
86
|
HTML
|
87
|
+
api.optional_blank_line
|
82
88
|
end
|
83
89
|
|
84
90
|
def chapterN(args = nil, body = nil)
|
@@ -95,6 +101,7 @@ def chapterN(args = nil, body = nil)
|
|
95
101
|
<h1>#{title}</h1>
|
96
102
|
|
97
103
|
HTML
|
104
|
+
api.optional_blank_line
|
98
105
|
end
|
99
106
|
|
100
107
|
def sec(args = nil, body = nil)
|
@@ -106,7 +113,9 @@ def sec(args = nil, body = nil)
|
|
106
113
|
api.data = _slug(api.data)
|
107
114
|
next_output
|
108
115
|
api.out "<h3>#@section #{title}</h3>\n"
|
116
|
+
api.optional_blank_line
|
109
117
|
rescue => err
|
118
|
+
api.tty "#{err}\n#{err.backtrace}"
|
110
119
|
::STDERR.puts "#{err}\n#{err.backtrace}"
|
111
120
|
exit
|
112
121
|
end
|
@@ -119,6 +128,7 @@ def subsec(args = nil, body = nil)
|
|
119
128
|
api.data = _slug(api.data)
|
120
129
|
next_output
|
121
130
|
api.out "<h3>#@subsec #{title}</h3>\n"
|
131
|
+
api.optional_blank_line
|
122
132
|
end
|
123
133
|
|
124
134
|
def definition_table(args = nil, body = nil)
|
@@ -234,6 +244,7 @@ end
|
|
234
244
|
def toc!(args = nil, body = nil)
|
235
245
|
_debug "Closing TOC"
|
236
246
|
@toc.close
|
247
|
+
api.optional_blank_line
|
237
248
|
rescue => err
|
238
249
|
puts @parent.body
|
239
250
|
@parent.body = ""
|
@@ -251,29 +262,34 @@ def toc2(args = nil, body = nil)
|
|
251
262
|
|
252
263
|
EOS
|
253
264
|
system("cat toc.tmp >>#{file}")
|
265
|
+
api.optional_blank_line
|
254
266
|
end
|
255
267
|
|
256
268
|
def missing(args = nil, body = nil)
|
257
269
|
@toc << "#{_nbsp(8)}<font color=red>TBD: #{api.data}</font><br>"
|
258
270
|
stuff = api.data.empty? ? "" : ": #{api.data}"
|
259
271
|
api.out "<br><font color=red><i>[Material missing#{stuff}]</i></font><br>\n "
|
272
|
+
api.optional_blank_line
|
260
273
|
end
|
261
274
|
|
262
275
|
def TBC(args = nil, body = nil)
|
263
276
|
@toc << "#{_nbsp(8)}<font color=red>To be continued...</font><br>"
|
264
277
|
api.out "<br><font color=red><i>To be continued...</i></font><br>"
|
278
|
+
api.optional_blank_line
|
265
279
|
end
|
266
280
|
|
267
281
|
def note(args = nil, body = nil)
|
268
282
|
api.out "<br><font color=red><i>Note: "
|
269
283
|
api.out api.data
|
270
284
|
api.out "</i></font><br>\n "
|
285
|
+
api.optional_blank_line
|
271
286
|
end
|
272
287
|
|
273
288
|
def quote(args = nil, body = nil)
|
274
289
|
api.out "<blockquote>"
|
275
290
|
api.body {|line| api.out line }
|
276
291
|
api.out "</blockquote>"
|
292
|
+
api.optional_blank_line
|
277
293
|
rescue => err
|
278
294
|
::STDERR.puts "#{err}\n#{err.backtrace}"
|
279
295
|
exit
|
@@ -285,3 +301,102 @@ def init_bookish
|
|
285
301
|
@chapter = -1
|
286
302
|
end
|
287
303
|
|
304
|
+
################### custom.rb
|
305
|
+
|
306
|
+
|
307
|
+
def outdir
|
308
|
+
@_outdir = api.args.first
|
309
|
+
# @output = STDOUT
|
310
|
+
@output = nil
|
311
|
+
api.optional_blank_line
|
312
|
+
end
|
313
|
+
|
314
|
+
def outdir! # FIXME ?
|
315
|
+
@_outdir = api.args.first
|
316
|
+
raise "No output directory specified" if @_outdir.nil?
|
317
|
+
raise "No output directory specified" if @_outdir.empty?
|
318
|
+
system("rm -f #@_outdir/*.html")
|
319
|
+
api.optional_blank_line
|
320
|
+
end
|
321
|
+
|
322
|
+
def _append(name)
|
323
|
+
@_outdir ||= "."
|
324
|
+
@output.close unless @output == STDOUT
|
325
|
+
@output = File.open(@_outdir + "/" + name, "a")
|
326
|
+
@output.puts "<meta charset='UTF-8'>\n\n"
|
327
|
+
end
|
328
|
+
|
329
|
+
|
330
|
+
def append
|
331
|
+
file = api.args[0]
|
332
|
+
_append(file)
|
333
|
+
end
|
334
|
+
|
335
|
+
def close_output
|
336
|
+
return if @output == STDOUT
|
337
|
+
@_outdir ||= "."
|
338
|
+
@output.puts "<meta charset='UTF-8'>\n\n"
|
339
|
+
@output.puts @parent.body
|
340
|
+
@output.close
|
341
|
+
@parent.body = "" # See bin/livetext
|
342
|
+
@output = STDOUT
|
343
|
+
end
|
344
|
+
|
345
|
+
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)
|
356
|
+
@_outdir ||= "."
|
357
|
+
unless @output.nil?
|
358
|
+
@output.puts "<meta charset='UTF-8'>\n\n"
|
359
|
+
@output.puts @parent.body
|
360
|
+
@parent.body = ""
|
361
|
+
@output.close unless @output == STDOUT
|
362
|
+
end
|
363
|
+
fname = @_outdir + "/" + name
|
364
|
+
@output = File.open(fname, "w")
|
365
|
+
api.optional_blank_line
|
366
|
+
end
|
367
|
+
|
368
|
+
def output
|
369
|
+
name = api.args.first
|
370
|
+
_debug "Redirecting output to: #{name}"
|
371
|
+
# _output(name)
|
372
|
+
@_outdir ||= "." # FIXME
|
373
|
+
@output.puts "<meta charset='UTF-8'>\n\n"
|
374
|
+
@output.puts @parent.body
|
375
|
+
@parent.body = ""
|
376
|
+
@output.close unless @output == STDOUT
|
377
|
+
fname = @_outdir + "/" + name #; STDERR.puts "--- _output: fname = #{fname.inspect}"
|
378
|
+
@output = File.open(fname, "w") #; STDERR.puts "---- @out = #{@output.inspect}"
|
379
|
+
end
|
380
|
+
|
381
|
+
def columns
|
382
|
+
api.out "<table border=1><tr><td valign=top><br>\n"
|
383
|
+
api.body.to_a.each do |line|
|
384
|
+
if line.start_with?("##col")
|
385
|
+
api.out "</td><td valign=top>"
|
386
|
+
elsif line.start_with?("##row")
|
387
|
+
api.out "</td></tr><tr><td valign=top>"
|
388
|
+
else
|
389
|
+
api.out line
|
390
|
+
end
|
391
|
+
end
|
392
|
+
api.out "<br>\n</td></tr></table>"
|
393
|
+
end
|
394
|
+
|
395
|
+
def quote
|
396
|
+
api.out "<blockquote>"
|
397
|
+
lines = api.body.to_a
|
398
|
+
# STDERR.puts "-----------------------------------------------------"
|
399
|
+
# STDERR.puts lines.inspect
|
400
|
+
lines.each {|line| api.out line }
|
401
|
+
api.out "</blockquote>"
|
402
|
+
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.35
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hal Fulton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A smart text processor extensible in Ruby
|
14
14
|
email: rubyhacker@gmail.com
|