rdoc 3.9.5 → 3.10.pre.1

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 (183) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +6 -3
  3. data/History.txt +63 -13
  4. data/LICENSE.rdoc +57 -0
  5. data/Manifest.txt +60 -6
  6. data/Rakefile +24 -12
  7. data/TODO.rdoc +30 -0
  8. data/bin/rdoc +0 -2
  9. data/lib/rdoc.rb +55 -2
  10. data/lib/rdoc/alias.rb +0 -2
  11. data/lib/rdoc/anon_class.rb +0 -2
  12. data/lib/rdoc/any_method.rb +0 -3
  13. data/lib/rdoc/attr.rb +0 -2
  14. data/lib/rdoc/class_module.rb +40 -7
  15. data/lib/rdoc/code_object.rb +1 -3
  16. data/lib/rdoc/code_objects.rb +3 -21
  17. data/lib/rdoc/comment.rb +225 -0
  18. data/lib/rdoc/constant.rb +0 -2
  19. data/lib/rdoc/context.rb +37 -120
  20. data/lib/rdoc/context/section.rb +114 -0
  21. data/lib/rdoc/cross_reference.rb +16 -7
  22. data/lib/rdoc/encoding.rb +0 -2
  23. data/lib/rdoc/gauntlet.rb +1 -1
  24. data/lib/rdoc/generator.rb +7 -2
  25. data/lib/rdoc/generator/darkfish.rb +126 -20
  26. data/lib/rdoc/generator/json_index.rb +240 -0
  27. data/lib/rdoc/generator/markup.rb +17 -54
  28. data/lib/rdoc/generator/ri.rb +0 -3
  29. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
  30. data/lib/rdoc/generator/template/darkfish/_head.rhtml +16 -0
  31. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +18 -0
  32. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
  33. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +8 -0
  34. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +16 -0
  35. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
  36. data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +7 -0
  37. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
  38. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +10 -0
  39. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +10 -0
  40. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +10 -0
  41. data/lib/rdoc/generator/template/darkfish/class.rhtml +161 -0
  42. data/lib/rdoc/generator/template/darkfish/fileinfo.rhtml +32 -0
  43. data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  44. data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  45. data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  46. data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
  47. data/lib/rdoc/generator/template/darkfish/index.rhtml +16 -61
  48. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +99 -64
  49. data/lib/rdoc/generator/template/darkfish/js/jquery.js +15 -29
  50. data/lib/rdoc/generator/template/darkfish/js/search.js +94 -0
  51. data/lib/rdoc/generator/template/darkfish/page.rhtml +16 -0
  52. data/lib/rdoc/generator/template/darkfish/rdoc.css +126 -286
  53. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +50 -0
  54. data/lib/rdoc/generator/template/json_index/js/navigation.js +142 -0
  55. data/lib/rdoc/generator/template/json_index/js/searcher.js +228 -0
  56. data/lib/rdoc/ghost_method.rb +0 -2
  57. data/lib/rdoc/include.rb +0 -2
  58. data/lib/rdoc/markup.rb +204 -43
  59. data/lib/rdoc/markup/attr_changer.rb +25 -0
  60. data/lib/rdoc/markup/attr_span.rb +29 -0
  61. data/lib/rdoc/markup/attribute.rb +51 -0
  62. data/lib/rdoc/markup/document.rb +22 -1
  63. data/lib/rdoc/markup/formatter.rb +4 -11
  64. data/lib/rdoc/markup/formatter_test_case.rb +1 -2
  65. data/lib/rdoc/markup/heading.rb +44 -0
  66. data/lib/rdoc/markup/include.rb +42 -0
  67. data/lib/rdoc/markup/inline.rb +1 -144
  68. data/lib/rdoc/markup/list.rb +2 -1
  69. data/lib/rdoc/markup/parser.rb +6 -16
  70. data/lib/rdoc/markup/pre_process.rb +64 -10
  71. data/lib/rdoc/markup/raw.rb +1 -1
  72. data/lib/rdoc/markup/special.rb +40 -0
  73. data/lib/rdoc/markup/text_formatter_test_case.rb +0 -2
  74. data/lib/rdoc/markup/to_ansi.rb +0 -2
  75. data/lib/rdoc/markup/to_bs.rb +0 -2
  76. data/lib/rdoc/markup/to_html.rb +102 -34
  77. data/lib/rdoc/markup/to_html_crossref.rb +36 -5
  78. data/lib/rdoc/markup/to_html_snippet.rb +270 -0
  79. data/lib/rdoc/markup/to_label.rb +55 -0
  80. data/lib/rdoc/markup/to_rdoc.rb +0 -3
  81. data/lib/rdoc/markup/to_table_of_contents.rb +62 -0
  82. data/lib/rdoc/markup/to_test.rb +0 -3
  83. data/lib/rdoc/markup/to_tt_only.rb +0 -3
  84. data/lib/rdoc/markup/verbatim.rb +18 -0
  85. data/lib/rdoc/meta_method.rb +0 -2
  86. data/lib/rdoc/method_attr.rb +17 -1
  87. data/lib/rdoc/normal_class.rb +0 -2
  88. data/lib/rdoc/normal_module.rb +0 -2
  89. data/lib/rdoc/options.rb +18 -3
  90. data/lib/rdoc/parser.rb +74 -42
  91. data/lib/rdoc/parser/c.rb +79 -118
  92. data/lib/rdoc/parser/rd.rb +22 -0
  93. data/lib/rdoc/parser/ruby.rb +86 -54
  94. data/lib/rdoc/parser/simple.rb +21 -9
  95. data/lib/rdoc/parser/text.rb +11 -0
  96. data/lib/rdoc/rd.rb +95 -0
  97. data/lib/rdoc/rd/block_parser.ry +638 -0
  98. data/lib/rdoc/rd/inline.rb +71 -0
  99. data/lib/rdoc/rd/inline_parser.ry +575 -0
  100. data/lib/rdoc/rdoc.rb +8 -23
  101. data/lib/rdoc/require.rb +0 -2
  102. data/lib/rdoc/ri.rb +4 -2
  103. data/lib/rdoc/ri/driver.rb +2 -6
  104. data/lib/rdoc/ri/store.rb +0 -1
  105. data/lib/rdoc/ruby_lex.rb +43 -20
  106. data/lib/rdoc/ruby_token.rb +44 -2
  107. data/lib/rdoc/single_class.rb +0 -2
  108. data/lib/rdoc/stats.rb +0 -5
  109. data/lib/rdoc/task.rb +2 -6
  110. data/lib/rdoc/test_case.rb +59 -0
  111. data/lib/rdoc/text.rb +42 -30
  112. data/lib/rdoc/token_stream.rb +45 -0
  113. data/lib/rdoc/tom_doc.rb +232 -0
  114. data/lib/rdoc/top_level.rb +36 -4
  115. data/test/test_attribute_manager.rb +26 -29
  116. data/test/test_rdoc_any_method.rb +2 -26
  117. data/test/test_rdoc_attr.rb +4 -4
  118. data/test/test_rdoc_class_module.rb +95 -12
  119. data/test/test_rdoc_code_object.rb +10 -3
  120. data/test/test_rdoc_comment.rb +504 -0
  121. data/test/test_rdoc_context.rb +60 -11
  122. data/test/test_rdoc_context_section.rb +16 -17
  123. data/test/test_rdoc_cross_reference.rb +17 -2
  124. data/test/test_rdoc_encoding.rb +4 -7
  125. data/test/test_rdoc_generator_darkfish.rb +12 -11
  126. data/test/test_rdoc_generator_json_index.rb +255 -0
  127. data/test/test_rdoc_generator_markup.rb +56 -0
  128. data/test/test_rdoc_generator_ri.rb +8 -11
  129. data/test/test_rdoc_markup.rb +9 -5
  130. data/test/test_rdoc_markup_attribute_manager.rb +5 -8
  131. data/test/test_rdoc_markup_document.rb +34 -6
  132. data/test/test_rdoc_markup_formatter.rb +11 -13
  133. data/test/test_rdoc_markup_heading.rb +20 -0
  134. data/test/test_rdoc_markup_include.rb +19 -0
  135. data/test/test_rdoc_markup_indented_paragraph.rb +4 -5
  136. data/test/test_rdoc_markup_paragraph.rb +2 -5
  137. data/test/test_rdoc_markup_parser.rb +87 -7
  138. data/test/test_rdoc_markup_pre_process.rb +60 -9
  139. data/test/test_rdoc_markup_raw.rb +4 -6
  140. data/test/test_rdoc_markup_to_ansi.rb +1 -4
  141. data/test/test_rdoc_markup_to_bs.rb +1 -4
  142. data/test/test_rdoc_markup_to_html.rb +170 -31
  143. data/test/test_rdoc_markup_to_html_crossref.rb +89 -11
  144. data/test/test_rdoc_markup_to_html_snippet.rb +668 -0
  145. data/test/test_rdoc_markup_to_label.rb +50 -0
  146. data/test/test_rdoc_markup_to_rdoc.rb +1 -4
  147. data/test/test_rdoc_markup_to_table_of_contents.rb +90 -0
  148. data/test/test_rdoc_markup_to_tt_only.rb +1 -4
  149. data/test/test_rdoc_markup_verbatim.rb +16 -0
  150. data/test/test_rdoc_method_attr.rb +16 -1
  151. data/test/test_rdoc_options.rb +17 -7
  152. data/test/test_rdoc_parser.rb +75 -6
  153. data/test/test_rdoc_parser_c.rb +56 -104
  154. data/test/test_rdoc_parser_rd.rb +52 -0
  155. data/test/test_rdoc_parser_ruby.rb +264 -323
  156. data/test/test_rdoc_parser_simple.rb +33 -17
  157. data/test/test_rdoc_rd.rb +30 -0
  158. data/test/test_rdoc_rd_block_parser.rb +527 -0
  159. data/test/test_rdoc_rd_inline.rb +63 -0
  160. data/test/test_rdoc_rd_inline_parser.rb +173 -0
  161. data/test/test_rdoc_rdoc.rb +7 -9
  162. data/test/test_rdoc_ri_driver.rb +10 -15
  163. data/test/test_rdoc_ri_paths.rb +6 -6
  164. data/test/test_rdoc_ri_store.rb +6 -13
  165. data/test/test_rdoc_ruby_lex.rb +53 -5
  166. data/test/test_rdoc_rubygems_hook.rb +2 -1
  167. data/test/test_rdoc_stats.rb +83 -103
  168. data/test/test_rdoc_task.rb +5 -4
  169. data/test/test_rdoc_text.rb +156 -11
  170. data/test/test_rdoc_token_stream.rb +42 -0
  171. data/test/test_rdoc_tom_doc.rb +458 -0
  172. data/test/test_rdoc_top_level.rb +49 -2
  173. data/test/xref_test_case.rb +4 -8
  174. metadata +217 -111
  175. metadata.gz.sig +0 -0
  176. checksums.yaml +0 -7
  177. checksums.yaml.gz.sig +0 -0
  178. data/CVE-2013-0256.rdoc +0 -49
  179. data/LICENSE.txt +0 -57
  180. data/lib/rdoc/generator/template/darkfish/classpage.rhtml +0 -321
  181. data/lib/rdoc/generator/template/darkfish/filepage.rhtml +0 -124
  182. data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +0 -114
  183. data/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +0 -10
@@ -0,0 +1,56 @@
1
+ require 'rdoc/test_case'
2
+
3
+ class TestRDocGeneratorMarkup < RDoc::TestCase
4
+
5
+ include RDoc::Text
6
+ include RDoc::Generator::Markup
7
+
8
+ def setup
9
+ super
10
+
11
+ @options = RDoc::Options.new
12
+ @rdoc = RDoc::RDoc.new
13
+ @rdoc.options = @options
14
+ @parent = self
15
+ @path = '/index.html'
16
+ @symbols = {}
17
+
18
+ RDoc::RDoc.current = @rdoc
19
+ end
20
+
21
+ def test_aref_to
22
+ assert_equal 'Foo/Bar.html', aref_to('Foo/Bar.html')
23
+ end
24
+
25
+ def test_as_href
26
+ assert_equal '../index.html', as_href('Foo/Bar.html')
27
+ end
28
+
29
+ def test_cvs_url
30
+ assert_equal 'http://example/this_page',
31
+ cvs_url('http://example/', 'this_page')
32
+
33
+ assert_equal 'http://example/?page=this_page&foo=bar',
34
+ cvs_url('http://example/?page=%s&foo=bar', 'this_page')
35
+ end
36
+
37
+ def test_description
38
+ @comment = '= Hello'
39
+
40
+ assert_equal "\n<h1 id=\"label-Hello\">Hello</h1>\n", description
41
+ end
42
+
43
+ def test_formatter
44
+ assert_kind_of RDoc::Markup::ToHtmlCrossref, formatter
45
+ refute formatter.show_hash
46
+ assert_same self, formatter.context
47
+ end
48
+
49
+ attr_reader :path
50
+
51
+ def find_symbol name
52
+ @symbols[name]
53
+ end
54
+
55
+ end
56
+
@@ -1,22 +1,15 @@
1
- require 'rubygems'
2
- require 'minitest/autorun'
3
- require 'rdoc/rdoc'
4
- require 'rdoc/generator/ri'
5
- require 'tmpdir'
6
- require 'fileutils'
1
+ require 'rdoc/test_case'
7
2
 
8
- class TestRDocGeneratorRI < MiniTest::Unit::TestCase
3
+ class TestRDocGeneratorRI < RDoc::TestCase
9
4
 
10
5
  def setup
6
+ super
7
+
11
8
  @options = RDoc::Options.new
12
9
  @options.encoding = Encoding::UTF_8 if Object.const_defined? :Encoding
13
10
 
14
- @pwd = Dir.pwd
15
- RDoc::TopLevel.reset
16
-
17
11
  @tmpdir = File.join Dir.tmpdir, "test_rdoc_generator_ri_#{$$}"
18
12
  FileUtils.mkdir_p @tmpdir
19
- Dir.chdir @tmpdir
20
13
 
21
14
  @g = RDoc::Generator::RI.new @options
22
15
 
@@ -35,9 +28,13 @@ class TestRDocGeneratorRI < MiniTest::Unit::TestCase
35
28
  @klass.add_method @meth
36
29
  @klass.add_method @meth_bang
37
30
  @klass.add_attribute @attr
31
+
32
+ Dir.chdir @tmpdir
38
33
  end
39
34
 
40
35
  def teardown
36
+ super
37
+
41
38
  Dir.chdir @pwd
42
39
  FileUtils.rm_rf @tmpdir
43
40
  end
@@ -1,9 +1,13 @@
1
- require 'rubygems'
2
- require 'minitest/autorun'
3
- require 'rdoc/markup'
4
- require 'rdoc/markup/to_test'
1
+ require 'rdoc/test_case'
5
2
 
6
- class TestRDocMarkup < MiniTest::Unit::TestCase
3
+ class TestRDocMarkup < RDoc::TestCase
4
+
5
+ def test_class_parse
6
+ expected = @RM::Document.new(
7
+ @RM::Paragraph.new('hello'))
8
+
9
+ assert_equal expected, RDoc::Markup.parse('hello')
10
+ end
7
11
 
8
12
  def test_convert
9
13
  str = <<-STR
@@ -1,13 +1,10 @@
1
- require 'rubygems'
2
- require 'minitest/autorun'
3
- require 'rdoc'
4
- require 'rdoc/markup'
5
- require 'rdoc/markup/inline'
6
- require 'rdoc/markup/to_html_crossref'
1
+ require 'rdoc/test_case'
7
2
 
8
- class TestRDocMarkupAttributeManager < MiniTest::Unit::TestCase
3
+ class TestRDocMarkupAttributeManager < RDoc::TestCase
9
4
 
10
5
  def setup
6
+ super
7
+
11
8
  @am = RDoc::Markup::AttributeManager.new
12
9
 
13
10
  @bold_on = @am.changed_attribute_by_name([], [:BOLD])
@@ -212,7 +209,7 @@ class TestRDocMarkupAttributeManager < MiniTest::Unit::TestCase
212
209
  end
213
210
 
214
211
  def test_special
215
- @am.add_special(RDoc::Markup::ToHtmlCrossref::CROSSREF_REGEXP, :CROSSREF)
212
+ @am.add_special(RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF)
216
213
 
217
214
  #
218
215
  # The apostrophes in "cats'" and "dogs'" suppress the flagging of these
@@ -1,12 +1,10 @@
1
- require 'pp'
2
- require 'rubygems'
3
- require 'minitest/autorun'
4
- require 'rdoc/markup'
1
+ require 'rdoc/test_case'
5
2
 
6
- class TestRDocMarkupDocument < MiniTest::Unit::TestCase
3
+ class TestRDocMarkupDocument < RDoc::TestCase
7
4
 
8
5
  def setup
9
- @RM = RDoc::Markup
6
+ super
7
+
10
8
  @d = @RM::Document.new
11
9
  end
12
10
 
@@ -82,6 +80,18 @@ class TestRDocMarkupDocument < MiniTest::Unit::TestCase
82
80
  assert_equal @d, d2
83
81
  end
84
82
 
83
+ def test_file_equals
84
+ @d.file = 'file.rb'
85
+
86
+ assert_equal 'file.rb', @d.file
87
+ end
88
+
89
+ def test_file_equals_top_level
90
+ @d.file = RDoc::TopLevel.new 'file.rb'
91
+
92
+ assert_equal 'file.rb', @d.file
93
+ end
94
+
85
95
  def test_lt2
86
96
  @d << @RM::BlankLine.new
87
97
 
@@ -148,5 +158,23 @@ class TestRDocMarkupDocument < MiniTest::Unit::TestCase
148
158
  refute_empty @d
149
159
  end
150
160
 
161
+ def test_table_of_contents
162
+ doc = @RM::Document.new(
163
+ @RM::Heading.new(1, 'A'),
164
+ @RM::Paragraph.new('B'),
165
+ @RM::Heading.new(2, 'C'),
166
+ @RM::Paragraph.new('D'),
167
+ @RM::Heading.new(1, 'E'),
168
+ @RM::Paragraph.new('F'))
169
+
170
+ expected = [
171
+ @RM::Heading.new(1, 'A'),
172
+ @RM::Heading.new(2, 'C'),
173
+ @RM::Heading.new(1, 'E'),
174
+ ]
175
+
176
+ assert_equal expected, doc.table_of_contents
177
+ end
178
+
151
179
  end
152
180
 
@@ -1,17 +1,13 @@
1
- require 'rubygems'
2
- require 'minitest/autorun'
3
- require 'rdoc'
4
- require 'rdoc/markup'
5
- require 'rdoc/markup/formatter'
1
+ require 'rdoc/test_case'
6
2
 
7
- class TestRDocMarkupFormatter < MiniTest::Unit::TestCase
3
+ class TestRDocMarkupFormatter < RDoc::TestCase
8
4
 
9
5
  class ToTest < RDoc::Markup::Formatter
10
6
 
11
7
  def initialize markup
12
8
  super
13
9
 
14
- add_tag :TT, '<tt>', '</tt>'
10
+ add_tag :TT, '<code>', '</code>'
15
11
  end
16
12
 
17
13
  def accept_paragraph paragraph
@@ -37,20 +33,22 @@ class TestRDocMarkupFormatter < MiniTest::Unit::TestCase
37
33
  end
38
34
 
39
35
  def setup
40
- @markup = RDoc::Markup.new
36
+ super
37
+
38
+ @markup = @RM.new
41
39
  @markup.add_special(/[A-Z]+/, :CAPS)
42
40
 
43
41
  @to = ToTest.new @markup
44
42
 
45
- @caps = RDoc::Markup::Attribute.bitmap_for :CAPS
46
- @special = RDoc::Markup::Attribute.bitmap_for :_SPECIAL_
47
- @tt = RDoc::Markup::Attribute.bitmap_for :TT
43
+ @caps = @RM::Attribute.bitmap_for :CAPS
44
+ @special = @RM::Attribute.bitmap_for :_SPECIAL_
45
+ @tt = @RM::Attribute.bitmap_for :TT
48
46
  end
49
47
 
50
48
  def test_convert_tt_special
51
- converted = @to.convert '<tt>AAA</tt>'
49
+ converted = @to.convert '<code>AAA</code>'
52
50
 
53
- assert_equal '<tt>AAA</tt>', converted
51
+ assert_equal '<code>AAA</code>', converted
54
52
  end
55
53
 
56
54
  end
@@ -0,0 +1,20 @@
1
+ require 'rdoc/test_case'
2
+
3
+ class TestRDocMarkupHeading < RDoc::TestCase
4
+
5
+ def setup
6
+ super
7
+
8
+ @h = RDoc::Markup::Heading.new 1, 'Hello *Friend*!'
9
+ end
10
+
11
+ def test_label
12
+ assert_equal 'label-Hello+Friend%21', @h.label
13
+ end
14
+
15
+ def test_plain_html
16
+ assert_equal 'Hello <strong>Friend</strong>!', @h.plain_html
17
+ end
18
+
19
+ end
20
+
@@ -0,0 +1,19 @@
1
+ require 'rdoc/test_case'
2
+
3
+ class TestRDocMarkupInclude < RDoc::TestCase
4
+
5
+ def setup
6
+ super
7
+
8
+ @include = @RM::Include.new 'file', [Dir.tmpdir]
9
+ end
10
+
11
+ def test_equals2
12
+ assert_equal @include, @RM::Include.new('file', [Dir.tmpdir])
13
+ refute_equal @include, @RM::Include.new('file', %w[.])
14
+ refute_equal @include, @RM::Include.new('other', [Dir.tmpdir])
15
+ refute_equal @include, Object.new
16
+ end
17
+
18
+ end
19
+
@@ -1,11 +1,10 @@
1
- require 'pp'
2
- require 'rubygems'
3
- require 'minitest/autorun'
4
- require 'rdoc/markup'
1
+ require 'rdoc/test_case'
5
2
 
6
- class TestRDocMarkupIndentedParagraph < MiniTest::Unit::TestCase
3
+ class TestRDocMarkupIndentedParagraph < RDoc::TestCase
7
4
 
8
5
  def setup
6
+ super
7
+
9
8
  @IP = RDoc::Markup::IndentedParagraph
10
9
  end
11
10
 
@@ -1,9 +1,6 @@
1
- require 'pp'
2
- require 'rubygems'
3
- require 'minitest/autorun'
4
- require 'rdoc/markup'
1
+ require 'rdoc/test_case'
5
2
 
6
- class TestRDocMarkupParagraph < MiniTest::Unit::TestCase
3
+ class TestRDocMarkupParagraph < RDoc::TestCase
7
4
 
8
5
  def test_accept
9
6
  visitor = Object.new
@@ -1,14 +1,12 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'pp'
4
- require 'rubygems'
5
- require 'minitest/autorun'
6
- require 'rdoc/markup'
3
+ require 'rdoc/test_case'
7
4
 
8
- class TestRDocMarkupParser < MiniTest::Unit::TestCase
5
+ class TestRDocMarkupParser < RDoc::TestCase
9
6
 
10
7
  def setup
11
- @RM = RDoc::Markup
8
+ super
9
+
12
10
  @RMP = @RM::Parser
13
11
  end
14
12
 
@@ -623,7 +621,7 @@ for all good men
623
621
  def test_parse_paragraph_multiline
624
622
  str = "now is the time\nfor all good men"
625
623
 
626
- expected = @RM::Paragraph.new 'now is the time for all good men'
624
+ expected = @RM::Paragraph.new 'now is the time', 'for all good men'
627
625
  assert_equal [expected], @RMP.parse(str).parts
628
626
  end
629
627
 
@@ -1185,6 +1183,38 @@ the time
1185
1183
  assert_equal expected, @RMP.tokenize(str)
1186
1184
  end
1187
1185
 
1186
+ def test_tokenize_label_newline
1187
+ str = <<-STR
1188
+ [cat]
1189
+ l1
1190
+ STR
1191
+
1192
+ expected = [
1193
+ [:LABEL, 'cat', 0, 0],
1194
+ [:NEWLINE, "\n", 5, 0],
1195
+ [:TEXT, 'l1', 2, 1],
1196
+ [:NEWLINE, "\n", 4, 1],
1197
+ ]
1198
+
1199
+ assert_equal expected, @RMP.tokenize(str)
1200
+ end
1201
+
1202
+ def test_tokenize_label_newline_windows
1203
+ str = <<-STR
1204
+ [cat]\r
1205
+ l1\r
1206
+ STR
1207
+
1208
+ expected = [
1209
+ [:LABEL, 'cat', 0, 0],
1210
+ [:NEWLINE, "\n", 6, 0],
1211
+ [:TEXT, 'l1', 2, 1],
1212
+ [:NEWLINE, "\n", 5, 1],
1213
+ ]
1214
+
1215
+ assert_equal expected, @RMP.tokenize(str)
1216
+ end
1217
+
1188
1218
  def test_tokenize_lalpha
1189
1219
  str = <<-STR
1190
1220
  a. l1
@@ -1237,6 +1267,38 @@ dog::
1237
1267
  assert_equal expected, @RMP.tokenize(str)
1238
1268
  end
1239
1269
 
1270
+ def test_tokenize_note_newline
1271
+ str = <<-STR
1272
+ cat::
1273
+ l1
1274
+ STR
1275
+
1276
+ expected = [
1277
+ [:NOTE, 'cat', 0, 0],
1278
+ [:NEWLINE, "\n", 5, 0],
1279
+ [:TEXT, 'l1', 2, 1],
1280
+ [:NEWLINE, "\n", 4, 1],
1281
+ ]
1282
+
1283
+ assert_equal expected, @RMP.tokenize(str)
1284
+ end
1285
+
1286
+ def test_tokenize_note_newline_windows
1287
+ str = <<-STR
1288
+ cat::\r
1289
+ l1\r
1290
+ STR
1291
+
1292
+ expected = [
1293
+ [:NOTE, 'cat', 0, 0],
1294
+ [:NEWLINE, "\n", 6, 0],
1295
+ [:TEXT, 'l1', 2, 1],
1296
+ [:NEWLINE, "\n", 5, 1],
1297
+ ]
1298
+
1299
+ assert_equal expected, @RMP.tokenize(str)
1300
+ end
1301
+
1240
1302
  def test_tokenize_note_not
1241
1303
  str = <<-STR
1242
1304
  Cat::Dog
@@ -1363,6 +1425,24 @@ for all
1363
1425
  assert_equal expected, @RMP.tokenize(str)
1364
1426
  end
1365
1427
 
1428
+ def test_tokenize_rule_windows
1429
+ str = <<-STR
1430
+ ---\r
1431
+
1432
+ --- blah ---\r
1433
+ STR
1434
+
1435
+ expected = [
1436
+ [:RULE, 1, 0, 0],
1437
+ [:NEWLINE, "\n", 4, 0],
1438
+ [:NEWLINE, "\n", 0, 1],
1439
+ [:TEXT, "--- blah ---", 0, 2],
1440
+ [:NEWLINE, "\n", 13, 2],
1441
+ ]
1442
+
1443
+ assert_equal expected, @RMP.tokenize(str)
1444
+ end
1445
+
1366
1446
  def test_tokenize_ualpha
1367
1447
  str = <<-STR
1368
1448
  A. l1