rdoc 3.12.2 → 4.0.0.preview2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rdoc might be problematic. Click here for more details.
- checksums.yaml +6 -6
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.autotest +3 -2
- data/DEVELOPERS.rdoc +53 -0
- data/History.rdoc +159 -25
- data/LEGAL.rdoc +12 -0
- data/Manifest.txt +56 -3
- data/README.rdoc +87 -19
- data/Rakefile +11 -2
- data/TODO.rdoc +20 -13
- data/bin/rdoc +4 -0
- data/lib/gauntlet_rdoc.rb +1 -1
- data/lib/rdoc.rb +32 -71
- data/lib/rdoc/any_method.rb +75 -21
- data/lib/rdoc/attr.rb +49 -10
- data/lib/rdoc/class_module.rb +182 -32
- data/lib/rdoc/code_object.rb +54 -12
- data/lib/rdoc/comment.rb +8 -1
- data/lib/rdoc/constant.rb +100 -6
- data/lib/rdoc/context.rb +93 -41
- data/lib/rdoc/context/section.rb +143 -28
- data/lib/rdoc/cross_reference.rb +58 -50
- data/lib/rdoc/encoding.rb +34 -29
- data/lib/rdoc/erb_partial.rb +18 -0
- data/lib/rdoc/extend.rb +117 -0
- data/lib/rdoc/generator.rb +11 -6
- data/lib/rdoc/generator/darkfish.rb +250 -62
- data/lib/rdoc/generator/json_index.rb +20 -12
- data/lib/rdoc/generator/markup.rb +10 -12
- data/lib/rdoc/generator/ri.rb +7 -60
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +7 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +16 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +14 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +13 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +15 -1
- data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -3
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +7 -9
- data/lib/rdoc/generator/template/darkfish/page.rhtml +2 -0
- data/lib/rdoc/generator/template/darkfish/rdoc.css +31 -0
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +37 -0
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
- data/lib/rdoc/include.rb +12 -3
- data/lib/rdoc/markdown.kpeg +1186 -0
- data/lib/rdoc/markdown.rb +16336 -0
- data/lib/rdoc/markdown/entities.rb +2128 -0
- data/lib/rdoc/markdown/literals_1_8.kpeg +18 -0
- data/lib/rdoc/markdown/literals_1_8.rb +454 -0
- data/lib/rdoc/markdown/literals_1_9.kpeg +22 -0
- data/lib/rdoc/markdown/literals_1_9.rb +417 -0
- data/lib/rdoc/markup.rb +69 -10
- data/lib/rdoc/markup/attr_changer.rb +2 -5
- data/lib/rdoc/markup/attribute_manager.rb +23 -14
- data/lib/rdoc/markup/attributes.rb +70 -0
- data/lib/rdoc/markup/block_quote.rb +14 -0
- data/lib/rdoc/markup/document.rb +20 -4
- data/lib/rdoc/markup/formatter.rb +17 -6
- data/lib/rdoc/markup/formatter_test_case.rb +93 -24
- data/lib/rdoc/markup/hard_break.rb +31 -0
- data/lib/rdoc/markup/heading.rb +1 -1
- data/lib/rdoc/markup/indented_paragraph.rb +14 -0
- data/lib/rdoc/markup/list.rb +23 -4
- data/lib/rdoc/markup/list_item.rb +17 -4
- data/lib/rdoc/markup/paragraph.rb +14 -0
- data/lib/rdoc/markup/parser.rb +107 -60
- data/lib/rdoc/markup/raw.rb +4 -4
- data/lib/rdoc/markup/special.rb +3 -3
- data/lib/rdoc/markup/to_ansi.rb +7 -1
- data/lib/rdoc/markup/to_html.rb +42 -14
- data/lib/rdoc/markup/to_html_crossref.rb +10 -9
- data/lib/rdoc/markup/to_html_snippet.rb +20 -4
- data/lib/rdoc/markup/to_joined_paragraph.rb +68 -0
- data/lib/rdoc/markup/to_label.rb +20 -1
- data/lib/rdoc/markup/to_markdown.rb +134 -0
- data/lib/rdoc/markup/to_rdoc.rb +36 -5
- data/lib/rdoc/markup/to_table_of_contents.rb +6 -1
- data/lib/rdoc/markup/to_tt_only.rb +11 -2
- data/lib/rdoc/markup/verbatim.rb +19 -0
- data/lib/rdoc/method_attr.rb +33 -19
- data/lib/rdoc/normal_class.rb +26 -7
- data/lib/rdoc/normal_module.rb +10 -5
- data/lib/rdoc/options.rb +95 -21
- data/lib/rdoc/parser.rb +6 -2
- data/lib/rdoc/parser/c.rb +212 -97
- data/lib/rdoc/parser/markdown.rb +23 -0
- data/lib/rdoc/parser/ruby.rb +115 -35
- data/lib/rdoc/parser/ruby_tools.rb +8 -3
- data/lib/rdoc/rd.rb +8 -4
- data/lib/rdoc/rd/block_parser.rb +1 -1
- data/lib/rdoc/rd/block_parser.ry +1 -1
- data/lib/rdoc/rdoc.rb +45 -21
- data/lib/rdoc/ri/driver.rb +322 -76
- data/lib/rdoc/ri/paths.rb +90 -31
- data/lib/rdoc/ri/store.rb +2 -353
- data/lib/rdoc/ruby_lex.rb +5 -21
- data/lib/rdoc/ruby_token.rb +2 -3
- data/lib/rdoc/rubygems_hook.rb +21 -9
- data/lib/rdoc/servlet.rb +302 -0
- data/lib/rdoc/stats.rb +28 -20
- data/lib/rdoc/store.rb +881 -0
- data/lib/rdoc/task.rb +2 -1
- data/lib/rdoc/test_case.rb +103 -1
- data/lib/rdoc/text.rb +5 -4
- data/lib/rdoc/tom_doc.rb +17 -16
- data/lib/rdoc/top_level.rb +43 -285
- data/test/MarkdownTest_1.0.3/Amps and angle encoding.text +21 -0
- data/test/MarkdownTest_1.0.3/Auto links.text +13 -0
- data/test/MarkdownTest_1.0.3/Backslash escapes.text +120 -0
- data/test/MarkdownTest_1.0.3/Blockquotes with code blocks.text +11 -0
- data/test/MarkdownTest_1.0.3/Code Blocks.text +14 -0
- data/test/MarkdownTest_1.0.3/Code Spans.text +6 -0
- data/test/MarkdownTest_1.0.3/Hard-wrapped paragraphs with list-like lines.text +8 -0
- data/test/MarkdownTest_1.0.3/Horizontal rules.text +67 -0
- data/test/MarkdownTest_1.0.3/Inline HTML (Advanced).text +15 -0
- data/test/MarkdownTest_1.0.3/Inline HTML (Simple).text +69 -0
- data/test/MarkdownTest_1.0.3/Inline HTML comments.text +13 -0
- data/test/MarkdownTest_1.0.3/Links, inline style.text +12 -0
- data/test/MarkdownTest_1.0.3/Links, reference style.text +71 -0
- data/test/MarkdownTest_1.0.3/Links, shortcut references.text +20 -0
- data/test/MarkdownTest_1.0.3/Literal quotes in titles.text +7 -0
- data/test/MarkdownTest_1.0.3/Markdown Documentation - Basics.text +306 -0
- data/test/MarkdownTest_1.0.3/Markdown Documentation - Syntax.text +888 -0
- data/test/MarkdownTest_1.0.3/Nested blockquotes.text +5 -0
- data/test/MarkdownTest_1.0.3/Ordered and unordered lists.text +131 -0
- data/test/MarkdownTest_1.0.3/Strong and em together.text +7 -0
- data/test/MarkdownTest_1.0.3/Tabs.text +21 -0
- data/test/MarkdownTest_1.0.3/Tidyness.text +5 -0
- data/test/test_attribute_manager.rb +7 -4
- data/test/test_rdoc_any_method.rb +84 -13
- data/test/test_rdoc_attr.rb +59 -9
- data/test/test_rdoc_class_module.rb +670 -73
- data/test/test_rdoc_code_object.rb +21 -1
- data/test/test_rdoc_comment.rb +1 -1
- data/test/test_rdoc_constant.rb +132 -0
- data/test/test_rdoc_context.rb +84 -18
- data/test/test_rdoc_context_section.rb +99 -15
- data/test/test_rdoc_cross_reference.rb +1 -1
- data/test/test_rdoc_encoding.rb +17 -1
- data/test/test_rdoc_extend.rb +94 -0
- data/test/test_rdoc_generator_darkfish.rb +45 -19
- data/test/test_rdoc_generator_json_index.rb +27 -7
- data/test/test_rdoc_generator_markup.rb +3 -3
- data/test/test_rdoc_generator_ri.rb +11 -9
- data/test/test_rdoc_include.rb +12 -0
- data/test/test_rdoc_markdown.rb +977 -0
- data/test/test_rdoc_markdown_test.rb +1891 -0
- data/test/test_rdoc_markup.rb +1 -1
- data/test/test_rdoc_markup_attribute_manager.rb +2 -2
- data/test/test_rdoc_markup_attributes.rb +39 -0
- data/test/test_rdoc_markup_document.rb +16 -1
- data/test/test_rdoc_markup_formatter.rb +7 -4
- data/test/test_rdoc_markup_hard_break.rb +31 -0
- data/test/test_rdoc_markup_indented_paragraph.rb +14 -0
- data/test/test_rdoc_markup_paragraph.rb +15 -1
- data/test/test_rdoc_markup_parser.rb +152 -89
- data/test/test_rdoc_markup_to_ansi.rb +23 -2
- data/test/test_rdoc_markup_to_bs.rb +24 -0
- data/test/test_rdoc_markup_to_html.rb +50 -19
- data/test/test_rdoc_markup_to_html_crossref.rb +23 -5
- data/test/test_rdoc_markup_to_html_snippet.rb +49 -8
- data/test/test_rdoc_markup_to_joined_paragraph.rb +32 -0
- data/test/test_rdoc_markup_to_label.rb +63 -1
- data/test/test_rdoc_markup_to_markdown.rb +352 -0
- data/test/test_rdoc_markup_to_rdoc.rb +22 -2
- data/test/test_rdoc_markup_to_table_of_contents.rb +44 -39
- data/test/test_rdoc_markup_to_tt_only.rb +20 -0
- data/test/test_rdoc_markup_verbatim.rb +13 -0
- data/test/test_rdoc_method_attr.rb +5 -0
- data/test/test_rdoc_normal_class.rb +24 -5
- data/test/test_rdoc_normal_module.rb +1 -1
- data/test/test_rdoc_options.rb +21 -6
- data/test/test_rdoc_parser.rb +24 -0
- data/test/test_rdoc_parser_c.rb +151 -26
- data/test/test_rdoc_parser_markdown.rb +55 -0
- data/test/test_rdoc_parser_rd.rb +2 -2
- data/test/test_rdoc_parser_ruby.rb +468 -109
- data/test/test_rdoc_parser_simple.rb +2 -2
- data/test/test_rdoc_rd_block_parser.rb +0 -4
- data/test/test_rdoc_rdoc.rb +110 -22
- data/test/test_rdoc_ri_driver.rb +415 -80
- data/test/test_rdoc_ri_paths.rb +122 -13
- data/test/test_rdoc_ruby_lex.rb +5 -61
- data/test/test_rdoc_ruby_token.rb +19 -0
- data/test/test_rdoc_rubygems_hook.rb +64 -43
- data/test/test_rdoc_servlet.rb +429 -0
- data/test/test_rdoc_stats.rb +83 -24
- data/test/{test_rdoc_ri_store.rb → test_rdoc_store.rb} +395 -22
- data/test/test_rdoc_task.rb +2 -2
- data/test/test_rdoc_text.rb +37 -11
- data/test/test_rdoc_tom_doc.rb +59 -62
- data/test/test_rdoc_top_level.rb +71 -113
- data/test/xref_test_case.rb +7 -9
- metadata +122 -39
- metadata.gz.sig +0 -0
- data/CVE-2013-0256.rdoc +0 -49
- data/lib/rdoc/markup/attribute.rb +0 -51
data/test/test_rdoc_markup.rb
CHANGED
@@ -29,8 +29,8 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def crossref(text)
|
32
|
-
crossref_bitmap =
|
33
|
-
|
32
|
+
crossref_bitmap = @am.attributes.bitmap_for(:_SPECIAL_) |
|
33
|
+
@am.attributes.bitmap_for(:CROSSREF)
|
34
34
|
|
35
35
|
[ @am.changed_attribute_by_name([], [:CROSSREF, :_SPECIAL_]),
|
36
36
|
RDoc::Markup::Special.new(crossref_bitmap, text),
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rdoc/test_case'
|
2
|
+
|
3
|
+
class TestRDocMarkupAttributes < RDoc::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
|
8
|
+
@as = RDoc::Markup::Attributes.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_bitmap_for
|
12
|
+
assert_equal 2, @as.bitmap_for('two')
|
13
|
+
assert_equal 2, @as.bitmap_for('two')
|
14
|
+
assert_equal 4, @as.bitmap_for('three')
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_as_string
|
18
|
+
@as.bitmap_for 'two'
|
19
|
+
@as.bitmap_for 'three'
|
20
|
+
|
21
|
+
assert_equal 'none', @as.as_string(0)
|
22
|
+
assert_equal '_SPECIAL_', @as.as_string(1)
|
23
|
+
assert_equal 'two', @as.as_string(2)
|
24
|
+
assert_equal '_SPECIAL_,two', @as.as_string(3)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_each_name_of
|
28
|
+
@as.bitmap_for 'two'
|
29
|
+
@as.bitmap_for 'three'
|
30
|
+
|
31
|
+
assert_equal %w[], @as.each_name_of(0).to_a
|
32
|
+
assert_equal %w[], @as.each_name_of(1).to_a
|
33
|
+
assert_equal %w[two], @as.each_name_of(2).to_a
|
34
|
+
assert_equal %w[three], @as.each_name_of(4).to_a
|
35
|
+
assert_equal %w[two three], @as.each_name_of(6).to_a
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
@@ -45,6 +45,21 @@ class TestRDocMarkupDocument < RDoc::TestCase
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
def test_concat
|
49
|
+
@d.concat [@RM::BlankLine.new, @RM::BlankLine.new]
|
50
|
+
|
51
|
+
refute_empty @d
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_each
|
55
|
+
a = @RM::Document.new
|
56
|
+
b = @RM::Document.new(@RM::Paragraph.new('hi'))
|
57
|
+
|
58
|
+
@d.push a, b
|
59
|
+
|
60
|
+
assert_equal [a, b], @d.map { |sub_doc| sub_doc }
|
61
|
+
end
|
62
|
+
|
48
63
|
def test_empty_eh
|
49
64
|
assert_empty @d
|
50
65
|
|
@@ -87,7 +102,7 @@ class TestRDocMarkupDocument < RDoc::TestCase
|
|
87
102
|
end
|
88
103
|
|
89
104
|
def test_file_equals_top_level
|
90
|
-
@d.file =
|
105
|
+
@d.file = @store.add_file 'file.rb'
|
91
106
|
|
92
107
|
assert_equal 'file.rb', @d.file
|
93
108
|
end
|
@@ -5,7 +5,7 @@ class TestRDocMarkupFormatter < RDoc::TestCase
|
|
5
5
|
class ToTest < RDoc::Markup::Formatter
|
6
6
|
|
7
7
|
def initialize markup
|
8
|
-
super
|
8
|
+
super nil, markup
|
9
9
|
|
10
10
|
add_tag :TT, '<code>', '</code>'
|
11
11
|
end
|
@@ -38,11 +38,14 @@ class TestRDocMarkupFormatter < RDoc::TestCase
|
|
38
38
|
@markup = @RM.new
|
39
39
|
@markup.add_special(/[A-Z]+/, :CAPS)
|
40
40
|
|
41
|
+
@attribute_manager = @markup.attribute_manager
|
42
|
+
@attributes = @attribute_manager.attributes
|
43
|
+
|
41
44
|
@to = ToTest.new @markup
|
42
45
|
|
43
|
-
@caps = @
|
44
|
-
@special = @
|
45
|
-
@tt = @
|
46
|
+
@caps = @attributes.bitmap_for :CAPS
|
47
|
+
@special = @attributes.bitmap_for :_SPECIAL_
|
48
|
+
@tt = @attributes.bitmap_for :TT
|
46
49
|
end
|
47
50
|
|
48
51
|
def test_convert_tt_special
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rdoc/test_case'
|
2
|
+
|
3
|
+
class TestRDocMarkupHardBreak < RDoc::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
|
8
|
+
@hb = RDoc::Markup::HardBreak.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_accept
|
12
|
+
visitor = Object.new
|
13
|
+
|
14
|
+
def visitor.accept_hard_break(obj) @obj = obj end
|
15
|
+
def visitor.obj() @obj end
|
16
|
+
|
17
|
+
@hb.accept visitor
|
18
|
+
|
19
|
+
assert_same @hb, visitor.obj
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_equals2
|
23
|
+
other = RDoc::Markup::HardBreak.new
|
24
|
+
|
25
|
+
assert_equal @hb, other
|
26
|
+
|
27
|
+
refute_equal @hb, Object.new
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
@@ -35,5 +35,19 @@ class TestRDocMarkupIndentedParagraph < RDoc::TestCase
|
|
35
35
|
refute_equal one, two
|
36
36
|
end
|
37
37
|
|
38
|
+
def test_text
|
39
|
+
paragraph = @IP.new(2, 'hello', ' world')
|
40
|
+
|
41
|
+
assert_equal 'hello world', paragraph.text
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_text_break
|
45
|
+
paragraph = @IP.new(2, 'hello', hard_break, 'world')
|
46
|
+
|
47
|
+
assert_equal 'helloworld', paragraph.text
|
48
|
+
|
49
|
+
assert_equal "hello\n world", paragraph.text("\n")
|
50
|
+
end
|
51
|
+
|
38
52
|
end
|
39
53
|
|
@@ -11,7 +11,21 @@ class TestRDocMarkupParagraph < RDoc::TestCase
|
|
11
11
|
|
12
12
|
paragraph.accept visitor
|
13
13
|
|
14
|
-
|
14
|
+
assert_same paragraph, visitor.obj
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_text
|
18
|
+
paragraph = para('hello', ' world')
|
19
|
+
|
20
|
+
assert_equal 'hello world', paragraph.text
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_text_break
|
24
|
+
paragraph = para('hello', hard_break, 'world')
|
25
|
+
|
26
|
+
assert_equal 'helloworld', paragraph.text
|
27
|
+
|
28
|
+
assert_equal "hello\nworld", paragraph.text("\n")
|
15
29
|
end
|
16
30
|
|
17
31
|
end
|
@@ -7,13 +7,15 @@ class TestRDocMarkupParser < RDoc::TestCase
|
|
7
7
|
def setup
|
8
8
|
super
|
9
9
|
|
10
|
+
@have_byteslice = ''.respond_to? :byteslice
|
11
|
+
|
10
12
|
@RMP = @RM::Parser
|
11
13
|
end
|
12
14
|
|
13
15
|
def mu_pp(obj)
|
14
16
|
s = ''
|
15
17
|
s = PP.pp obj, s
|
16
|
-
s = s.force_encoding(Encoding.default_external) if
|
18
|
+
s = s.force_encoding(Encoding.default_external) if @have_encoding
|
17
19
|
s.chomp
|
18
20
|
end
|
19
21
|
|
@@ -28,6 +30,19 @@ class TestRDocMarkupParser < RDoc::TestCase
|
|
28
30
|
assert_equal @RM::Heading.new(3, 'heading three'), parser.build_heading(3)
|
29
31
|
end
|
30
32
|
|
33
|
+
def test_char_pos
|
34
|
+
parser = @RMP.new
|
35
|
+
s = parser.setup_scanner 'cät'
|
36
|
+
|
37
|
+
s.scan(/\S+/)
|
38
|
+
|
39
|
+
if @have_byteslice or @have_encoding then
|
40
|
+
assert_equal 3, parser.char_pos(s.pos)
|
41
|
+
else
|
42
|
+
assert_equal 4, parser.char_pos(s.pos)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
31
46
|
def test_get
|
32
47
|
parser = util_parser
|
33
48
|
|
@@ -146,13 +161,11 @@ the time
|
|
146
161
|
STR
|
147
162
|
|
148
163
|
expected = [
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
]),
|
155
|
-
]
|
164
|
+
list(:BULLET,
|
165
|
+
item(nil,
|
166
|
+
para('l1 ', 'l1+')),
|
167
|
+
item(nil,
|
168
|
+
para('l2')))]
|
156
169
|
|
157
170
|
assert_equal expected, @RMP.parse(str).parts
|
158
171
|
end
|
@@ -189,16 +202,16 @@ the time
|
|
189
202
|
STR
|
190
203
|
|
191
204
|
expected = [
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
205
|
+
list(:BULLET,
|
206
|
+
item(nil,
|
207
|
+
para('l1'),
|
208
|
+
list(:BULLET,
|
209
|
+
item(nil,
|
210
|
+
para('l1.1 ', 'text'),
|
211
|
+
verb("code\n", " code\n"),
|
212
|
+
para('text')))),
|
213
|
+
item(nil,
|
214
|
+
para('l2')))]
|
202
215
|
|
203
216
|
assert_equal expected, @RMP.parse(str).parts
|
204
217
|
end
|
@@ -324,11 +337,11 @@ the time
|
|
324
337
|
STR
|
325
338
|
|
326
339
|
expected = [
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
340
|
+
list(:LABEL,
|
341
|
+
item(%w[one],
|
342
|
+
para('item one')),
|
343
|
+
item(%w[two],
|
344
|
+
para('item two')))]
|
332
345
|
|
333
346
|
assert_equal expected, @RMP.parse(str).parts
|
334
347
|
end
|
@@ -341,19 +354,33 @@ the time
|
|
341
354
|
STR
|
342
355
|
|
343
356
|
expected = [
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
357
|
+
list(:LABEL,
|
358
|
+
item(%w[cat],
|
359
|
+
para('l1'),
|
360
|
+
list(:BULLET,
|
361
|
+
item(nil,
|
362
|
+
para('l1.1')))),
|
363
|
+
item(%w[dog],
|
364
|
+
para('l2')))]
|
365
|
+
|
366
|
+
assert_equal expected, @RMP.parse(str).parts
|
367
|
+
end
|
368
|
+
|
369
|
+
def test_parse_label_multi_label
|
370
|
+
str = <<-STR
|
371
|
+
[one]
|
372
|
+
[two] some description
|
373
|
+
STR
|
374
|
+
|
375
|
+
expected = [
|
376
|
+
list(:LABEL,
|
377
|
+
item(%w[one two],
|
378
|
+
para('some description')))]
|
352
379
|
|
353
380
|
assert_equal expected, @RMP.parse(str).parts
|
354
381
|
end
|
355
382
|
|
356
|
-
def
|
383
|
+
def test_parse_label_multi_line
|
357
384
|
str = <<-STR
|
358
385
|
[cat] l1
|
359
386
|
continuation
|
@@ -361,11 +388,11 @@ the time
|
|
361
388
|
STR
|
362
389
|
|
363
390
|
expected = [
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
391
|
+
list(:LABEL,
|
392
|
+
item(%w[cat],
|
393
|
+
para('l1 ', 'continuation')),
|
394
|
+
item(%w[dog],
|
395
|
+
para('l2')))]
|
369
396
|
|
370
397
|
assert_equal expected, @RMP.parse(str).parts
|
371
398
|
end
|
@@ -379,12 +406,11 @@ the time
|
|
379
406
|
STR
|
380
407
|
|
381
408
|
expected = [
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
])]
|
409
|
+
list(:LABEL,
|
410
|
+
item(%w[one],
|
411
|
+
para('item one')),
|
412
|
+
item(%w[two],
|
413
|
+
para('item two')))]
|
388
414
|
|
389
415
|
assert_equal expected, @RMP.parse(str).parts
|
390
416
|
end
|
@@ -445,9 +471,9 @@ a. 新しい機能
|
|
445
471
|
str = "now is\nthe time \nfor all"
|
446
472
|
|
447
473
|
expected = [
|
448
|
-
|
449
|
-
|
450
|
-
|
474
|
+
para('now is ', 'the time'),
|
475
|
+
blank_line,
|
476
|
+
para('for all')]
|
451
477
|
|
452
478
|
assert_equal expected, @RMP.parse(str).parts
|
453
479
|
end
|
@@ -465,16 +491,16 @@ a. 新しい機能
|
|
465
491
|
STR
|
466
492
|
|
467
493
|
expected = [
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
494
|
+
list(:NUMBER,
|
495
|
+
item(nil,
|
496
|
+
para('para 1'),
|
497
|
+
blank_line,
|
498
|
+
list(:LABEL,
|
499
|
+
item(%w[label\ 1],
|
500
|
+
para('para 1.1'),
|
501
|
+
blank_line,
|
502
|
+
verb("code\n"),
|
503
|
+
para('para 1.2')))))]
|
478
504
|
|
479
505
|
assert_equal expected, @RMP.parse(str).parts
|
480
506
|
end
|
@@ -488,15 +514,15 @@ a. 新しい機能
|
|
488
514
|
STR
|
489
515
|
|
490
516
|
expected = [
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
517
|
+
list(:NUMBER,
|
518
|
+
item(nil,
|
519
|
+
para('para'),
|
520
|
+
blank_line,
|
521
|
+
list(:NOTE,
|
522
|
+
item(%w[label\ 1],
|
523
|
+
para('text 1')),
|
524
|
+
item(%w[label\ 2],
|
525
|
+
para('text 2')))))]
|
500
526
|
|
501
527
|
assert_equal expected, @RMP.parse(str).parts
|
502
528
|
end
|
@@ -555,11 +581,11 @@ two:: item two
|
|
555
581
|
STR
|
556
582
|
|
557
583
|
expected = [
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
584
|
+
list(:NOTE,
|
585
|
+
item(%w[one],
|
586
|
+
para('item one')),
|
587
|
+
item(%w[two],
|
588
|
+
para('item two')))]
|
563
589
|
|
564
590
|
assert_equal expected, @RMP.parse(str).parts
|
565
591
|
end
|
@@ -571,11 +597,9 @@ two::
|
|
571
597
|
STR
|
572
598
|
|
573
599
|
expected = [
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
@RM::ListItem.new('two',
|
578
|
-
@RM::BlankLine.new)])]
|
600
|
+
list(:NOTE,
|
601
|
+
item(%w[one two],
|
602
|
+
blank_line))]
|
579
603
|
|
580
604
|
assert_equal expected, @RMP.parse(str).parts
|
581
605
|
end
|
@@ -586,11 +610,11 @@ one:: two::
|
|
586
610
|
STR
|
587
611
|
|
588
612
|
expected = [
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
613
|
+
list(:NOTE,
|
614
|
+
item(%w[one],
|
615
|
+
list(:NOTE,
|
616
|
+
item(%w[two],
|
617
|
+
blank_line))))]
|
594
618
|
|
595
619
|
assert_equal expected, @RMP.parse(str).parts
|
596
620
|
end
|
@@ -603,14 +627,14 @@ one:: two::
|
|
603
627
|
STR
|
604
628
|
|
605
629
|
expected = [
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
630
|
+
list(:NUMBER,
|
631
|
+
item(nil,
|
632
|
+
para('l1'),
|
633
|
+
list(:BULLET,
|
634
|
+
item(nil,
|
635
|
+
para('l1.1')))),
|
636
|
+
item(nil,
|
637
|
+
para('l2')))]
|
614
638
|
|
615
639
|
assert_equal expected, @RMP.parse(str).parts
|
616
640
|
end
|
@@ -632,7 +656,7 @@ for all good men
|
|
632
656
|
def test_parse_paragraph_multiline
|
633
657
|
str = "now is the time\nfor all good men"
|
634
658
|
|
635
|
-
expected = @RM::Paragraph.new 'now is the time', 'for all good men'
|
659
|
+
expected = @RM::Paragraph.new 'now is the time ', 'for all good men'
|
636
660
|
assert_equal [expected], @RMP.parse(str).parts
|
637
661
|
end
|
638
662
|
|
@@ -1341,6 +1365,32 @@ cat::
|
|
1341
1365
|
assert_equal expected, @RMP.tokenize(str)
|
1342
1366
|
end
|
1343
1367
|
|
1368
|
+
def test_tokenize_note_utf_8
|
1369
|
+
skip 'Encoding not implemented' unless @have_encoding
|
1370
|
+
|
1371
|
+
str = <<-STR
|
1372
|
+
cät:: l1a
|
1373
|
+
l1b
|
1374
|
+
døg:: l2a
|
1375
|
+
l2b
|
1376
|
+
STR
|
1377
|
+
|
1378
|
+
expected = [
|
1379
|
+
[:NOTE, 'cät', 0, 0],
|
1380
|
+
[:TEXT, 'l1a', 6, 0],
|
1381
|
+
[:NEWLINE, "\n", 9, 0],
|
1382
|
+
[:TEXT, 'l1b', 6, 1],
|
1383
|
+
[:NEWLINE, "\n", 9, 1],
|
1384
|
+
[:NOTE, 'døg', 0, 2],
|
1385
|
+
[:TEXT, 'l2a', 6, 2],
|
1386
|
+
[:NEWLINE, "\n", 9, 2],
|
1387
|
+
[:TEXT, 'l2b', 6, 3],
|
1388
|
+
[:NEWLINE, "\n", 9, 3],
|
1389
|
+
]
|
1390
|
+
|
1391
|
+
assert_equal expected, @RMP.tokenize(str)
|
1392
|
+
end
|
1393
|
+
|
1344
1394
|
def test_tokenize_note_newline_windows
|
1345
1395
|
str = <<-STR
|
1346
1396
|
cat::\r
|
@@ -1576,6 +1626,19 @@ Example heading:
|
|
1576
1626
|
assert_equal expected, @RMP.tokenize(str)
|
1577
1627
|
end
|
1578
1628
|
|
1629
|
+
def test_token_pos
|
1630
|
+
parser = @RMP.new
|
1631
|
+
s = parser.setup_scanner 'cät'
|
1632
|
+
|
1633
|
+
s.scan(/\S+/)
|
1634
|
+
|
1635
|
+
if @have_encoding or @have_byteslice then
|
1636
|
+
assert_equal [3, 0], parser.token_pos(s.pos)
|
1637
|
+
else
|
1638
|
+
assert_equal [4, 0], parser.token_pos(s.pos)
|
1639
|
+
end
|
1640
|
+
end
|
1641
|
+
|
1579
1642
|
# HACK move to Verbatim test case
|
1580
1643
|
def test_verbatim_normalize
|
1581
1644
|
v = @RM::Verbatim.new "foo\n", "\n", "\n", "bar\n"
|