livetext 0.9.21 → 0.9.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.lt3 +8 -8
- data/bin/livetext +57 -40
- data/imports/bookish.rb +89 -90
- data/imports/calibre.rb +3 -3
- data/imports/livemagick.rb +17 -17
- data/imports/markdown.rb +10 -10
- data/imports/pyggish.rb +15 -47
- data/imports/tutorial.rb +18 -18
- data/lib/cmdargs.rb +10 -6
- data/lib/{errors.rb → livetext/errors.rb} +1 -1
- data/lib/{formatline.rb → livetext/formatline.rb} +69 -125
- data/lib/livetext/funcall.rb +84 -0
- data/lib/{functions.rb → livetext/functions.rb} +16 -3
- data/lib/livetext/global_helpers.rb +37 -0
- data/lib/livetext/handler/import.rb +44 -0
- data/lib/livetext/handler/mixin.rb +37 -0
- data/lib/livetext/handler.rb +3 -0
- data/lib/{helpers.rb → livetext/helpers.rb} +89 -67
- data/lib/{html.rb → livetext/html.rb} +3 -2
- data/lib/{parser → livetext/parser}/general.rb +0 -3
- data/lib/{parser → livetext/parser}/set.rb +1 -6
- data/lib/{parser → livetext/parser}/string.rb +2 -2
- data/lib/{parser.rb → livetext/parser.rb} +0 -1
- data/lib/livetext/parsing.rb +29 -0
- data/lib/livetext/paths.rb +13 -0
- data/lib/livetext/processor.rb +89 -0
- data/lib/livetext/reopen.rb +12 -0
- data/lib/livetext/skeleton.rb +17 -0
- data/lib/{standard.rb → livetext/standard.rb} +152 -122
- data/lib/livetext/userapi.rb +153 -0
- data/lib/livetext/version.rb +6 -0
- data/lib/livetext.rb +66 -27
- data/plugin/bookish.rb +85 -85
- data/plugin/calibre.rb +3 -3
- data/plugin/livemagick.rb +17 -17
- data/plugin/markdown.rb +10 -10
- data/plugin/pyggish.rb +131 -162
- data/plugin/tutorial.rb +15 -16
- data/test/all.rb +6 -0
- data/test/snapshots/def_method/expected-output.txt +2 -0
- data/test/snapshots/def_method/source.lt3 +4 -2
- data/test/snapshots/error_inc_line_num/OUT +17 -0
- data/test/snapshots/error_inc_line_num/README.txt +20 -0
- data/test/snapshots/error_inc_line_num/expected-output.txt +0 -6
- data/test/snapshots/error_inc_line_num/match-error.txt +1 -1
- data/test/snapshots/error_line_num/match-error.txt +1 -1
- data/test/snapshots/error_missing_end/expected-output.txt +0 -1
- data/test/snapshots/error_name_not_permitted/expected-output.txt +4 -0
- data/test/snapshots/error_name_not_permitted/match-error.txt +1 -1
- data/test/snapshots/error_no_such_copy/duh +26 -0
- data/test/snapshots/error_no_such_copy/expected-output.txt +1 -0
- data/test/snapshots/error_no_such_copy/match-error.txt +1 -1
- data/test/snapshots/error_no_such_copy/mystery.txt +36 -0
- data/test/snapshots/error_no_such_inc/match-error.txt +1 -1
- data/test/snapshots/error_no_such_mixin/expected-output.txt +1 -0
- data/test/snapshots/error_no_such_mixin/match-error.txt +1 -1
- data/test/snapshots/error_no_such_mixin/source.lt3 +1 -1
- data/test/snapshots/example_alpha/source.lt3 +2 -2
- data/test/snapshots/example_alpha2/expected-output.txt +0 -2
- data/test/snapshots/example_alpha2/source.lt3 +5 -4
- data/test/snapshots/{icanhaz → import}/expected-output.txt +2 -1
- data/test/snapshots/import/match-error.txt +1 -0
- data/test/snapshots/{icanhaz → import}/simple_import.rb +1 -1
- data/test/snapshots/{icanhaz → import}/source.lt3 +2 -2
- data/test/snapshots/{icanhaz2 → import2}/expected-error.txt +0 -0
- data/test/snapshots/{icanhaz2 → import2}/expected-output.txt +3 -1
- data/test/snapshots/{icanhaz2/simple_canhaz.rb → import2/simple_import.rb} +1 -1
- data/test/snapshots/import2/source.lt3 +8 -0
- data/test/snapshots/import_bookish/expected-error.txt +0 -0
- data/test/snapshots/import_bookish/expected-output.txt +10 -0
- data/test/snapshots/import_bookish/source.lt3 +7 -0
- data/test/snapshots/import_bookish/toc.tmp +0 -0
- data/test/snapshots/mixin_bookish/expected-error.txt +0 -0
- data/test/snapshots/mixin_bookish/expected-output.txt +10 -0
- data/test/snapshots/mixin_bookish/source.lt3 +7 -0
- data/test/snapshots/mixin_bookish/toc.tmp +0 -0
- data/test/snapshots/more_functions/expected-error.txt +0 -0
- data/test/snapshots/more_functions/expected-output.txt +37 -0
- data/test/snapshots/more_functions/source.lt3 +40 -0
- data/test/snapshots/raw_lines/expected-output.txt +0 -2
- data/test/snapshots/simple_import/expected-output.txt +2 -0
- data/test/snapshots/simple_import/simple_import.rb +1 -1
- data/test/snapshots/simple_import/source.lt3 +3 -1
- data/test/snapshots/simple_mixin/simple_mixin.rb +1 -1
- data/test/snapshots/single_raw_line/expected-output.txt +0 -2
- data/test/snapshots/subset.txt +14 -14
- data/test/snapshots.rb +30 -13
- data/test/unit/formatline.rb +253 -134
- data/test/unit/html.rb +2 -3
- data/test/unit/parser/general.rb +1 -2
- data/test/unit/parser/mixin.rb +1 -3
- data/test/unit/parser/set.rb +8 -12
- data/test/unit/parser/string.rb +6 -6
- data/test/unit/parser.rb +0 -1
- data/test/unit/standard.rb +0 -2
- metadata +47 -30
- data/imports/markdown_importable.rb +0 -45
- data/lib/handler/icanhaz.rb +0 -35
- data/lib/handler.rb +0 -1
- data/lib/livetext/importable.rb +0 -2
- data/lib/parser/file.rb +0 -8
- data/lib/parser/import.rb +0 -15
- data/lib/parser/mixin.rb +0 -38
- data/lib/processor.rb +0 -83
- data/lib/userapi.rb +0 -160
- data/test/snapshots/icanhaz/match-error.txt +0 -1
- data/test/snapshots/icanhaz2/source.lt3 +0 -6
- data/test/unit/parser/importable.rb +0 -19
data/plugin/pyggish.rb
CHANGED
@@ -1,44 +1,44 @@
|
|
1
1
|
require 'rouge'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
3
|
+
# FIXME This whole file has a weird vibe. It has dead code and
|
4
|
+
# also exposes methods that are not dot commands...
|
5
|
+
|
6
|
+
def self.pyg_change(code, klass, style)
|
7
|
+
color = style[0..6]
|
8
|
+
modifier = style[8]
|
9
|
+
mod_open = modifier ? "<#{modifier}>" : ""
|
10
|
+
mod_close = modifier ? "</#{modifier}>" : ""
|
11
|
+
rx = /<span class="#{klass}">(?<cname>[^<]+?)<\/span>/
|
12
|
+
loop do
|
13
|
+
md = rx.match(code)
|
14
|
+
break if md.nil?
|
15
|
+
str = md[:cname]
|
16
|
+
result = code.sub!(rx, "<font color=#{color}>#{mod_open}#{str}#{mod_close}</font>")
|
17
|
+
break if result.nil?
|
16
18
|
end
|
19
|
+
end
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
21
|
+
def self._codebar_color(lexer)
|
22
|
+
color = case lexer
|
23
|
+
when :elixir
|
24
|
+
"#fc88fc"
|
25
|
+
when :ruby
|
26
|
+
"#fc8888"
|
27
|
+
else
|
28
|
+
raise "Unknown lexer"
|
27
29
|
end
|
30
|
+
end
|
28
31
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
code.gsub!(/<\/span>/, "")
|
32
|
+
def self.pyg_finalize(code, lexer=:elixir)
|
33
|
+
Styles.each_pair {|klass, style| pyg_change(code, klass, style) }
|
34
|
+
code.sub!(/<pre>/, "<pre>\n")
|
35
|
+
code.gsub!(/<span class="[np]">/, "")
|
36
|
+
code.gsub!(/<\/span>/, "")
|
35
37
|
color = _codebar_color(lexer)
|
36
38
|
code.sub!(/<td class="linenos"/, "<td width=2%></td><td width=5% bgcolor=#{color}")
|
37
39
|
code.gsub!(/<td/, "<td valign=top ")
|
38
40
|
code.gsub!(/ class="[^"]*?"/, "") # Get rid of remaining Pygments CSS
|
39
|
-
File.open("debug-pf2", "w") {|f| f.puts code }
|
40
41
|
lines = code.split("\n")
|
41
|
-
# lines.each {|line| line << "\n" }
|
42
42
|
n1 = lines.index {|x| x =~ /<pre>/ }
|
43
43
|
n2 = lines.index {|x| x =~ /<\/pre>/ }
|
44
44
|
# FIXME ?
|
@@ -47,157 +47,126 @@ File.open("debug-pf2", "w") {|f| f.puts code }
|
|
47
47
|
lines[n1].sub!(/ 1$/, " 1 ")
|
48
48
|
(n1+1).upto(n2) {|n| lines[n].replace(" " + lines[n] + " ") }
|
49
49
|
code = lines.join("\n")
|
50
|
-
File.open("debug-pf3", "w") {|f| f.puts code }
|
51
50
|
code
|
52
51
|
end
|
53
52
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
line.replace(frag)
|
53
|
+
def _process_code(text)
|
54
|
+
lines = text.split("\n")
|
55
|
+
lines = lines.select {|x| x !~ /##~ omit/ }
|
56
|
+
@refs = {}
|
57
|
+
lines.each.with_index do |line, i|
|
58
|
+
if line =~ /##~ ref/
|
59
|
+
frag, name = line.split(/ *##~ ref/)
|
60
|
+
@refs[name.strip] = i
|
61
|
+
line.replace(frag)
|
62
|
+
end
|
65
63
|
end
|
64
|
+
lines.map! {|line| " " + line }
|
65
|
+
text2 = lines.join("\n")
|
66
|
+
text.replace(text2)
|
66
67
|
end
|
67
|
-
lines.map! {|line| " " + line }
|
68
|
-
text2 = lines.join("\n")
|
69
|
-
File.open("debug-pc2", "w") {|f| f.puts text2 }
|
70
|
-
text.replace(text2)
|
71
|
-
end
|
72
|
-
|
73
|
-
def _colorize(code, lexer=:elixir)
|
74
|
-
text = ::Pygments.highlight(code, lexer: lexer, options: {linenos: "table"})
|
75
|
-
_debug "--- in _colorize: text = #{text.inspect}"
|
76
|
-
text2 = PygmentFix.pyg_finalize(text, lexer)
|
77
|
-
result = "<!-- colorized code -->\n" + text2
|
78
|
-
result
|
79
|
-
end
|
80
68
|
|
81
|
-
def _colorize
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
def OLD_ruby
|
90
|
-
file = @_args.first
|
91
|
-
if file.nil?
|
92
|
-
code = "# Ruby code\n"
|
93
|
-
_body {|line| code << line + "\n" }
|
94
|
-
else
|
95
|
-
code = "# Ruby code\n\n" + ::File.read(file)
|
69
|
+
def _colorize(code, lexer=:elixir)
|
70
|
+
text = ::Pygments.highlight(code, lexer: lexer, options: {linenos: "table"})
|
71
|
+
_debug "--- in _colorize: text = #{text.inspect}"
|
72
|
+
text2 = PygmentFix.pyg_finalize(text, lexer)
|
73
|
+
result = "<!-- colorized code -->\n" + text2
|
74
|
+
result
|
96
75
|
end
|
97
76
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
file = @_args.first
|
105
|
-
if file.nil?
|
106
|
-
code = ""
|
107
|
-
_body {|line| code << line + "\n" }
|
108
|
-
else
|
109
|
-
code = ::File.read(file)
|
77
|
+
def _colorize!(code, lexer=:elixir)
|
78
|
+
text = ::Pygments.highlight(code, lexer: lexer, options: {})
|
79
|
+
_debug "--- in _colorize!: text = #{text.inspect}"
|
80
|
+
text2 = PygmentFix.pyg_finalize(text, lexer)
|
81
|
+
result = "<!-- colorized code -->\n" + text2
|
82
|
+
result
|
110
83
|
end
|
111
84
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
@_args = []
|
120
|
-
send(lang)
|
121
|
-
_out "\n"
|
122
|
-
end
|
123
|
-
|
124
|
-
def code # FIXME ?
|
125
|
-
text = ""
|
126
|
-
_body {|line| _out " " + line }
|
127
|
-
end
|
85
|
+
def fragment
|
86
|
+
lang = api.args.empty? ? :elixir : api.args.first.to_sym # ruby or elixir
|
87
|
+
api.args = []
|
88
|
+
# TTY.puts "\n#{self.inspect}"
|
89
|
+
send(lang)
|
90
|
+
api.out "\n"
|
91
|
+
end
|
128
92
|
|
129
|
-
def
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
end
|
93
|
+
def code # FIXME ?
|
94
|
+
text = ""
|
95
|
+
api.body {|line| api.out " " + line }
|
96
|
+
end
|
134
97
|
|
135
|
-
def
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
.rb_highlight {
|
141
|
-
font-family: 'Monaco', 'Andale Mono', 'Lucida Grande', 'Courier', 'Lucida Console', 'Courier New', monospace;
|
142
|
-
white-space: pre;
|
143
|
-
background-color: #{back}
|
144
|
-
}
|
145
|
-
CSS
|
146
|
-
|
147
|
-
css.gsub!(/{\n/, "{\n font-family: courier;")
|
148
|
-
css = added + "\n" + css
|
149
|
-
# STDERR.puts "Writing #{theme} theme to ruby.css"
|
150
|
-
File.write("#{dir}/ruby.css", css)
|
151
|
-
|
152
|
-
css = Rouge::Themes.const_get(theme).render(scope: '.ex_highlight')
|
153
|
-
added = added.sub(/rb/, "ex")
|
154
|
-
css.gsub!(/{\n/, "{\n font-family: courier;")
|
155
|
-
css = added + "\n" + css
|
156
|
-
# STDERR.puts "Writing #{theme} theme to elixir.css"
|
157
|
-
File.write("#{dir}/elixir.css", css)
|
158
|
-
end
|
98
|
+
def mono
|
99
|
+
api.out "<pre>"
|
100
|
+
api.body {|line| api.out " " + line }
|
101
|
+
api.out "</pre>"
|
102
|
+
end
|
159
103
|
|
104
|
+
def create_code_styles
|
105
|
+
dir = @_outdir || "."
|
106
|
+
theme, back = "Github", "white"
|
107
|
+
css = Rouge::Themes.const_get(theme).render(scope: '.rb_highlight')
|
108
|
+
added = <<~CSS
|
109
|
+
.rb_highlight {
|
110
|
+
font-family: 'Monaco', 'Andale Mono', 'Lucida Grande', 'Courier', 'Lucida Console', 'Courier New', monospace;
|
111
|
+
white-space: pre;
|
112
|
+
background-color: #{back}
|
113
|
+
}
|
114
|
+
CSS
|
115
|
+
|
116
|
+
css.gsub!(/{\n/, "{\n font-family: courier;")
|
117
|
+
css = added + "\n" + css
|
118
|
+
# STDERR.puts "Writing #{theme} theme to ruby.css"
|
119
|
+
File.write("#{dir}/ruby.css", css)
|
120
|
+
|
121
|
+
css = Rouge::Themes.const_get(theme).render(scope: '.ex_highlight')
|
122
|
+
added = added.sub(/rb/, "ex")
|
123
|
+
css.gsub!(/{\n/, "{\n font-family: courier;")
|
124
|
+
css = added + "\n" + css
|
125
|
+
# STDERR.puts "Writing #{theme} theme to elixir.css"
|
126
|
+
File.write("#{dir}/elixir.css", css)
|
127
|
+
end
|
160
128
|
|
161
|
-
def format_ruby(source, theme = "Github", back = "black")
|
162
|
-
# theme/back not used now
|
163
|
-
formatter = Rouge::Formatters::HTML.new
|
164
|
-
lexer = Rouge::Lexers::Ruby.new
|
165
|
-
body = formatter.format(lexer.lex(source))
|
166
|
-
text = "<div class=rb_highlight>#{body}</div>"
|
167
|
-
text
|
168
|
-
end
|
169
129
|
|
170
|
-
def
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
end
|
130
|
+
def format_ruby(source, theme = "Github", back = "black")
|
131
|
+
# theme/back not used now
|
132
|
+
formatter = Rouge::Formatters::HTML.new
|
133
|
+
lexer = Rouge::Lexers::Ruby.new
|
134
|
+
body = formatter.format(lexer.lex(source))
|
135
|
+
text = "<div class=rb_highlight>#{body}</div>"
|
136
|
+
text
|
137
|
+
end
|
178
138
|
|
179
|
-
def
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
139
|
+
def format_elixir(source, theme = "Github", back = "black")
|
140
|
+
# theme/back not used now
|
141
|
+
formatter = Rouge::Formatters::HTML.new
|
142
|
+
lexer = Rouge::Lexers::Elixir.new
|
143
|
+
body = formatter.format(lexer.lex(source))
|
144
|
+
text = "<div class=ex_highlight>#{body}</div>"
|
145
|
+
text
|
186
146
|
end
|
187
147
|
|
188
|
-
|
189
|
-
|
190
|
-
|
148
|
+
def ruby
|
149
|
+
file = api.args.first
|
150
|
+
if file.nil?
|
151
|
+
code = " # Ruby code\n\n"
|
152
|
+
api.body {|line| code << " " + line + "\n" }
|
153
|
+
else
|
154
|
+
code = "# Ruby code\n\n" + ::File.read(file)
|
155
|
+
end
|
191
156
|
|
192
|
-
|
193
|
-
|
194
|
-
if file.nil?
|
195
|
-
code = ""
|
196
|
-
_body {|line| code << " " + line + "\n" }
|
197
|
-
else
|
198
|
-
code = ::File.read(file)
|
157
|
+
html = format_ruby(code)
|
158
|
+
api.out html
|
199
159
|
end
|
200
160
|
|
201
|
-
|
202
|
-
|
161
|
+
def elixir
|
162
|
+
file = api.args.first
|
163
|
+
if file.nil?
|
164
|
+
code = ""
|
165
|
+
api.body {|line| code << " " + line + "\n" }
|
166
|
+
else
|
167
|
+
code = ::File.read(file)
|
168
|
+
end
|
169
|
+
|
170
|
+
html = format_elixir(code)
|
171
|
+
api.out html
|
203
172
|
end
|
data/plugin/tutorial.rb
CHANGED
@@ -2,22 +2,22 @@ require 'cgi'
|
|
2
2
|
|
3
3
|
def title(args = nil, body = nil)
|
4
4
|
h1
|
5
|
-
|
5
|
+
api.optional_blank_line
|
6
6
|
end
|
7
7
|
|
8
8
|
def section(args = nil, body = nil)
|
9
9
|
h3
|
10
|
-
|
10
|
+
api.optional_blank_line
|
11
11
|
end
|
12
12
|
|
13
13
|
def code(args = nil, body = nil)
|
14
14
|
first = true # dumb hack! fixes blank space
|
15
|
-
|
15
|
+
api.body do |line|
|
16
16
|
tag, first = "<pre>", false if first
|
17
|
-
|
17
|
+
api.out "#{tag} #{::CGI.escape_html(line)}" # indentation
|
18
18
|
end
|
19
|
-
|
20
|
-
|
19
|
+
api.out "</pre>"
|
20
|
+
api.optional_blank_line
|
21
21
|
end
|
22
22
|
|
23
23
|
def rx(str)
|
@@ -25,14 +25,14 @@ def rx(str)
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def inout(args = nil, body = nil)
|
28
|
-
src, out =
|
28
|
+
src, out = api.args
|
29
29
|
t1 = ::File.readlines(src) rescue (abort "t1 = #{src}")
|
30
30
|
t2 = ::File.readlines(out) rescue (abort "t2 = #{out}")
|
31
31
|
# To pacify markdown for README (FIXME later)
|
32
32
|
t1 = t1.map {|x| " " + x.sub(/ +$/,"").gsub(/_/, "\\_") }.join
|
33
33
|
t2 = t2.map {|x| " " + x.sub(/ +$/,"").gsub(/_/, "\\_") }.join
|
34
34
|
|
35
|
-
|
35
|
+
api.out <<-HTML
|
36
36
|
<table width=80% cellpadding=4>
|
37
37
|
<tr>
|
38
38
|
<td width=50%><b>Input</b></td>
|
@@ -48,17 +48,16 @@ def inout(args = nil, body = nil)
|
|
48
48
|
</tr>
|
49
49
|
</table>
|
50
50
|
HTML
|
51
|
-
|
51
|
+
api.optional_blank_line
|
52
52
|
end
|
53
53
|
|
54
54
|
def put_table(src, exp)
|
55
|
-
STDERR.puts "put_table: #{[src, exp].inspect}"
|
56
55
|
t1 = ::File.readlines(src) rescue (abort "Fail - src = #{src} t1 = #{src}")
|
57
56
|
t2 = ::File.readlines(exp) rescue (abort "Fail - src = #{exp} t2 = #{out}")
|
58
57
|
t1 = t1.map {|x| " " + x.sub(/ +$/,"").gsub(/_/, "\\_") }.join
|
59
58
|
t2 = t2.map {|x| " " + x.sub(/ +$/,"").gsub(/_/, "\\_") }.join
|
60
59
|
|
61
|
-
|
60
|
+
api.out <<-HTML
|
62
61
|
<font size=+1>
|
63
62
|
<table width=80% cellpadding=4>
|
64
63
|
<tr>
|
@@ -79,11 +78,11 @@ STDERR.puts "put_table: #{[src, exp].inspect}"
|
|
79
78
|
end
|
80
79
|
|
81
80
|
def testcase(args = nil, body = nil)
|
82
|
-
name =
|
83
|
-
|
81
|
+
name = api.args.first
|
82
|
+
api.out "\n<font size=+1><b>Test: </font><font size=+2><tt>#{name}</tt></font></b></h3><br>"
|
84
83
|
src, exp = "test/snapshots/#{name}/source.lt3", "test/snapshots/#{name}/expected-output.txt"
|
85
|
-
|
84
|
+
api.args = [src, exp] # Better way to do this??
|
86
85
|
put_table(src, exp)
|
87
|
-
|
88
|
-
|
86
|
+
api.out "<br>"
|
87
|
+
api.optional_blank_line
|
89
88
|
end
|
data/test/all.rb
CHANGED
@@ -2,10 +2,12 @@
|
|
2
2
|
abc
|
3
3
|
123
|
4
4
|
.def foobar # yet another experimental comment
|
5
|
-
::STDERR.puts "This is the"
|
6
|
-
::STDERR.puts "foobar method"
|
5
|
+
::STDERR.puts "This is the"
|
6
|
+
::STDERR.puts "foobar method"
|
7
|
+
true
|
7
8
|
.end
|
8
9
|
xyz
|
9
10
|
.foobar # and still another
|
11
|
+
|
10
12
|
xyzzy
|
11
13
|
123
|
@@ -0,0 +1,17 @@
|
|
1
|
+
This is my
|
2
|
+
source file
|
3
|
+
which includes file2 here:
|
4
|
+
This is file2
|
5
|
+
which has an error
|
6
|
+
about an unknown command
|
7
|
+
in line 5
|
8
|
+
This is my
|
9
|
+
source file
|
10
|
+
which includes file2 here:
|
11
|
+
This is file2
|
12
|
+
which has an error
|
13
|
+
about an unknown command
|
14
|
+
in line 5
|
15
|
+
<p>
|
16
|
+
|
17
|
+
And this is file2 line 7.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
---- File: source.lt3
|
2
|
+
|
3
|
+
This is my
|
4
|
+
source file
|
5
|
+
which includes file2 here:
|
6
|
+
.include file2.lt3
|
7
|
+
|
8
|
+
And here we are
|
9
|
+
back in the
|
10
|
+
original file.
|
11
|
+
|
12
|
+
--- File: file2.lt3
|
13
|
+
|
14
|
+
This is file2
|
15
|
+
which has an error
|
16
|
+
about an unknown command
|
17
|
+
in line 5
|
18
|
+
.foobar
|
19
|
+
|
20
|
+
And this is file2 line 7.
|
@@ -1 +1 @@
|
|
1
|
-
1 /
|
1
|
+
1 /Error: name 'foobar' is unknown/
|
@@ -1 +1 @@
|
|
1
|
-
1 /
|
1
|
+
1 /Error: name 'foobar' is unknown/
|
@@ -1 +1 @@
|
|
1
|
-
1 /
|
1
|
+
1 /name 'class' is invalid/
|
@@ -0,0 +1,26 @@
|
|
1
|
+
####
|
2
|
+
self =
|
3
|
+
#<Processor:0x00007fd5ec14d290
|
4
|
+
@parent=#<Livetext:0x00007fd5ec14d358
|
5
|
+
@source=nil,
|
6
|
+
@_mixins=[],
|
7
|
+
@_imports=[],
|
8
|
+
@_outdir=".",
|
9
|
+
@no_puts=false,
|
10
|
+
@body="Make sure a\nnonexistent file with .copy\ngives an error.\n<p>\n\n",
|
11
|
+
@main=#<Processor:0x00007fd5ec14d290 ...>,
|
12
|
+
@indentation=[0],
|
13
|
+
@_vars={"User"=>"Hal", :User=>"Hal", "Version"=>"0.9.24", :Version=>"0.9.24",
|
14
|
+
"File"=>"source.lt3", :File=>"source.lt3",
|
15
|
+
"FileDir"=>"/Users/Hal/Dropbox/topx/git/livetext/test/snapshots/error_no_such_copy",
|
16
|
+
:FileDir=>"/Users/Hal/Dropbox/topx/git/livetext/test/snapshots/error_no_such_copy"},
|
17
|
+
@backtrace=true>,
|
18
|
+
@_nopass=false,
|
19
|
+
@_nopara=false,
|
20
|
+
@output=#<IO:<STDOUT>>,
|
21
|
+
@sources=[[#<Enumerator: ["Make sure a", "nonexistent file with .copy", "gives an error.", "\n", ".copy nosuchfile.txt\n", "\n", "Nothing to\n", "see here.\n"]:each>, "source.lt3", 5]],
|
22
|
+
@indentation=nil,
|
23
|
+
@_mixins=[],
|
24
|
+
@_imports=[],
|
25
|
+
@_data="nosuchfile.txt",
|
26
|
+
@_args=["nosuchfile.txt"]>
|
@@ -1 +1 @@
|
|
1
|
-
1 /file nosuchfile.txt not found/
|
1
|
+
1 /file 'nosuchfile.txt' not found/
|
@@ -0,0 +1,36 @@
|
|
1
|
+
livetext:78:in `parse_command_line'
|
2
|
+
livetext:78:in `loop'
|
3
|
+
livetext:92:in `block in parse_command_line'
|
4
|
+
helpers.rb:72:in `process_file'
|
5
|
+
helpers.rb:72:in `loop'
|
6
|
+
helpers.rb:75:in `block in process_file'
|
7
|
+
helpers.rb:95:in `process_line'
|
8
|
+
helpers.rb:124:in `handle_dotcmd'
|
9
|
+
standard.rb:273:in `copy': Error: file 'nosuchfile.txt' not found (FileNotFound)
|
10
|
+
|
11
|
+
|
12
|
+
parse_command_line
|
13
|
+
process_file
|
14
|
+
process_line
|
15
|
+
handle_dotcmd
|
16
|
+
copy
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
livetext "main" rescue unexpected
|
22
|
+
process_file ret Bool, print warning, rescue unex, no raise
|
23
|
+
process_line ret Bool, no rescue, no raise
|
24
|
+
handle_dotcmd ret Bool, no rescue, 2 custom exceptions
|
25
|
+
copy ret Bool, rescue only unexpected
|
26
|
+
check_file_exists returns Boolean, no rescue, no raise
|
27
|
+
|
28
|
+
|
29
|
+
METHOD RETURNS RESCUE RAISES OTHER
|
30
|
+
------------------- ----------------- ----------------- ----------------- -----------------
|
31
|
+
parse_command_line nothing only unexpected
|
32
|
+
process_file
|
33
|
+
process_line
|
34
|
+
handle_dotcmd
|
35
|
+
copy
|
36
|
+
|
@@ -1 +1 @@
|
|
1
|
-
1 /file nosuchinc.lt3 not found/
|
1
|
+
1 /file 'nosuchinc.lt3' not found/
|
@@ -1 +1 @@
|
|
1
|
-
1 /
|
1
|
+
1 /file 'nosuchthing' not found/
|
@@ -1,15 +1,16 @@
|
|
1
1
|
.def alpha
|
2
|
-
cols =
|
2
|
+
cols = api.args.first
|
3
3
|
cols = "1" if cols == ""
|
4
4
|
cols = cols.to_i
|
5
5
|
raise "Columns must be 1-5" unless cols.between?(1,5)
|
6
|
-
text =
|
6
|
+
text = api.body.join("\n")
|
7
7
|
text.gsub!(/\n/, " ")
|
8
8
|
words = text.split.sort
|
9
9
|
words.each_slice(cols) do |row|
|
10
|
-
row.each {|w|
|
11
|
-
|
10
|
+
row.each {|w| api.out! '%-15s' % w }
|
11
|
+
api.out
|
12
12
|
end
|
13
|
+
api.optional_blank_line
|
13
14
|
.end
|
14
15
|
Here is an alphabetized list:
|
15
16
|
|