livetext 0.9.14 → 0.9.15
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/lib/cmdargs.rb +93 -0
- data/lib/formatline.rb +56 -83
- data/lib/helpers.rb +142 -4
- data/lib/livetext.rb +11 -141
- data/lib/parser/file.rb +8 -0
- data/lib/parser/mixin.rb +28 -15
- data/lib/parser/set.rb +35 -26
- data/lib/parser/string.rb +19 -4
- data/lib/processor.rb +1 -4
- data/lib/standard.rb +56 -96
- data/plugin/bookish.rb +26 -22
- data/plugin/calibre.rb +1 -1
- data/plugin/livemagick.rb +10 -10
- data/plugin/markdown.rb +13 -11
- data/plugin/pyggish.rb +94 -84
- data/plugin/tutorial.rb +10 -5
- data/test/all.rb +0 -1
- data/test/snapshots/OMIT.txt +7 -8
- data/test/snapshots/clusion.txt +35 -0
- data/test/snapshots/error_inc_line_num/actual-error.txt +14 -0
- data/test/snapshots/error_inc_line_num/actual-output.txt +7 -0
- data/test/snapshots/error_inc_line_num/match-error.txt +1 -1
- data/test/snapshots/error_inc_line_num/out-sdiff.txt +14 -0
- data/test/snapshots/error_invalid_name/actual-error.txt +10 -0
- data/test/snapshots/error_invalid_name/actual-output.txt +0 -0
- data/test/snapshots/error_invalid_name/match-error.txt +1 -1
- data/test/snapshots/error_invalid_name/out-sdiff.txt +6 -0
- data/test/snapshots/error_line_num/match-error.txt +1 -1
- data/test/snapshots/error_mismatched_end/match-error.txt +1 -1
- data/test/snapshots/error_missing_end/actual-error.txt +10 -0
- data/test/snapshots/error_missing_end/actual-output.txt +0 -0
- data/test/snapshots/error_missing_end/match-error.txt +1 -1
- data/test/snapshots/error_missing_end/out-sdiff.txt +6 -0
- data/test/snapshots/error_no_such_copy/actual-error.txt +10 -0
- data/test/snapshots/error_no_such_copy/actual-output.txt +0 -0
- data/test/snapshots/error_no_such_copy/match-error.txt +1 -1
- data/test/snapshots/error_no_such_copy/out-sdiff.txt +5 -0
- data/test/snapshots/error_no_such_copy/source.lt3 +0 -1
- data/test/snapshots/error_no_such_inc/actual-error.txt +10 -0
- data/test/snapshots/error_no_such_inc/actual-output.txt +0 -0
- data/test/snapshots/error_no_such_inc/match-error.txt +1 -1
- data/test/snapshots/error_no_such_inc/out-sdiff.txt +6 -0
- data/test/snapshots/error_no_such_mixin/actual-error.txt +37 -0
- data/test/snapshots/error_no_such_mixin/actual-output.txt +0 -0
- data/test/snapshots/error_no_such_mixin/out-sdiff.txt +6 -0
- data/test/snapshots/simple_import/actual-error.txt +8 -0
- data/test/snapshots/simple_import/actual-output.txt +3 -0
- data/test/snapshots/simple_import/err-sdiff.txt +9 -0
- data/test/snapshots/simple_import/expected-error.txt +0 -0
- data/test/snapshots/simple_import/expected-output.txt +7 -0
- data/test/snapshots/simple_import/out-sdiff.txt +9 -0
- data/test/snapshots/simple_import/simple_import.rb +5 -0
- data/test/snapshots/simple_import/source.lt3 +7 -0
- data/test/snapshots/simple_include/source.lt3 +0 -1
- data/test/snapshots.rb +3 -2
- data/test/unit/all.rb +1 -0
- data/test/unit/formatline.rb +650 -0
- data/test/unit/parser/importable.rb +1 -1
- data/test/unit/parser/mixin.rb +1 -1
- data/test/unit/parser/set.rb +19 -12
- data/test/unit/parser/string.rb +14 -14
- metadata +32 -5
- data/test/formatting-tests.rb +0 -35
- data/test/formatting.rb +0 -103
- data/test/snapshots/formatting-tests.txt +0 -124
data/lib/standard.rb
CHANGED
@@ -5,8 +5,8 @@ require_relative 'html'
|
|
5
5
|
require_relative 'helpers'
|
6
6
|
|
7
7
|
make_exception(:ExpectedOnOff, "Error: expected 'on' or 'off'")
|
8
|
-
make_exception(:DisallowedName, "Error: name %1 is invalid")
|
9
|
-
make_exception(:FileNotFound, "Error: file %1 not found")
|
8
|
+
make_exception(:DisallowedName, "Error: name '%1' is invalid")
|
9
|
+
make_exception(:FileNotFound, "Error: file '%1' not found")
|
10
10
|
|
11
11
|
|
12
12
|
# Module Standard comprises most of the standard or "common" methods.
|
@@ -30,7 +30,8 @@ module Livetext::Standard
|
|
30
30
|
@_mixins = []
|
31
31
|
end
|
32
32
|
|
33
|
-
|
33
|
+
# dumb name - bold, italic, teletype, striketrough
|
34
|
+
def bits(args = nil, body = nil)
|
34
35
|
b0, b1, i0, i1, t0, t1, s0, s1 = *@_args
|
35
36
|
SimpleFormats[:b] = [b0, b1]
|
36
37
|
SimpleFormats[:i] = [i0, i1]
|
@@ -38,23 +39,23 @@ module Livetext::Standard
|
|
38
39
|
SimpleFormats[:s] = [s0, s1]
|
39
40
|
end
|
40
41
|
|
41
|
-
def backtrace
|
42
|
+
def backtrace(args = nil, body = nil)
|
42
43
|
@backtrace = onoff(@_args.first)
|
43
44
|
_optional_blank_line
|
44
45
|
end
|
45
46
|
|
46
|
-
def comment
|
47
|
+
def comment(args = nil, body = nil)
|
47
48
|
_body
|
48
49
|
_optional_blank_line
|
49
50
|
end
|
50
51
|
|
51
|
-
def shell
|
52
|
+
def shell(args = nil, body = nil)
|
52
53
|
cmd = @_data.chomp
|
53
54
|
system(cmd)
|
54
55
|
_optional_blank_line
|
55
56
|
end
|
56
57
|
|
57
|
-
def func
|
58
|
+
def func(args = nil, body = nil)
|
58
59
|
funcname = @_args[0]
|
59
60
|
check_disallowed(funcname)
|
60
61
|
func_def = <<~EOS
|
@@ -63,25 +64,24 @@ module Livetext::Standard
|
|
63
64
|
end
|
64
65
|
EOS
|
65
66
|
_optional_blank_line
|
66
|
-
|
67
67
|
Livetext::Functions.class_eval func_def
|
68
68
|
end
|
69
69
|
|
70
|
-
def h1; _out wrapped(@_data, :h1); end
|
71
|
-
def h2; _out wrapped(@_data, :h2); end
|
72
|
-
def h3; _out wrapped(@_data, :h3); end
|
73
|
-
def h4; _out wrapped(@_data, :h4); end
|
74
|
-
def h5; _out wrapped(@_data, :h5); end
|
75
|
-
def h6; _out wrapped(@_data, :h6); end
|
70
|
+
def h1(args = nil, body = nil); _out wrapped(@_data, :h1); end
|
71
|
+
def h2(args = nil, body = nil); _out wrapped(@_data, :h2); end
|
72
|
+
def h3(args = nil, body = nil); _out wrapped(@_data, :h3); end
|
73
|
+
def h4(args = nil, body = nil); _out wrapped(@_data, :h4); end
|
74
|
+
def h5(args = nil, body = nil); _out wrapped(@_data, :h5); end
|
75
|
+
def h6(args = nil, body = nil); _out wrapped(@_data, :h6); end
|
76
76
|
|
77
|
-
def list
|
77
|
+
def list(args = nil, body = nil)
|
78
78
|
wrap :ul do
|
79
79
|
_body {|line| _out wrapped(line, :li) }
|
80
80
|
end
|
81
81
|
_optional_blank_line
|
82
82
|
end
|
83
83
|
|
84
|
-
def list!
|
84
|
+
def list!(args = nil, body = nil)
|
85
85
|
wrap(:ul) do
|
86
86
|
lines = _body.each # enumerator
|
87
87
|
loop do
|
@@ -94,49 +94,49 @@ module Livetext::Standard
|
|
94
94
|
_optional_blank_line
|
95
95
|
end
|
96
96
|
|
97
|
-
def shell!
|
97
|
+
def shell!(args = nil, body = nil)
|
98
98
|
cmd = @_data.chomp
|
99
99
|
system(cmd)
|
100
100
|
_optional_blank_line
|
101
101
|
end
|
102
102
|
|
103
|
-
def errout
|
103
|
+
def errout(args = nil, body = nil)
|
104
104
|
STDERR.puts @_data.chomp
|
105
105
|
_optional_blank_line
|
106
106
|
end
|
107
107
|
|
108
|
-
def ttyout
|
108
|
+
def ttyout(args = nil, body = nil)
|
109
109
|
TTY.puts @_data.chomp
|
110
110
|
_optional_blank_line
|
111
111
|
end
|
112
112
|
|
113
|
-
def say
|
113
|
+
def say(args = nil, body = nil)
|
114
114
|
str = _format(@_data.chomp)
|
115
115
|
TTY.puts str
|
116
116
|
_optional_blank_line
|
117
117
|
end
|
118
118
|
|
119
|
-
def banner
|
119
|
+
def banner(args = nil, body = nil)
|
120
120
|
str = _format(@_data.chomp)
|
121
121
|
num = str.length - 1
|
122
122
|
decor = "-"*num + "\n"
|
123
123
|
puts decor + str + "\n" + decor
|
124
124
|
end
|
125
125
|
|
126
|
-
def quit
|
126
|
+
def quit(args = nil, body = nil)
|
127
127
|
puts @body
|
128
128
|
@body = ""
|
129
129
|
@output.close
|
130
130
|
end
|
131
131
|
|
132
|
-
def cleanup
|
132
|
+
def cleanup(args = nil, body = nil)
|
133
133
|
@_args.each do |item|
|
134
134
|
cmd = ::File.directory?(item) ? "rm -f #{item}/*" : "rm #{item}"
|
135
135
|
system(cmd)
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
|
-
def
|
139
|
+
def dot_def(args = nil, body = nil)
|
140
140
|
name = @_args[0]
|
141
141
|
str = "def #{name}\n"
|
142
142
|
check_disallowed(name)
|
@@ -144,11 +144,9 @@ module Livetext::Standard
|
|
144
144
|
str << _body(true).join("\n")
|
145
145
|
str << "\nend\n"
|
146
146
|
eval str
|
147
|
-
# rescue => err
|
148
|
-
# _error!(err)
|
149
147
|
end
|
150
148
|
|
151
|
-
def set
|
149
|
+
def set(args = nil, body = nil)
|
152
150
|
line = _data.chomp
|
153
151
|
pairs = Livetext::ParseSet.new(line).parse
|
154
152
|
set_variables(pairs)
|
@@ -156,7 +154,7 @@ module Livetext::Standard
|
|
156
154
|
|
157
155
|
# FIXME really these should be one method...
|
158
156
|
|
159
|
-
def variables! # cwd, not FileDir - weird, fix later
|
157
|
+
def variables!(args = nil, body = nil) # cwd, not FileDir - weird, fix later
|
160
158
|
prefix = _args[0]
|
161
159
|
file = _args[1]
|
162
160
|
prefix = nil if prefix == "-" # FIXME dumb hack
|
@@ -170,7 +168,7 @@ module Livetext::Standard
|
|
170
168
|
set_variables(pairs)
|
171
169
|
end
|
172
170
|
|
173
|
-
def variables
|
171
|
+
def variables(args = nil, body = nil)
|
174
172
|
prefix = _args[0]
|
175
173
|
file = _args[1]
|
176
174
|
prefix = nil if prefix == "-" # FIXME dumb hack
|
@@ -184,7 +182,7 @@ module Livetext::Standard
|
|
184
182
|
set_variables(pairs)
|
185
183
|
end
|
186
184
|
|
187
|
-
def heredoc
|
185
|
+
def heredoc(args = nil, body = nil)
|
188
186
|
var = @_args[0]
|
189
187
|
text = _body.join("\n")
|
190
188
|
rhs = ""
|
@@ -194,52 +192,26 @@ module Livetext::Standard
|
|
194
192
|
end
|
195
193
|
indent = @parent.indentation.last
|
196
194
|
indented = " " * indent
|
197
|
-
@parent.
|
195
|
+
@parent.setvar(var, rhs.chomp)
|
198
196
|
_optional_blank_line
|
199
197
|
end
|
200
198
|
|
201
|
-
def
|
202
|
-
value = nil
|
203
|
-
return file if File.exist?(file)
|
204
|
-
|
205
|
-
count = 1
|
206
|
-
loop do
|
207
|
-
front = "../" * count
|
208
|
-
count += 1
|
209
|
-
here = Pathname.new(front).expand_path.dirname.to_s
|
210
|
-
break if here == "/"
|
211
|
-
path = front + file
|
212
|
-
value = path if File.exist?(path)
|
213
|
-
break if value
|
214
|
-
end
|
215
|
-
STDERR.puts "Cannot find #{file.inspect} from #{Dir.pwd}" unless value
|
216
|
-
return value
|
217
|
-
rescue
|
218
|
-
STDERR.puts "Can't find #{file.inspect} from #{Dir.pwd}"
|
219
|
-
return nil
|
220
|
-
end
|
221
|
-
|
222
|
-
def seek # like include, but search upward as needed
|
199
|
+
def seek(args = nil, body = nil) # like include, but search upward as needed
|
223
200
|
file = @_args.first
|
224
|
-
file =
|
201
|
+
file = search_upward(file)
|
225
202
|
check_file_exists(file)
|
226
203
|
@parent.process_file(file)
|
227
204
|
_optional_blank_line
|
228
205
|
end
|
229
206
|
|
230
|
-
def
|
207
|
+
def dot_include(args = nil, body = nil) # dot command
|
231
208
|
file = _format(@_args.first) # allows for variables
|
232
209
|
check_file_exists(file)
|
233
210
|
@parent.process_file(file)
|
234
211
|
_optional_blank_line
|
235
212
|
end
|
236
213
|
|
237
|
-
def
|
238
|
-
@_args = [file]
|
239
|
-
_include
|
240
|
-
end
|
241
|
-
|
242
|
-
def inherit
|
214
|
+
def inherit(args = nil, body = nil)
|
243
215
|
file = @_args.first
|
244
216
|
upper = "../#{file}"
|
245
217
|
got_upper, got_file = File.exist?(upper), File.exist?(file)
|
@@ -251,95 +223,83 @@ module Livetext::Standard
|
|
251
223
|
_optional_blank_line
|
252
224
|
end
|
253
225
|
|
254
|
-
def mixin
|
226
|
+
def mixin(args = nil, body = nil)
|
255
227
|
name = @_args.first # Expect a module name
|
256
228
|
return if @_mixins.include?(name)
|
257
229
|
@_mixins << name
|
258
|
-
|
259
|
-
|
260
|
-
|
230
|
+
mod = Livetext::ParseMixin.get_module(name) # FIXME??
|
231
|
+
self.extend(mod)
|
232
|
+
init = "init_#{name}"
|
233
|
+
self.send(init) if self.respond_to? init
|
261
234
|
_optional_blank_line
|
262
235
|
end
|
263
236
|
|
264
|
-
def import
|
237
|
+
def import(args = nil, body = nil)
|
265
238
|
name = @_args.first # Expect a module name
|
266
239
|
return if @_mixins.include?(name)
|
267
240
|
@_mixins << name
|
268
|
-
|
241
|
+
mod = Livetext::ParseImport.get_module(name)
|
269
242
|
parse.use_import(name)
|
270
243
|
_optional_blank_line
|
271
244
|
end
|
272
245
|
|
273
|
-
def copy
|
246
|
+
def copy(args = nil, body = nil)
|
274
247
|
file = @_args.first
|
275
248
|
check_file_exists(file)
|
276
249
|
_out grab_file(file)
|
277
250
|
_optional_blank_line
|
278
251
|
end
|
279
252
|
|
280
|
-
def r
|
253
|
+
def r(args = nil, body = nil)
|
281
254
|
_out @_data.chomp # No processing at all
|
282
255
|
end
|
283
256
|
|
284
|
-
def raw
|
257
|
+
def raw(args = nil, body = nil)
|
285
258
|
# No processing at all (terminate with __EOF__)
|
286
259
|
_raw_body {|line| _out line } # no formatting
|
287
260
|
end
|
288
261
|
|
289
|
-
def debug
|
262
|
+
def debug(args = nil, body = nil)
|
290
263
|
self._debug = onoff(@_args.first)
|
291
264
|
end
|
292
265
|
|
293
|
-
def passthru
|
266
|
+
def passthru(args = nil, body = nil)
|
294
267
|
# FIXME - add check for args size? (helpers)
|
295
268
|
@_nopass = ! onoff(_args.first)
|
296
269
|
end
|
297
270
|
|
298
|
-
def nopass
|
271
|
+
def nopass(args = nil, body = nil)
|
299
272
|
@_nopass = true
|
300
273
|
end
|
301
274
|
|
302
|
-
def para
|
275
|
+
def para(args = nil, body = nil)
|
303
276
|
# FIXME - add check for args size? (helpers)
|
304
277
|
@_nopara = ! onoff(_args.first)
|
305
278
|
end
|
306
279
|
|
307
|
-
def
|
308
|
-
arg ||= "on"
|
309
|
-
raise ExpectedOnOff unless String === arg
|
310
|
-
case arg.downcase
|
311
|
-
when "on"
|
312
|
-
return true
|
313
|
-
when "off"
|
314
|
-
return false
|
315
|
-
else
|
316
|
-
raise ExpectedOnOff
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
|
-
def nopara
|
280
|
+
def nopara(args = nil, body = nil)
|
321
281
|
@_nopara = true
|
322
282
|
end
|
323
283
|
|
324
|
-
def heading
|
284
|
+
def heading(args = nil, body = nil)
|
325
285
|
_print "<center><font size=+1><b>"
|
326
286
|
_print @_data.chomp
|
327
287
|
_print "</b></font></center>"
|
328
288
|
end
|
329
289
|
|
330
|
-
def newpage
|
290
|
+
def newpage(args = nil, body = nil)
|
331
291
|
_out '<p style="page-break-after:always;"></p>'
|
332
292
|
_out "<p/>"
|
333
293
|
end
|
334
294
|
|
335
|
-
def mono
|
295
|
+
def mono(args = nil, body = nil)
|
336
296
|
wrap ":pre" do
|
337
297
|
_body(true) {|line| _out line }
|
338
298
|
end
|
339
299
|
_optional_blank_line
|
340
300
|
end
|
341
301
|
|
342
|
-
def dlist
|
302
|
+
def dlist(args = nil, body = nil)
|
343
303
|
delim = _args.first
|
344
304
|
wrap(:dl) do
|
345
305
|
_body do |line|
|
@@ -351,13 +311,13 @@ module Livetext::Standard
|
|
351
311
|
end
|
352
312
|
end
|
353
313
|
|
354
|
-
def link
|
314
|
+
def link(args = nil, body = nil)
|
355
315
|
url = _args.first
|
356
316
|
text = _args[2..-1].join(" ")
|
357
317
|
_out "<a style='text-decoration: none' href='#{url}'>#{text}</a>"
|
358
318
|
end
|
359
319
|
|
360
|
-
def xtable # Borrowed from bookish - FIXME
|
320
|
+
def xtable(args = nil, body = nil) # Borrowed from bookish - FIXME
|
361
321
|
title = @_data.chomp
|
362
322
|
delim = " :: "
|
363
323
|
_out "<br><center><table width=90% cellpadding=5>"
|
@@ -384,12 +344,12 @@ module Livetext::Standard
|
|
384
344
|
_out "</table></center>"
|
385
345
|
end
|
386
346
|
|
387
|
-
def image
|
347
|
+
def image(args = nil, body = nil)
|
388
348
|
name = @_args[0]
|
389
349
|
_out "<img src='#{name}'></img>"
|
390
350
|
end
|
391
351
|
|
392
|
-
def br
|
352
|
+
def br(args = nil, body = nil)
|
393
353
|
num = _args.first || "1"
|
394
354
|
out = ""
|
395
355
|
num.to_i.times { out << "<br>" }
|
data/plugin/bookish.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
def hardbreaks
|
1
|
+
def hardbreaks(args = nil, body = nil)
|
2
2
|
@hard = false
|
3
3
|
@hard = true unless @_args.first == "off"
|
4
4
|
end
|
@@ -7,15 +7,17 @@ def hardbreaks?
|
|
7
7
|
@hard
|
8
8
|
end
|
9
9
|
|
10
|
-
def credit
|
10
|
+
def credit(args = nil, body = nil)
|
11
11
|
# really just a place marker in source
|
12
12
|
end
|
13
13
|
|
14
|
+
# These are duplicated. Remove safely
|
15
|
+
|
14
16
|
def h1; _out "<h1>#{@_data}</h1>"; end
|
15
17
|
def h2; _out "<h2>#{@_data}</h2>"; end
|
16
18
|
def h3; _out "<h3>#{@_data}</h3>"; end
|
17
19
|
|
18
|
-
def alpha_columns
|
20
|
+
def alpha_columns(args = nil, body = nil)
|
19
21
|
n = @_args.first.to_i # FIXME: what if missing?
|
20
22
|
words = []
|
21
23
|
_body do |line|
|
@@ -30,9 +32,9 @@ def alpha_columns
|
|
30
32
|
_out "</table>"
|
31
33
|
end
|
32
34
|
|
33
|
-
def comment
|
34
|
-
|
35
|
-
end
|
35
|
+
# def comment
|
36
|
+
# _body { } # ignore body
|
37
|
+
# end
|
36
38
|
|
37
39
|
def _errout(*args)
|
38
40
|
::STDERR.puts *args
|
@@ -48,12 +50,14 @@ def _slug(str)
|
|
48
50
|
s2
|
49
51
|
end
|
50
52
|
|
51
|
-
|
53
|
+
|
54
|
+
# FIXME duplicated?
|
55
|
+
def image(args = nil, body = nil)
|
52
56
|
name = @_args[0]
|
53
57
|
_out "<img src='#{name}'></img>"
|
54
58
|
end
|
55
59
|
|
56
|
-
def figure
|
60
|
+
def figure(args = nil, body = nil)
|
57
61
|
name = @_args[0]
|
58
62
|
num = @_args[1]
|
59
63
|
title = @_args[2..-1].join(" ")
|
@@ -62,7 +66,7 @@ def figure
|
|
62
66
|
_out "<center><b>Figure #{num}</b> #{title}</center>"
|
63
67
|
end
|
64
68
|
|
65
|
-
def chapter
|
69
|
+
def chapter(args = nil, body = nil)
|
66
70
|
# _errout("chapter")
|
67
71
|
@chapter = @_args.first.to_i
|
68
72
|
@sec = @sec2 = 0
|
@@ -78,7 +82,7 @@ def chapter
|
|
78
82
|
HTML
|
79
83
|
end
|
80
84
|
|
81
|
-
def chapterN
|
85
|
+
def chapterN(args = nil, body = nil)
|
82
86
|
@chapter += 1
|
83
87
|
@sec = @sec2 = 0
|
84
88
|
title = @_data # .split(" ",2)[1]
|
@@ -94,7 +98,7 @@ def chapterN
|
|
94
98
|
HTML
|
95
99
|
end
|
96
100
|
|
97
|
-
def sec
|
101
|
+
def sec(args = nil, body = nil)
|
98
102
|
@sec += 1
|
99
103
|
@sec2 = 0
|
100
104
|
@section = "#@chapter.#@sec"
|
@@ -108,7 +112,7 @@ rescue => err
|
|
108
112
|
exit
|
109
113
|
end
|
110
114
|
|
111
|
-
def subsec
|
115
|
+
def subsec(args = nil, body = nil)
|
112
116
|
@sec2 += 1
|
113
117
|
@subsec = "#@chapter.#@sec.#@sec2"
|
114
118
|
title = @_data.dup
|
@@ -118,7 +122,7 @@ def subsec
|
|
118
122
|
_out "<h3>#@subsec #{title}</h3>\n"
|
119
123
|
end
|
120
124
|
|
121
|
-
def definition_table
|
125
|
+
def definition_table(args = nil, body = nil)
|
122
126
|
title = @_data
|
123
127
|
wide = "95"
|
124
128
|
delim = " :: "
|
@@ -140,7 +144,7 @@ def definition_table
|
|
140
144
|
_optional_blank_line
|
141
145
|
end
|
142
146
|
|
143
|
-
def table2
|
147
|
+
def table2(args = nil, body = nil)
|
144
148
|
title = @_data
|
145
149
|
wide = "90"
|
146
150
|
extra = _args[2]
|
@@ -164,7 +168,7 @@ def table2
|
|
164
168
|
_optional_blank_line
|
165
169
|
end
|
166
170
|
|
167
|
-
def simple_table
|
171
|
+
def simple_table(args = nil, body = nil)
|
168
172
|
title = @_data
|
169
173
|
delim = " :: "
|
170
174
|
_out "<table cellpadding=2>"
|
@@ -193,7 +197,7 @@ def simple_table
|
|
193
197
|
_out "</table>"
|
194
198
|
end
|
195
199
|
|
196
|
-
def table
|
200
|
+
def table(args = nil, body = nil)
|
197
201
|
@table_num ||= 0
|
198
202
|
@table_num += 1
|
199
203
|
title = @_data
|
@@ -227,7 +231,7 @@ def table
|
|
227
231
|
_out "<b>Table #@chapter.#@table_num #{title}</b></center><br>"
|
228
232
|
end
|
229
233
|
|
230
|
-
def toc!
|
234
|
+
def toc!(args = nil, body = nil)
|
231
235
|
_debug "Closing TOC"
|
232
236
|
@toc.close
|
233
237
|
rescue => err
|
@@ -236,7 +240,7 @@ rescue => err
|
|
236
240
|
_errout "Exception: #{err.inspect}"
|
237
241
|
end
|
238
242
|
|
239
|
-
def toc2
|
243
|
+
def toc2(args = nil, body = nil)
|
240
244
|
file = @_args[0]
|
241
245
|
@toc.close
|
242
246
|
::File.write(file, <<-EOS)
|
@@ -249,24 +253,24 @@ EOS
|
|
249
253
|
system("cat toc.tmp >>#{file}")
|
250
254
|
end
|
251
255
|
|
252
|
-
def missing
|
256
|
+
def missing(args = nil, body = nil)
|
253
257
|
@toc << "#{_nbsp(8)}<font color=red>TBD: #@_data</font><br>"
|
254
258
|
stuff = @_data.empty? ? "" : ": #@_data"
|
255
259
|
_out "<br><font color=red><i>[Material missing#{stuff}]</i></font><br>\n "
|
256
260
|
end
|
257
261
|
|
258
|
-
def TBC
|
262
|
+
def TBC(args = nil, body = nil)
|
259
263
|
@toc << "#{_nbsp(8)}<font color=red>To be continued...</font><br>"
|
260
264
|
_out "<br><font color=red><i>To be continued...</i></font><br>"
|
261
265
|
end
|
262
266
|
|
263
|
-
def note
|
267
|
+
def note(args = nil, body = nil)
|
264
268
|
_out "<br><font color=red><i>Note: "
|
265
269
|
_out @_data
|
266
270
|
_out "</i></font><br>\n "
|
267
271
|
end
|
268
272
|
|
269
|
-
def quote
|
273
|
+
def quote(args = nil, body = nil)
|
270
274
|
_out "<blockquote>"
|
271
275
|
_body {|line| _out line }
|
272
276
|
_out "</blockquote>"
|
data/plugin/calibre.rb
CHANGED
data/plugin/livemagick.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'rmagick'
|
2
2
|
include ::Magick
|
3
3
|
|
4
|
-
def image
|
4
|
+
def image(args = nil, body = nil)
|
5
5
|
xx, yy, bg = _args
|
6
6
|
xx, yy = xx.to_i, yy.to_i
|
7
7
|
@image = Image.new(xx,yy) { self.background_color = bg }
|
8
8
|
_optional_blank_line
|
9
9
|
end
|
10
10
|
|
11
|
-
def canvas
|
11
|
+
def canvas(args = nil, body = nil)
|
12
12
|
color, width, opacity = _args
|
13
13
|
opacity, width = opacity.to_i, width.to_i
|
14
14
|
@canvas = Draw.new
|
@@ -18,7 +18,7 @@ def canvas
|
|
18
18
|
_optional_blank_line
|
19
19
|
end
|
20
20
|
|
21
|
-
def rectangle
|
21
|
+
def rectangle(args = nil, body = nil)
|
22
22
|
xy, wxh, stroke_color, stroke_width = _args
|
23
23
|
x, y = xy.split(",").map(&:to_i)
|
24
24
|
width, height = wxh.split("x").map(&:to_i)
|
@@ -29,14 +29,14 @@ def rectangle
|
|
29
29
|
@canvas.rectangle(x, y, x+width, y+height)
|
30
30
|
end
|
31
31
|
|
32
|
-
def pen
|
32
|
+
def pen(args = nil, body = nil)
|
33
33
|
@fill, @stroke = _args
|
34
34
|
@stroke = "black" if @stroke.nil? || @stroke.empty?
|
35
35
|
_debug "pen: fill=#@fill stroke=#@stroke"
|
36
36
|
_optional_blank_line
|
37
37
|
end
|
38
38
|
|
39
|
-
def font
|
39
|
+
def font(args = nil, body = nil)
|
40
40
|
size, font = _args
|
41
41
|
font = "Helvetica" if font.nil? || font.empty?
|
42
42
|
size = "32" if size.nil? || size.empty?
|
@@ -59,14 +59,14 @@ def _text(xy, wxh, str, weight, gravity)
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
def text
|
62
|
+
def text(args = nil, body = nil)
|
63
63
|
xy, wxh, str = _data.split
|
64
64
|
weight, gravity = BoldWeight, CenterGravity
|
65
65
|
_text(xy, wxh, str, weight, gravity)
|
66
66
|
_optional_blank_line
|
67
67
|
end
|
68
68
|
|
69
|
-
def text!
|
69
|
+
def text!(args = nil, body = nil)
|
70
70
|
xy, wxh = _data.split
|
71
71
|
str = _body_text # .join
|
72
72
|
weight, gravity = BoldWeight, CenterGravity
|
@@ -74,17 +74,17 @@ def text!
|
|
74
74
|
_optional_blank_line
|
75
75
|
end
|
76
76
|
|
77
|
-
def draw
|
77
|
+
def draw(args = nil, body = nil)
|
78
78
|
@canvas.draw(@image)
|
79
79
|
_optional_blank_line
|
80
80
|
end
|
81
81
|
|
82
|
-
def save
|
82
|
+
def save(args = nil, body = nil)
|
83
83
|
@image.write(_args.first)
|
84
84
|
_optional_blank_line
|
85
85
|
end
|
86
86
|
|
87
|
-
def save!
|
87
|
+
def save!(args = nil, body = nil)
|
88
88
|
save
|
89
89
|
system("open #{_args.first}")
|
90
90
|
_optional_blank_line
|
data/plugin/markdown.rb
CHANGED
@@ -1,35 +1,37 @@
|
|
1
1
|
# This file is intended to be used via a Livetext .mixin
|
2
2
|
# or the equivalent.
|
3
3
|
|
4
|
+
SimpleFormats = {}
|
4
5
|
SimpleFormats[:b] = %w[* *]
|
5
6
|
SimpleFormats[:i] = %w[_ _]
|
6
7
|
SimpleFormats[:t] = %w[` `]
|
7
8
|
SimpleFormats[:s] = %w[<strike> </strike>]
|
8
9
|
|
9
|
-
def h1; _out "# #{FormatLine.var_func_parse(@_data)}"; _optional_blank_line end # atx style for now
|
10
|
-
def h2; _out "## #{FormatLine.var_func_parse(@_data)}"; _optional_blank_line end
|
11
|
-
def h3; _out "### #{FormatLine.var_func_parse(@_data)}"; _optional_blank_line end
|
12
|
-
def h4; _out "#### #{FormatLine.var_func_parse(@_data)}"; _optional_blank_line end
|
13
|
-
def h5; _out "##### #{FormatLine.var_func_parse(@_data)}"; _optional_blank_line end
|
14
|
-
def h6; _out "###### #{FormatLine.var_func_parse(@_data)}"; _optional_blank_line end
|
15
10
|
|
16
|
-
def
|
11
|
+
def h1(args = nil, body = nil); _out "# #{FormatLine.var_func_parse(@_data)}"; _optional_blank_line end # atx style for now
|
12
|
+
def h2(args = nil, body = nil); _out "## #{FormatLine.var_func_parse(@_data)}"; _optional_blank_line end
|
13
|
+
def h3(args = nil, body = nil); _out "### #{FormatLine.var_func_parse(@_data)}"; _optional_blank_line end
|
14
|
+
def h4(args = nil, body = nil); _out "#### #{FormatLine.var_func_parse(@_data)}"; _optional_blank_line end
|
15
|
+
def h5(args = nil, body = nil); _out "##### #{FormatLine.var_func_parse(@_data)}"; _optional_blank_line end
|
16
|
+
def h6(args = nil, body = nil); _out "###### #{FormatLine.var_func_parse(@_data)}"; _optional_blank_line end
|
17
|
+
|
18
|
+
def title(args = nil, body = nil)
|
17
19
|
h1
|
18
20
|
end
|
19
21
|
|
20
|
-
def section
|
22
|
+
def section(args = nil, body = nil)
|
21
23
|
h3
|
22
24
|
end
|
23
25
|
|
24
|
-
def bq # block quote
|
26
|
+
def bq(args = nil, body = nil) # block quote
|
25
27
|
_body {|line| _out "> #{line}" }
|
26
28
|
end
|
27
29
|
|
28
|
-
def list
|
30
|
+
def list(args = nil, body = nil)
|
29
31
|
_body {|line| _out " * #{line}" }
|
30
32
|
end
|
31
33
|
|
32
|
-
def olist # Doesn't handle paragraphs yet
|
34
|
+
def olist(args = nil, body = nil) # Doesn't handle paragraphs yet
|
33
35
|
n = 0
|
34
36
|
_body do |line|
|
35
37
|
n += 1
|