livetext 0.8.76 → 0.8.77
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/bin/livetext +2 -0
- data/lib/livetext.rb +3 -1
- data/lib/processor.rb +1 -0
- data/lib/standard.rb +1 -0
- data/lib/userapi.rb +13 -7
- data/plugin/bookish.rb +46 -45
- data/plugin/markdown.rb +9 -9
- data/plugin/pyggish.rb +3 -3
- data/plugin/tutorial.rb +5 -5
- data/test/data/error_invalid_name/expected-output.txt +1 -0
- data/test/data/error_missing_end/expected-output.txt +1 -0
- data/test/data/example_alpha/expected-output.txt +3 -3
- data/test/data/example_alpha2/expected-output.txt +3 -3
- data/test/data/raw_text_block/source.lt3 +1 -0
- data/test/data/simple_mixin/expected-output.txt +0 -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: 904d935b6923cb3dd8a70dc6042b03a95dcd18851d7e3dfb4d9cae61cc0653b9
|
|
4
|
+
data.tar.gz: afdfa6c79db3beeb644bd12de6ab2ee061c48b786f87fdc4b6fb10dbeb706f45
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7f18d43dd7672ad30d7c4029e39ddda2eb27316d31f0312cc68f2e751ad34f818949150cb6306dd513194e73d2d54e88b457ce34b37003162f12df3aae476264
|
|
7
|
+
data.tar.gz: c533499a1aeb11bcdaf5937dd9ce25fed799c0e8c02034cff9c6fe845ae57159b8d2a8f5211eeece89eb09e34d1777b69bb36a65d54b40b142dfb877f22b53a0
|
data/bin/livetext
CHANGED
data/lib/livetext.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
class Livetext
|
|
2
|
-
VERSION = "0.8.
|
|
2
|
+
VERSION = "0.8.77"
|
|
3
3
|
Path = File.expand_path(File.join(File.dirname(__FILE__)))
|
|
4
4
|
end
|
|
5
5
|
|
|
@@ -99,6 +99,7 @@ class Livetext
|
|
|
99
99
|
val = @main.finalize if @main.respond_to? :finalize
|
|
100
100
|
val
|
|
101
101
|
rescue => err
|
|
102
|
+
puts @body
|
|
102
103
|
puts "process_text: err = #{err}"
|
|
103
104
|
puts err.backtrace.join("\n")
|
|
104
105
|
end
|
|
@@ -169,6 +170,7 @@ class Livetext
|
|
|
169
170
|
end
|
|
170
171
|
result
|
|
171
172
|
rescue => err
|
|
173
|
+
puts @body
|
|
172
174
|
@main._error!(err)
|
|
173
175
|
end
|
|
174
176
|
|
data/lib/processor.rb
CHANGED
|
@@ -32,6 +32,7 @@ class Livetext
|
|
|
32
32
|
|
|
33
33
|
def _error!(err, abort=true, trace=false)
|
|
34
34
|
where = @sources.last || @save_location
|
|
35
|
+
puts @parent.body
|
|
35
36
|
STDERR.puts "Error: #{err} (at #{where[1]} line #{where[2]})"
|
|
36
37
|
STDERR.puts err.backtrace if trace && err.respond_to?(:backtrace)
|
|
37
38
|
exit if abort
|
data/lib/standard.rb
CHANGED
data/lib/userapi.rb
CHANGED
|
@@ -77,7 +77,8 @@ module Livetext::UserAPI
|
|
|
77
77
|
lines
|
|
78
78
|
end
|
|
79
79
|
rescue => err
|
|
80
|
-
|
|
80
|
+
puts @body
|
|
81
|
+
# FIXME ?
|
|
81
82
|
_error!("Expecting .end, found end of file")
|
|
82
83
|
end
|
|
83
84
|
|
|
@@ -110,12 +111,17 @@ module Livetext::UserAPI
|
|
|
110
111
|
_out line
|
|
111
112
|
end
|
|
112
113
|
|
|
113
|
-
def _out(str)
|
|
114
|
-
|
|
115
|
-
@parent.body << str
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
def _out(str = "")
|
|
115
|
+
# if @no_puts
|
|
116
|
+
@parent.body << str
|
|
117
|
+
@parent.body << "\n" unless str.end_with?("\n")
|
|
118
|
+
# else
|
|
119
|
+
# _puts str
|
|
120
|
+
# end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def _out!(str = "")
|
|
124
|
+
@parent.body << str # no newline
|
|
119
125
|
end
|
|
120
126
|
|
|
121
127
|
def _puts(*args)
|
data/plugin/bookish.rb
CHANGED
|
@@ -11,28 +11,28 @@ def credit
|
|
|
11
11
|
# really just a place marker in source
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
def h1;
|
|
15
|
-
def h3;
|
|
14
|
+
def h1; _out "<h1>#{@_data}</h1>"; end
|
|
15
|
+
def h3; _out "<h3>#{@_data}</h3>"; end
|
|
16
16
|
|
|
17
17
|
def list
|
|
18
|
-
|
|
19
|
-
_body {|line|
|
|
20
|
-
|
|
18
|
+
_out "<ul>"
|
|
19
|
+
_body {|line| _out "<li>#{line}</li>" }
|
|
20
|
+
_out "</ul>"
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def list!
|
|
24
|
-
|
|
25
|
-
lines = _body.each # {|line|
|
|
24
|
+
_out "<ul>"
|
|
25
|
+
lines = _body.each # {|line| _out "<li>#{line}</li>" }
|
|
26
26
|
loop do
|
|
27
27
|
line = lines.next
|
|
28
28
|
line = _formatting(line)
|
|
29
29
|
if line[0] == " "
|
|
30
|
-
|
|
30
|
+
_out line
|
|
31
31
|
else
|
|
32
|
-
|
|
32
|
+
_out "<li>#{line}</li>"
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
|
-
|
|
35
|
+
_out "</ul>"
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def alpha_columns
|
|
@@ -42,12 +42,12 @@ def alpha_columns
|
|
|
42
42
|
words << line.chomp
|
|
43
43
|
end
|
|
44
44
|
words.sort!
|
|
45
|
-
|
|
45
|
+
_out "<table cellpadding=10>"
|
|
46
46
|
words.each_slice(n) do |w|
|
|
47
47
|
items = w.map {|x| "<tt>#{x}</tt>" }
|
|
48
|
-
|
|
48
|
+
_out "<tr><td width=5% valign=top></td><td>" + items.join("</td><td>") + "</td></tr>"
|
|
49
49
|
end
|
|
50
|
-
|
|
50
|
+
_out "</table>"
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
def comment
|
|
@@ -70,7 +70,7 @@ end
|
|
|
70
70
|
|
|
71
71
|
def image
|
|
72
72
|
name = @_args[0]
|
|
73
|
-
|
|
73
|
+
_out "<img src='#{name}'></img>"
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
def figure
|
|
@@ -78,8 +78,8 @@ def figure
|
|
|
78
78
|
num = @_args[1]
|
|
79
79
|
title = @_args[2..-1].join(" ")
|
|
80
80
|
title = _formatting(title)
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
_out "<img src='#{name}'></img>"
|
|
82
|
+
_out "<center><b>Figure #{num}</b> #{title}</center>"
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
def chapter
|
|
@@ -89,8 +89,8 @@ def chapter
|
|
|
89
89
|
title = @_data.split(" ",2)[1]
|
|
90
90
|
@toc << "<br><b>#@chapter</b> #{title}<br>"
|
|
91
91
|
_next_output(_slug(title))
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
_out "<title>#{@chapter}. #{title}</title>"
|
|
93
|
+
_out <<-HTML
|
|
94
94
|
<h2>Chapter #{@chapter}</h1>
|
|
95
95
|
<h1>#{title}</h1>
|
|
96
96
|
|
|
@@ -104,8 +104,8 @@ def chapterN
|
|
|
104
104
|
_errout("Chapter #@chapter: #{title}")
|
|
105
105
|
@toc << "<br><b>#@chapter</b> #{title}<br>"
|
|
106
106
|
_next_output(_slug(title))
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
_out "<title>#{@chapter}. #{title}</title>"
|
|
108
|
+
_out <<-HTML
|
|
109
109
|
<h2>Chapter #{@chapter}</h1>
|
|
110
110
|
<h1>#{title}</h1>
|
|
111
111
|
|
|
@@ -119,7 +119,7 @@ def sec
|
|
|
119
119
|
# _errout("section #@section")
|
|
120
120
|
@toc << "#{_nbsp(3)}<b>#@section</b> #@_data<br>"
|
|
121
121
|
# _next_output(_slug(@_data))
|
|
122
|
-
|
|
122
|
+
_out "<h3>#@section #{@_data}</h3>\n"
|
|
123
123
|
end
|
|
124
124
|
|
|
125
125
|
def subsec
|
|
@@ -128,7 +128,7 @@ def subsec
|
|
|
128
128
|
@toc << "#{_nbsp(6)}<b>#@subsec</b> #@_data<br>"
|
|
129
129
|
# _errout("section #@subsec")
|
|
130
130
|
# _next_output(_slug(@_data))
|
|
131
|
-
|
|
131
|
+
_out "<h3>#@subsec #{@_data}</h3>\n"
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
def table2
|
|
@@ -136,21 +136,21 @@ def table2
|
|
|
136
136
|
wide = "90"
|
|
137
137
|
extra = _args[2]
|
|
138
138
|
delim = " :: "
|
|
139
|
-
|
|
139
|
+
_out "<br><center><table border=1 width=#{wide}% cellpadding=5>"
|
|
140
140
|
lines = _body(true)
|
|
141
141
|
lines.map! {|line| _formatting(line) }
|
|
142
142
|
|
|
143
143
|
lines.each do |line|
|
|
144
144
|
cells = line.split(delim)
|
|
145
145
|
percent = (100/cells.size.to_f).round
|
|
146
|
-
|
|
146
|
+
_out "<tr>"
|
|
147
147
|
cells.each do |cell|
|
|
148
|
-
|
|
148
|
+
_out " <td width=#{percent}% valign=top " +
|
|
149
149
|
"#{extra}>#{cell}</td>"
|
|
150
150
|
end
|
|
151
|
-
|
|
151
|
+
_out "</tr>"
|
|
152
152
|
end
|
|
153
|
-
|
|
153
|
+
_out "</table></center><br><br>"
|
|
154
154
|
|
|
155
155
|
_optional_blank_line
|
|
156
156
|
end
|
|
@@ -158,7 +158,7 @@ end
|
|
|
158
158
|
def simple_table
|
|
159
159
|
title = @_data
|
|
160
160
|
delim = " :: "
|
|
161
|
-
|
|
161
|
+
_out "<table cellpadding=2>"
|
|
162
162
|
lines = _body(true)
|
|
163
163
|
maxw = nil
|
|
164
164
|
lines.each do |line|
|
|
@@ -174,14 +174,14 @@ def simple_table
|
|
|
174
174
|
|
|
175
175
|
lines.each do |line|
|
|
176
176
|
cells = line.split(delim)
|
|
177
|
-
|
|
177
|
+
_out "<tr>"
|
|
178
178
|
cells.each.with_index do |cell, i|
|
|
179
|
-
|
|
179
|
+
_out " <td width=#{maxw}% valign=top>" +
|
|
180
180
|
"#{cell}</td>"
|
|
181
181
|
end
|
|
182
|
-
|
|
182
|
+
_out "</tr>"
|
|
183
183
|
end
|
|
184
|
-
|
|
184
|
+
_out "</table>"
|
|
185
185
|
end
|
|
186
186
|
|
|
187
187
|
def table
|
|
@@ -189,7 +189,7 @@ def table
|
|
|
189
189
|
@table_num += 1
|
|
190
190
|
title = @_data
|
|
191
191
|
delim = " :: "
|
|
192
|
-
|
|
192
|
+
_out "<br><center><table border=1 width=90% cellpadding=5>"
|
|
193
193
|
lines = _body(true)
|
|
194
194
|
maxw = nil
|
|
195
195
|
lines.each do |line|
|
|
@@ -205,23 +205,24 @@ def table
|
|
|
205
205
|
|
|
206
206
|
lines.each do |line|
|
|
207
207
|
cells = line.split(delim)
|
|
208
|
-
|
|
208
|
+
_out "<tr>"
|
|
209
209
|
cells.each.with_index do |cell, i|
|
|
210
|
-
|
|
210
|
+
_out " <td width=#{maxw}% valign=top>" +
|
|
211
211
|
"#{cell}</td>"
|
|
212
212
|
end
|
|
213
|
-
|
|
213
|
+
_out "</tr>"
|
|
214
214
|
end
|
|
215
|
-
|
|
215
|
+
_out "</table>"
|
|
216
216
|
@toc << "#{_nbsp(8)}<b>Table #@chapter.#@table_num</b> #{title}<br>"
|
|
217
217
|
# _next_output(_slug("table_#{title}"))
|
|
218
|
-
|
|
218
|
+
_out "<b>Table #@chapter.#@table_num #{title}</b></center><br>"
|
|
219
219
|
end
|
|
220
220
|
|
|
221
221
|
def toc!
|
|
222
222
|
_debug "Closing TOC"
|
|
223
223
|
@toc.close
|
|
224
224
|
rescue => err
|
|
225
|
+
puts @body
|
|
225
226
|
_errout "Exception: #{err.inspect}"
|
|
226
227
|
end
|
|
227
228
|
|
|
@@ -242,7 +243,7 @@ def missing
|
|
|
242
243
|
@toc << "#{_nbsp(8)}<font color=red>TBD: #@_data</font><br>"
|
|
243
244
|
_print "<br><font color=red><i>[Material missing"
|
|
244
245
|
_print ": #@_data" unless @_data.empty?
|
|
245
|
-
|
|
246
|
+
_out "]</i></font><br>\n "
|
|
246
247
|
end
|
|
247
248
|
|
|
248
249
|
def TBC
|
|
@@ -251,15 +252,15 @@ def TBC
|
|
|
251
252
|
end
|
|
252
253
|
|
|
253
254
|
def note
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
255
|
+
_out "<br><font color=red><i>Note: "
|
|
256
|
+
_out @_data
|
|
257
|
+
_out "</i></font><br>\n "
|
|
257
258
|
end
|
|
258
259
|
|
|
259
260
|
def quote
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
261
|
+
_out "<blockquote>"
|
|
262
|
+
_out _body
|
|
263
|
+
_out "</blockquote>"
|
|
263
264
|
end
|
|
264
265
|
|
|
265
266
|
def init_bookish
|
data/plugin/markdown.rb
CHANGED
|
@@ -6,12 +6,12 @@ SimpleFormats[:i] = %w[_ _]
|
|
|
6
6
|
SimpleFormats[:t] = %w[` `]
|
|
7
7
|
SimpleFormats[:s] = %w[<strike> </strike>]
|
|
8
8
|
|
|
9
|
-
def h1;
|
|
10
|
-
def h2;
|
|
11
|
-
def h3;
|
|
12
|
-
def h4;
|
|
13
|
-
def h5;
|
|
14
|
-
def h6;
|
|
9
|
+
def h1; _out "# #{@_data}"; _optional_blank_line end # atx style for now
|
|
10
|
+
def h2; _out "## #{@_data}"; _optional_blank_line end
|
|
11
|
+
def h3; _out "### #{@_data}"; _optional_blank_line end
|
|
12
|
+
def h4; _out "#### #{@_data}"; _optional_blank_line end
|
|
13
|
+
def h5; _out "##### #{@_data}"; _optional_blank_line end
|
|
14
|
+
def h6; _out "###### #{@_data}"; _optional_blank_line end
|
|
15
15
|
|
|
16
16
|
def title
|
|
17
17
|
h1
|
|
@@ -22,18 +22,18 @@ def section
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def bq # block quote
|
|
25
|
-
_body {|line|
|
|
25
|
+
_body {|line| _out "> #{line}" }
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def list
|
|
29
|
-
_body {|line|
|
|
29
|
+
_body {|line| _out " * #{line}" }
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def olist # Doesn't handle paragraphs yet
|
|
33
33
|
n = 0
|
|
34
34
|
_body do |line|
|
|
35
35
|
n += 1
|
|
36
|
-
|
|
36
|
+
_out "#{n}. #{_formatting(line)}"
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
data/plugin/pyggish.rb
CHANGED
data/plugin/tutorial.rb
CHANGED
|
@@ -9,7 +9,7 @@ def section
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def code
|
|
12
|
-
#
|
|
12
|
+
# _out "<pre>"
|
|
13
13
|
first = true # dumb hack! fixes blank space
|
|
14
14
|
_body do |line|
|
|
15
15
|
if first
|
|
@@ -17,9 +17,9 @@ def code
|
|
|
17
17
|
first = false
|
|
18
18
|
else
|
|
19
19
|
end
|
|
20
|
-
|
|
20
|
+
_out "#{tag} #{::CGI.escape_html(line)}" # indentation
|
|
21
21
|
end
|
|
22
|
-
|
|
22
|
+
_out "</pre>"
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def rx(str)
|
|
@@ -80,9 +80,9 @@ end
|
|
|
80
80
|
|
|
81
81
|
def testcase
|
|
82
82
|
name = _args.first
|
|
83
|
-
|
|
83
|
+
_out "\n<font size=+1><b>Test: </font><font size=+2><tt>#{name}</tt></font></b></h3><br>"
|
|
84
84
|
src, exp = "test/data/#{name}/source.lt3", "test/data/#{name}/expected-output.txt"
|
|
85
85
|
@_args = [src, exp] # Better way to do this??
|
|
86
86
|
put_table(src, exp)
|
|
87
|
-
|
|
87
|
+
_out "<br>"
|
|
88
88
|
end
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
Here is an alphabetized list:
|
|
2
|
-
<p>
|
|
3
|
-
|
|
4
1
|
aardvark anamorphic anarchist
|
|
5
2
|
bellicose cytology ectomorph
|
|
6
3
|
fishmonger fusillade glyph
|
|
7
4
|
gryphon halcyon manicotti
|
|
8
5
|
mataeotechny pareidolia quark
|
|
9
6
|
zootrope zymurgy
|
|
7
|
+
Here is an alphabetized list:
|
|
8
|
+
<p>
|
|
9
|
+
|
|
10
10
|
<p>
|
|
11
11
|
|
|
12
12
|
And that is all.
|
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.8.
|
|
4
|
+
version: 0.8.77
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hal Fulton
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-04-
|
|
11
|
+
date: 2019-04-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A smart text processor extensible in Ruby
|
|
14
14
|
email: rubyhacker@gmail.com
|