livetext 0.9.32 → 0.9.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/livetext +1 -1
- data/imports/bookish.rb +5 -1
- data/lib/livetext/formatter.rb +0 -20
- data/lib/livetext/html.rb +37 -35
- data/lib/livetext/more.rb +13 -1
- data/lib/livetext/processor.rb +2 -0
- data/lib/livetext/standard.rb +12 -12
- data/lib/livetext/userapi.rb +19 -1
- 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/bin/livetext
CHANGED
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/formatter.rb
CHANGED
@@ -41,7 +41,6 @@ module Formatter
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def grab_terminator
|
44
|
-
status("** grabterm 0")
|
45
44
|
@state = :LOOPING
|
46
45
|
# goes onto buffer by default
|
47
46
|
# Don't? what if searching for space_marker?
|
@@ -73,7 +72,6 @@ module Formatter
|
|
73
72
|
end
|
74
73
|
|
75
74
|
def wrap(text)
|
76
|
-
status("** wrap 0")
|
77
75
|
if text.empty?
|
78
76
|
result = @marker
|
79
77
|
result = "" if @marker[1] == "["
|
@@ -83,60 +81,45 @@ module Formatter
|
|
83
81
|
end
|
84
82
|
|
85
83
|
def initial
|
86
|
-
status("** init 0")
|
87
84
|
n = @marker.length
|
88
85
|
case
|
89
86
|
when escape?
|
90
|
-
status("** esc i0")
|
91
87
|
grab # backslash
|
92
|
-
status("** esc i1")
|
93
88
|
@buffer << grab # char
|
94
|
-
status("** esc i2")
|
95
89
|
when space_marker?
|
96
|
-
status("** init 1")
|
97
90
|
@buffer << grab # append the space
|
98
91
|
grab(n) # eat the marker
|
99
92
|
@state = :CDATA
|
100
93
|
when marker?
|
101
|
-
status("** init 2")
|
102
94
|
grab(n) # Eat the marker
|
103
95
|
@state = :CDATA
|
104
96
|
when eol?
|
105
|
-
status("** init 3")
|
106
97
|
@state = :FINAL
|
107
98
|
else
|
108
|
-
status("** init 4")
|
109
99
|
@state = :BUFFER
|
110
100
|
end
|
111
101
|
end
|
112
102
|
|
113
103
|
def buffer
|
114
|
-
status("** buffer 0")
|
115
104
|
@buffer << grab
|
116
105
|
@state = :LOOPING
|
117
106
|
end
|
118
107
|
|
119
108
|
def cdata
|
120
|
-
status("** cdata 0")
|
121
109
|
case
|
122
110
|
when eol?
|
123
|
-
status("** cdata 1")
|
124
111
|
if @cdata.empty?
|
125
|
-
status("** cdata 2")
|
126
112
|
@buffer << @marker unless @marker[1] == "["
|
127
113
|
else
|
128
|
-
status("** cdata 3")
|
129
114
|
@buffer << wrap(@cdata)
|
130
115
|
end
|
131
116
|
@state = :FINAL
|
132
117
|
when terminated?
|
133
|
-
status("** cdata 4")
|
134
118
|
@buffer << wrap(@cdata)
|
135
119
|
grab_terminator # "*a *b" case???
|
136
120
|
@cdata = ""
|
137
121
|
@state = :LOOPING
|
138
122
|
else
|
139
|
-
status("** cdata 5")
|
140
123
|
@cdata << grab
|
141
124
|
@state = :CDATA
|
142
125
|
end
|
@@ -146,11 +129,8 @@ module Formatter
|
|
146
129
|
n = @marker.length
|
147
130
|
case
|
148
131
|
when escape?
|
149
|
-
status("** esc l0")
|
150
132
|
grab # backslash
|
151
|
-
status("** esc l1")
|
152
133
|
@buffer << grab # char
|
153
|
-
status("** esc l2")
|
154
134
|
when space_marker?
|
155
135
|
@buffer << grab # append the space
|
156
136
|
grab(n) # eat the marker
|
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
@@ -7,6 +7,7 @@ class Livetext
|
|
7
7
|
|
8
8
|
class Variables
|
9
9
|
attr_reader :vars
|
10
|
+
|
10
11
|
def initialize(hash = {})
|
11
12
|
@vars = {}
|
12
13
|
hash.each_pair {|k, v| @vars[k.to_sym] = v }
|
@@ -34,6 +35,10 @@ class Livetext
|
|
34
35
|
api.setvar(var, value)
|
35
36
|
end
|
36
37
|
end
|
38
|
+
|
39
|
+
def to_a
|
40
|
+
@vars.to_a
|
41
|
+
end
|
37
42
|
end
|
38
43
|
|
39
44
|
Vars = Variables.new
|
@@ -95,7 +100,10 @@ class Livetext
|
|
95
100
|
obj = self.new
|
96
101
|
mix = Array(mix)
|
97
102
|
call = Array(call)
|
98
|
-
|
103
|
+
# STDERR.puts "#{__method__}: obj meth = #{obj.methods.sort.inspect}"
|
104
|
+
mix.each do |lib|
|
105
|
+
obj.invoke_dotcmd(:mixin, lib.dup)
|
106
|
+
end
|
99
107
|
call.each {|cmd| obj.main.send(cmd[1..-1]) } # ignores leading dot, no param
|
100
108
|
# vars.each_pair {|var, val| obj.setvar(var, val.to_s) }
|
101
109
|
obj.api.setvars(vars)
|
@@ -130,6 +138,10 @@ class Livetext
|
|
130
138
|
@api
|
131
139
|
end
|
132
140
|
|
141
|
+
def api=(obj)
|
142
|
+
@api = obj
|
143
|
+
end
|
144
|
+
|
133
145
|
def initial_vars
|
134
146
|
# Other predefined variables (see also setfile)
|
135
147
|
@api.setvar(:User, `whoami`.chomp)
|
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
|
@@ -173,7 +173,6 @@ module Livetext::Standard
|
|
173
173
|
lines = api.body
|
174
174
|
end
|
175
175
|
pairs = Livetext::ParseGeneral.parse_vars(lines, prefix: nil)
|
176
|
-
STDERR.puts "! pairs = #{pairs.inspect}"
|
177
176
|
api.setvars(pairs)
|
178
177
|
api.optional_blank_line
|
179
178
|
end
|
@@ -189,7 +188,6 @@ STDERR.puts "! pairs = #{pairs.inspect}"
|
|
189
188
|
lines = api.body
|
190
189
|
end
|
191
190
|
pairs = Livetext::ParseGeneral.parse_vars(lines, prefix: nil)
|
192
|
-
STDERR.puts "pairs = #{pairs.inspect}"
|
193
191
|
api.setvars(pairs)
|
194
192
|
api.optional_blank_line
|
195
193
|
end
|
@@ -217,7 +215,7 @@ STDERR.puts "pairs = #{pairs.inspect}"
|
|
217
215
|
end
|
218
216
|
|
219
217
|
def dot_include # dot command
|
220
|
-
file = api.
|
218
|
+
file = api.expand_variables(api.args.first) # allows for variables
|
221
219
|
check_file_exists(file)
|
222
220
|
@parent.process_file(file)
|
223
221
|
api.optional_blank_line
|
@@ -283,7 +281,7 @@ STDERR.puts "pairs = #{pairs.inspect}"
|
|
283
281
|
end
|
284
282
|
|
285
283
|
def debug
|
286
|
-
self.
|
284
|
+
self.debug = onoff(api.args.first)
|
287
285
|
api.optional_blank_line
|
288
286
|
end
|
289
287
|
|
@@ -323,7 +321,7 @@ STDERR.puts "pairs = #{pairs.inspect}"
|
|
323
321
|
end
|
324
322
|
|
325
323
|
def mono
|
326
|
-
wrap ":pre" do
|
324
|
+
html.wrap ":pre" do
|
327
325
|
api.body(true) {|line| api.out line }
|
328
326
|
end
|
329
327
|
api.optional_blank_line
|
@@ -331,7 +329,7 @@ STDERR.puts "pairs = #{pairs.inspect}"
|
|
331
329
|
|
332
330
|
def dlist
|
333
331
|
delim = api.args.first
|
334
|
-
wrap(:dl) do
|
332
|
+
html.wrap(:dl) do
|
335
333
|
api.body do |line|
|
336
334
|
line = api.format(line)
|
337
335
|
term, defn = line.split(delim)
|
@@ -371,7 +369,7 @@ STDERR.puts "pairs = #{pairs.inspect}"
|
|
371
369
|
|
372
370
|
processed.each do |line|
|
373
371
|
cells = line.split(delim)
|
374
|
-
wrap :tr do
|
372
|
+
html.wrap :tr do
|
375
373
|
cells.each {|cell| api.out " <td valign=top>#{cell}</td>" }
|
376
374
|
end
|
377
375
|
end
|
@@ -380,8 +378,10 @@ STDERR.puts "pairs = #{pairs.inspect}"
|
|
380
378
|
end
|
381
379
|
|
382
380
|
def image
|
383
|
-
name = api.args
|
384
|
-
|
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>"
|
385
385
|
api.optional_blank_line
|
386
386
|
end
|
387
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
|
|
@@ -31,12 +33,28 @@ class Livetext::UserAPI
|
|
31
33
|
@live
|
32
34
|
end
|
33
35
|
|
36
|
+
def include_file(file)
|
37
|
+
api.data = file
|
38
|
+
api.args = [file]
|
39
|
+
STDERR.puts "incfile: #{api.methods.sort.inspect}\n "
|
40
|
+
api.dot_include
|
41
|
+
end
|
42
|
+
|
43
|
+
def expand_variables(str)
|
44
|
+
@expander.expand_variables(str)
|
45
|
+
end
|
46
|
+
|
47
|
+
def expand_functions(str)
|
48
|
+
@expander.expand_functions(str)
|
49
|
+
end
|
50
|
+
|
34
51
|
def setvar(var, val) # FIXME
|
35
52
|
@live.vars.set(var, val)
|
36
53
|
end
|
37
54
|
|
38
55
|
def setvars(pairs)
|
39
|
-
pairs = pairs.
|
56
|
+
# STDERR.puts "#{__method__}: pairs = #{pairs.inspect} (#{pairs.class})"
|
57
|
+
pairs = pairs.to_a # could be Hash or Variables
|
40
58
|
pairs.each do |var, value|
|
41
59
|
@live.vars.set(var, value)
|
42
60
|
end
|
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
|