livetext 0.9.23 → 0.9.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.lt3 +6 -6
- data/bin/livetext +57 -40
- data/imports/bookish.rb +81 -81
- data/imports/calibre.rb +3 -3
- data/imports/livemagick.rb +17 -17
- data/imports/markdown.rb +10 -10
- data/imports/pyggish.rb +13 -13
- data/imports/tutorial.rb +15 -15
- data/lib/cmdargs.rb +7 -4
- data/lib/{errors.rb → livetext/errors.rb} +4 -3
- data/lib/{formatline.rb → livetext/formatline.rb} +119 -18
- data/lib/livetext/funcall.rb +168 -0
- data/lib/{functions.rb → livetext/functions.rb} +0 -2
- data/lib/{global_helpers.rb → livetext/global_helpers.rb} +6 -3
- data/lib/{handler → livetext/handler}/import.rb +5 -9
- data/lib/livetext/handler/mixin.rb +33 -0
- data/lib/{handler.rb → livetext/handler.rb} +1 -1
- data/lib/{helpers.rb → livetext/helpers.rb} +78 -66
- data/lib/{html.rb → livetext/html.rb} +2 -3
- data/lib/livetext/lineparser.rb +441 -0
- data/lib/livetext/more.rb +158 -0
- data/lib/{parser → livetext/parser}/general.rb +0 -0
- data/lib/{parser → livetext/parser}/set.rb +0 -0
- data/lib/{parser → livetext/parser}/string.rb +0 -0
- data/lib/{parser.rb → livetext/parser.rb} +0 -3
- data/lib/{parsing.rb → livetext/parsing.rb} +0 -2
- data/lib/livetext/paths.rb +13 -0
- data/lib/{processor.rb → livetext/processor.rb} +18 -8
- data/lib/livetext/reopen.rb +12 -0
- data/lib/livetext/skeleton.rb +22 -0
- data/lib/{standard.rb → livetext/standard.rb} +150 -127
- data/lib/livetext/userapi.rb +170 -0
- data/lib/livetext/version.rb +6 -0
- data/lib/livetext.rb +14 -152
- data/plugin/bookish.rb +82 -81
- data/plugin/calibre.rb +3 -3
- data/plugin/livemagick.rb +17 -17
- data/plugin/markdown.rb +10 -10
- data/plugin/pyggish.rb +118 -118
- data/plugin/tutorial.rb +15 -15
- data/test/all.rb +6 -0
- data/test/snapshots/{error_inc_line_num → basic_formatting}/actual-error.txt +0 -0
- data/test/snapshots/basic_formatting/actual-output.txt +13 -0
- data/test/snapshots/basic_formatting/err-sdiff.txt +1 -0
- data/test/snapshots/basic_formatting/out-sdiff.txt +14 -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 → README.txt} +11 -8
- 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_invalid_name/foo +5 -0
- 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/expected-output.txt +1 -0
- 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/import/expected-output.txt +2 -1
- data/test/snapshots/import/match-error.txt +1 -1
- data/test/snapshots/import/simple_import.rb +1 -1
- data/test/snapshots/import2/simple_import.rb +1 -1
- data/test/snapshots/import_bookish/expected-output.txt +4 -4
- data/test/snapshots/{error_invalid_name/actual-output.txt → more_functions/actual-error.txt} +0 -0
- data/test/snapshots/more_functions/actual-output.txt +37 -0
- data/test/snapshots/more_functions/err-sdiff.txt +1 -0
- data/test/snapshots/more_functions/expected-output.txt +1 -1
- data/test/snapshots/more_functions/out-sdiff.txt +38 -0
- data/test/snapshots/more_functions/source.lt3 +1 -1
- data/test/snapshots/raw_lines/expected-output.txt +0 -2
- data/test/snapshots/simple_import/simple_import.rb +1 -1
- data/test/snapshots/simple_mixin/simple_mixin.rb +1 -1
- data/test/snapshots/{error_missing_end/actual-output.txt → simple_vars/actual-error.txt} +0 -0
- data/test/snapshots/simple_vars/actual-output.txt +6 -0
- data/test/snapshots/simple_vars/err-sdiff.txt +1 -0
- data/test/snapshots/simple_vars/out-sdiff.txt +7 -0
- data/test/snapshots/single_raw_line/expected-output.txt +0 -2
- data/test/snapshots/subset.txt +9 -7
- data/test/snapshots/{error_no_such_copy/actual-output.txt → var_into_func/actual-error.txt} +0 -0
- data/test/snapshots/var_into_func/actual-output.txt +16 -0
- data/test/snapshots/var_into_func/err-sdiff.txt +1 -0
- data/test/snapshots/{error_no_such_inc/actual-output.txt → var_into_func/expected-error.txt} +0 -0
- data/test/snapshots/var_into_func/expected-output.txt +16 -0
- data/test/snapshots/var_into_func/out-sdiff.txt +17 -0
- data/test/snapshots/var_into_func/source.lt3 +16 -0
- data/test/snapshots.rb +16 -7
- data/test/unit/all.rb +3 -1
- data/test/unit/formatline.rb +145 -276
- data/test/unit/html.rb +1 -2
- data/test/unit/lineparser.rb +650 -0
- data/test/unit/parser/set.rb +13 -12
- data/test/unit/standard.rb +0 -1
- data/test/unit/tokenizer.rb +534 -0
- metadata +49 -39
- data/lib/funcall.rb +0 -93
- data/lib/parser/file.rb +0 -6
- data/lib/parser/mixin.rb +0 -34
- data/lib/userapi.rb +0 -164
- data/test/snapshots/error_inc_line_num/actual-output.txt +0 -17
- data/test/snapshots/error_invalid_name/actual-error.txt +0 -10
- data/test/snapshots/error_invalid_name/out-sdiff.txt +0 -6
- data/test/snapshots/error_missing_end/actual-error.txt +0 -10
- data/test/snapshots/error_missing_end/out-sdiff.txt +0 -6
- data/test/snapshots/error_no_such_copy/actual-error.txt +0 -10
- data/test/snapshots/error_no_such_copy/out-sdiff.txt +0 -5
- data/test/snapshots/error_no_such_inc/actual-error.txt +0 -10
- data/test/snapshots/error_no_such_inc/out-sdiff.txt +0 -6
- data/test/snapshots/error_no_such_mixin/actual-error.txt +0 -13
- data/test/snapshots/error_no_such_mixin/actual-output.txt +0 -0
- data/test/snapshots/error_no_such_mixin/out-sdiff.txt +0 -6
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.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hal Fulton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A smart text processor extensible in Ruby
|
14
14
|
email: rubyhacker@gmail.com
|
@@ -27,26 +27,31 @@ files:
|
|
27
27
|
- imports/pyggish.rb
|
28
28
|
- imports/tutorial.rb
|
29
29
|
- lib/cmdargs.rb
|
30
|
-
- lib/errors.rb
|
31
|
-
- lib/formatline.rb
|
32
|
-
- lib/funcall.rb
|
33
|
-
- lib/functions.rb
|
34
|
-
- lib/global_helpers.rb
|
35
|
-
- lib/handler.rb
|
36
|
-
- lib/handler/import.rb
|
37
|
-
- lib/helpers.rb
|
38
|
-
- lib/html.rb
|
39
30
|
- lib/livetext.rb
|
40
|
-
- lib/
|
41
|
-
- lib/
|
42
|
-
- lib/
|
43
|
-
- lib/
|
44
|
-
- lib/
|
45
|
-
- lib/
|
46
|
-
- lib/
|
47
|
-
- lib/
|
48
|
-
- lib/
|
49
|
-
- lib/
|
31
|
+
- lib/livetext/errors.rb
|
32
|
+
- lib/livetext/formatline.rb
|
33
|
+
- lib/livetext/funcall.rb
|
34
|
+
- lib/livetext/functions.rb
|
35
|
+
- lib/livetext/global_helpers.rb
|
36
|
+
- lib/livetext/handler.rb
|
37
|
+
- lib/livetext/handler/import.rb
|
38
|
+
- lib/livetext/handler/mixin.rb
|
39
|
+
- lib/livetext/helpers.rb
|
40
|
+
- lib/livetext/html.rb
|
41
|
+
- lib/livetext/lineparser.rb
|
42
|
+
- lib/livetext/more.rb
|
43
|
+
- lib/livetext/parser.rb
|
44
|
+
- lib/livetext/parser/general.rb
|
45
|
+
- lib/livetext/parser/set.rb
|
46
|
+
- lib/livetext/parser/string.rb
|
47
|
+
- lib/livetext/parsing.rb
|
48
|
+
- lib/livetext/paths.rb
|
49
|
+
- lib/livetext/processor.rb
|
50
|
+
- lib/livetext/reopen.rb
|
51
|
+
- lib/livetext/skeleton.rb
|
52
|
+
- lib/livetext/standard.rb
|
53
|
+
- lib/livetext/userapi.rb
|
54
|
+
- lib/livetext/version.rb
|
50
55
|
- livetext.gemspec
|
51
56
|
- plugin/bookish.rb
|
52
57
|
- plugin/calibre.rb
|
@@ -56,8 +61,12 @@ files:
|
|
56
61
|
- plugin/tutorial.rb
|
57
62
|
- test/all.rb
|
58
63
|
- test/snapshots.rb
|
64
|
+
- test/snapshots/basic_formatting/actual-error.txt
|
65
|
+
- test/snapshots/basic_formatting/actual-output.txt
|
66
|
+
- test/snapshots/basic_formatting/err-sdiff.txt
|
59
67
|
- test/snapshots/basic_formatting/expected-error.txt
|
60
68
|
- test/snapshots/basic_formatting/expected-output.txt
|
69
|
+
- test/snapshots/basic_formatting/out-sdiff.txt
|
61
70
|
- test/snapshots/basic_formatting/source.lt3
|
62
71
|
- test/snapshots/block_comment/expected-error.txt
|
63
72
|
- test/snapshots/block_comment/expected-output.txt
|
@@ -72,18 +81,14 @@ files:
|
|
72
81
|
- test/snapshots/def_method/expected-error.txt
|
73
82
|
- test/snapshots/def_method/expected-output.txt
|
74
83
|
- test/snapshots/def_method/source.lt3
|
75
|
-
- test/snapshots/error_inc_line_num/
|
76
|
-
- test/snapshots/error_inc_line_num/actual-error.txt
|
77
|
-
- test/snapshots/error_inc_line_num/actual-output.txt
|
84
|
+
- test/snapshots/error_inc_line_num/README.txt
|
78
85
|
- test/snapshots/error_inc_line_num/expected-output.txt
|
79
86
|
- test/snapshots/error_inc_line_num/file2.lt3
|
80
87
|
- test/snapshots/error_inc_line_num/match-error.txt
|
81
88
|
- test/snapshots/error_inc_line_num/source.lt3
|
82
|
-
- test/snapshots/error_invalid_name/actual-error.txt
|
83
|
-
- test/snapshots/error_invalid_name/actual-output.txt
|
84
89
|
- test/snapshots/error_invalid_name/expected-output.txt
|
90
|
+
- test/snapshots/error_invalid_name/foo
|
85
91
|
- test/snapshots/error_invalid_name/match-error.txt
|
86
|
-
- test/snapshots/error_invalid_name/out-sdiff.txt
|
87
92
|
- test/snapshots/error_invalid_name/source.lt3
|
88
93
|
- test/snapshots/error_line_num/expected-output.txt
|
89
94
|
- test/snapshots/error_line_num/match-error.txt
|
@@ -91,32 +96,20 @@ files:
|
|
91
96
|
- test/snapshots/error_mismatched_end/expected-output.txt
|
92
97
|
- test/snapshots/error_mismatched_end/match-error.txt
|
93
98
|
- test/snapshots/error_mismatched_end/source.lt3
|
94
|
-
- test/snapshots/error_missing_end/actual-error.txt
|
95
|
-
- test/snapshots/error_missing_end/actual-output.txt
|
96
99
|
- test/snapshots/error_missing_end/expected-output.txt
|
97
100
|
- test/snapshots/error_missing_end/match-error.txt
|
98
|
-
- test/snapshots/error_missing_end/out-sdiff.txt
|
99
101
|
- test/snapshots/error_missing_end/source.lt3
|
100
102
|
- test/snapshots/error_name_not_permitted/expected-output.txt
|
101
103
|
- test/snapshots/error_name_not_permitted/match-error.txt
|
102
104
|
- test/snapshots/error_name_not_permitted/source.lt3
|
103
|
-
- test/snapshots/error_no_such_copy/actual-error.txt
|
104
|
-
- test/snapshots/error_no_such_copy/actual-output.txt
|
105
105
|
- test/snapshots/error_no_such_copy/expected-output.txt
|
106
106
|
- test/snapshots/error_no_such_copy/match-error.txt
|
107
|
-
- test/snapshots/error_no_such_copy/out-sdiff.txt
|
108
107
|
- test/snapshots/error_no_such_copy/source.lt3
|
109
|
-
- test/snapshots/error_no_such_inc/actual-error.txt
|
110
|
-
- test/snapshots/error_no_such_inc/actual-output.txt
|
111
108
|
- test/snapshots/error_no_such_inc/expected-output.txt
|
112
109
|
- test/snapshots/error_no_such_inc/match-error.txt
|
113
|
-
- test/snapshots/error_no_such_inc/out-sdiff.txt
|
114
110
|
- test/snapshots/error_no_such_inc/source.lt3
|
115
|
-
- test/snapshots/error_no_such_mixin/actual-error.txt
|
116
|
-
- test/snapshots/error_no_such_mixin/actual-output.txt
|
117
111
|
- test/snapshots/error_no_such_mixin/expected-output.txt
|
118
112
|
- test/snapshots/error_no_such_mixin/match-error.txt
|
119
|
-
- test/snapshots/error_no_such_mixin/out-sdiff.txt
|
120
113
|
- test/snapshots/error_no_such_mixin/source.lt3
|
121
114
|
- test/snapshots/example_alpha/expected-error.txt
|
122
115
|
- test/snapshots/example_alpha/expected-output.txt
|
@@ -149,8 +142,12 @@ files:
|
|
149
142
|
- test/snapshots/more_complex_vars/expected-error.txt
|
150
143
|
- test/snapshots/more_complex_vars/expected-output.txt
|
151
144
|
- test/snapshots/more_complex_vars/source.lt3
|
145
|
+
- test/snapshots/more_functions/actual-error.txt
|
146
|
+
- test/snapshots/more_functions/actual-output.txt
|
147
|
+
- test/snapshots/more_functions/err-sdiff.txt
|
152
148
|
- test/snapshots/more_functions/expected-error.txt
|
153
149
|
- test/snapshots/more_functions/expected-output.txt
|
150
|
+
- test/snapshots/more_functions/out-sdiff.txt
|
154
151
|
- test/snapshots/more_functions/source.lt3
|
155
152
|
- test/snapshots/predef_vars/expected-error.txt
|
156
153
|
- test/snapshots/predef_vars/match-output.txt
|
@@ -178,8 +175,12 @@ files:
|
|
178
175
|
- test/snapshots/simple_mixin/expected-output.txt
|
179
176
|
- test/snapshots/simple_mixin/simple_mixin.rb
|
180
177
|
- test/snapshots/simple_mixin/source.lt3
|
178
|
+
- test/snapshots/simple_vars/actual-error.txt
|
179
|
+
- test/snapshots/simple_vars/actual-output.txt
|
180
|
+
- test/snapshots/simple_vars/err-sdiff.txt
|
181
181
|
- test/snapshots/simple_vars/expected-error.txt
|
182
182
|
- test/snapshots/simple_vars/expected-output.txt
|
183
|
+
- test/snapshots/simple_vars/out-sdiff.txt
|
183
184
|
- test/snapshots/simple_vars/source.lt3
|
184
185
|
- test/snapshots/single_raw_line/expected-error.txt
|
185
186
|
- test/snapshots/single_raw_line/expected-output.txt
|
@@ -188,10 +189,18 @@ files:
|
|
188
189
|
- test/snapshots/table_with_heredocs/expected-error.txt
|
189
190
|
- test/snapshots/table_with_heredocs/expected-output.txt
|
190
191
|
- test/snapshots/table_with_heredocs/source.lt3
|
192
|
+
- test/snapshots/var_into_func/actual-error.txt
|
193
|
+
- test/snapshots/var_into_func/actual-output.txt
|
194
|
+
- test/snapshots/var_into_func/err-sdiff.txt
|
195
|
+
- test/snapshots/var_into_func/expected-error.txt
|
196
|
+
- test/snapshots/var_into_func/expected-output.txt
|
197
|
+
- test/snapshots/var_into_func/out-sdiff.txt
|
198
|
+
- test/snapshots/var_into_func/source.lt3
|
191
199
|
- test/testlines.rb
|
192
200
|
- test/unit/all.rb
|
193
201
|
- test/unit/formatline.rb
|
194
202
|
- test/unit/html.rb
|
203
|
+
- test/unit/lineparser.rb
|
195
204
|
- test/unit/parser.rb
|
196
205
|
- test/unit/parser/all.rb
|
197
206
|
- test/unit/parser/general.rb
|
@@ -200,6 +209,7 @@ files:
|
|
200
209
|
- test/unit/parser/string.rb
|
201
210
|
- test/unit/standard.rb
|
202
211
|
- test/unit/stringparser.rb
|
212
|
+
- test/unit/tokenizer.rb
|
203
213
|
homepage: https://github.com/Hal9000/livetext
|
204
214
|
licenses:
|
205
215
|
- Ruby
|
data/lib/funcall.rb
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
# p __FILE__
|
2
|
-
|
3
|
-
require_relative 'livetext'
|
4
|
-
# require_relative 'formatline'
|
5
|
-
|
6
|
-
# Parse function calls
|
7
|
-
|
8
|
-
module Livetext::FormatLine::FunCall
|
9
|
-
|
10
|
-
include Livetext::ParsingConstants
|
11
|
-
|
12
|
-
def grab_colon_param
|
13
|
-
grab # grab :
|
14
|
-
param = ""
|
15
|
-
loop do
|
16
|
-
case lookahead
|
17
|
-
when Escape
|
18
|
-
grab
|
19
|
-
param << lookahead
|
20
|
-
grab
|
21
|
-
when Space, LF, nil; break
|
22
|
-
else
|
23
|
-
param << lookahead
|
24
|
-
grab
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
param = nil if param.empty?
|
29
|
-
param
|
30
|
-
end
|
31
|
-
|
32
|
-
def grab_bracket_param
|
33
|
-
grab # [
|
34
|
-
param = ""
|
35
|
-
loop do
|
36
|
-
case lookahead
|
37
|
-
when Escape
|
38
|
-
grab
|
39
|
-
param << lookahead
|
40
|
-
grab
|
41
|
-
when "]", LF, nil
|
42
|
-
break
|
43
|
-
else
|
44
|
-
param << lookahead
|
45
|
-
grab
|
46
|
-
end
|
47
|
-
end
|
48
|
-
add peek
|
49
|
-
grab
|
50
|
-
param = nil if param.empty?
|
51
|
-
param
|
52
|
-
end
|
53
|
-
|
54
|
-
def funcall(name, param)
|
55
|
-
err = "[Error evaluating $$#{name}(#{param})]"
|
56
|
-
func_name = name # "func_" + name.to_s
|
57
|
-
result =
|
58
|
-
if self.send?(func_name, param) # self.respond_to?(func_name)
|
59
|
-
# do nothing
|
60
|
-
else
|
61
|
-
fobj = ::Livetext::Functions.new
|
62
|
-
fobj.send(name, param) rescue err
|
63
|
-
end
|
64
|
-
result.to_s
|
65
|
-
end
|
66
|
-
|
67
|
-
def double_dollar
|
68
|
-
case lookahead
|
69
|
-
when Space; add_token :string, "$$ "; grab; return
|
70
|
-
when LF, nil; add "$$"; add_token :str
|
71
|
-
when Alpha
|
72
|
-
add_token(:str, @token)
|
73
|
-
func = grab_alpha
|
74
|
-
add_token(:func, func)
|
75
|
-
param = grab_func_param # may be null/missing
|
76
|
-
else
|
77
|
-
grab; add_token :str, "$$" + peek; return
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def grab_func_param
|
82
|
-
case lookahead
|
83
|
-
when "["
|
84
|
-
param = grab_bracket_param
|
85
|
-
add_token(:brackets, param)
|
86
|
-
when ":"
|
87
|
-
param = grab_colon_param
|
88
|
-
add_token(:colon, param)
|
89
|
-
else # do nothing
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
data/lib/parser/file.rb
DELETED
data/lib/parser/mixin.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require_relative '../helpers' # FIXME This seems wrong
|
2
|
-
|
3
|
-
make_exception(:NoEqualSign, "Error: no equal sign found")
|
4
|
-
|
5
|
-
class Livetext::ParseMixin
|
6
|
-
include Livetext::Helpers
|
7
|
-
|
8
|
-
def initialize(name)
|
9
|
-
@name = name
|
10
|
-
@file = find_file(name, ".rb", "plugin")
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.get_module(name)
|
14
|
-
parse = self.new(name)
|
15
|
-
modname, code = parse.read_mixin
|
16
|
-
eval(code) # Avoid in the future
|
17
|
-
newmod = Object.const_get("::" + modname)
|
18
|
-
newmod # return actual module
|
19
|
-
end
|
20
|
-
|
21
|
-
def read_mixin
|
22
|
-
modname = @name.gsub("/","_").capitalize
|
23
|
-
meths = grab_file(@file)
|
24
|
-
[modname, "module ::#{modname}; #{meths}\nend"]
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def cwd_root?
|
30
|
-
File.dirname(File.expand_path(".")) == "/"
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
data/lib/userapi.rb
DELETED
@@ -1,164 +0,0 @@
|
|
1
|
-
# p __FILE__
|
2
|
-
|
3
|
-
require_relative 'formatline'
|
4
|
-
|
5
|
-
# UserAPI deals mostly with user-level methods.
|
6
|
-
|
7
|
-
module Livetext::UserAPI
|
8
|
-
|
9
|
-
# FIXME I am tired of all my leading underscores...
|
10
|
-
# FIXME Q: Could this be converted into a class?? What about its
|
11
|
-
# interaction thru instance vars?
|
12
|
-
|
13
|
-
def setvar(var, val)
|
14
|
-
str, sym = var.to_s, var.to_sym
|
15
|
-
Livetext::Vars[str] = val
|
16
|
-
Livetext::Vars[sym] = val
|
17
|
-
end
|
18
|
-
|
19
|
-
def _check_existence(file, msg)
|
20
|
-
_error! msg unless File.exist?(file)
|
21
|
-
end
|
22
|
-
|
23
|
-
def _source
|
24
|
-
@input
|
25
|
-
end
|
26
|
-
|
27
|
-
def _args
|
28
|
-
@_args = _format(@_data).chomp.split
|
29
|
-
if block_given?
|
30
|
-
@_args.each {|arg| yield arg }
|
31
|
-
else
|
32
|
-
@_args
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def _vars
|
37
|
-
@_vars.dup
|
38
|
-
end
|
39
|
-
|
40
|
-
def _optional_blank_line
|
41
|
-
peek = peek_nextline
|
42
|
-
return if peek.nil?
|
43
|
-
@line = nextline if peek =~ /^ *$/
|
44
|
-
end
|
45
|
-
|
46
|
-
def _comment?(str)
|
47
|
-
sigil = Livetext::Sigil
|
48
|
-
c1 = sigil + Livetext::Space
|
49
|
-
c2 = sigil + sigil + Livetext::Space
|
50
|
-
str.index(c1) == 0 || str.index(c2) == 0
|
51
|
-
end
|
52
|
-
|
53
|
-
def _trailing?(char)
|
54
|
-
return true if ["\n", " ", nil].include?(char)
|
55
|
-
return false
|
56
|
-
end
|
57
|
-
|
58
|
-
def _end?(str)
|
59
|
-
return true if str == ".end" || str =~ / *\$\.end/
|
60
|
-
return false
|
61
|
-
end
|
62
|
-
|
63
|
-
def _raw_body(tag = "__EOF__")
|
64
|
-
lines = []
|
65
|
-
# @save_location = @sources.last
|
66
|
-
loop do
|
67
|
-
@line = nextline
|
68
|
-
break if @line.nil?
|
69
|
-
break if @line.chomp.strip == tag
|
70
|
-
lines << @line
|
71
|
-
end
|
72
|
-
_optional_blank_line
|
73
|
-
if block_given?
|
74
|
-
lines.each {|line| yield line }
|
75
|
-
else
|
76
|
-
lines
|
77
|
-
end
|
78
|
-
lines
|
79
|
-
end
|
80
|
-
|
81
|
-
def _body(raw=false)
|
82
|
-
lines = []
|
83
|
-
end_found = false
|
84
|
-
loop do
|
85
|
-
@line = nextline
|
86
|
-
break if @line.nil?
|
87
|
-
@line.chomp!
|
88
|
-
break if _end?(@line)
|
89
|
-
next if _comment?(@line)
|
90
|
-
@line = _format(@line) unless raw
|
91
|
-
lines << @line
|
92
|
-
end
|
93
|
-
|
94
|
-
raise "Expected .end, found end of file" unless _end?(@line)
|
95
|
-
|
96
|
-
_optional_blank_line
|
97
|
-
if block_given?
|
98
|
-
lines.each {|line| yield line } # FIXME what about $. ?
|
99
|
-
else
|
100
|
-
lines
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def _body_text(raw=false)
|
105
|
-
_raw_body.join("\n")
|
106
|
-
end
|
107
|
-
|
108
|
-
def _raw_body!
|
109
|
-
_raw_body(Livetext::Sigil).join("\n")
|
110
|
-
end
|
111
|
-
|
112
|
-
def _handle_escapes(str, set)
|
113
|
-
str = str.dup
|
114
|
-
set.each_char do |ch|
|
115
|
-
str.gsub!("\\#{ch}", ch)
|
116
|
-
end
|
117
|
-
str
|
118
|
-
end
|
119
|
-
|
120
|
-
def _format(line)
|
121
|
-
return "" if line == "\n" || line.nil?
|
122
|
-
line2 = Livetext::FormatLine.parse!(line)
|
123
|
-
line.replace(line2)
|
124
|
-
line
|
125
|
-
end
|
126
|
-
|
127
|
-
def _passthru(line)
|
128
|
-
return if @_nopass
|
129
|
-
_out "<p>" if line == "\n" and ! @_nopara
|
130
|
-
line = _format(line)
|
131
|
-
_out line
|
132
|
-
end
|
133
|
-
|
134
|
-
def _out(str = "", file = nil)
|
135
|
-
return if str.nil?
|
136
|
-
if file.nil? # FIXME do this elsewhere?
|
137
|
-
@parent.body << str
|
138
|
-
@parent.body << "\n" unless str.end_with?("\n")
|
139
|
-
else
|
140
|
-
file.puts str
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
def _out!(str = "")
|
145
|
-
@parent.body << str # no newline
|
146
|
-
end
|
147
|
-
|
148
|
-
def _puts(*args)
|
149
|
-
@output.puts *args
|
150
|
-
end
|
151
|
-
|
152
|
-
def _print(*args)
|
153
|
-
@output.print *args
|
154
|
-
end
|
155
|
-
|
156
|
-
def _debug=(val)
|
157
|
-
@_debug = val
|
158
|
-
end
|
159
|
-
|
160
|
-
def _debug(*args)
|
161
|
-
TTY.puts *args if @_debug
|
162
|
-
end
|
163
|
-
|
164
|
-
end
|
@@ -1,17 +0,0 @@
|
|
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.
|
@@ -1,10 +0,0 @@
|
|
1
|
-
/Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:146:in `check_disallowed': Error: name 'to_s' is invalid (DisallowedName)
|
2
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/standard.rb:142:in `dot_def'
|
3
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:101:in `handle_dotcmd'
|
4
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:79:in `process_line'
|
5
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:63:in `block in process_file'
|
6
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:60:in `loop'
|
7
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:60:in `process_file'
|
8
|
-
from ../../../bin/livetext:86:in `block in <main>'
|
9
|
-
from ../../../bin/livetext:57:in `loop'
|
10
|
-
from ../../../bin/livetext:57:in `<main>'
|
@@ -1,10 +0,0 @@
|
|
1
|
-
/Users/Hal/Dropbox/topx/git/livetext/lib/userapi.rb:92:in `_body': Expected .end, found end of file (RuntimeError)
|
2
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/standard.rb:48:in `comment'
|
3
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:101:in `handle_dotcmd'
|
4
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:79:in `process_line'
|
5
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:63:in `block in process_file'
|
6
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:60:in `loop'
|
7
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:60:in `process_file'
|
8
|
-
from ../../../bin/livetext:86:in `block in <main>'
|
9
|
-
from ../../../bin/livetext:57:in `loop'
|
10
|
-
from ../../../bin/livetext:57:in `<main>'
|
@@ -1,10 +0,0 @@
|
|
1
|
-
/Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:150:in `check_file_exists': Error: file 'nosuchfile.txt' not found (FileNotFound)
|
2
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/standard.rb:255:in `copy'
|
3
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:101:in `handle_dotcmd'
|
4
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:79:in `process_line'
|
5
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:63:in `block in process_file'
|
6
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:60:in `loop'
|
7
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:60:in `process_file'
|
8
|
-
from ../../../bin/livetext:86:in `block in <main>'
|
9
|
-
from ../../../bin/livetext:57:in `loop'
|
10
|
-
from ../../../bin/livetext:57:in `<main>'
|
@@ -1,10 +0,0 @@
|
|
1
|
-
/Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:150:in `check_file_exists': Error: file 'nosuchinc.lt3' not found (FileNotFound)
|
2
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/standard.rb:209:in `dot_include'
|
3
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:101:in `handle_dotcmd'
|
4
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:79:in `process_line'
|
5
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:63:in `block in process_file'
|
6
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:60:in `loop'
|
7
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:60:in `process_file'
|
8
|
-
from ../../../bin/livetext:86:in `block in <main>'
|
9
|
-
from ../../../bin/livetext:57:in `loop'
|
10
|
-
from ../../../bin/livetext:57:in `<main>'
|
@@ -1,13 +0,0 @@
|
|
1
|
-
/Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:36:in `find_file': No such mixin 'nosuchthing' (RuntimeError)
|
2
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/parser/mixin.rb:12:in `initialize'
|
3
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/parser/mixin.rb:16:in `new'
|
4
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/parser/mixin.rb:16:in `get_module'
|
5
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/standard.rb:234:in `mixin'
|
6
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:101:in `handle_dotcmd'
|
7
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:79:in `process_line'
|
8
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:63:in `block in process_file'
|
9
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:60:in `loop'
|
10
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:60:in `process_file'
|
11
|
-
from ../../../bin/livetext:86:in `block in <main>'
|
12
|
-
from ../../../bin/livetext:57:in `loop'
|
13
|
-
from ../../../bin/livetext:57:in `<main>'
|
File without changes
|