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.

Files changed (200) hide show
  1. checksums.yaml +6 -6
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.autotest +3 -2
  5. data/DEVELOPERS.rdoc +53 -0
  6. data/History.rdoc +159 -25
  7. data/LEGAL.rdoc +12 -0
  8. data/Manifest.txt +56 -3
  9. data/README.rdoc +87 -19
  10. data/Rakefile +11 -2
  11. data/TODO.rdoc +20 -13
  12. data/bin/rdoc +4 -0
  13. data/lib/gauntlet_rdoc.rb +1 -1
  14. data/lib/rdoc.rb +32 -71
  15. data/lib/rdoc/any_method.rb +75 -21
  16. data/lib/rdoc/attr.rb +49 -10
  17. data/lib/rdoc/class_module.rb +182 -32
  18. data/lib/rdoc/code_object.rb +54 -12
  19. data/lib/rdoc/comment.rb +8 -1
  20. data/lib/rdoc/constant.rb +100 -6
  21. data/lib/rdoc/context.rb +93 -41
  22. data/lib/rdoc/context/section.rb +143 -28
  23. data/lib/rdoc/cross_reference.rb +58 -50
  24. data/lib/rdoc/encoding.rb +34 -29
  25. data/lib/rdoc/erb_partial.rb +18 -0
  26. data/lib/rdoc/extend.rb +117 -0
  27. data/lib/rdoc/generator.rb +11 -6
  28. data/lib/rdoc/generator/darkfish.rb +250 -62
  29. data/lib/rdoc/generator/json_index.rb +20 -12
  30. data/lib/rdoc/generator/markup.rb +10 -12
  31. data/lib/rdoc/generator/ri.rb +7 -60
  32. data/lib/rdoc/generator/template/darkfish/_head.rhtml +7 -7
  33. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +16 -0
  34. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +1 -1
  35. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +14 -0
  36. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +1 -1
  37. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +13 -0
  38. data/lib/rdoc/generator/template/darkfish/class.rhtml +15 -1
  39. data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  40. data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -3
  41. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +7 -9
  42. data/lib/rdoc/generator/template/darkfish/page.rhtml +2 -0
  43. data/lib/rdoc/generator/template/darkfish/rdoc.css +31 -0
  44. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
  45. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +37 -0
  46. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
  47. data/lib/rdoc/include.rb +12 -3
  48. data/lib/rdoc/markdown.kpeg +1186 -0
  49. data/lib/rdoc/markdown.rb +16336 -0
  50. data/lib/rdoc/markdown/entities.rb +2128 -0
  51. data/lib/rdoc/markdown/literals_1_8.kpeg +18 -0
  52. data/lib/rdoc/markdown/literals_1_8.rb +454 -0
  53. data/lib/rdoc/markdown/literals_1_9.kpeg +22 -0
  54. data/lib/rdoc/markdown/literals_1_9.rb +417 -0
  55. data/lib/rdoc/markup.rb +69 -10
  56. data/lib/rdoc/markup/attr_changer.rb +2 -5
  57. data/lib/rdoc/markup/attribute_manager.rb +23 -14
  58. data/lib/rdoc/markup/attributes.rb +70 -0
  59. data/lib/rdoc/markup/block_quote.rb +14 -0
  60. data/lib/rdoc/markup/document.rb +20 -4
  61. data/lib/rdoc/markup/formatter.rb +17 -6
  62. data/lib/rdoc/markup/formatter_test_case.rb +93 -24
  63. data/lib/rdoc/markup/hard_break.rb +31 -0
  64. data/lib/rdoc/markup/heading.rb +1 -1
  65. data/lib/rdoc/markup/indented_paragraph.rb +14 -0
  66. data/lib/rdoc/markup/list.rb +23 -4
  67. data/lib/rdoc/markup/list_item.rb +17 -4
  68. data/lib/rdoc/markup/paragraph.rb +14 -0
  69. data/lib/rdoc/markup/parser.rb +107 -60
  70. data/lib/rdoc/markup/raw.rb +4 -4
  71. data/lib/rdoc/markup/special.rb +3 -3
  72. data/lib/rdoc/markup/to_ansi.rb +7 -1
  73. data/lib/rdoc/markup/to_html.rb +42 -14
  74. data/lib/rdoc/markup/to_html_crossref.rb +10 -9
  75. data/lib/rdoc/markup/to_html_snippet.rb +20 -4
  76. data/lib/rdoc/markup/to_joined_paragraph.rb +68 -0
  77. data/lib/rdoc/markup/to_label.rb +20 -1
  78. data/lib/rdoc/markup/to_markdown.rb +134 -0
  79. data/lib/rdoc/markup/to_rdoc.rb +36 -5
  80. data/lib/rdoc/markup/to_table_of_contents.rb +6 -1
  81. data/lib/rdoc/markup/to_tt_only.rb +11 -2
  82. data/lib/rdoc/markup/verbatim.rb +19 -0
  83. data/lib/rdoc/method_attr.rb +33 -19
  84. data/lib/rdoc/normal_class.rb +26 -7
  85. data/lib/rdoc/normal_module.rb +10 -5
  86. data/lib/rdoc/options.rb +95 -21
  87. data/lib/rdoc/parser.rb +6 -2
  88. data/lib/rdoc/parser/c.rb +212 -97
  89. data/lib/rdoc/parser/markdown.rb +23 -0
  90. data/lib/rdoc/parser/ruby.rb +115 -35
  91. data/lib/rdoc/parser/ruby_tools.rb +8 -3
  92. data/lib/rdoc/rd.rb +8 -4
  93. data/lib/rdoc/rd/block_parser.rb +1 -1
  94. data/lib/rdoc/rd/block_parser.ry +1 -1
  95. data/lib/rdoc/rdoc.rb +45 -21
  96. data/lib/rdoc/ri/driver.rb +322 -76
  97. data/lib/rdoc/ri/paths.rb +90 -31
  98. data/lib/rdoc/ri/store.rb +2 -353
  99. data/lib/rdoc/ruby_lex.rb +5 -21
  100. data/lib/rdoc/ruby_token.rb +2 -3
  101. data/lib/rdoc/rubygems_hook.rb +21 -9
  102. data/lib/rdoc/servlet.rb +302 -0
  103. data/lib/rdoc/stats.rb +28 -20
  104. data/lib/rdoc/store.rb +881 -0
  105. data/lib/rdoc/task.rb +2 -1
  106. data/lib/rdoc/test_case.rb +103 -1
  107. data/lib/rdoc/text.rb +5 -4
  108. data/lib/rdoc/tom_doc.rb +17 -16
  109. data/lib/rdoc/top_level.rb +43 -285
  110. data/test/MarkdownTest_1.0.3/Amps and angle encoding.text +21 -0
  111. data/test/MarkdownTest_1.0.3/Auto links.text +13 -0
  112. data/test/MarkdownTest_1.0.3/Backslash escapes.text +120 -0
  113. data/test/MarkdownTest_1.0.3/Blockquotes with code blocks.text +11 -0
  114. data/test/MarkdownTest_1.0.3/Code Blocks.text +14 -0
  115. data/test/MarkdownTest_1.0.3/Code Spans.text +6 -0
  116. data/test/MarkdownTest_1.0.3/Hard-wrapped paragraphs with list-like lines.text +8 -0
  117. data/test/MarkdownTest_1.0.3/Horizontal rules.text +67 -0
  118. data/test/MarkdownTest_1.0.3/Inline HTML (Advanced).text +15 -0
  119. data/test/MarkdownTest_1.0.3/Inline HTML (Simple).text +69 -0
  120. data/test/MarkdownTest_1.0.3/Inline HTML comments.text +13 -0
  121. data/test/MarkdownTest_1.0.3/Links, inline style.text +12 -0
  122. data/test/MarkdownTest_1.0.3/Links, reference style.text +71 -0
  123. data/test/MarkdownTest_1.0.3/Links, shortcut references.text +20 -0
  124. data/test/MarkdownTest_1.0.3/Literal quotes in titles.text +7 -0
  125. data/test/MarkdownTest_1.0.3/Markdown Documentation - Basics.text +306 -0
  126. data/test/MarkdownTest_1.0.3/Markdown Documentation - Syntax.text +888 -0
  127. data/test/MarkdownTest_1.0.3/Nested blockquotes.text +5 -0
  128. data/test/MarkdownTest_1.0.3/Ordered and unordered lists.text +131 -0
  129. data/test/MarkdownTest_1.0.3/Strong and em together.text +7 -0
  130. data/test/MarkdownTest_1.0.3/Tabs.text +21 -0
  131. data/test/MarkdownTest_1.0.3/Tidyness.text +5 -0
  132. data/test/test_attribute_manager.rb +7 -4
  133. data/test/test_rdoc_any_method.rb +84 -13
  134. data/test/test_rdoc_attr.rb +59 -9
  135. data/test/test_rdoc_class_module.rb +670 -73
  136. data/test/test_rdoc_code_object.rb +21 -1
  137. data/test/test_rdoc_comment.rb +1 -1
  138. data/test/test_rdoc_constant.rb +132 -0
  139. data/test/test_rdoc_context.rb +84 -18
  140. data/test/test_rdoc_context_section.rb +99 -15
  141. data/test/test_rdoc_cross_reference.rb +1 -1
  142. data/test/test_rdoc_encoding.rb +17 -1
  143. data/test/test_rdoc_extend.rb +94 -0
  144. data/test/test_rdoc_generator_darkfish.rb +45 -19
  145. data/test/test_rdoc_generator_json_index.rb +27 -7
  146. data/test/test_rdoc_generator_markup.rb +3 -3
  147. data/test/test_rdoc_generator_ri.rb +11 -9
  148. data/test/test_rdoc_include.rb +12 -0
  149. data/test/test_rdoc_markdown.rb +977 -0
  150. data/test/test_rdoc_markdown_test.rb +1891 -0
  151. data/test/test_rdoc_markup.rb +1 -1
  152. data/test/test_rdoc_markup_attribute_manager.rb +2 -2
  153. data/test/test_rdoc_markup_attributes.rb +39 -0
  154. data/test/test_rdoc_markup_document.rb +16 -1
  155. data/test/test_rdoc_markup_formatter.rb +7 -4
  156. data/test/test_rdoc_markup_hard_break.rb +31 -0
  157. data/test/test_rdoc_markup_indented_paragraph.rb +14 -0
  158. data/test/test_rdoc_markup_paragraph.rb +15 -1
  159. data/test/test_rdoc_markup_parser.rb +152 -89
  160. data/test/test_rdoc_markup_to_ansi.rb +23 -2
  161. data/test/test_rdoc_markup_to_bs.rb +24 -0
  162. data/test/test_rdoc_markup_to_html.rb +50 -19
  163. data/test/test_rdoc_markup_to_html_crossref.rb +23 -5
  164. data/test/test_rdoc_markup_to_html_snippet.rb +49 -8
  165. data/test/test_rdoc_markup_to_joined_paragraph.rb +32 -0
  166. data/test/test_rdoc_markup_to_label.rb +63 -1
  167. data/test/test_rdoc_markup_to_markdown.rb +352 -0
  168. data/test/test_rdoc_markup_to_rdoc.rb +22 -2
  169. data/test/test_rdoc_markup_to_table_of_contents.rb +44 -39
  170. data/test/test_rdoc_markup_to_tt_only.rb +20 -0
  171. data/test/test_rdoc_markup_verbatim.rb +13 -0
  172. data/test/test_rdoc_method_attr.rb +5 -0
  173. data/test/test_rdoc_normal_class.rb +24 -5
  174. data/test/test_rdoc_normal_module.rb +1 -1
  175. data/test/test_rdoc_options.rb +21 -6
  176. data/test/test_rdoc_parser.rb +24 -0
  177. data/test/test_rdoc_parser_c.rb +151 -26
  178. data/test/test_rdoc_parser_markdown.rb +55 -0
  179. data/test/test_rdoc_parser_rd.rb +2 -2
  180. data/test/test_rdoc_parser_ruby.rb +468 -109
  181. data/test/test_rdoc_parser_simple.rb +2 -2
  182. data/test/test_rdoc_rd_block_parser.rb +0 -4
  183. data/test/test_rdoc_rdoc.rb +110 -22
  184. data/test/test_rdoc_ri_driver.rb +415 -80
  185. data/test/test_rdoc_ri_paths.rb +122 -13
  186. data/test/test_rdoc_ruby_lex.rb +5 -61
  187. data/test/test_rdoc_ruby_token.rb +19 -0
  188. data/test/test_rdoc_rubygems_hook.rb +64 -43
  189. data/test/test_rdoc_servlet.rb +429 -0
  190. data/test/test_rdoc_stats.rb +83 -24
  191. data/test/{test_rdoc_ri_store.rb → test_rdoc_store.rb} +395 -22
  192. data/test/test_rdoc_task.rb +2 -2
  193. data/test/test_rdoc_text.rb +37 -11
  194. data/test/test_rdoc_tom_doc.rb +59 -62
  195. data/test/test_rdoc_top_level.rb +71 -113
  196. data/test/xref_test_case.rb +7 -9
  197. metadata +122 -39
  198. metadata.gz.sig +0 -0
  199. data/CVE-2013-0256.rdoc +0 -49
  200. data/lib/rdoc/markup/attribute.rb +0 -51
@@ -48,7 +48,7 @@ the time
48
48
  m = RDoc::Markup.new
49
49
  m.add_word_pair '{', '}', :STRIKE
50
50
 
51
- tt = RDoc::Markup::ToTest.new m
51
+ tt = RDoc::Markup::ToTest.new nil, m
52
52
  tt.add_tag :STRIKE, 'STRIKE ', ' STRIKE'
53
53
 
54
54
  out = m.convert str, tt
@@ -29,8 +29,8 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
29
29
  end
30
30
 
31
31
  def crossref(text)
32
- crossref_bitmap = RDoc::Markup::Attribute.bitmap_for(:_SPECIAL_) |
33
- RDoc::Markup::Attribute.bitmap_for(:CROSSREF)
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 = RDoc::TopLevel.new 'file.rb'
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 = @RM::Attribute.bitmap_for :CAPS
44
- @special = @RM::Attribute.bitmap_for :_SPECIAL_
45
- @tt = @RM::Attribute.bitmap_for :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
- assert_equal paragraph, visitor.obj
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 defined? Encoding
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
- @RM::List.new(:BULLET, *[
150
- @RM::ListItem.new(nil,
151
- @RM::Paragraph.new('l1', 'l1+')),
152
- @RM::ListItem.new(nil,
153
- @RM::Paragraph.new('l2')),
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
- @RM::List.new(:BULLET, *[
193
- @RM::ListItem.new(nil,
194
- @RM::Paragraph.new('l1'),
195
- @RM::List.new(:BULLET, *[
196
- @RM::ListItem.new(nil,
197
- @RM::Paragraph.new('l1.1', 'text'),
198
- @RM::Verbatim.new("code\n", " code\n"),
199
- @RM::Paragraph.new('text'))])),
200
- @RM::ListItem.new(nil,
201
- @RM::Paragraph.new('l2'))])]
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
- @RM::List.new(:LABEL, *[
328
- @RM::ListItem.new('one',
329
- @RM::Paragraph.new('item one')),
330
- @RM::ListItem.new('two',
331
- @RM::Paragraph.new('item two'))])]
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
- @RM::List.new(:LABEL, *[
345
- @RM::ListItem.new('cat',
346
- @RM::Paragraph.new('l1'),
347
- @RM::List.new(:BULLET, *[
348
- @RM::ListItem.new(nil,
349
- @RM::Paragraph.new('l1.1'))])),
350
- @RM::ListItem.new('dog',
351
- @RM::Paragraph.new('l2'))])]
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 test_parse_label_multiline
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
- @RM::List.new(:LABEL, *[
365
- @RM::ListItem.new('cat',
366
- @RM::Paragraph.new('l1', 'continuation')),
367
- @RM::ListItem.new('dog',
368
- @RM::Paragraph.new('l2'))])]
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
- @RM::List.new(:LABEL, *[
383
- @RM::ListItem.new('one',
384
- @RM::Paragraph.new('item one')),
385
- @RM::ListItem.new('two',
386
- @RM::Paragraph.new('item two')),
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
- @RM::Paragraph.new('now is', 'the time'),
449
- @RM::BlankLine.new,
450
- @RM::Paragraph.new('for all')]
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
- @RM::List.new(:NUMBER, *[
469
- @RM::ListItem.new(nil, *[
470
- @RM::Paragraph.new('para 1'),
471
- @RM::BlankLine.new,
472
- @RM::List.new(:LABEL, *[
473
- @RM::ListItem.new('label 1', *[
474
- @RM::Paragraph.new('para 1.1'),
475
- @RM::BlankLine.new,
476
- @RM::Verbatim.new("code\n"),
477
- @RM::Paragraph.new('para 1.2')])])])])]
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
- @RM::List.new(:NUMBER, *[
492
- @RM::ListItem.new(nil, *[
493
- @RM::Paragraph.new('para'),
494
- @RM::BlankLine.new,
495
- @RM::List.new(:NOTE, *[
496
- @RM::ListItem.new('label 1',
497
- @RM::Paragraph.new('text 1')),
498
- @RM::ListItem.new('label 2',
499
- @RM::Paragraph.new('text 2'))])])])]
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
- @RM::List.new(:NOTE, *[
559
- @RM::ListItem.new('one',
560
- @RM::Paragraph.new('item one')),
561
- @RM::ListItem.new('two',
562
- @RM::Paragraph.new('item two'))])]
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
- @RM::List.new(:NOTE, *[
575
- @RM::ListItem.new('one',
576
- @RM::BlankLine.new),
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
- @RM::List.new(:NOTE, *[
590
- @RM::ListItem.new('one',
591
- @RM::List.new(:NOTE, *[
592
- @RM::ListItem.new('two',
593
- @RM::BlankLine.new)]))])]
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
- @RM::List.new(:NUMBER, *[
607
- @RM::ListItem.new(nil,
608
- @RM::Paragraph.new('l1'),
609
- @RM::List.new(:BULLET, *[
610
- @RM::ListItem.new(nil,
611
- @RM::Paragraph.new('l1.1'))])),
612
- @RM::ListItem.new(nil,
613
- @RM::Paragraph.new('l2'))])]
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"