livetext 0.9.27 → 0.9.30
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/README.lt3 +3 -2
- data/lib/livetext/expansion.rb +106 -0
- data/lib/livetext/formatter.rb +104 -0
- data/lib/livetext/functions.rb +9 -0
- data/lib/livetext/helpers.rb +23 -18
- data/lib/livetext/html.rb +73 -0
- data/lib/livetext/more.rb +24 -4
- data/lib/livetext/parser/general.rb +1 -1
- data/lib/livetext/parser/set.rb +10 -3
- data/lib/livetext/processor.rb +5 -0
- data/lib/livetext/standard.rb +16 -6
- data/lib/livetext/userapi.rb +39 -16
- data/lib/livetext/version.rb +1 -1
- data/lib/livetext.rb +1 -1
- data/plugin/bootstrap_menu.rb +140 -0
- data/plugin/misc/navbar.rb +162 -0
- data/test/snapshots/basic_formatting/expected-output.txt +1 -2
- data/test/snapshots/{basic_formatting/actual-error.txt → bootstrap_menu/expected-error.txt} +0 -0
- data/test/snapshots/bootstrap_menu/expected-output.txt +4 -0
- data/test/snapshots/bootstrap_menu/source.lt3 +17 -0
- data/test/snapshots/subset.txt +50 -48
- data/test/unit/all.rb +2 -2
- data/test/unit/lineparser.rb +1 -1
- data/test/unit/parser/general.rb +2 -2
- data/test/unit/parser/set.rb +0 -9
- metadata +9 -32
- data/lib/livetext/funcall.rb +0 -87
- data/lib/livetext/lineparser.rb +0 -575
- data/test/snapshots/basic_formatting/actual-output.txt +0 -13
- data/test/snapshots/basic_formatting/err-sdiff.txt +0 -1
- data/test/snapshots/basic_formatting/out-sdiff.txt +0 -14
- data/test/snapshots/functions/actual-error.txt +0 -19
- data/test/snapshots/functions/actual-output.txt +0 -0
- data/test/snapshots/functions/err-sdiff.txt +0 -20
- data/test/snapshots/import_bookish/toc.tmp +0 -0
- data/test/snapshots/mixin_bookish/toc.tmp +0 -0
- data/test/snapshots/more_complex_vars/actual-error.txt +0 -0
- data/test/snapshots/more_complex_vars/actual-output.txt +0 -4
- data/test/snapshots/more_complex_vars/err-sdiff.txt +0 -1
- data/test/snapshots/more_complex_vars/out-sdiff.txt +0 -5
- data/test/snapshots/more_functions/actual-error.txt +0 -19
- data/test/snapshots/more_functions/actual-output.txt +0 -0
- data/test/snapshots/more_functions/err-sdiff.txt +0 -20
- data/test/snapshots/raw_lines/actual-error.txt +0 -22
- data/test/snapshots/raw_lines/actual-output.txt +0 -0
- data/test/snapshots/raw_lines/err-sdiff.txt +0 -23
- data/test/snapshots/simple_vars/actual-error.txt +0 -0
- data/test/snapshots/simple_vars/actual-output.txt +0 -6
- data/test/snapshots/simple_vars/err-sdiff.txt +0 -1
- data/test/snapshots/simple_vars/out-sdiff.txt +0 -7
- data/test/snapshots/var_into_func/actual-error.txt +0 -19
- data/test/snapshots/var_into_func/actual-output.txt +0 -0
- data/test/snapshots/var_into_func/err-sdiff.txt +0 -20
- data/test/snapshots/var_into_func/out-sdiff.txt +0 -17
- data/test/unit/tokenizer.rb +0 -535
data/lib/livetext/userapi.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
require_relative '
|
1
|
+
require_relative 'expansion'
|
2
|
+
require_relative 'html'
|
3
3
|
|
4
4
|
# Encapsulate the UserAPI as a class
|
5
5
|
|
@@ -15,18 +15,32 @@ class Livetext::UserAPI
|
|
15
15
|
def initialize(live)
|
16
16
|
@live = live
|
17
17
|
@vars = live.vars
|
18
|
+
@html = HTML.new(self)
|
19
|
+
@expander = Livetext::Expansion.new(live)
|
18
20
|
end
|
19
21
|
|
20
22
|
def api
|
21
23
|
@live.api
|
22
24
|
end
|
23
25
|
|
26
|
+
def html
|
27
|
+
@html
|
28
|
+
end
|
29
|
+
|
24
30
|
def dot
|
25
31
|
@live
|
26
32
|
end
|
27
33
|
|
28
|
-
def setvar(var, val)
|
29
|
-
Livetext::Vars[var] = val # Now indifferent and "safe"
|
34
|
+
def setvar(var, val) # FIXME
|
35
|
+
# Livetext::Vars[var] = val # Now indifferent and "safe"
|
36
|
+
@live.vars.set(var, val)
|
37
|
+
end
|
38
|
+
|
39
|
+
def setvars(pairs)
|
40
|
+
pairs = pairs.to_a if pairs.is_a?(Hash)
|
41
|
+
pairs.each do |var, value|
|
42
|
+
@live.vars.set(var, value)
|
43
|
+
end
|
30
44
|
end
|
31
45
|
|
32
46
|
def check_existence(file, msg)
|
@@ -34,19 +48,22 @@ class Livetext::UserAPI
|
|
34
48
|
end
|
35
49
|
|
36
50
|
def data=(value)
|
37
|
-
# TTY.puts "in #{__FILE__}: api = #{@live.api.inspect}"
|
38
51
|
@data = value
|
39
52
|
@args = format(@data).chomp.split
|
40
53
|
end
|
41
54
|
|
55
|
+
def data
|
56
|
+
@data
|
57
|
+
end
|
58
|
+
|
42
59
|
def args
|
43
60
|
return @args unless block_given?
|
44
61
|
@args.each {|arg| yield arg }
|
45
62
|
end
|
46
63
|
|
47
|
-
|
48
|
-
|
49
|
-
|
64
|
+
def vars
|
65
|
+
@vars
|
66
|
+
end
|
50
67
|
|
51
68
|
def optional_blank_line
|
52
69
|
peek = @live.peek_nextline # ???
|
@@ -93,7 +110,7 @@ class Livetext::UserAPI
|
|
93
110
|
break if end?(@line)
|
94
111
|
next if comment?(@line)
|
95
112
|
@line = format(@line) unless raw
|
96
|
-
lines << @line
|
113
|
+
lines << @line
|
97
114
|
end
|
98
115
|
raise "Expected .end, found end of file" unless end?(@line) # use custom exception
|
99
116
|
optional_blank_line # FIXME Delete this??
|
@@ -119,21 +136,27 @@ class Livetext::UserAPI
|
|
119
136
|
|
120
137
|
def format(line)
|
121
138
|
return "" if line == "\n" || line.nil?
|
122
|
-
line2 =
|
139
|
+
line2 = @expander.format(line)
|
123
140
|
line2
|
124
141
|
end
|
125
142
|
|
126
143
|
def passthru(line)
|
127
144
|
return if @live.nopass
|
128
|
-
|
129
|
-
|
130
|
-
|
145
|
+
if line == "\n"
|
146
|
+
unless @live.nopara
|
147
|
+
out "<p>"
|
148
|
+
out
|
149
|
+
end
|
150
|
+
else
|
151
|
+
text = @expander.format(line.chomp)
|
152
|
+
out text
|
153
|
+
end
|
131
154
|
end
|
132
155
|
|
133
156
|
def out(str = "", file = nil)
|
134
157
|
return if str.nil?
|
135
158
|
return file.puts str unless file.nil?
|
136
|
-
@live.body << str
|
159
|
+
@live.body << str
|
137
160
|
@live.body << "\n" unless str.end_with?("\n")
|
138
161
|
end
|
139
162
|
|
@@ -150,11 +173,11 @@ class Livetext::UserAPI
|
|
150
173
|
end
|
151
174
|
|
152
175
|
def puts(*args)
|
153
|
-
@live.output.puts *args
|
176
|
+
@live.output.puts *args
|
154
177
|
end
|
155
178
|
|
156
179
|
def print(*args)
|
157
|
-
@live.output.print *args
|
180
|
+
@live.output.print *args
|
158
181
|
end
|
159
182
|
|
160
183
|
def debug=(val)
|
data/lib/livetext/version.rb
CHANGED
data/lib/livetext.rb
CHANGED
@@ -9,7 +9,7 @@ require_relative 'livetext/errors'
|
|
9
9
|
require_relative 'livetext/standard'
|
10
10
|
require_relative 'livetext/functions'
|
11
11
|
require_relative 'livetext/userapi'
|
12
|
-
require_relative 'livetext/
|
12
|
+
require_relative 'livetext/formatter'
|
13
13
|
require_relative 'livetext/processor'
|
14
14
|
require_relative 'livetext/helpers'
|
15
15
|
require_relative 'livetext/handler'
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# https://getbootstrap.com/docs/5.1/components/navs-tabs/#base-nav
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
def api_out(indent_level, content)
|
6
|
+
api.out "#{(" " * (indent_level * indent_size))}#{content}"
|
7
|
+
end
|
8
|
+
|
9
|
+
def indent_size; 2; end
|
10
|
+
|
11
|
+
def menu(indent_level: 0, &block)
|
12
|
+
api_out indent_level, "<ul class='nav'>"
|
13
|
+
read_to_end_of_block(root_indent_level: indent_level)
|
14
|
+
yield
|
15
|
+
api_out indent_level, "</ul>"
|
16
|
+
end
|
17
|
+
|
18
|
+
def menu_dropdown(title, indent_level: 0, &block)
|
19
|
+
api_out indent_level, '<li class="nav-item dropdown">'
|
20
|
+
api_out indent_level, " <a class='nav-link dropdown-toggle' data-bs-toggle='dropdown' href='#' role='button' aria-expanded='false'"
|
21
|
+
api_out indent_level, " #{title}"
|
22
|
+
api_out indent_level, ' </a>'
|
23
|
+
|
24
|
+
api_out indent_level, ' <ul class="dropdown-menu">'
|
25
|
+
yield
|
26
|
+
api_out indent_level, ' </ul>'
|
27
|
+
|
28
|
+
api_out indent_level, '</li>'
|
29
|
+
end
|
30
|
+
|
31
|
+
def menu_link(title, href, active: false, indent_level: 0)
|
32
|
+
# Work out if it's possible to determine active state or not
|
33
|
+
api_out indent_level, "<a class='nav-link #{"active" if active}' aria-current='page' href='#{href}'"
|
34
|
+
api_out indent_level, " #{title}"
|
35
|
+
api_out indent_level, '</a>'
|
36
|
+
end
|
37
|
+
|
38
|
+
def menu_dropdown_link(title, href, active: false, indent_level: 0)
|
39
|
+
# Work out if it's possible to determine active state or not
|
40
|
+
api_out indent_level, "<a class='dropdown-item #{"active" if active}' href='#{href}'"
|
41
|
+
api_out indent_level, " #{title}"
|
42
|
+
api_out indent_level, '</a>'
|
43
|
+
end
|
44
|
+
|
45
|
+
def next_line
|
46
|
+
nextline
|
47
|
+
end
|
48
|
+
|
49
|
+
def peek_next_line
|
50
|
+
peek_nextline
|
51
|
+
end
|
52
|
+
|
53
|
+
def line_indent_level(line)
|
54
|
+
indent_level = (line.size - line.lstrip.size) / indent_size.to_f
|
55
|
+
raise "Unbalanced Indenting: Expecting #{indent_size} indents" if indent_level.to_i != indent_level
|
56
|
+
indent_level = indent_level.to_i
|
57
|
+
end
|
58
|
+
|
59
|
+
def line_command(line)
|
60
|
+
base_line = line.strip
|
61
|
+
|
62
|
+
base_command = base_line.split.first
|
63
|
+
|
64
|
+
if base_command.start_with?(".")
|
65
|
+
return base_command.gsub(".")
|
66
|
+
else
|
67
|
+
raise "Command Expected: #{base_line}"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def line_attributes_array(line)
|
72
|
+
line_attributes = line.strip.split("", 2).last
|
73
|
+
api.out 0, line_attributes.inspect
|
74
|
+
|
75
|
+
attributes_parsed = JSON.parse(line_attributes)
|
76
|
+
attributes_parsed.is_a?(String) ? [attributes_parsed] : attributes_parsed
|
77
|
+
end
|
78
|
+
|
79
|
+
def read_to_end_of_block(root_indent_level: 0)
|
80
|
+
expected_indent_level = root_indent_level + 1
|
81
|
+
loop do
|
82
|
+
peeked_line = peek_next_line
|
83
|
+
return if peeked_line.nil? # End of File
|
84
|
+
unless peeked_line.strip.size > 0 # Blank line
|
85
|
+
next_line
|
86
|
+
next
|
87
|
+
end
|
88
|
+
|
89
|
+
line_indent_level = line_indent_level(peeked_line)
|
90
|
+
|
91
|
+
if expected_indent_level != line_indent_level
|
92
|
+
raise "Unexpected Indent Level: Is #{line_indent_level} expected #{expected_indent_level}:\n#{peeked_line}"
|
93
|
+
end
|
94
|
+
|
95
|
+
return if root_indent_level >= line_indent_level # End of Block
|
96
|
+
|
97
|
+
line = next_line # Actually move to the next line
|
98
|
+
|
99
|
+
send(line_command(line), *line_attributes_array(line)) do
|
100
|
+
# This block doesn't run if command doesn't accept a block
|
101
|
+
read_to_end_of_block(root_indent_level: line_indent_level)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# Loop should be something like:
|
107
|
+
# read `.menu` and log current indent level
|
108
|
+
# => send(:menu) do
|
109
|
+
# # Read until indent is
|
110
|
+
# end
|
111
|
+
|
112
|
+
def simple_test
|
113
|
+
menu do
|
114
|
+
menu_link "Home", "http://fake.com/home"
|
115
|
+
menu_dropdown("Blog") do
|
116
|
+
menu_dropdown_link("Home", "http://fake.com/blog")
|
117
|
+
end
|
118
|
+
menu_link "About", "http://fake.com/about"
|
119
|
+
end
|
120
|
+
# This should have the same output as:
|
121
|
+
# .menu
|
122
|
+
# .menu_link
|
123
|
+
# .menu_dropdown ["Blog"]
|
124
|
+
# .menu_dropdown_link ["Home", "http://fake.com/blog"]
|
125
|
+
# .menu_link ["About", "http://fake.com/about"]
|
126
|
+
# or this if we end up sticking with .end
|
127
|
+
# .menu
|
128
|
+
# .menu_link
|
129
|
+
# .menu_dropdown "Blog"
|
130
|
+
# .menu_dropdown_link ["Home", "http://fake.com/blog"]
|
131
|
+
# .end
|
132
|
+
# .menu_link ["About", "http://fake.com/about"]
|
133
|
+
# .end
|
134
|
+
|
135
|
+
|
136
|
+
# Really this should probably just re-use Rails ActionView to avoid a ton of duplicate code
|
137
|
+
# This would allow us to leverage all the Rails HTML generation logic.
|
138
|
+
# Downside of that is that it does break the paradigm a bit in that blocks with errors won't partially render
|
139
|
+
# it does however also means we would get sanitization and such for free
|
140
|
+
end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
|
2
|
+
private def get_href_title(line)
|
3
|
+
*title, href = line[1..-1].split(@space)
|
4
|
+
if href[0] == "@"
|
5
|
+
blank = true
|
6
|
+
href = href[1..-1]
|
7
|
+
else
|
8
|
+
blank = false
|
9
|
+
end
|
10
|
+
title = title.join(@space)
|
11
|
+
[href, title, blank]
|
12
|
+
end
|
13
|
+
|
14
|
+
private def add_root(url)
|
15
|
+
return url if url =~ /^http/ # already has http[s]
|
16
|
+
return url unless @root # no root defined
|
17
|
+
range1 = 0..-1
|
18
|
+
range1 = 0..-2 if @root[-1] == "/"
|
19
|
+
root = @root[range1]
|
20
|
+
range2 = 0..-1
|
21
|
+
range2 = 1..-1 if url[0] == "/"
|
22
|
+
url = url[range2]
|
23
|
+
root + "/" + url
|
24
|
+
end
|
25
|
+
|
26
|
+
private def get_brand
|
27
|
+
peek = @enum.peek
|
28
|
+
arg = peek[6..-1]
|
29
|
+
href, item, blank = get_href_title(arg)
|
30
|
+
# doesn't honor @root... and blank is unused here
|
31
|
+
if item =~ /\.(jpg|png|gif)$/i
|
32
|
+
item = "<img src='#{item}'></img>"
|
33
|
+
end
|
34
|
+
details = {class: "navbar-brand mr-auto", href: add_root(href)}
|
35
|
+
@brand = html.tag(:a, **details, cdata: item)
|
36
|
+
end
|
37
|
+
|
38
|
+
private def slash_tags
|
39
|
+
@root = @brand = nil
|
40
|
+
@classes = "navbar-light bg-light"
|
41
|
+
loop do # /brand /root ...
|
42
|
+
peek = @enum.peek
|
43
|
+
break if peek[0] != '/'
|
44
|
+
case
|
45
|
+
when peek.start_with?("/brand ")
|
46
|
+
get_brand
|
47
|
+
when peek.start_with?("/root ")
|
48
|
+
@root = peek[6..-1]
|
49
|
+
when peek.start_with?("/classes ")
|
50
|
+
@classes = peek[9..-1]
|
51
|
+
end
|
52
|
+
line = @enum.next
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private def handle_children
|
57
|
+
value = ""
|
58
|
+
loop do
|
59
|
+
if @enum.peek.start_with?(@space) # it's a child
|
60
|
+
line = @enum.next
|
61
|
+
href, title, blank = get_href_title(line)
|
62
|
+
details = {class: "dropdown-item", href: add_root(href)}
|
63
|
+
details[:target] = "_blank" if blank
|
64
|
+
link = html.tag(:a, **details, cdata: title)
|
65
|
+
str = html.tag(:li, cdata: link)
|
66
|
+
value << str + "\n"
|
67
|
+
else
|
68
|
+
break
|
69
|
+
end
|
70
|
+
end
|
71
|
+
api.out value
|
72
|
+
end
|
73
|
+
|
74
|
+
private def no_children(href, title)
|
75
|
+
html.li(class: "nav-item") do
|
76
|
+
api.out html.tag(:a, class: "nav-link", href: add_root(href), cdata: title)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
private def has_children(href, title)
|
81
|
+
css = "nav-item dropdown"
|
82
|
+
html.li(class: css) do
|
83
|
+
details = {class: "nav-link dropdown-toggle", href: "#", id: "navbarDropdown",
|
84
|
+
role: "button", :"data-bs-toggle" => "dropdown", :"aria-expanded" => "false"}
|
85
|
+
@dropdowns += 1
|
86
|
+
api.out html.tag(:a, **details, cdata: title)
|
87
|
+
details = {class: "dropdown-menu", :"aria-labelledby" => "navbarDropdown"}
|
88
|
+
html.ul(**details) do # children...
|
89
|
+
handle_children
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
private def handle_body
|
95
|
+
@dropdowns = 1
|
96
|
+
loop do
|
97
|
+
line = @enum.next
|
98
|
+
href, title, blank = get_href_title(line)
|
99
|
+
case line[0]
|
100
|
+
when "-"
|
101
|
+
no_children(href, title)
|
102
|
+
when "="
|
103
|
+
has_children(href, title)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def bootstrap
|
109
|
+
api.out <<~HTML
|
110
|
+
<head>
|
111
|
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
|
112
|
+
rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
|
113
|
+
crossorigin="anonymous">
|
114
|
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
|
115
|
+
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
|
116
|
+
crossorigin="anonymous">
|
117
|
+
</script>
|
118
|
+
</head>
|
119
|
+
HTML
|
120
|
+
end
|
121
|
+
|
122
|
+
private def toggler
|
123
|
+
details = {class: "navbar-toggler", type: "button", "data-bs-toggle": "collapse",
|
124
|
+
"data-bs-target": "#navbarSupportedContent",
|
125
|
+
"aria-controls": "navbarSupportedContent", "aria-expanded": "false",
|
126
|
+
"aria-label": "Toggle navigation"}
|
127
|
+
str = html.tag(:button, **details, cdata: '<span class="navbar-toggler-icon"></span>')
|
128
|
+
api.out str
|
129
|
+
end
|
130
|
+
|
131
|
+
private def branding
|
132
|
+
return if @brand.empty? || @brand.nil?
|
133
|
+
api.out @brand
|
134
|
+
end
|
135
|
+
|
136
|
+
def html
|
137
|
+
@html
|
138
|
+
end
|
139
|
+
|
140
|
+
def navbar
|
141
|
+
@html = HTML.new(api)
|
142
|
+
# bootstrap
|
143
|
+
@space = " "
|
144
|
+
@enum = api.body.each
|
145
|
+
slash_tags
|
146
|
+
|
147
|
+
css = "navbar navbar-expand-md " + @classes
|
148
|
+
html.nav(class: css) do
|
149
|
+
html.div(class: "container-fluid") do
|
150
|
+
toggler
|
151
|
+
branding
|
152
|
+
content = {class: "collapse navbar-collapse", id: "navbarSupportedContent"}
|
153
|
+
html.div(**content) do
|
154
|
+
css = "navbar-nav me-auto mb-2 mb-md-0"
|
155
|
+
html.ul(class: css) do
|
156
|
+
handle_body
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
@@ -3,11 +3,10 @@ and <i>italics</i>
|
|
3
3
|
and <font size=+1><tt>code</tt></font>
|
4
4
|
as well as <b>more complex</b> examples
|
5
5
|
of <i>italicized text</i>
|
6
|
-
and <
|
6
|
+
and <tt>code font</tt>.
|
7
7
|
<p>
|
8
8
|
|
9
9
|
Here are some random punctuation marks:
|
10
10
|
; # . * _ ` : @ % ^ & $
|
11
11
|
<p>
|
12
|
-
|
13
12
|
No need to escape these: * _ `
|
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
.nopara
|
2
|
+
|
3
|
+
.mixin bootstrap_menu
|
4
|
+
|
5
|
+
.menu
|
6
|
+
.menu_link "Home", "http://fake.com/home"
|
7
|
+
.menu_dropdown "Blog"
|
8
|
+
.menu_dropdown_link "Home", "http://fake.com/blog"
|
9
|
+
.menu_dropdown_link "Design", "http://fake.com/design"
|
10
|
+
.menu_dropdown_link "HTML", "http://fake.com/html"
|
11
|
+
.menu_dropdown_link "CSS", "http://fake.com/css"
|
12
|
+
.menu_dropdown_link "Javascript", "http://fake.com/jscript"
|
13
|
+
.menu_dropdown "Work"
|
14
|
+
.menu_dropdown_item "Web Design", "http://fake.com/webdes"
|
15
|
+
.menu_dropdown_item "Typography", "http://fake.com/typog"
|
16
|
+
.menu_dropdown_item "Front-end", "http://fake.com/fronten"
|
17
|
+
.menu_link "About", "http://fake.com/about"
|
data/test/snapshots/subset.txt
CHANGED
@@ -19,68 +19,70 @@ h This file specifies which snapshots will/won't be run.
|
|
19
19
|
|
20
20
|
# Note that QUIT (on a line by itself) will stop processing the file
|
21
21
|
|
22
|
+
# Bootstrap
|
22
23
|
|
23
24
|
# Others (usually passing):
|
24
25
|
|
25
26
|
# import/include/mixin, others...
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
28
|
+
error_no_such_inc # Output BEFORE error doesn't get passed through ("leading" output)
|
29
|
+
error_no_such_copy # ^ Same behavior as error_no_such_inc
|
30
|
+
error_no_such_mixin # ^ Same behavior as error_missing_end
|
31
|
+
simple_copy #
|
32
|
+
simple_import #
|
33
|
+
simple_include #
|
34
|
+
simple_mixin #
|
35
|
+
import # "Leading" output doesn't get generated (same as error_no_such_inc)
|
36
|
+
import2 #
|
37
|
+
mixin_bookish #
|
38
|
+
import_bookish #
|
39
|
+
test_wtf_bookish #
|
40
|
+
|
41
|
+
# raw input
|
42
|
+
|
43
|
+
single_raw_line #
|
44
|
+
raw_lines #
|
45
|
+
raw_text_block #
|
46
|
+
copy_is_raw #
|
47
|
+
|
48
|
+
# comments
|
49
|
+
|
50
|
+
block_comment #
|
51
|
+
comments_ignored_1 #
|
52
|
+
|
53
|
+
# variables and heredocs
|
54
|
+
|
55
|
+
predef_vars #
|
56
|
+
simple_vars #
|
57
|
+
more_complex_vars #
|
58
|
+
table_with_heredocs #
|
57
59
|
|
58
60
|
# testing def
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
+
def_method #
|
63
|
+
|
62
64
|
# intraline formatting
|
63
65
|
|
64
|
-
|
65
|
-
|
66
|
-
|
66
|
+
basic_formatting #
|
67
|
+
test_formatting_34 #
|
68
|
+
test_formatting_35 #
|
67
69
|
|
68
70
|
# Errors
|
69
71
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
error_line_num #
|
73
|
+
error_mismatched_end #
|
74
|
+
error_name_not_permitted #
|
75
|
+
error_invalid_name # ^ Same behavior as error_no_such_inc
|
76
|
+
error_missing_end # Output is duplicated somehow. Look for: puts @body or puts @main.body
|
77
|
+
error_inc_line_num # Forgot what's wrong here
|
76
78
|
|
77
79
|
# functions
|
78
80
|
|
79
|
-
|
80
|
-
|
81
|
+
functions #
|
82
|
+
more_functions #
|
83
|
+
|
84
|
+
# More/misc...
|
81
85
|
|
82
|
-
#
|
83
|
-
|
84
|
-
|
85
|
-
example_alpha2 #
|
86
|
-
hello_world #
|
86
|
+
example_alpha #
|
87
|
+
example_alpha2 #
|
88
|
+
hello_world #
|
data/test/unit/all.rb
CHANGED
data/test/unit/lineparser.rb
CHANGED
@@ -332,7 +332,7 @@ end
|
|
332
332
|
TestLines.each.with_index do |item, num|
|
333
333
|
msg, src, exp, blank = *item
|
334
334
|
# generate tests...
|
335
|
-
name = "test_formatting_#{'%
|
335
|
+
name = "test_formatting_#{'%03d' % (num + 1)}"
|
336
336
|
method_source = <<~RUBY
|
337
337
|
def #{name} # #{msg}
|
338
338
|
msg, src, exp = <<~STUFF.split("\\n")
|
data/test/unit/parser/general.rb
CHANGED
@@ -33,11 +33,11 @@ class TestParseGeneral < MiniTest::Test
|
|
33
33
|
def test_variables
|
34
34
|
vars = ["foo 234\n", "bar 456\n"]
|
35
35
|
expect = [%w[foo 234], %w[bar 456]]
|
36
|
-
assert_equal ParseGeneral.parse_vars(vars), expect
|
36
|
+
assert_equal ParseGeneral.parse_vars(vars), expect, "case 1 failed"
|
37
37
|
|
38
38
|
vars = ["foo2 234", "bar2 456"] # newline irrelevant
|
39
39
|
expect = [%w[foo2 234], %w[bar2 456]]
|
40
|
-
assert_equal ParseGeneral.parse_vars(vars), expect
|
40
|
+
assert_equal ParseGeneral.parse_vars(vars), expect, "case 2 failed"
|
41
41
|
|
42
42
|
# quotes are not stripped... hmm
|
43
43
|
vars = ["alpha 'simple string'", 'beta "another string"']
|
data/test/unit/parser/set.rb
CHANGED
@@ -145,15 +145,6 @@ class TestParseSet < MiniTest::Test
|
|
145
145
|
# ^ ParseSet isn't smart enough to know about variables/functions
|
146
146
|
end
|
147
147
|
|
148
|
-
def test_var_eq_func
|
149
|
-
set = ParseSet.new("date = $$date").parse
|
150
|
-
set = set.first # [["var", "value"]]
|
151
|
-
assert_equal set.first, "date"
|
152
|
-
p set.last
|
153
|
-
assert set.last =~ /undefined/, "Found 'undefined' for variable value"
|
154
|
-
# ^ ParseSet isn't smart enough to know about variables/functions
|
155
|
-
end
|
156
|
-
|
157
148
|
def xtest_two_strings
|
158
149
|
line = %[bday="May 31", date='5/31']
|
159
150
|
set = ParseSet.new(line).parse
|