livetext 0.9.30 → 0.9.31
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/imports/bookish.rb +1 -1
- data/lib/livetext/expansion.rb +15 -13
- data/lib/livetext/formatter.rb +206 -87
- data/lib/livetext/helpers.rb +24 -13
- data/lib/livetext/standard.rb +62 -57
- data/lib/livetext/userapi.rb +13 -2
- data/lib/livetext/version.rb +1 -1
- data/plugin/bookish.rb +1 -1
- data/test/extra/README.txt +149 -0
- data/test/extra/bracketed.rb +121 -0
- data/test/extra/bracketed.txt +44 -0
- data/test/extra/double.rb +121 -0
- data/test/extra/double.txt +44 -0
- data/test/extra/functions.rb +148 -0
- data/test/extra/functions.txt +58 -0
- data/test/extra/single.rb +139 -0
- data/test/extra/single.txt +52 -0
- data/test/extra/testgen.rb +104 -0
- data/test/{snapshots/bootstrap_menu/expected-error.txt → extra/variables..rb} +0 -0
- data/test/extra/variables.rb +94 -0
- data/test/extra/variables.txt +35 -0
- data/test/snapshots/basic_formatting/expected-output.txt +2 -1
- data/test/snapshots/import_bookish/toc.tmp +0 -0
- data/test/snapshots/mixin_bookish/toc.tmp +0 -0
- data/test/snapshots/simple_vars/source.lt3 +1 -1
- data/test/snapshots/subset.txt +0 -2
- data/test/unit/all.rb +1 -2
- metadata +17 -9
- data/test/snapshots/bootstrap_menu/expected-output.txt +0 -4
- data/test/snapshots/bootstrap_menu/source.lt3 +0 -17
- data/test/snapshots/error_inc_line_num/README.txt +0 -20
- data/test/snapshots/error_invalid_name/foo +0 -5
- data/test/unit/lineparser.rb +0 -359
- data/test/unit/new_lineparser.rb +0 -359
@@ -0,0 +1,44 @@
|
|
1
|
+
Single bracketed item
|
2
|
+
"*[abc]"
|
3
|
+
"<b>abc</b>"
|
4
|
+
--------------------------------
|
5
|
+
End of line can replace bracket
|
6
|
+
"*[abc"
|
7
|
+
"<b>abc</b>"
|
8
|
+
--------------------------------
|
9
|
+
End of line can replace bracket again
|
10
|
+
"abc *[d"
|
11
|
+
"abc <b>d</b>"
|
12
|
+
--------------------------------
|
13
|
+
Missing right bracket ignored at eol if empty
|
14
|
+
"abc*["
|
15
|
+
"abc*["
|
16
|
+
--------------------------------
|
17
|
+
Two simple bracketed items
|
18
|
+
"*[A], *[B], C"
|
19
|
+
"<b>A</b>, <b>B</b>, C"
|
20
|
+
--------------------------------
|
21
|
+
Simple bracketed item
|
22
|
+
"Just a *[test]..."
|
23
|
+
"Just a <b>test</b>..."
|
24
|
+
--------------------------------
|
25
|
+
Bracketed item with space
|
26
|
+
"A *[simple test]"
|
27
|
+
"A <b>simple test</b>"
|
28
|
+
--------------------------------
|
29
|
+
Empty bracketed item results in null
|
30
|
+
" *[] "
|
31
|
+
" "
|
32
|
+
--------------------------------
|
33
|
+
Bracketed item with space again
|
34
|
+
"*[ab c] d"
|
35
|
+
"<b>ab c</b> d"
|
36
|
+
--------------------------------
|
37
|
+
Two bracketed items with spaces
|
38
|
+
"*[a b] *[c d]"
|
39
|
+
"<b>a b</b> <b>c d</b>"
|
40
|
+
--------------------------------
|
41
|
+
Solitary item, missing right bracket ignored at eol if empty
|
42
|
+
"*["
|
43
|
+
""
|
44
|
+
--------------------------------
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
|
3
|
+
require 'livetext'
|
4
|
+
|
5
|
+
# Just another testing class. Chill.
|
6
|
+
|
7
|
+
class TestingLivetextDouble < MiniTest::Test
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@live = Livetext.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def check_match(exp, actual)
|
14
|
+
if exp.is_a? Regexp
|
15
|
+
assert_match(exp, actual, "actual does not match expected")
|
16
|
+
else
|
17
|
+
assert_equal(exp, actual, "actual != expected")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_double_001_double_marker_plus_end_of_line
|
22
|
+
# Double marker plus end of line
|
23
|
+
# No special initialization
|
24
|
+
src = "**abc"
|
25
|
+
exp = "<b>abc</b>"
|
26
|
+
actual = @live.api.format(src)
|
27
|
+
check_match(exp, actual)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_double_002_embedded_double_marker_is_ignored
|
31
|
+
# Embedded double marker is ignored
|
32
|
+
# No special initialization
|
33
|
+
src = "abc**d"
|
34
|
+
exp = "abc**d"
|
35
|
+
actual = @live.api.format(src)
|
36
|
+
check_match(exp, actual)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_double_003_double_marker_at_end_of_line_is_ignored
|
40
|
+
# Double marker at end of line is ignored
|
41
|
+
# No special initialization
|
42
|
+
src = "abc**"
|
43
|
+
exp = "abc**"
|
44
|
+
actual = @live.api.format(src)
|
45
|
+
check_match(exp, actual)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_double_004_two_valid_double_markers
|
49
|
+
# Two valid double markers
|
50
|
+
# No special initialization
|
51
|
+
src = "**A, **B, C"
|
52
|
+
exp = "<b>A</b>, <b>B</b>, C"
|
53
|
+
actual = @live.api.format(src)
|
54
|
+
check_match(exp, actual)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_double_005_one_valid_double_marker
|
58
|
+
# One valid double marker
|
59
|
+
# No special initialization
|
60
|
+
src = "Just a **test..."
|
61
|
+
exp = "Just a <b>test</b>..."
|
62
|
+
actual = @live.api.format(src)
|
63
|
+
check_match(exp, actual)
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_double_006_double_marker_by_itself_is_ignored
|
67
|
+
# Double marker by itself is ignored
|
68
|
+
# No special initialization
|
69
|
+
src = " ** "
|
70
|
+
exp = " ** "
|
71
|
+
actual = @live.api.format(src)
|
72
|
+
check_match(exp, actual)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_double_007_double_marker_terminated_by_comma_period_end_of_line
|
76
|
+
# Double marker terminated by comma, period, end of line
|
77
|
+
# No special initialization
|
78
|
+
src = "**ab, **c. d **e"
|
79
|
+
exp = "<b>ab</b>, <b>c</b>. d <b>e</b>"
|
80
|
+
actual = @live.api.format(src)
|
81
|
+
check_match(exp, actual)
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_double_008_embedded_double_markers_are_ignored
|
85
|
+
# Embedded double markers are ignored
|
86
|
+
# No special initialization
|
87
|
+
src = "x**y**z"
|
88
|
+
exp = "x**y**z"
|
89
|
+
actual = @live.api.format(src)
|
90
|
+
check_match(exp, actual)
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_double_009_double_markers_terminated_by_space_or_end_of_line
|
94
|
+
# Double markers terminated by space or end of line
|
95
|
+
# No special initialization
|
96
|
+
src = "**a **b"
|
97
|
+
exp = "<b>a</b> <b>b</b>"
|
98
|
+
actual = @live.api.format(src)
|
99
|
+
check_match(exp, actual)
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_double_010_single_valid_double_marker
|
103
|
+
# Single valid double marker
|
104
|
+
# No special initialization
|
105
|
+
src = "**A"
|
106
|
+
exp = "<b>A</b>"
|
107
|
+
actual = @live.api.format(src)
|
108
|
+
check_match(exp, actual)
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_double_011_double_marker_by_itself_is_ignored
|
112
|
+
# Double marker by itself is ignored
|
113
|
+
# No special initialization
|
114
|
+
src = "**"
|
115
|
+
exp = "**"
|
116
|
+
actual = @live.api.format(src)
|
117
|
+
check_match(exp, actual)
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
Double marker plus end of line
|
2
|
+
"**abc"
|
3
|
+
"<b>abc</b>"
|
4
|
+
-----------------------------------
|
5
|
+
Embedded double marker is ignored
|
6
|
+
"abc**d"
|
7
|
+
"abc**d"
|
8
|
+
-----------------------------------
|
9
|
+
Double marker at end of line is ignored
|
10
|
+
"abc**"
|
11
|
+
"abc**"
|
12
|
+
-----------------------------------
|
13
|
+
Two valid double markers
|
14
|
+
"**A, **B, C"
|
15
|
+
"<b>A</b>, <b>B</b>, C"
|
16
|
+
-----------------------------------
|
17
|
+
One valid double marker
|
18
|
+
"Just a **test..."
|
19
|
+
"Just a <b>test</b>..."
|
20
|
+
-----------------------------------
|
21
|
+
Double marker by itself is ignored
|
22
|
+
" ** "
|
23
|
+
" ** "
|
24
|
+
-----------------------------------
|
25
|
+
Double marker terminated by comma, period, end of line
|
26
|
+
"**ab, **c. d **e"
|
27
|
+
"<b>ab</b>, <b>c</b>. d <b>e</b>"
|
28
|
+
-----------------------------------
|
29
|
+
Embedded double markers are ignored
|
30
|
+
"x**y**z"
|
31
|
+
"x**y**z"
|
32
|
+
-----------------------------------
|
33
|
+
Double markers terminated by space or end of line
|
34
|
+
"**a **b"
|
35
|
+
"<b>a</b> <b>b</b>"
|
36
|
+
-----------------------------------
|
37
|
+
Single valid double marker
|
38
|
+
"**A"
|
39
|
+
"<b>A</b>"
|
40
|
+
-----------------------------------
|
41
|
+
Double marker by itself is ignored
|
42
|
+
"**"
|
43
|
+
"**"
|
44
|
+
-----------------------------------
|
@@ -0,0 +1,148 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
|
3
|
+
require 'livetext'
|
4
|
+
|
5
|
+
# Just another testing class. Chill.
|
6
|
+
|
7
|
+
class TestingLivetextFunctions < MiniTest::Test
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@live = Livetext.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def check_match(exp, actual)
|
14
|
+
if exp.is_a? Regexp
|
15
|
+
assert_match(exp, actual, "actual does not match expected")
|
16
|
+
else
|
17
|
+
assert_equal(exp, actual, "actual != expected")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_functions_001_simple_function_call
|
22
|
+
# Simple function call
|
23
|
+
# No special initialization
|
24
|
+
src = "Today is $$date"
|
25
|
+
exp = /Today is [[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}/
|
26
|
+
actual = @live.api.format(src)
|
27
|
+
check_match(exp, actual)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_functions_002_function_call_with_colon_parameter
|
31
|
+
# Function call with colon parameter
|
32
|
+
# No special initialization
|
33
|
+
src = "Square root of 225 is $$isqrt:225"
|
34
|
+
exp = /is 15$/
|
35
|
+
actual = @live.api.format(src)
|
36
|
+
check_match(exp, actual)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_functions_003_function_call_with_empty_colon_parameter
|
40
|
+
# Function call with empty colon parameter
|
41
|
+
# No special initialization
|
42
|
+
src = "Calculate $$isqrt:"
|
43
|
+
exp = /Error evaluating/
|
44
|
+
actual = @live.api.format(src)
|
45
|
+
check_match(exp, actual)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_functions_004_function_call_with_empty_bracket_parameter
|
49
|
+
# Function call with empty bracket parameter
|
50
|
+
# No special initialization
|
51
|
+
src = "Calculate $$isqrt[]"
|
52
|
+
exp = /Error evaluating/
|
53
|
+
actual = @live.api.format(src)
|
54
|
+
check_match(exp, actual)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_functions_005_function_detects_invalid_bracket_parameter
|
58
|
+
# Function detects invalid bracket parameter
|
59
|
+
# No special initialization
|
60
|
+
src = "Calculate $$isqrt[3a5]"
|
61
|
+
exp = /Error evaluating/
|
62
|
+
actual = @live.api.format(src)
|
63
|
+
check_match(exp, actual)
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_functions_006_function_call_followed_by_comma
|
67
|
+
# Function call followed by comma
|
68
|
+
# No special initialization
|
69
|
+
src = "Today is $$date, I think"
|
70
|
+
exp = /Today is [[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}, I think/
|
71
|
+
actual = @live.api.format(src)
|
72
|
+
check_match(exp, actual)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_functions_007_undefined_function
|
76
|
+
# Undefined function
|
77
|
+
# No special initialization
|
78
|
+
src = "I am calling an $$unknown.function here"
|
79
|
+
exp = /evaluating/
|
80
|
+
actual = @live.api.format(src)
|
81
|
+
check_match(exp, actual)
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_functions_008_functions_date_time_pwd
|
85
|
+
# Functions date, time, pwd
|
86
|
+
# No special initialization
|
87
|
+
src = "Today is $$date at $$time, and I am in $$pwd"
|
88
|
+
exp = /Today is [[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2} at [[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}, and I am in (\/[[:alnum:]]+)+\/?/
|
89
|
+
actual = @live.api.format(src)
|
90
|
+
check_match(exp, actual)
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_functions_009_function_detects_missing_parameter
|
94
|
+
# Function detects missing parameter
|
95
|
+
# No special initialization
|
96
|
+
src = "Here I call $$reverse with no parameters"
|
97
|
+
exp = "Here I call (reverse: No parameter) with no parameters"
|
98
|
+
actual = @live.api.format(src)
|
99
|
+
check_match(exp, actual)
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_functions_010_simple_function_test
|
103
|
+
# Simple function test
|
104
|
+
# No special initialization
|
105
|
+
src = "'animal' spelled backwards is '$$reverse[animal]'"
|
106
|
+
exp = "'animal' spelled backwards is 'lamina'"
|
107
|
+
actual = @live.api.format(src)
|
108
|
+
check_match(exp, actual)
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_functions_011_simple_function_with_colon_parameter
|
112
|
+
# Simple function with colon parameter
|
113
|
+
# No special initialization
|
114
|
+
src = "'lamina' spelled backwards is $$reverse:lamina"
|
115
|
+
exp = "'lamina' spelled backwards is animal"
|
116
|
+
actual = @live.api.format(src)
|
117
|
+
check_match(exp, actual)
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_functions_012_variable_inside_function_bracket_parameter
|
121
|
+
# Variable inside function bracket parameter
|
122
|
+
@live.api.setvar(:whatever, "some var value")
|
123
|
+
src = "$whatever backwards is $$reverse[$whatever]"
|
124
|
+
exp = "some var value backwards is eulav rav emos"
|
125
|
+
actual = @live.api.format(src)
|
126
|
+
check_match(exp, actual)
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_functions_013_function_with_variable_in_colon_param_is_nonhygienic
|
130
|
+
# Function with variable in colon param is nonhygienic
|
131
|
+
@live.api.setvar(:whatever, "some var value")
|
132
|
+
src = "Like non-hygienic macros: $whatever backwards != $$reverse:$whatever"
|
133
|
+
exp = "Like non-hygienic macros: some var value backwards != emos var value"
|
134
|
+
actual = @live.api.format(src)
|
135
|
+
check_match(exp, actual)
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_functions_014_function_call_with_variable_in_bracket_param
|
139
|
+
# Function call with variable in bracket param
|
140
|
+
# No special initialization
|
141
|
+
src = "User $User backwards is $$reverse[$User]"
|
142
|
+
exp = /User [[:alnum:]]+ backwards is [[:alnum:]]+$/
|
143
|
+
actual = @live.api.format(src)
|
144
|
+
check_match(exp, actual)
|
145
|
+
end
|
146
|
+
|
147
|
+
|
148
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
Simple function call
|
2
|
+
"Today is $$date"
|
3
|
+
/Today is RX_DATE/
|
4
|
+
-------------------------------------------------
|
5
|
+
Function call with colon parameter
|
6
|
+
"Square root of 225 is $$isqrt:225"
|
7
|
+
/is 15$/
|
8
|
+
-------------------------------------------------
|
9
|
+
Function call with empty colon parameter
|
10
|
+
"Calculate $$isqrt:"
|
11
|
+
/Error evaluating/
|
12
|
+
-------------------------------------------------
|
13
|
+
Function call with empty bracket parameter
|
14
|
+
"Calculate $$isqrt[]"
|
15
|
+
/Error evaluating/
|
16
|
+
-------------------------------------------------
|
17
|
+
Function detects invalid bracket parameter
|
18
|
+
"Calculate $$isqrt[3a5]"
|
19
|
+
/Error evaluating/
|
20
|
+
-------------------------------------------------
|
21
|
+
Function call followed by comma
|
22
|
+
"Today is $$date, I think"
|
23
|
+
/Today is RX_DATE, I think/
|
24
|
+
-------------------------------------------------
|
25
|
+
Undefined function
|
26
|
+
"I am calling an $$unknown.function here"
|
27
|
+
/evaluating/
|
28
|
+
-------------------------------------------------
|
29
|
+
Functions date, time, pwd
|
30
|
+
"Today is $$date at $$time, and I am in $$pwd"
|
31
|
+
/Today is RX_DATE at RX_TIME, and I am in RX_PATH/
|
32
|
+
-------------------------------------------------
|
33
|
+
Function detects missing parameter
|
34
|
+
"Here I call $$reverse with no parameters"
|
35
|
+
"Here I call (reverse: No parameter) with no parameters"
|
36
|
+
-------------------------------------------------
|
37
|
+
Simple function test
|
38
|
+
"'animal' spelled backwards is '$$reverse[animal]'"
|
39
|
+
"'animal' spelled backwards is 'lamina'"
|
40
|
+
-------------------------------------------------
|
41
|
+
Simple function with colon parameter
|
42
|
+
"'lamina' spelled backwards is $$reverse:lamina"
|
43
|
+
"'lamina' spelled backwards is animal"
|
44
|
+
-------------------------------------------------
|
45
|
+
Variable inside function bracket parameter
|
46
|
+
init: @live.api.setvar(:whatever, "some var value")
|
47
|
+
"$whatever backwards is $$reverse[$whatever]"
|
48
|
+
"some var value backwards is eulav rav emos"
|
49
|
+
-------------------------------------------------
|
50
|
+
Function with variable in colon param is nonhygienic
|
51
|
+
init: @live.api.setvar(:whatever, "some var value")
|
52
|
+
"Like non-hygienic macros: $whatever backwards != $$reverse:$whatever"
|
53
|
+
"Like non-hygienic macros: some var value backwards != emos var value"
|
54
|
+
-------------------------------------------------
|
55
|
+
Function call with variable in bracket param
|
56
|
+
"User $User backwards is $$reverse[$User]"
|
57
|
+
/User RX_USER backwards is RX_USER$/
|
58
|
+
-------------------------------------------------
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
|
3
|
+
require 'livetext'
|
4
|
+
|
5
|
+
# Just another testing class. Chill.
|
6
|
+
|
7
|
+
class TestingLivetextSingle < MiniTest::Test
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@live = Livetext.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def check_match(exp, actual)
|
14
|
+
if exp.is_a? Regexp
|
15
|
+
assert_match(exp, actual, "actual does not match expected")
|
16
|
+
else
|
17
|
+
assert_equal(exp, actual, "actual != expected")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_single_001_no_marker_at_all
|
22
|
+
# No marker at all
|
23
|
+
# No special initialization
|
24
|
+
src = "abc"
|
25
|
+
exp = "abc"
|
26
|
+
actual = @live.api.format(src)
|
27
|
+
check_match(exp, actual)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_single_002_single_marker_at_front
|
31
|
+
# Single marker at front
|
32
|
+
# No special initialization
|
33
|
+
src = "*abc"
|
34
|
+
exp = "<b>abc</b>"
|
35
|
+
actual = @live.api.format(src)
|
36
|
+
check_match(exp, actual)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_single_003_embedded_marker_is_ignored
|
40
|
+
# Embedded marker is ignored
|
41
|
+
# No special initialization
|
42
|
+
src = "abc*d"
|
43
|
+
exp = "abc*d"
|
44
|
+
actual = @live.api.format(src)
|
45
|
+
check_match(exp, actual)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_single_004_trailing_marker_is_ignored
|
49
|
+
# Trailing marker is ignored
|
50
|
+
# No special initialization
|
51
|
+
src = "abc*"
|
52
|
+
exp = "abc*"
|
53
|
+
actual = @live.api.format(src)
|
54
|
+
check_match(exp, actual)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_single_005_two_valid_markers
|
58
|
+
# Two valid markers
|
59
|
+
# No special initialization
|
60
|
+
src = "*A *B C"
|
61
|
+
exp = "<b>A</b> <b>B</b> C"
|
62
|
+
actual = @live.api.format(src)
|
63
|
+
check_match(exp, actual)
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_single_006_one_valid_marker
|
67
|
+
# One valid marker
|
68
|
+
# No special initialization
|
69
|
+
src = "Just a little *test here"
|
70
|
+
exp = "Just a little <b>test</b> here"
|
71
|
+
actual = @live.api.format(src)
|
72
|
+
check_match(exp, actual)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_single_007_marker_surrounded_by_spaces_is_ignored
|
76
|
+
# Marker surrounded by spaces is ignored
|
77
|
+
# No special initialization
|
78
|
+
src = " * "
|
79
|
+
exp = " * "
|
80
|
+
actual = @live.api.format(src)
|
81
|
+
check_match(exp, actual)
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_single_008_multiple_valid_markers
|
85
|
+
# Multiple valid markers
|
86
|
+
# No special initialization
|
87
|
+
src = "*abc *d ef *gh i"
|
88
|
+
exp = "<b>abc</b> <b>d</b> ef <b>gh</b> i"
|
89
|
+
actual = @live.api.format(src)
|
90
|
+
check_match(exp, actual)
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_single_009_valid_markers_are_ignored
|
94
|
+
# Valid markers are ignored
|
95
|
+
# No special initialization
|
96
|
+
src = "x*y*z"
|
97
|
+
exp = "x*y*z"
|
98
|
+
actual = @live.api.format(src)
|
99
|
+
check_match(exp, actual)
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_single_010_valid_markers_at_start_end_of_string
|
103
|
+
# Valid markers at start+end of string
|
104
|
+
# No special initialization
|
105
|
+
src = "*a *b"
|
106
|
+
exp = "<b>a</b> <b>b</b>"
|
107
|
+
actual = @live.api.format(src)
|
108
|
+
check_match(exp, actual)
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_single_011_marker_by_itself_on_line_is_ignored
|
112
|
+
# Marker by itself on line is ignored
|
113
|
+
# No special initialization
|
114
|
+
src = "*"
|
115
|
+
exp = "*"
|
116
|
+
actual = @live.api.format(src)
|
117
|
+
check_match(exp, actual)
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_single_012_marker_at_end_unaffected_by_newline
|
121
|
+
# Marker at end unaffected by newline
|
122
|
+
# No special initialization
|
123
|
+
src = "This is *bold\n"
|
124
|
+
exp = "This is <b>bold</b>"
|
125
|
+
actual = @live.api.format(src)
|
126
|
+
check_match(exp, actual)
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_single_013_escaped_marker_is_ignored
|
130
|
+
# Escaped marker is ignored
|
131
|
+
# No special initialization
|
132
|
+
src = "\\\\*escaped"
|
133
|
+
exp = "*escaped"
|
134
|
+
actual = @live.api.format(src)
|
135
|
+
check_match(exp, actual)
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
No marker at all
|
2
|
+
"abc"
|
3
|
+
"abc"
|
4
|
+
------------------------------------
|
5
|
+
Single marker at front
|
6
|
+
"*abc"
|
7
|
+
"<b>abc</b>"
|
8
|
+
------------------------------------
|
9
|
+
Embedded marker is ignored
|
10
|
+
"abc*d"
|
11
|
+
"abc*d"
|
12
|
+
------------------------------------
|
13
|
+
Trailing marker is ignored
|
14
|
+
"abc*"
|
15
|
+
"abc*"
|
16
|
+
------------------------------------
|
17
|
+
Two valid markers
|
18
|
+
"*A *B C"
|
19
|
+
"<b>A</b> <b>B</b> C"
|
20
|
+
------------------------------------
|
21
|
+
One valid marker
|
22
|
+
"Just a little *test here"
|
23
|
+
"Just a little <b>test</b> here"
|
24
|
+
------------------------------------
|
25
|
+
Marker surrounded by spaces is ignored
|
26
|
+
" * "
|
27
|
+
" * "
|
28
|
+
------------------------------------
|
29
|
+
Multiple valid markers
|
30
|
+
"*abc *d ef *gh i"
|
31
|
+
"<b>abc</b> <b>d</b> ef <b>gh</b> i"
|
32
|
+
------------------------------------
|
33
|
+
Valid markers are ignored
|
34
|
+
"x*y*z"
|
35
|
+
"x*y*z"
|
36
|
+
------------------------------------
|
37
|
+
Valid markers at start+end of string
|
38
|
+
"*a *b"
|
39
|
+
"<b>a</b> <b>b</b>"
|
40
|
+
------------------------------------
|
41
|
+
Marker by itself on line is ignored
|
42
|
+
"*"
|
43
|
+
"*"
|
44
|
+
------------------------------------
|
45
|
+
Marker at end unaffected by newline
|
46
|
+
"This is *bold\n"
|
47
|
+
"This is <b>bold</b>"
|
48
|
+
------------------------------------
|
49
|
+
Escaped marker is ignored
|
50
|
+
"\\*escaped"
|
51
|
+
"*escaped"
|
52
|
+
------------------------------------
|