livetext 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/bin/livetext +13 -5
  3. data/lib/livetext.rb +1 -1
  4. data/lib/standard.rb +231 -0
  5. data/lib/userapi.rb +181 -0
  6. data/livetext.gemspec +9 -86
  7. data/test/affirm/kbks.jpg +0 -0
  8. data/test/affirm/lm-kbks.lt +19 -0
  9. data/test/testfiles/copy_is_raw/rawtext.inc +4 -0
  10. data/test/testfiles/crap +16 -0
  11. data/test/testfiles/error_inc_line_num/expected-error.txt +1 -0
  12. data/test/testfiles/error_inc_line_num/expected-output.txt +7 -0
  13. data/test/testfiles/error_inc_line_num/file2.ltx +7 -0
  14. data/test/testfiles/error_inc_line_num/source.ltx +8 -0
  15. data/test/testfiles/error_invalid_name/expected-error.txt +1 -0
  16. data/test/testfiles/error_invalid_name/expected-output.txt +5 -0
  17. data/test/testfiles/error_invalid_name/source.ltx +9 -0
  18. data/test/testfiles/error_line_num/expected-error.txt +1 -0
  19. data/test/testfiles/error_line_num/expected-output.txt +3 -0
  20. data/test/testfiles/error_line_num/source.ltx +6 -0
  21. data/test/testfiles/error_mismatched_end/expected-error.txt +1 -0
  22. data/test/testfiles/error_mismatched_end/expected-output.txt +6 -0
  23. data/test/testfiles/error_mismatched_end/source.ltx +8 -0
  24. data/test/testfiles/error_missing_end/expected-error.txt +1 -0
  25. data/test/testfiles/error_missing_end/expected-output.txt +4 -0
  26. data/test/testfiles/error_missing_end/source.ltx +6 -0
  27. data/test/testfiles/error_name_not_permitted/expected-error.txt +1 -0
  28. data/test/testfiles/error_name_not_permitted/expected-output.txt +4 -0
  29. data/test/testfiles/error_name_not_permitted/source.ltx +6 -0
  30. data/test/testfiles/error_no_such_copy/expected-error.txt +1 -0
  31. data/test/testfiles/error_no_such_copy/expected-output.txt +5 -0
  32. data/test/testfiles/error_no_such_copy/source.ltx +8 -0
  33. data/test/testfiles/error_no_such_inc/expected-error.txt +1 -0
  34. data/test/testfiles/error_no_such_inc/expected-output.txt +5 -0
  35. data/test/testfiles/error_no_such_inc/source.ltx +8 -0
  36. data/test/testfiles/error_no_such_mixin/expected-error.txt +1 -0
  37. data/test/testfiles/error_no_such_mixin/expected-output.txt +6 -0
  38. data/test/testfiles/error_no_such_mixin/source.ltx +10 -0
  39. data/test/testfiles/functions/expected-error.txt +0 -0
  40. data/test/testfiles/functions/expected-output.txt +8 -0
  41. data/test/testfiles/functions/source.ltx +11 -0
  42. data/test/testfiles/raw_text_block/rawtext.inc +4 -0
  43. data/test/testfiles/simple_copy/simplefile.inc +2 -0
  44. data/test/testfiles/simple_include/simplefile.inc +2 -0
  45. data/test/testfiles/simple_mixin/simple_mixin.rb +3 -0
  46. data/test/try.lt +20 -0
  47. data/test/try2.lt +20 -0
  48. metadata +106 -63
  49. data/notes.txt +0 -146
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ae7c917ce5e93c8b0d53795b72471d5b7ca18ea
4
- data.tar.gz: aca0850f743ae6d906c8581a466510dd022e53cf
3
+ metadata.gz: b7059d92044e10b0b6434ca10c8fca98495abd9c
4
+ data.tar.gz: 7811dac366af024bd3257d31278902d023a5d4ec
5
5
  SHA512:
6
- metadata.gz: 4036aeecc7357e64ad8cb9328ee5fdb808e218d2f1b4d96b1164152ef02ae1602725570e8a521237b9d3ade1fd3e716f76b5440baa8a83f8e52e9e046806d739
7
- data.tar.gz: 7e2ed315502c6868aed402b91364285a99a89d5db83e38d69dda55ba98dfce10fb388ca34ee6de7e50f4830778605d7621acc600de351a84cb5b7fb0d8491d79
6
+ metadata.gz: 09c0a9e24e023e36a26c3b176a5ddb7d1e4f474ffe372da8595d947b88f2e7bce49269190dc2e76f4d293354b8582974da41b64dd801dd10c5b0fb84a59d99db
7
+ data.tar.gz: eba59a3e5dde7c6c609bbc0e5c6d093d7dc2dacee41301451e06eb5ceb770754025180694fe1cafde14e141301e8d9fc2f273e1e46f76ebe87f74422e67f8d18
data/bin/livetext CHANGED
@@ -4,18 +4,26 @@ require_relative '../lib/livetext'
4
4
 
5
5
  def handle_ltx(src)
6
6
  abort "Unknown file extension" unless src =~ /.ltx$/
7
-
8
7
  x = Livetext.new
9
8
  x.process_file(src)
10
9
  end
11
10
 
12
11
  # Main
13
12
 
14
- if ARGV.first == "--clean-all"
15
- clean_all
16
- exit
13
+ case ARGV.first
14
+ when "-v", "--version"
15
+ puts "livetext version #{Livetext::VERSION}\n "
16
+ exit
17
+ when nil
18
+ puts "Usage: "
19
+ puts " livetext -v"
20
+ puts " livetext --version"
21
+ puts " livetext filename"
22
+ puts
23
+ exit
24
+ else
25
+ src = ARGV.first
17
26
  end
18
27
 
19
- src = ARGV.first
20
28
  handle_ltx(src)
21
29
 
data/lib/livetext.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Livetext
2
- VERSION = "0.7.5"
2
+ VERSION = "0.7.6"
3
3
  end
4
4
 
5
5
  require 'fileutils'
data/lib/standard.rb ADDED
@@ -0,0 +1,231 @@
1
+ module Livetext::Standard
2
+
3
+ def data=(val)
4
+ @_data = val
5
+ @_args = val.split
6
+ @_mixins = []
7
+ end
8
+
9
+ def comment
10
+ junk = _body # do nothing with contents
11
+ end
12
+
13
+ def shell
14
+ cmd = @_data
15
+ _errout("Running: #{cmd}")
16
+ system(cmd)
17
+ end
18
+
19
+ def func
20
+ funcname = @_args[0]
21
+ _error! "Illegal name '#{funcname}'" if _disallowed?(funcname)
22
+ func_def = <<-EOS
23
+ def #{funcname}
24
+ #{_body!}
25
+ end
26
+ EOS
27
+ Livetext::Functions.class_eval func_def
28
+ end
29
+
30
+ def shell!
31
+ cmd = @_data
32
+ system(cmd)
33
+ end
34
+
35
+ def errout
36
+ TTY.puts @_data
37
+ end
38
+
39
+ def say
40
+ str = _substitution(@_data)
41
+ TTY.puts str
42
+ _optional_blank_line
43
+ end
44
+
45
+ def banner
46
+ str = _substitution(@_data)
47
+ n = str.length - 1
48
+ _errout "-"*n
49
+ _errout str
50
+ _errout "-"*n
51
+ end
52
+
53
+ def quit
54
+ @output.close
55
+ exit
56
+ end
57
+
58
+ def outdir
59
+ @_outdir = @_args.first
60
+ _optional_blank_line
61
+ end
62
+
63
+ def outdir! # FIXME ?
64
+ @_outdir = @_args.first
65
+ raise "No output directory specified" if @_outdir.nil?
66
+ raise "No output directory specified" if @_outdir.empty?
67
+ system("rm -f #@_outdir/*.html")
68
+ _optional_blank_line
69
+ end
70
+
71
+ def _output(name)
72
+ @output.close unless @output == STDOUT
73
+ @output = File.open(@_outdir + "/" + name, "w")
74
+ @output.puts "<meta charset='UTF-8'>\n\n"
75
+ end
76
+
77
+ def _append(name)
78
+ @output.close unless @output == STDOUT
79
+ @output = File.open(@_outdir + "/" + name, "a")
80
+ @output.puts "<meta charset='UTF-8'>\n\n"
81
+ end
82
+
83
+ def output
84
+ name = @_args.first
85
+ _debug "Redirecting output to: #{name}"
86
+ _output(name)
87
+ end
88
+
89
+ def append
90
+ file = @_args[0]
91
+ _append(file)
92
+ end
93
+
94
+ def next_output
95
+ tag, num = @_args
96
+ _next_output(tag, num)
97
+ _optional_blank_line
98
+ end
99
+
100
+ def cleanup
101
+ @_args.each do |item|
102
+ if ::File.directory?(item)
103
+ system("rm -f #{item}/*")
104
+ else
105
+ ::FileUtils.rm(item)
106
+ end
107
+ end
108
+ end
109
+
110
+ def _next_output(tag = "sec", num = nil)
111
+ @_file_num = num ? num : @_file_num + 1
112
+ @_file_num = @_file_num.to_i
113
+ name = "#{'%03d' % @_file_num}-#{tag}.html"
114
+ _output(name)
115
+ end
116
+
117
+ def _def
118
+ name = @_args[0]
119
+ str = "def #{name}\n"
120
+ raise "Illegal name '#{name}'" if _disallowed?(name)
121
+ str += _body!
122
+ str += "end\n"
123
+ eval str
124
+ rescue => err
125
+ _error!(err)
126
+ end
127
+
128
+ def nopass
129
+ @_nopass = true
130
+ end
131
+
132
+ def set
133
+ assigns = @_data.chomp.split(/, */)
134
+ assigns.each do |a|
135
+ var, val = a.split("=")
136
+ val = val[1..-2] if val[0] == ?" and val[-1] == ?"
137
+ val = val[1..-2] if val[0] == ?' and val[-1] == ?'
138
+ @vars[var] = val
139
+ end
140
+ _optional_blank_line
141
+ end
142
+
143
+ def _include
144
+ file = @_args.first
145
+ _check_existence(file, "No such include file '#{file}'")
146
+ @parent.process_file(file)
147
+ _optional_blank_line
148
+ end
149
+
150
+ def include! # FIXME huh?
151
+ file = @_args.first
152
+ return unless File.exist?(file)
153
+
154
+ lines = @parent.process_file(file)
155
+ File.delete(file)
156
+ _optional_blank_line
157
+ end
158
+
159
+ def mixin
160
+ name = @_args.first # Expect a module name
161
+ file = "#{Plugins}/" + name.downcase + ".rb"
162
+ return if @_mixins.include?(name)
163
+ file = "./#{name}.rb" unless File.exist?(file)
164
+ _check_existence(file, "No such mixin '#{name}'")
165
+
166
+ @_mixins << name
167
+ meths = grab_file(file)
168
+ modname = name.gsub("/","_").capitalize
169
+ string = "module ::#{modname}\n#{meths}\nend"
170
+ eval(string)
171
+ newmod = Object.const_get("::" + modname)
172
+ self.extend(newmod)
173
+ init = "init_#{name}"
174
+ self.send(init) if self.respond_to? init
175
+ _optional_blank_line
176
+ end
177
+
178
+ def copy
179
+ file = @_args.first
180
+ _check_existence(file, "No such file '#{file}' to copy")
181
+ @output.puts grab_file(file)
182
+ _optional_blank_line
183
+ end
184
+
185
+ def r
186
+ _puts @_data # No processing at all
187
+ end
188
+
189
+ def raw
190
+ # No processing at all (terminate with __EOF__)
191
+ _puts _raw_body
192
+ end
193
+
194
+ def debug
195
+ arg = @_args.first
196
+ self._debug = true
197
+ self._debug = false if arg == "off"
198
+ end
199
+
200
+ def nopara
201
+ @_nopara = true
202
+ end
203
+
204
+ def heading
205
+ _print "<center><font size=+1><b>"
206
+ _print @_data
207
+ _print "</b></font></center>"
208
+ end
209
+
210
+ def newpage
211
+ _puts '<p style="page-break-after:always;"></p>'
212
+ _puts "<p/>"
213
+ end
214
+
215
+ def invoke(str)
216
+ end
217
+
218
+ def dlist
219
+ delim = "~~"
220
+ _puts "<table>"
221
+ _body do |line|
222
+ line = _formatting(line)
223
+ term, defn = line.split(delim)
224
+ _puts "<tr>"
225
+ _puts "<td width=3%><td width=10%>#{term}</td><td>#{defn}</td>"
226
+ _puts "</tr>"
227
+ end
228
+ _puts "</table>"
229
+ end
230
+
231
+ end
data/lib/userapi.rb ADDED
@@ -0,0 +1,181 @@
1
+ # User API
2
+
3
+ module Livetext::UserAPI
4
+
5
+ def _check_existence(file, msg)
6
+ _error! msg unless File.exist?(file)
7
+ # puts "ERROR" unless File.exist?(file)
8
+ end
9
+
10
+ def _source
11
+ @input
12
+ end
13
+
14
+ def _args
15
+ if block_given?
16
+ @_args.each {|arg| yield arg }
17
+ else
18
+ @_args
19
+ end
20
+ end
21
+
22
+ def _optional_blank_line
23
+ @line = nextline if peek_nextline =~ /^ *$/
24
+ end
25
+
26
+ def _comment?(str, sigil=".")
27
+ c1 = sigil + Livetext::Space
28
+ c2 = sigil + sigil + Livetext::Space
29
+ str.index(c1) == 0 || str.index(c2) == 0
30
+ end
31
+
32
+ def _trailing?(char)
33
+ return true if ["\n", " ", nil].include?(char)
34
+ return false
35
+ end
36
+
37
+ def _end?(str, sigil=".")
38
+ cmd = sigil + "end"
39
+ return false if str.index(cmd) != 0
40
+ return false unless _trailing?(str[5])
41
+ return true
42
+ end
43
+
44
+ def _raw_body(tag = "__EOF__", sigil = ".")
45
+ lines = []
46
+ @save_location = @sources.last
47
+ loop do
48
+ @line = nextline
49
+ break if @line.chomp.strip == tag
50
+ lines << @line
51
+ end
52
+ _optional_blank_line
53
+ if block_given?
54
+ lines.each {|line| yield @line }
55
+ else
56
+ lines
57
+ end
58
+ end
59
+
60
+ def _body(sigil=".")
61
+ lines = []
62
+ @save_location = @sources.last
63
+ loop do
64
+ @line = nextline
65
+ break if _end?(@line, sigil)
66
+ next if _comment?(@line, sigil) # FIXME?
67
+ lines << @line
68
+ end
69
+ _optional_blank_line
70
+ if block_given?
71
+ lines.each {|line| yield line }
72
+ else
73
+ lines
74
+ end
75
+ rescue => err
76
+ _error!("Expecting .end, found end of file")
77
+ end
78
+
79
+ def _body!(sigil=".")
80
+ _body(sigil).join("\n")
81
+ end
82
+
83
+ def _basic_format(line, delim, tag)
84
+ s = line.each_char
85
+ c = s.next
86
+ last = nil
87
+ getch = -> { last = c; c = s.next }
88
+ buffer = ""
89
+ loop do
90
+ case c
91
+ when " "
92
+ buffer << " "
93
+ last = " "
94
+ when delim
95
+ if last == " " || last == nil
96
+ buffer << "<#{tag}>"
97
+ c = getch.call
98
+ if c == "("
99
+ loop { getch.call; break if c == ")"; buffer << c }
100
+ buffer << "</#{tag}>"
101
+ else
102
+ loop { buffer << c; getch.call; break if c == " " || c == nil || c == "\n" }
103
+ buffer << "</#{tag}>"
104
+ buffer << " " if c == " "
105
+ end
106
+ else
107
+ buffer << delim
108
+ end
109
+ else
110
+ buffer << c
111
+ end
112
+ getch.call
113
+ end
114
+ buffer
115
+ end
116
+
117
+ def _handle_escapes(str, set)
118
+ str = str.dup
119
+ set.each_char do |ch|
120
+ str.gsub!("\\#{ch}", ch)
121
+ end
122
+ str
123
+ end
124
+
125
+ def _formatting(line)
126
+ l2 = _basic_format(line, "_", "i")
127
+ l2 = _basic_format(l2, "*", "b")
128
+ l2 = _basic_format(l2, "`", "tt")
129
+ l2 = _handle_escapes(l2, "_*`")
130
+ line.replace(l2)
131
+ end
132
+
133
+ def _func_sub
134
+ end
135
+
136
+ def _substitution(line)
137
+ # FIXME handle vars/functions separately later??
138
+ # FIXME permit parameters to functions
139
+ fobj = ::Livetext::Functions.new
140
+ @funcs = ::Livetext::Functions.instance_methods
141
+ @funcs.each do |func|
142
+ name = ::Regexp.escape("$$#{func}")
143
+ rx = /#{name}\b/
144
+ line.gsub!(rx) do |str|
145
+ val = fobj.send(func)
146
+ str.sub(rx, val)
147
+ end
148
+ end
149
+ @vars.each_pair do |var, val|
150
+ name = ::Regexp.escape("$#{var}")
151
+ rx = /#{name}\b/
152
+ line.gsub!(rx, val)
153
+ end
154
+ line
155
+ end
156
+
157
+ def _passthru(line)
158
+ return if @_nopass
159
+ _puts "<p>" if line == "\n" and ! @_nopara
160
+ _formatting(line)
161
+ _substitution(line)
162
+ _puts line
163
+ end
164
+
165
+ def _puts(*args)
166
+ @output.puts *args
167
+ end
168
+
169
+ def _print(*args)
170
+ @output.print *args
171
+ end
172
+
173
+ def _debug=(val)
174
+ @_debug = val
175
+ end
176
+
177
+ def _debug(*args)
178
+ TTY.puts *args if @_debug
179
+ end
180
+
181
+ end
data/livetext.gemspec CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'date'
2
+ require 'find'
2
3
 
3
4
  $: << "."
4
5
  require "lib/livetext"
@@ -12,92 +13,14 @@ Gem::Specification.new do |s|
12
13
  s.description = "A smart text processor extensible in Ruby"
13
14
  s.authors = ["Hal Fulton"]
14
15
  s.email = 'rubyhacker@gmail.com'
15
- s.files = %w[
16
- ./bin
17
- ./bin/livetext
18
- ./lib
19
- ./lib/livetext.rb
20
- ./lib/functions.rb
21
- ./dsl
22
- ./dsl/bookish.rb
23
- ./dsl/calibre.rb
24
- ./dsl/liveblog.rb
25
- ./dsl/livemagick.rb
26
- ./dsl/markdown.rb
27
- ./dsl/pyggish.rb
28
- ./dsl/tutorial.rb
29
- ./livetext.gemspec
30
- ./notes.txt
31
- ./README.html
32
- ./README.ltx
33
- ./README.md
34
- ./test
35
- ./test/cleanup
36
- ./test/newtest
37
- ./test/test.rb
38
- ./test/testfiles
39
- ./test/testfiles/basic_formatting
40
- ./test/testfiles/basic_formatting/expected-error.txt
41
- ./test/testfiles/basic_formatting/expected-output.txt
42
- ./test/testfiles/basic_formatting/source.ltx
43
- ./test/testfiles/block_comment
44
- ./test/testfiles/block_comment/expected-error.txt
45
- ./test/testfiles/block_comment/expected-output.txt
46
- ./test/testfiles/block_comment/source.ltx
47
- ./test/testfiles/comments_ignored_1
48
- ./test/testfiles/comments_ignored_1/expected-error.txt
49
- ./test/testfiles/comments_ignored_1/expected-output.txt
50
- ./test/testfiles/comments_ignored_1/source.ltx
51
- ./test/testfiles/copy_is_raw
52
- ./test/testfiles/copy_is_raw/expected-error.txt
53
- ./test/testfiles/copy_is_raw/expected-output.txt
54
- ./test/testfiles/copy_is_raw/source.ltx
55
- ./test/testfiles/def_method
56
- ./test/testfiles/def_method/expected-error.txt
57
- ./test/testfiles/def_method/expected-output.txt
58
- ./test/testfiles/def_method/source.ltx
59
- ./test/testfiles/example_alpha
60
- ./test/testfiles/example_alpha/expected-error.txt
61
- ./test/testfiles/example_alpha/expected-output.txt
62
- ./test/testfiles/example_alpha/source.ltx
63
- ./test/testfiles/example_alpha2
64
- ./test/testfiles/example_alpha2/expected-error.txt
65
- ./test/testfiles/example_alpha2/expected-output.txt
66
- ./test/testfiles/example_alpha2/source.ltx
67
- ./test/testfiles/fixit
68
- ./test/testfiles/hello_world
69
- ./test/testfiles/hello_world/expected-error.txt
70
- ./test/testfiles/hello_world/expected-output.txt
71
- ./test/testfiles/hello_world/source.ltx
72
- ./test/testfiles/more_complex_vars
73
- ./test/testfiles/more_complex_vars/expected-error.txt
74
- ./test/testfiles/more_complex_vars/expected-output.txt
75
- ./test/testfiles/more_complex_vars/source.ltx
76
- ./test/testfiles/raw_text_block
77
- ./test/testfiles/raw_text_block/expected-error.txt
78
- ./test/testfiles/raw_text_block/expected-output.txt
79
- ./test/testfiles/raw_text_block/source.ltx
80
- ./test/testfiles/simple_copy
81
- ./test/testfiles/simple_copy/expected-error.txt
82
- ./test/testfiles/simple_copy/expected-output.txt
83
- ./test/testfiles/simple_copy/source.ltx
84
- ./test/testfiles/simple_include
85
- ./test/testfiles/simple_include/expected-error.txt
86
- ./test/testfiles/simple_include/expected-output.txt
87
- ./test/testfiles/simple_include/source.ltx
88
- ./test/testfiles/simple_mixin
89
- ./test/testfiles/simple_mixin/expected-error.txt
90
- ./test/testfiles/simple_mixin/expected-output.txt
91
- ./test/testfiles/simple_mixin/source.ltx
92
- ./test/testfiles/simple_vars
93
- ./test/testfiles/simple_vars/expected-error.txt
94
- ./test/testfiles/simple_vars/expected-output.txt
95
- ./test/testfiles/simple_vars/source.ltx
96
- ./test/testfiles/single_raw_line
97
- ./test/testfiles/single_raw_line/expected-error.txt
98
- ./test/testfiles/single_raw_line/expected-output.txt
99
- ./test/testfiles/single_raw_line/source.ltx
100
- ]
16
+ s.executables << "livetext"
17
+
18
+ # Files...
19
+ main = Find.find("bin").to_a + Find.find("lib").to_a + Find.find("dsl").to_a
20
+ misc = %w[./README.html ./README.ltx ./README.md livetext.gemspec]
21
+ test = Find.find("test").to_a
22
+
23
+ s.files = main + misc + test
101
24
  s.homepage = 'https://github.com/Hal9000/livetext'
102
25
  s.license = "Ruby's license"
103
26
  end
Binary file
@@ -0,0 +1,19 @@
1
+ .mixin livemagick
2
+
3
+ .nopass
4
+
5
+ .image 300 100 lightgray
6
+ .canvas green 1 0
7
+ .pen red red
8
+ .font 80 Arial
9
+
10
+ .rectangle 100,50 300x300 green 9
11
+
12
+ .text! 100,50 100x100
13
+ K B K Z
14
+ .end
15
+ .draw
16
+ .save! myfile.jpg
17
+
18
+ .def foobar
19
+
@@ -0,0 +1,4 @@
1
+ This is not a comment:
2
+ .comment woohoo!
3
+ This is not a method:
4
+ .no_such_method
@@ -0,0 +1,16 @@
1
+ ./fixit block_comment
2
+ ./fixit comments_ignored_1
3
+ ./fixit comments_ignored_2
4
+ ./fixit copy_is_raw
5
+ ./fixit def_method
6
+ ./fixit example_alpha
7
+ ./fixit example_alpha2
8
+ ./fixit hello_world
9
+ ./fixit more_complex_vars
10
+ ./fixit raw_text_block
11
+ ./fixit sigil_can_change
12
+ ./fixit simple_copy
13
+ ./fixit simple_include
14
+ ./fixit simple_mixin
15
+ ./fixit simple_vars
16
+ ./fixit single_raw_line
@@ -0,0 +1 @@
1
+ Error: Name 'foobar' is unknown (at file2.ltx line 5)
@@ -0,0 +1,7 @@
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
@@ -0,0 +1,7 @@
1
+ This is file2
2
+ which has an error
3
+ about an unknown command
4
+ in line 5
5
+ .foobar
6
+
7
+ And this is file2 line 7.
@@ -0,0 +1,8 @@
1
+ This is my
2
+ source file
3
+ which includes file2 here:
4
+ .include file2.ltx
5
+
6
+ And here we are
7
+ back in the
8
+ original file.
@@ -0,0 +1 @@
1
+ Error: Illegal name 'to_s' (at source.ltx line 5)
@@ -0,0 +1,5 @@
1
+ This file has
2
+ a defined method
3
+ that is invalid:
4
+ <p>
5
+
@@ -0,0 +1,9 @@
1
+ This file has
2
+ a defined method
3
+ that is invalid:
4
+
5
+ .def to_s
6
+ # whatever...
7
+ .end
8
+
9
+
@@ -0,0 +1 @@
1
+ Error: Name 'foobar' is unknown (at source.ltx line 4)
@@ -0,0 +1,3 @@
1
+ This file
2
+ will have an error
3
+ on line 4
@@ -0,0 +1,6 @@
1
+ This file
2
+ will have an error
3
+ on line 4
4
+ .foobar
5
+ if all goes
6
+ well.
@@ -0,0 +1 @@
1
+ Error: Mismatched 'end' (at source.ltx line 6)
@@ -0,0 +1,6 @@
1
+ It is an error
2
+ to specify .end
3
+ without something
4
+ beginning a block:
5
+ <p>
6
+
@@ -0,0 +1,8 @@
1
+ It is an error
2
+ to specify .end
3
+ without something
4
+ beginning a block:
5
+
6
+ .end
7
+ foo bar
8
+ baz
@@ -0,0 +1 @@
1
+ Error: Expecting .end, found end of file (at source.ltx line 6)
@@ -0,0 +1,4 @@
1
+ Blah
2
+ blah
3
+ <p>
4
+
@@ -0,0 +1,6 @@
1
+ Blah
2
+ blah
3
+
4
+ .comment
5
+ meh
6
+ foo
@@ -0,0 +1 @@
1
+ Error: Name 'class' is not permitted (at source.ltx line 4)
@@ -0,0 +1,4 @@
1
+ Names such as 'class'
2
+ are not permitted here...
3
+ <p>
4
+
@@ -0,0 +1,6 @@
1
+ Names such as 'class'
2
+ are not permitted here...
3
+
4
+ .class
5
+ meh
6
+ foo
@@ -0,0 +1 @@
1
+ Error: No such file 'nosuchfile.txt' to copy (at source.ltx line 5)
@@ -0,0 +1,5 @@
1
+ Make sure a
2
+ nonexistent file with .copy
3
+ gives an error.
4
+ <p>
5
+
@@ -0,0 +1,8 @@
1
+ Make sure a
2
+ nonexistent file with .copy
3
+ gives an error.
4
+
5
+ .copy nosuchfile.txt
6
+
7
+ Nothing to
8
+ see here.
@@ -0,0 +1 @@
1
+ Error: No such include file 'nosuchinc.ltx' (at source.ltx line 5)
@@ -0,0 +1,5 @@
1
+ Make sure
2
+ a nonexistent include
3
+ will give an error.
4
+ <p>
5
+
@@ -0,0 +1,8 @@
1
+ Make sure
2
+ a nonexistent include
3
+ will give an error.
4
+
5
+ .include nosuchinc.ltx
6
+
7
+ Nothing to
8
+ see here.
@@ -0,0 +1 @@
1
+ Error: No such mixin 'nosuchthing' (at source.ltx line 6)
@@ -0,0 +1,6 @@
1
+ Test that
2
+ we give an error
3
+ when a mixin does not
4
+ exist:
5
+ <p>
6
+
@@ -0,0 +1,10 @@
1
+ Test that
2
+ we give an error
3
+ when a mixin does not
4
+ exist:
5
+
6
+ .mixin nosuchthing
7
+
8
+ We shouldn't
9
+ reach this point
10
+ in the file.
File without changes
@@ -0,0 +1,8 @@
1
+ Testing out
2
+ some functions
3
+ here...
4
+ <p>
5
+
6
+ I am calling Eureka! here...
7
+ Let's see
8
+ what happens.
@@ -0,0 +1,11 @@
1
+ Testing out
2
+ some functions
3
+ here...
4
+
5
+ .func myfunc
6
+ "Eureka!"
7
+ .end
8
+
9
+ I am calling $$myfunc here...
10
+ Let's see
11
+ what happens.
@@ -0,0 +1,4 @@
1
+ This is not a comment:
2
+ .comment woohoo!
3
+ This is not a method:
4
+ .no_such_method
@@ -0,0 +1,2 @@
1
+ a simple
2
+ include file.
@@ -0,0 +1,2 @@
1
+ a simple
2
+ include file.
@@ -0,0 +1,3 @@
1
+ def hello_world
2
+ puts "Hello, world."
3
+ end
data/test/try.lt ADDED
@@ -0,0 +1,20 @@
1
+ .mixin livemagick
2
+
3
+ .nopass
4
+
5
+ .image 800 600 skyblue
6
+ .canvas green 1 0
7
+ .pen red red
8
+ .font 80 AvantGarde
9
+
10
+ .rectangle 100,100 300x300 green 9
11
+
12
+ .text! 150,200 500x200
13
+ This is
14
+ only
15
+ a test.
16
+ .end
17
+ .draw
18
+ .save! somefile.jpg
19
+
20
+
data/test/try2.lt ADDED
@@ -0,0 +1,20 @@
1
+ .mixin livemagick
2
+
3
+ .nopass
4
+
5
+ .image 400 400 skyblue
6
+ .canvas green 1 0
7
+ .pen red red
8
+ .font 80 Arial
9
+
10
+ .rectangle 50,50 300x300 green 9
11
+
12
+ .text! 0,150 400x200
13
+ This is
14
+ only
15
+ a test.
16
+ .end
17
+ .draw
18
+ .save! myfile.jpg
19
+
20
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: livetext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton
@@ -12,74 +12,117 @@ date: 2017-03-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A smart text processor extensible in Ruby
14
14
  email: rubyhacker@gmail.com
15
- executables: []
15
+ executables:
16
+ - livetext
16
17
  extensions: []
17
18
  extra_rdoc_files: []
18
19
  files:
19
20
  - "./README.html"
20
21
  - "./README.ltx"
21
22
  - "./README.md"
22
- - "./bin/livetext"
23
- - "./dsl/bookish.rb"
24
- - "./dsl/calibre.rb"
25
- - "./dsl/liveblog.rb"
26
- - "./dsl/livemagick.rb"
27
- - "./dsl/markdown.rb"
28
- - "./dsl/pyggish.rb"
29
- - "./dsl/tutorial.rb"
30
- - "./lib/functions.rb"
31
- - "./lib/livetext.rb"
32
- - "./livetext.gemspec"
33
- - "./notes.txt"
34
- - "./test/cleanup"
35
- - "./test/newtest"
36
- - "./test/test.rb"
37
- - "./test/testfiles/basic_formatting/expected-error.txt"
38
- - "./test/testfiles/basic_formatting/expected-output.txt"
39
- - "./test/testfiles/basic_formatting/source.ltx"
40
- - "./test/testfiles/block_comment/expected-error.txt"
41
- - "./test/testfiles/block_comment/expected-output.txt"
42
- - "./test/testfiles/block_comment/source.ltx"
43
- - "./test/testfiles/comments_ignored_1/expected-error.txt"
44
- - "./test/testfiles/comments_ignored_1/expected-output.txt"
45
- - "./test/testfiles/comments_ignored_1/source.ltx"
46
- - "./test/testfiles/copy_is_raw/expected-error.txt"
47
- - "./test/testfiles/copy_is_raw/expected-output.txt"
48
- - "./test/testfiles/copy_is_raw/source.ltx"
49
- - "./test/testfiles/def_method/expected-error.txt"
50
- - "./test/testfiles/def_method/expected-output.txt"
51
- - "./test/testfiles/def_method/source.ltx"
52
- - "./test/testfiles/example_alpha/expected-error.txt"
53
- - "./test/testfiles/example_alpha/expected-output.txt"
54
- - "./test/testfiles/example_alpha/source.ltx"
55
- - "./test/testfiles/example_alpha2/expected-error.txt"
56
- - "./test/testfiles/example_alpha2/expected-output.txt"
57
- - "./test/testfiles/example_alpha2/source.ltx"
58
- - "./test/testfiles/fixit"
59
- - "./test/testfiles/hello_world/expected-error.txt"
60
- - "./test/testfiles/hello_world/expected-output.txt"
61
- - "./test/testfiles/hello_world/source.ltx"
62
- - "./test/testfiles/more_complex_vars/expected-error.txt"
63
- - "./test/testfiles/more_complex_vars/expected-output.txt"
64
- - "./test/testfiles/more_complex_vars/source.ltx"
65
- - "./test/testfiles/raw_text_block/expected-error.txt"
66
- - "./test/testfiles/raw_text_block/expected-output.txt"
67
- - "./test/testfiles/raw_text_block/source.ltx"
68
- - "./test/testfiles/simple_copy/expected-error.txt"
69
- - "./test/testfiles/simple_copy/expected-output.txt"
70
- - "./test/testfiles/simple_copy/source.ltx"
71
- - "./test/testfiles/simple_include/expected-error.txt"
72
- - "./test/testfiles/simple_include/expected-output.txt"
73
- - "./test/testfiles/simple_include/source.ltx"
74
- - "./test/testfiles/simple_mixin/expected-error.txt"
75
- - "./test/testfiles/simple_mixin/expected-output.txt"
76
- - "./test/testfiles/simple_mixin/source.ltx"
77
- - "./test/testfiles/simple_vars/expected-error.txt"
78
- - "./test/testfiles/simple_vars/expected-output.txt"
79
- - "./test/testfiles/simple_vars/source.ltx"
80
- - "./test/testfiles/single_raw_line/expected-error.txt"
81
- - "./test/testfiles/single_raw_line/expected-output.txt"
82
- - "./test/testfiles/single_raw_line/source.ltx"
23
+ - bin/livetext
24
+ - dsl/bookish.rb
25
+ - dsl/calibre.rb
26
+ - dsl/liveblog.rb
27
+ - dsl/livemagick.rb
28
+ - dsl/markdown.rb
29
+ - dsl/pyggish.rb
30
+ - dsl/tutorial.rb
31
+ - lib/functions.rb
32
+ - lib/livetext.rb
33
+ - lib/standard.rb
34
+ - lib/userapi.rb
35
+ - livetext.gemspec
36
+ - test/affirm/kbks.jpg
37
+ - test/affirm/lm-kbks.lt
38
+ - test/cleanup
39
+ - test/newtest
40
+ - test/test.rb
41
+ - test/testfiles/basic_formatting/expected-error.txt
42
+ - test/testfiles/basic_formatting/expected-output.txt
43
+ - test/testfiles/basic_formatting/source.ltx
44
+ - test/testfiles/block_comment/expected-error.txt
45
+ - test/testfiles/block_comment/expected-output.txt
46
+ - test/testfiles/block_comment/source.ltx
47
+ - test/testfiles/comments_ignored_1/expected-error.txt
48
+ - test/testfiles/comments_ignored_1/expected-output.txt
49
+ - test/testfiles/comments_ignored_1/source.ltx
50
+ - test/testfiles/copy_is_raw/expected-error.txt
51
+ - test/testfiles/copy_is_raw/expected-output.txt
52
+ - test/testfiles/copy_is_raw/rawtext.inc
53
+ - test/testfiles/copy_is_raw/source.ltx
54
+ - test/testfiles/crap
55
+ - test/testfiles/def_method/expected-error.txt
56
+ - test/testfiles/def_method/expected-output.txt
57
+ - test/testfiles/def_method/source.ltx
58
+ - test/testfiles/error_inc_line_num/expected-error.txt
59
+ - test/testfiles/error_inc_line_num/expected-output.txt
60
+ - test/testfiles/error_inc_line_num/file2.ltx
61
+ - test/testfiles/error_inc_line_num/source.ltx
62
+ - test/testfiles/error_invalid_name/expected-error.txt
63
+ - test/testfiles/error_invalid_name/expected-output.txt
64
+ - test/testfiles/error_invalid_name/source.ltx
65
+ - test/testfiles/error_line_num/expected-error.txt
66
+ - test/testfiles/error_line_num/expected-output.txt
67
+ - test/testfiles/error_line_num/source.ltx
68
+ - test/testfiles/error_mismatched_end/expected-error.txt
69
+ - test/testfiles/error_mismatched_end/expected-output.txt
70
+ - test/testfiles/error_mismatched_end/source.ltx
71
+ - test/testfiles/error_missing_end/expected-error.txt
72
+ - test/testfiles/error_missing_end/expected-output.txt
73
+ - test/testfiles/error_missing_end/source.ltx
74
+ - test/testfiles/error_name_not_permitted/expected-error.txt
75
+ - test/testfiles/error_name_not_permitted/expected-output.txt
76
+ - test/testfiles/error_name_not_permitted/source.ltx
77
+ - test/testfiles/error_no_such_copy/expected-error.txt
78
+ - test/testfiles/error_no_such_copy/expected-output.txt
79
+ - test/testfiles/error_no_such_copy/source.ltx
80
+ - test/testfiles/error_no_such_inc/expected-error.txt
81
+ - test/testfiles/error_no_such_inc/expected-output.txt
82
+ - test/testfiles/error_no_such_inc/source.ltx
83
+ - test/testfiles/error_no_such_mixin/expected-error.txt
84
+ - test/testfiles/error_no_such_mixin/expected-output.txt
85
+ - test/testfiles/error_no_such_mixin/source.ltx
86
+ - test/testfiles/example_alpha/expected-error.txt
87
+ - test/testfiles/example_alpha/expected-output.txt
88
+ - test/testfiles/example_alpha/source.ltx
89
+ - test/testfiles/example_alpha2/expected-error.txt
90
+ - test/testfiles/example_alpha2/expected-output.txt
91
+ - test/testfiles/example_alpha2/source.ltx
92
+ - test/testfiles/fixit
93
+ - test/testfiles/functions/expected-error.txt
94
+ - test/testfiles/functions/expected-output.txt
95
+ - test/testfiles/functions/source.ltx
96
+ - test/testfiles/hello_world/expected-error.txt
97
+ - test/testfiles/hello_world/expected-output.txt
98
+ - test/testfiles/hello_world/source.ltx
99
+ - test/testfiles/more_complex_vars/expected-error.txt
100
+ - test/testfiles/more_complex_vars/expected-output.txt
101
+ - test/testfiles/more_complex_vars/source.ltx
102
+ - test/testfiles/raw_text_block/expected-error.txt
103
+ - test/testfiles/raw_text_block/expected-output.txt
104
+ - test/testfiles/raw_text_block/rawtext.inc
105
+ - test/testfiles/raw_text_block/source.ltx
106
+ - test/testfiles/simple_copy/expected-error.txt
107
+ - test/testfiles/simple_copy/expected-output.txt
108
+ - test/testfiles/simple_copy/simplefile.inc
109
+ - test/testfiles/simple_copy/source.ltx
110
+ - test/testfiles/simple_include/expected-error.txt
111
+ - test/testfiles/simple_include/expected-output.txt
112
+ - test/testfiles/simple_include/simplefile.inc
113
+ - test/testfiles/simple_include/source.ltx
114
+ - test/testfiles/simple_mixin/expected-error.txt
115
+ - test/testfiles/simple_mixin/expected-output.txt
116
+ - test/testfiles/simple_mixin/simple_mixin.rb
117
+ - test/testfiles/simple_mixin/source.ltx
118
+ - test/testfiles/simple_vars/expected-error.txt
119
+ - test/testfiles/simple_vars/expected-output.txt
120
+ - test/testfiles/simple_vars/source.ltx
121
+ - test/testfiles/single_raw_line/expected-error.txt
122
+ - test/testfiles/single_raw_line/expected-output.txt
123
+ - test/testfiles/single_raw_line/source.ltx
124
+ - test/try.lt
125
+ - test/try2.lt
83
126
  homepage: https://github.com/Hal9000/livetext
84
127
  licenses:
85
128
  - Ruby's license
data/notes.txt DELETED
@@ -1,146 +0,0 @@
1
- Mostly done
2
- -----------
3
- define variables
4
- define methods
5
- allow switching sigils, etc.
6
- .raw
7
- .mixin
8
- .include
9
- double sigil + blank = true comment
10
- sigil + blank = passthru comment
11
- double sigil + token = internal sigil
12
- .comment/.end
13
- .func
14
-
15
-
16
- To Be Done
17
- ----------
18
- Bug: Optional blank line at EOF causes problem
19
- turn "blank=para" on/off?
20
- keyword args
21
- .defaults
22
- better variable support
23
- need a 'require' (with sigil?)
24
- .init ?
25
- .method or .private
26
- Prioritized formatting: markdown b/i/c, lt b/i/c, emdash, varsub, funcsub, etc.?
27
- em dash
28
- variable for source file
29
- variable for line number
30
- ignore trailing punctuation for * _ `
31
- args vs bare args (quotes)
32
- comment! pass this thru as comment
33
- comment!/end
34
- .proc
35
- .break to eof ?
36
- warn when overriding?
37
- .meth?/.end (.else?)
38
- $var.subvar
39
- $$func $$func(params)
40
-
41
-
42
-
43
- Undecided
44
- ---------
45
- encourage overriding passthru?
46
- disallow leading underscore
47
- HTML entities?
48
- explicit Unicode support?
49
- intermediate format prior to output?
50
- .say
51
- .debug
52
- .dump
53
- links?
54
- images?
55
- safe level?
56
- exceptions?
57
- .if, .else ?
58
- .shell ?
59
- table styles?
60
- define "quotes" such as * _ ?
61
- Issues:
62
- - substitution and bold/italics on @data and @args?
63
- - substitution before or after bold/italics?
64
- .run Arbitrary Ruby code?
65
- BEGIN/END for require or mixin?
66
- other langs??
67
- configurable delimiters (tables, etc.)
68
-
69
-
70
-
71
- For bookish
72
- -----------
73
- .index
74
- .indexable
75
-
76
-
77
- Assignment
78
- ----------
79
- myvar=foo
80
- myvar.x = "This and that"
81
- $myvar
82
- $myvar.x
83
- $(myvar.x)
84
-
85
- Functions
86
- ---------
87
- $$func
88
- $$func.blah
89
- $$(func.blah)
90
- $$proc ?
91
- $$(func args)
92
-
93
- Predef functions?
94
- -----------------
95
- $$sourceline
96
- $index
97
-
98
- What is Livetext?
99
- -----------------
100
- It's a text transformer
101
- Agnostic about output format
102
- Like a macro processor but not
103
- Like markdown but not
104
- Like erb or HAML but not
105
- Later on - language agnostic?
106
- Like an old-fashioned text formatter, but extensible
107
- Plugin-oriented
108
- Aims to be easy/flexible but not too dangerous
109
- Predefine but don't clutter namespace
110
- Mention softcover
111
-
112
- Tutorial
113
- --------
114
- What is it?
115
- Any text file is (probably) valid
116
- Simple built-in methods
117
- Pass-through mode
118
- Comments
119
- Methods with bodies
120
- Changing sigils
121
- Reusing text and code
122
- Predefined stuff: methods, functions, variables, libs?
123
- Defining your own code: inline, methods, func, proc, ...
124
- require, include
125
- variables
126
- functions
127
-
128
- Mixins etc
129
- ----------
130
- PlainHTML
131
- PDFout
132
- Bookish
133
- InlineMarkdown
134
- Pygments
135
-
136
-
137
- Logic:
138
- ------
139
- Handle . .. .name
140
- In each body:
141
- - allow . and ..
142
- - handle ..name
143
- - disallow .name ?
144
- - handle italics
145
- - handle substitution
146
-