rdoc 4.2.1 → 6.3.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 (277) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTING.rdoc +8 -7
  3. data/Gemfile +12 -0
  4. data/History.rdoc +48 -4
  5. data/LEGAL.rdoc +2 -2
  6. data/README.rdoc +5 -5
  7. data/Rakefile +73 -155
  8. data/bin/console +7 -0
  9. data/bin/setup +6 -0
  10. data/{bin → exe}/rdoc +0 -0
  11. data/{bin → exe}/ri +0 -0
  12. data/lib/rdoc/alias.rb +1 -0
  13. data/lib/rdoc/anon_class.rb +1 -0
  14. data/lib/rdoc/any_method.rb +59 -14
  15. data/lib/rdoc/attr.rb +1 -0
  16. data/lib/rdoc/class_module.rb +5 -2
  17. data/lib/rdoc/code_object.rb +3 -11
  18. data/lib/rdoc/code_objects.rb +1 -0
  19. data/lib/rdoc/comment.rb +32 -11
  20. data/lib/rdoc/constant.rb +3 -2
  21. data/lib/rdoc/context/section.rb +7 -13
  22. data/lib/rdoc/context.rb +78 -23
  23. data/lib/rdoc/cross_reference.rb +33 -14
  24. data/lib/rdoc/encoding.rb +92 -55
  25. data/lib/rdoc/erb_partial.rb +2 -1
  26. data/lib/rdoc/erbio.rb +8 -3
  27. data/lib/rdoc/extend.rb +1 -0
  28. data/lib/rdoc/generator/darkfish.rb +62 -32
  29. data/lib/rdoc/generator/json_index.rb +8 -5
  30. data/lib/rdoc/generator/markup.rb +3 -12
  31. data/lib/rdoc/generator/pot/message_extractor.rb +68 -0
  32. data/lib/rdoc/generator/pot/po.rb +84 -0
  33. data/lib/rdoc/generator/pot/po_entry.rb +141 -0
  34. data/lib/rdoc/generator/pot.rb +4 -3
  35. data/lib/rdoc/generator/ri.rb +1 -0
  36. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +2 -2
  37. data/lib/rdoc/generator/template/darkfish/_head.rhtml +11 -8
  38. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +2 -2
  39. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +2 -2
  40. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +7 -7
  41. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +2 -2
  42. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +7 -7
  43. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +6 -6
  44. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +5 -5
  45. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +5 -5
  46. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +5 -5
  47. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
  48. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +4 -4
  49. data/lib/rdoc/generator/template/darkfish/class.rhtml +45 -47
  50. data/lib/rdoc/generator/template/darkfish/css/fonts.css +6 -6
  51. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +55 -6
  52. data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -4
  53. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +23 -100
  54. data/lib/rdoc/generator/template/darkfish/js/search.js +32 -31
  55. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +15 -16
  56. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +16 -16
  57. data/lib/rdoc/generator/template/json_index/js/navigation.js +4 -41
  58. data/lib/rdoc/generator/template/json_index/js/searcher.js +7 -6
  59. data/lib/rdoc/generator.rb +1 -1
  60. data/lib/rdoc/ghost_method.rb +1 -0
  61. data/lib/rdoc/i18n/locale.rb +2 -1
  62. data/lib/rdoc/i18n/text.rb +5 -4
  63. data/lib/rdoc/i18n.rb +3 -2
  64. data/lib/rdoc/include.rb +1 -0
  65. data/lib/rdoc/known_classes.rb +1 -0
  66. data/lib/rdoc/markdown/entities.rb +1 -0
  67. data/lib/rdoc/markdown/{literals_1_9.kpeg → literals.kpeg} +1 -0
  68. data/lib/rdoc/markdown/{literals_1_9.rb → literals.rb} +1 -4
  69. data/lib/rdoc/markdown.kpeg +94 -51
  70. data/lib/rdoc/markdown.rb +1171 -619
  71. data/lib/rdoc/markup/attr_changer.rb +1 -0
  72. data/lib/rdoc/markup/attr_span.rb +9 -2
  73. data/lib/rdoc/markup/attribute_manager.rb +115 -49
  74. data/lib/rdoc/markup/attributes.rb +7 -6
  75. data/lib/rdoc/markup/blank_line.rb +1 -0
  76. data/lib/rdoc/markup/block_quote.rb +1 -0
  77. data/lib/rdoc/markup/document.rb +1 -0
  78. data/lib/rdoc/markup/formatter.rb +25 -23
  79. data/lib/rdoc/markup/hard_break.rb +1 -0
  80. data/lib/rdoc/markup/heading.rb +4 -3
  81. data/lib/rdoc/markup/include.rb +1 -0
  82. data/lib/rdoc/markup/indented_paragraph.rb +1 -0
  83. data/lib/rdoc/markup/list.rb +1 -0
  84. data/lib/rdoc/markup/list_item.rb +1 -0
  85. data/lib/rdoc/markup/paragraph.rb +1 -0
  86. data/lib/rdoc/markup/parser.rb +78 -61
  87. data/lib/rdoc/markup/pre_process.rb +12 -9
  88. data/lib/rdoc/markup/raw.rb +1 -0
  89. data/lib/rdoc/markup/regexp_handling.rb +41 -0
  90. data/lib/rdoc/markup/rule.rb +1 -0
  91. data/lib/rdoc/markup/to_ansi.rb +1 -0
  92. data/lib/rdoc/markup/to_bs.rb +4 -5
  93. data/lib/rdoc/markup/to_html.rb +71 -25
  94. data/lib/rdoc/markup/to_html_crossref.rb +41 -25
  95. data/lib/rdoc/markup/to_html_snippet.rb +10 -9
  96. data/lib/rdoc/markup/to_joined_paragraph.rb +7 -31
  97. data/lib/rdoc/markup/to_label.rb +10 -9
  98. data/lib/rdoc/markup/to_markdown.rb +9 -8
  99. data/lib/rdoc/markup/to_rdoc.rb +35 -6
  100. data/lib/rdoc/markup/to_table_of_contents.rb +2 -0
  101. data/lib/rdoc/markup/to_test.rb +1 -0
  102. data/lib/rdoc/markup/to_tt_only.rb +3 -2
  103. data/lib/rdoc/markup/verbatim.rb +1 -0
  104. data/lib/rdoc/markup.rb +14 -16
  105. data/lib/rdoc/meta_method.rb +1 -0
  106. data/lib/rdoc/method_attr.rb +2 -1
  107. data/lib/rdoc/mixin.rb +1 -0
  108. data/lib/rdoc/normal_class.rb +3 -2
  109. data/lib/rdoc/normal_module.rb +1 -0
  110. data/lib/rdoc/options.rb +92 -58
  111. data/lib/rdoc/parser/c.rb +219 -223
  112. data/lib/rdoc/parser/changelog.rb +155 -18
  113. data/lib/rdoc/parser/markdown.rb +1 -0
  114. data/lib/rdoc/parser/rd.rb +1 -0
  115. data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
  116. data/lib/rdoc/parser/ruby.rb +635 -468
  117. data/lib/rdoc/parser/ruby_tools.rb +33 -33
  118. data/lib/rdoc/parser/simple.rb +3 -3
  119. data/lib/rdoc/parser/text.rb +1 -0
  120. data/lib/rdoc/parser.rb +17 -50
  121. data/lib/rdoc/rd/block_parser.rb +66 -65
  122. data/lib/rdoc/rd/block_parser.ry +3 -3
  123. data/lib/rdoc/rd/inline.rb +5 -4
  124. data/lib/rdoc/rd/inline_parser.rb +52 -51
  125. data/lib/rdoc/rd/inline_parser.ry +1 -1
  126. data/lib/rdoc/rd.rb +1 -0
  127. data/lib/rdoc/rdoc.rb +68 -63
  128. data/lib/rdoc/require.rb +1 -0
  129. data/lib/rdoc/ri/driver.rb +133 -58
  130. data/lib/rdoc/ri/formatter.rb +1 -0
  131. data/lib/rdoc/ri/paths.rb +4 -20
  132. data/lib/rdoc/ri/store.rb +1 -0
  133. data/lib/rdoc/ri/task.rb +71 -0
  134. data/lib/rdoc/ri.rb +1 -0
  135. data/lib/rdoc/rubygems_hook.rb +5 -12
  136. data/lib/rdoc/servlet.rb +24 -14
  137. data/lib/rdoc/single_class.rb +1 -0
  138. data/lib/rdoc/stats/normal.rb +20 -21
  139. data/lib/rdoc/stats/quiet.rb +1 -0
  140. data/lib/rdoc/stats/verbose.rb +1 -0
  141. data/lib/rdoc/stats.rb +1 -0
  142. data/lib/rdoc/store.rb +41 -41
  143. data/lib/rdoc/task.rb +2 -3
  144. data/lib/rdoc/text.rb +19 -38
  145. data/lib/rdoc/token_stream.rb +56 -32
  146. data/lib/rdoc/tom_doc.rb +17 -11
  147. data/lib/rdoc/top_level.rb +9 -2
  148. data/lib/rdoc/version.rb +8 -0
  149. data/lib/rdoc.rb +24 -10
  150. data/man/ri.1 +247 -0
  151. data/rdoc.gemspec +248 -0
  152. metadata +43 -236
  153. data/.autotest +0 -24
  154. data/.document +0 -5
  155. data/Manifest.txt +0 -306
  156. data/lib/gauntlet_rdoc.rb +0 -84
  157. data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -4
  158. data/lib/rdoc/markdown/literals_1_8.kpeg +0 -18
  159. data/lib/rdoc/markdown/literals_1_8.rb +0 -416
  160. data/lib/rdoc/markup/formatter_test_case.rb +0 -767
  161. data/lib/rdoc/markup/inline.rb +0 -1
  162. data/lib/rdoc/markup/special.rb +0 -40
  163. data/lib/rdoc/markup/text_formatter_test_case.rb +0 -114
  164. data/lib/rdoc/ruby_lex.rb +0 -1377
  165. data/lib/rdoc/ruby_token.rb +0 -460
  166. data/lib/rdoc/test_case.rb +0 -217
  167. data/test/MarkdownTest_1.0.3/Amps and angle encoding.text +0 -21
  168. data/test/MarkdownTest_1.0.3/Auto links.text +0 -13
  169. data/test/MarkdownTest_1.0.3/Backslash escapes.text +0 -120
  170. data/test/MarkdownTest_1.0.3/Blockquotes with code blocks.text +0 -11
  171. data/test/MarkdownTest_1.0.3/Code Blocks.text +0 -14
  172. data/test/MarkdownTest_1.0.3/Code Spans.text +0 -6
  173. data/test/MarkdownTest_1.0.3/Hard-wrapped paragraphs with list-like lines.text +0 -8
  174. data/test/MarkdownTest_1.0.3/Horizontal rules.text +0 -67
  175. data/test/MarkdownTest_1.0.3/Inline HTML (Advanced).text +0 -15
  176. data/test/MarkdownTest_1.0.3/Inline HTML (Simple).text +0 -69
  177. data/test/MarkdownTest_1.0.3/Inline HTML comments.text +0 -13
  178. data/test/MarkdownTest_1.0.3/Links, inline style.text +0 -12
  179. data/test/MarkdownTest_1.0.3/Links, reference style.text +0 -71
  180. data/test/MarkdownTest_1.0.3/Links, shortcut references.text +0 -20
  181. data/test/MarkdownTest_1.0.3/Literal quotes in titles.text +0 -7
  182. data/test/MarkdownTest_1.0.3/Markdown Documentation - Basics.text +0 -306
  183. data/test/MarkdownTest_1.0.3/Markdown Documentation - Syntax.text +0 -888
  184. data/test/MarkdownTest_1.0.3/Nested blockquotes.text +0 -5
  185. data/test/MarkdownTest_1.0.3/Ordered and unordered lists.text +0 -131
  186. data/test/MarkdownTest_1.0.3/Strong and em together.text +0 -7
  187. data/test/MarkdownTest_1.0.3/Tabs.text +0 -21
  188. data/test/MarkdownTest_1.0.3/Tidyness.text +0 -5
  189. data/test/README +0 -1
  190. data/test/binary.dat +0 -0
  191. data/test/hidden.zip.txt +0 -1
  192. data/test/test.ja.largedoc +0 -3
  193. data/test/test.ja.rdoc +0 -10
  194. data/test/test.ja.txt +0 -8
  195. data/test/test.txt +0 -1
  196. data/test/test_rdoc_alias.rb +0 -13
  197. data/test/test_rdoc_any_method.rb +0 -460
  198. data/test/test_rdoc_attr.rb +0 -190
  199. data/test/test_rdoc_class_module.rb +0 -1492
  200. data/test/test_rdoc_code_object.rb +0 -450
  201. data/test/test_rdoc_comment.rb +0 -504
  202. data/test/test_rdoc_constant.rb +0 -181
  203. data/test/test_rdoc_context.rb +0 -901
  204. data/test/test_rdoc_context_section.rb +0 -130
  205. data/test/test_rdoc_cross_reference.rb +0 -192
  206. data/test/test_rdoc_encoding.rb +0 -227
  207. data/test/test_rdoc_extend.rb +0 -94
  208. data/test/test_rdoc_generator_darkfish.rb +0 -229
  209. data/test/test_rdoc_generator_json_index.rb +0 -324
  210. data/test/test_rdoc_generator_markup.rb +0 -59
  211. data/test/test_rdoc_generator_pot.rb +0 -91
  212. data/test/test_rdoc_generator_pot_po.rb +0 -51
  213. data/test/test_rdoc_generator_pot_po_entry.rb +0 -139
  214. data/test/test_rdoc_generator_ri.rb +0 -78
  215. data/test/test_rdoc_i18n_locale.rb +0 -73
  216. data/test/test_rdoc_i18n_text.rb +0 -123
  217. data/test/test_rdoc_include.rb +0 -108
  218. data/test/test_rdoc_markdown.rb +0 -980
  219. data/test/test_rdoc_markdown_test.rb +0 -1884
  220. data/test/test_rdoc_markup.rb +0 -95
  221. data/test/test_rdoc_markup_attribute_manager.rb +0 -364
  222. data/test/test_rdoc_markup_attributes.rb +0 -39
  223. data/test/test_rdoc_markup_document.rb +0 -207
  224. data/test/test_rdoc_markup_formatter.rb +0 -175
  225. data/test/test_rdoc_markup_hard_break.rb +0 -31
  226. data/test/test_rdoc_markup_heading.rb +0 -29
  227. data/test/test_rdoc_markup_include.rb +0 -19
  228. data/test/test_rdoc_markup_indented_paragraph.rb +0 -53
  229. data/test/test_rdoc_markup_paragraph.rb +0 -32
  230. data/test/test_rdoc_markup_parser.rb +0 -1680
  231. data/test/test_rdoc_markup_pre_process.rb +0 -473
  232. data/test/test_rdoc_markup_raw.rb +0 -22
  233. data/test/test_rdoc_markup_to_ansi.rb +0 -369
  234. data/test/test_rdoc_markup_to_bs.rb +0 -366
  235. data/test/test_rdoc_markup_to_html.rb +0 -662
  236. data/test/test_rdoc_markup_to_html_crossref.rb +0 -225
  237. data/test/test_rdoc_markup_to_html_snippet.rb +0 -711
  238. data/test/test_rdoc_markup_to_joined_paragraph.rb +0 -32
  239. data/test/test_rdoc_markup_to_label.rb +0 -112
  240. data/test/test_rdoc_markup_to_markdown.rb +0 -389
  241. data/test/test_rdoc_markup_to_rdoc.rb +0 -377
  242. data/test/test_rdoc_markup_to_table_of_contents.rb +0 -126
  243. data/test/test_rdoc_markup_to_tt_only.rb +0 -246
  244. data/test/test_rdoc_markup_verbatim.rb +0 -29
  245. data/test/test_rdoc_method_attr.rb +0 -193
  246. data/test/test_rdoc_normal_class.rb +0 -47
  247. data/test/test_rdoc_normal_module.rb +0 -42
  248. data/test/test_rdoc_options.rb +0 -766
  249. data/test/test_rdoc_parser.rb +0 -327
  250. data/test/test_rdoc_parser_c.rb +0 -1896
  251. data/test/test_rdoc_parser_changelog.rb +0 -315
  252. data/test/test_rdoc_parser_markdown.rb +0 -61
  253. data/test/test_rdoc_parser_rd.rb +0 -55
  254. data/test/test_rdoc_parser_ruby.rb +0 -3322
  255. data/test/test_rdoc_parser_simple.rb +0 -115
  256. data/test/test_rdoc_rd.rb +0 -30
  257. data/test/test_rdoc_rd_block_parser.rb +0 -535
  258. data/test/test_rdoc_rd_inline.rb +0 -63
  259. data/test/test_rdoc_rd_inline_parser.rb +0 -177
  260. data/test/test_rdoc_rdoc.rb +0 -455
  261. data/test/test_rdoc_require.rb +0 -25
  262. data/test/test_rdoc_ri_driver.rb +0 -1436
  263. data/test/test_rdoc_ri_paths.rb +0 -155
  264. data/test/test_rdoc_ruby_lex.rb +0 -421
  265. data/test/test_rdoc_ruby_token.rb +0 -19
  266. data/test/test_rdoc_rubygems_hook.rb +0 -251
  267. data/test/test_rdoc_servlet.rb +0 -534
  268. data/test/test_rdoc_single_class.rb +0 -20
  269. data/test/test_rdoc_stats.rb +0 -722
  270. data/test/test_rdoc_store.rb +0 -993
  271. data/test/test_rdoc_task.rb +0 -173
  272. data/test/test_rdoc_text.rb +0 -557
  273. data/test/test_rdoc_token_stream.rb +0 -42
  274. data/test/test_rdoc_tom_doc.rb +0 -520
  275. data/test/test_rdoc_top_level.rb +0 -287
  276. data/test/xref_data.rb +0 -76
  277. data/test/xref_test_case.rb +0 -67
@@ -1,980 +0,0 @@
1
- # coding: UTF-8
2
-
3
- require 'rdoc/test_case'
4
- require 'rdoc/markup/block_quote'
5
- require 'rdoc/markdown'
6
-
7
- class TestRDocMarkdown < RDoc::TestCase
8
-
9
- def setup
10
- @RM = RDoc::Markup
11
-
12
- @parser = RDoc::Markdown.new
13
-
14
- @to_html = RDoc::Markup::ToHtml.new(RDoc::Options.new, nil)
15
- end
16
-
17
- def test_class_parse
18
- doc = RDoc::Markdown.parse "hello\n\nworld"
19
-
20
- expected = doc(para("hello"), para("world"))
21
-
22
- assert_equal expected, doc
23
- end
24
-
25
- def test_emphasis
26
- assert_equal '_word_', @parser.emphasis('word')
27
- assert_equal '<em>two words</em>', @parser.emphasis('two words')
28
- assert_equal '<em>*bold*</em>', @parser.emphasis('*bold*')
29
- end
30
-
31
- def test_parse_auto_link_email
32
- doc = parse "Autolink: <nobody-0+_./!%~$@example>"
33
-
34
- expected = doc(para("Autolink: mailto:nobody-0+_./!%~$@example"))
35
-
36
- assert_equal expected, doc
37
- end
38
-
39
- def test_parse_auto_link_url
40
- doc = parse "Autolink: <http://example>"
41
-
42
- expected = doc(para("Autolink: http://example"))
43
-
44
- assert_equal expected, doc
45
- end
46
-
47
- def test_parse_block_quote
48
- doc = parse <<-BLOCK_QUOTE
49
- > this is
50
- > a block quote
51
- BLOCK_QUOTE
52
-
53
- expected =
54
- doc(
55
- block(
56
- para("this is\na block quote")))
57
-
58
- assert_equal expected, doc
59
- end
60
-
61
- def test_parse_block_quote_continue
62
- doc = parse <<-BLOCK_QUOTE
63
- > this is
64
- a block quote
65
- BLOCK_QUOTE
66
-
67
- expected =
68
- doc(
69
- block(
70
- para("this is\na block quote")))
71
-
72
- assert_equal expected, doc
73
- end
74
-
75
- def test_parse_block_quote_list
76
- doc = parse <<-BLOCK_QUOTE
77
- > text
78
- >
79
- > * one
80
- > * two
81
- BLOCK_QUOTE
82
-
83
- expected =
84
- doc(
85
- block(
86
- para("text"),
87
- list(:BULLET,
88
- item(nil, para("one")),
89
- item(nil, para("two")))))
90
-
91
- assert_equal expected, doc
92
- end
93
-
94
- def test_parse_block_quote_newline
95
- doc = parse <<-BLOCK_QUOTE
96
- > this is
97
- a block quote
98
-
99
- BLOCK_QUOTE
100
-
101
- expected =
102
- doc(
103
- block(
104
- para("this is\na block quote")))
105
-
106
- assert_equal expected, doc
107
- end
108
-
109
- def test_parse_block_quote_separate
110
- doc = parse <<-BLOCK_QUOTE
111
- > this is
112
- a block quote
113
-
114
- > that continues
115
- BLOCK_QUOTE
116
-
117
- expected =
118
- doc(
119
- block(
120
- para("this is\na block quote"),
121
- para("that continues")))
122
-
123
- assert_equal expected, doc
124
- end
125
-
126
- def test_parse_char_entity
127
- doc = parse '&pi; &nn;'
128
-
129
- expected = doc(para('π &nn;'))
130
-
131
- assert_equal expected, doc
132
- end
133
-
134
- def test_parse_code
135
- doc = parse "Code: `text`"
136
-
137
- expected = doc(para("Code: <code>text</code>"))
138
-
139
- assert_equal expected, doc
140
- end
141
-
142
- def test_parse_code_github
143
- doc = parse <<-MD
144
- Example:
145
-
146
- ```
147
- code goes here
148
- ```
149
- MD
150
-
151
- expected =
152
- doc(
153
- para("Example:"),
154
- verb("code goes here\n"))
155
-
156
- assert_equal expected, doc
157
- end
158
-
159
- def test_parse_code_github_format
160
- doc = parse <<-MD
161
- Example:
162
-
163
- ``` ruby
164
- code goes here
165
- ```
166
- MD
167
-
168
- code = verb("code goes here\n")
169
- code.format = :ruby
170
-
171
- expected =
172
- doc(
173
- para("Example:"),
174
- code)
175
-
176
- assert_equal expected, doc
177
- end
178
-
179
- def test_parse_definition_list
180
- doc = parse <<-MD
181
- one
182
- : This is a definition
183
-
184
- two
185
- : This is another definition
186
- MD
187
-
188
- expected = doc(
189
- list(:NOTE,
190
- item(%w[one], para("This is a definition")),
191
- item(%w[two], para("This is another definition"))))
192
-
193
- assert_equal expected, doc
194
- end
195
-
196
- def test_parse_definition_list_indents
197
- doc = parse <<-MD
198
- zero
199
- : Indented zero characters
200
-
201
- one
202
- : Indented one characters
203
-
204
- two
205
- : Indented two characters
206
-
207
- three
208
- : Indented three characters
209
-
210
- four
211
- : Indented four characters
212
-
213
- MD
214
-
215
- expected = doc(
216
- list(:NOTE,
217
- item(%w[zero], para("Indented zero characters")),
218
- item(%w[one], para("Indented one characters")),
219
- item(%w[two], para("Indented two characters")),
220
- item(%w[three], para("Indented three characters"))),
221
- para("four\n : Indented four characters"))
222
-
223
- assert_equal expected, doc
224
- end
225
-
226
- def test_parse_definition_list_multi_description
227
- doc = parse <<-MD
228
- label
229
- : This is a definition
230
-
231
- : This is another definition
232
- MD
233
-
234
- expected = doc(
235
- list(:NOTE,
236
- item(%w[label], para("This is a definition")),
237
- item(nil, para("This is another definition"))))
238
-
239
- assert_equal expected, doc
240
- end
241
-
242
- def test_parse_definition_list_multi_label
243
- doc = parse <<-MD
244
- one
245
- two
246
- : This is a definition
247
- MD
248
-
249
- expected = doc(
250
- list(:NOTE,
251
- item(%w[one two], para("This is a definition"))))
252
-
253
- assert_equal expected, doc
254
- end
255
-
256
- def test_parse_definition_list_multi_line
257
- doc = parse <<-MD
258
- one
259
- : This is a definition
260
- that extends to two lines
261
-
262
- two
263
- : This is another definition
264
- that also extends to two lines
265
- MD
266
-
267
- expected = doc(
268
- list(:NOTE,
269
- item(%w[one],
270
- para("This is a definition\nthat extends to two lines")),
271
- item(%w[two],
272
- para("This is another definition\nthat also extends to two lines"))))
273
-
274
- assert_equal expected, doc
275
- end
276
-
277
- def test_parse_definition_list_no
278
- @parser.definition_lists = false
279
-
280
- doc = parse <<-MD
281
- one
282
- : This is a definition
283
-
284
- two
285
- : This is another definition
286
- MD
287
-
288
- expected = doc(
289
- para("one\n: This is a definition"),
290
- para("two\n: This is another definition"))
291
-
292
- assert_equal expected, doc
293
- end
294
-
295
- def test_parse_entity_dec
296
- doc = parse "Entity: &#65;"
297
-
298
- expected = doc(para("Entity: A"))
299
-
300
- assert_equal expected, doc
301
- end
302
-
303
- def test_parse_entity_hex
304
- doc = parse "Entity: &#x41;"
305
-
306
- expected = doc(para("Entity: A"))
307
-
308
- assert_equal expected, doc
309
- end
310
-
311
- def test_parse_entity_named
312
- doc = parse "Entity: &pi;"
313
-
314
- expected = doc(para("Entity: π"))
315
-
316
- assert_equal expected, doc
317
- end
318
-
319
- def test_parse_emphasis_star
320
- doc = parse "it *works*\n"
321
-
322
- expected = @RM::Document.new(
323
- @RM::Paragraph.new("it _works_"))
324
-
325
- assert_equal expected, doc
326
- end
327
-
328
- def test_parse_emphasis_underscore
329
- doc = parse "it _works_\n"
330
-
331
- expected =
332
- doc(
333
- para("it _works_"))
334
-
335
- assert_equal expected, doc
336
- end
337
-
338
- def test_parse_emphasis_underscore_embedded
339
- doc = parse "foo_bar bar_baz\n"
340
-
341
- expected =
342
- doc(
343
- para("foo_bar bar_baz"))
344
-
345
- assert_equal expected, doc
346
- end
347
-
348
- def test_parse_emphasis_underscore_in_word
349
- doc = parse "it foo_bar_baz\n"
350
-
351
- expected =
352
- doc(
353
- para("it foo_bar_baz"))
354
-
355
- assert_equal expected, doc
356
- end
357
-
358
- def test_parse_escape
359
- assert_equal doc(para("Backtick: `")), parse("Backtick: \\`")
360
-
361
- assert_equal doc(para("Backslash: \\")), parse("Backslash: \\\\")
362
-
363
- assert_equal doc(para("Colon: :")), parse("Colon: \\:")
364
- end
365
-
366
- def test_parse_heading_atx
367
- doc = parse "# heading\n"
368
-
369
- expected = @RM::Document.new(
370
- @RM::Heading.new(1, "heading"))
371
-
372
- assert_equal expected, doc
373
- end
374
-
375
- def test_parse_heading_setext_dash
376
- doc = parse <<-MD
377
- heading
378
- ---
379
- MD
380
-
381
- expected = @RM::Document.new(
382
- @RM::Heading.new(2, "heading"))
383
-
384
- assert_equal expected, doc
385
- end
386
-
387
- def test_parse_heading_setext_equals
388
- doc = parse <<-MD
389
- heading
390
- ===
391
- MD
392
-
393
- expected = @RM::Document.new(
394
- @RM::Heading.new(1, "heading"))
395
-
396
- assert_equal expected, doc
397
- end
398
-
399
- def test_parse_html
400
- @parser.html = true
401
-
402
- doc = parse "<address>Links here</address>\n"
403
-
404
- expected = doc(
405
- @RM::Raw.new("<address>Links here</address>"))
406
-
407
- assert_equal expected, doc
408
- end
409
-
410
- def test_parse_html_hr
411
- @parser.html = true
412
-
413
- doc = parse "<hr>\n"
414
-
415
- expected = doc(raw("<hr>"))
416
-
417
- assert_equal expected, doc
418
- end
419
-
420
- def test_parse_html_no_html
421
- @parser.html = false
422
-
423
- doc = parse "<address>Links here</address>\n"
424
-
425
- expected = doc()
426
-
427
- assert_equal expected, doc
428
- end
429
-
430
- def test_parse_image
431
- doc = parse "image ![alt text](path/to/image.jpg)"
432
-
433
- expected = doc(para("image rdoc-image:path/to/image.jpg"))
434
-
435
- assert_equal expected, doc
436
- end
437
-
438
- def test_parse_image_link
439
- @parser.html = true
440
-
441
- doc = parse "[![alt text](path/to/image.jpg)](http://example.com)"
442
-
443
- expected =
444
- doc(
445
- para('{rdoc-image:path/to/image.jpg}[http://example.com]'))
446
-
447
- assert_equal expected, doc
448
- end
449
-
450
- def test_parse_line_break
451
- doc = parse "Some text \nwith extra lines"
452
-
453
- expected = doc(
454
- para("Some text", hard_break, "with extra lines"))
455
-
456
- assert_equal expected, doc
457
- end
458
-
459
- def test_parse_link_reference_id
460
- doc = parse <<-MD
461
- This is [an example][id] reference-style link.
462
-
463
- [id]: http://example.com "Optional Title Here"
464
- MD
465
-
466
- expected = doc(
467
- para("This is {an example}[http://example.com] reference-style link."))
468
-
469
- assert_equal expected, doc
470
- end
471
-
472
- def test_parse_link_reference_id_adjacent
473
- doc = parse <<-MD
474
- [this] [this] should work
475
-
476
- [this]: example
477
- MD
478
-
479
- expected = doc(
480
- para("{this}[example] should work"))
481
-
482
- assert_equal expected, doc
483
- end
484
-
485
- def test_parse_link_reference_id_eof
486
- doc = parse <<-MD.chomp
487
- This is [an example][id] reference-style link.
488
-
489
- [id]: http://example.com "Optional Title Here"
490
- MD
491
-
492
- expected = doc(
493
- para("This is {an example}[http://example.com] reference-style link."))
494
-
495
- assert_equal expected, doc
496
- end
497
-
498
- def test_parse_link_reference_id_many
499
- doc = parse <<-MD
500
- This is [an example][id] reference-style link.
501
-
502
- And [another][id].
503
-
504
- [id]: http://example.com "Optional Title Here"
505
- MD
506
-
507
- expected = doc(
508
- para("This is {an example}[http://example.com] reference-style link."),
509
- para("And {another}[http://example.com]."))
510
-
511
- assert_equal expected, doc
512
- end
513
-
514
- def test_parse_link_reference_implicit
515
- doc = parse <<-MD
516
- This is [an example][] reference-style link.
517
-
518
- [an example]: http://example.com "Optional Title Here"
519
- MD
520
-
521
- expected = doc(
522
- para("This is {an example}[http://example.com] reference-style link."))
523
-
524
- assert_equal expected, doc
525
- end
526
-
527
- def test_parse_list_bullet
528
- doc = parse <<-MD
529
- * one
530
- * two
531
- MD
532
-
533
- expected = doc(
534
- list(:BULLET,
535
- item(nil, para("one")),
536
- item(nil, para("two"))))
537
-
538
- assert_equal expected, doc
539
- end
540
-
541
- def test_parse_list_bullet_auto_link
542
- doc = parse <<-MD
543
- * <http://example/>
544
- MD
545
-
546
- expected = doc(
547
- list(:BULLET,
548
- item(nil, para("http://example/"))))
549
-
550
- assert_equal expected, doc
551
- end
552
-
553
- def test_parse_list_bullet_continue
554
- doc = parse <<-MD
555
- * one
556
-
557
- * two
558
- MD
559
-
560
- expected = doc(
561
- list(:BULLET,
562
- item(nil, para("one")),
563
- item(nil, para("two"))))
564
-
565
- assert_equal expected, doc
566
- end
567
-
568
- def test_parse_list_bullet_multiline
569
- doc = parse <<-MD
570
- * one
571
- two
572
- MD
573
-
574
- expected = doc(
575
- list(:BULLET,
576
- item(nil, para("one\n two"))))
577
-
578
- assert_equal expected, doc
579
- end
580
-
581
- def test_parse_list_bullet_nest
582
- doc = parse <<-MD
583
- * outer
584
- * inner
585
- MD
586
-
587
- expected = doc(
588
- list(:BULLET,
589
- item(nil,
590
- para("outer"),
591
- list(:BULLET,
592
- item(nil,
593
- para("inner"))))))
594
-
595
- assert_equal expected, doc
596
- end
597
-
598
- def test_parse_list_bullet_nest_loose
599
- doc = parse <<-MD
600
- * outer
601
-
602
- * inner
603
- MD
604
-
605
- expected = doc(
606
- list(:BULLET,
607
- item(nil,
608
- para("outer"),
609
- list(:BULLET,
610
- item(nil, para("inner"))))))
611
-
612
- assert_equal expected, doc
613
- end
614
-
615
- def test_parse_list_bullet_nest_continue
616
- doc = parse <<-MD
617
- * outer
618
- * inner
619
- continue inner
620
- * outer 2
621
- MD
622
-
623
- expected = doc(
624
- list(:BULLET,
625
- item(nil,
626
- para("outer"),
627
- list(:BULLET,
628
- item(nil,
629
- para("inner\n continue inner")))),
630
- item(nil,
631
- para("outer 2"))))
632
-
633
- assert_equal expected, doc
634
- end
635
-
636
- def test_parse_list_number
637
- doc = parse <<-MD
638
- 1. one
639
- 1. two
640
- MD
641
-
642
- expected = doc(
643
- list(:NUMBER,
644
- item(nil, para("one")),
645
- item(nil, para("two"))))
646
-
647
- assert_equal expected, doc
648
- end
649
-
650
- def test_parse_list_number_continue
651
- doc = parse <<-MD
652
- 1. one
653
-
654
- 1. two
655
- MD
656
-
657
- expected = doc(
658
- list(:NUMBER,
659
- item(nil, para("one")),
660
- item(nil, para("two"))))
661
-
662
- assert_equal expected, doc
663
- end
664
-
665
- def test_parse_note
666
- @parser.notes = true
667
-
668
- doc = parse <<-MD
669
- Some text.[^1]
670
-
671
- [^1]: With a footnote
672
- MD
673
-
674
- expected = doc(
675
- para("Some text.{*1}[rdoc-label:foottext-1:footmark-1]"),
676
- @RM::Rule.new(1),
677
- para("{^1}[rdoc-label:footmark-1:foottext-1] With a footnote"))
678
-
679
- assert_equal expected, doc
680
- end
681
-
682
- def test_parse_note_indent
683
- @parser.notes = true
684
-
685
- doc = parse <<-MD
686
- Some text.[^1]
687
-
688
- [^1]: With a footnote
689
-
690
- more
691
- MD
692
-
693
- expected = doc(
694
- para("Some text.{*1}[rdoc-label:foottext-1:footmark-1]"),
695
- rule(1),
696
- para("{^1}[rdoc-label:footmark-1:foottext-1] With a footnote\n\nmore"))
697
-
698
- assert_equal expected, doc
699
- end
700
-
701
- def test_parse_note_inline
702
- @parser.notes = true
703
-
704
- doc = parse <<-MD
705
- Some text. ^[With a footnote]
706
- MD
707
-
708
- expected = doc(
709
- para("Some text. {*1}[rdoc-label:foottext-1:footmark-1]"),
710
- @RM::Rule.new(1),
711
- para("{^1}[rdoc-label:footmark-1:foottext-1] With a footnote"))
712
-
713
- assert_equal expected, doc
714
- end
715
-
716
- def test_parse_note_no_notes
717
- @parser.notes = false
718
-
719
- assert_raises RuntimeError do # TODO use a real error
720
- parse "Some text.[^1]"
721
- end
722
- end
723
-
724
- def test_parse_note_multiple
725
- @parser.notes = true
726
-
727
- doc = parse <<-MD
728
- Some text[^1]
729
- with inline notes^[like this]
730
- and an extra note.[^2]
731
-
732
- [^1]: With a footnote
733
-
734
- [^2]: Which should be numbered correctly
735
- MD
736
-
737
- expected = doc(
738
- para("Some text{*1}[rdoc-label:foottext-1:footmark-1]\n" +
739
- "with inline notes{*2}[rdoc-label:foottext-2:footmark-2]\n" +
740
- "and an extra note.{*3}[rdoc-label:foottext-3:footmark-3]"),
741
-
742
- rule(1),
743
-
744
- para("{^1}[rdoc-label:footmark-1:foottext-1] With a footnote"),
745
- para("{^2}[rdoc-label:footmark-2:foottext-2] like this"),
746
- para("{^3}[rdoc-label:footmark-3:foottext-3] " +
747
- "Which should be numbered correctly"))
748
-
749
- assert_equal expected, doc
750
- end
751
-
752
- def test_parse_paragraph
753
- doc = parse "it worked\n"
754
-
755
- expected = doc(para("it worked"))
756
-
757
- assert_equal expected, doc
758
- end
759
-
760
- def test_parse_paragraph_break_on_newline
761
- @parser.break_on_newline = true
762
-
763
- doc = parse "one\ntwo\n"
764
-
765
- expected = doc(para("one", hard_break, "two"))
766
-
767
- assert_equal expected, doc
768
-
769
- doc = parse "one \ntwo\nthree\n"
770
-
771
- expected = doc(para("one", hard_break, "two", hard_break, "three"))
772
-
773
- assert_equal expected, doc
774
- end
775
-
776
- def test_parse_paragraph_stars
777
- doc = parse "it worked ****\n"
778
-
779
- expected = @RM::Document.new(
780
- @RM::Paragraph.new("it worked ****"))
781
-
782
- assert_equal expected, doc
783
- end
784
-
785
- def test_parse_paragraph_html
786
- @parser.html = true
787
-
788
- doc = parse "<address>Links here</address>"
789
-
790
- expected = doc(raw("<address>Links here</address>"))
791
-
792
- assert_equal expected, doc
793
- end
794
-
795
- def test_parse_paragraph_html_no_html
796
- @parser.html = false
797
-
798
- doc = parse "<address>Links here</address>"
799
-
800
- expected = doc()
801
-
802
- assert_equal expected, doc
803
- end
804
-
805
- def test_parse_paragraph_indent_one
806
- doc = parse <<-MD
807
- text
808
- MD
809
-
810
- expected = doc(para("text"))
811
-
812
- assert_equal expected, doc
813
- end
814
-
815
- def test_parse_paragraph_indent_two
816
- doc = parse <<-MD
817
- text
818
- MD
819
-
820
- expected = doc(para("text"))
821
-
822
- assert_equal expected, doc
823
- end
824
-
825
- def test_parse_paragraph_indent_three
826
- doc = parse <<-MD
827
- text
828
- MD
829
-
830
- expected = doc(para("text"))
831
-
832
- assert_equal expected, doc
833
- end
834
-
835
- def test_parse_paragraph_multiline
836
- doc = parse "one\ntwo"
837
-
838
- expected = doc(para("one\ntwo"))
839
-
840
- assert_equal expected, doc
841
- end
842
-
843
- def test_parse_paragraph_two
844
- doc = parse "one\n\ntwo"
845
-
846
- expected = @RM::Document.new(
847
- @RM::Paragraph.new("one"),
848
- @RM::Paragraph.new("two"))
849
-
850
- assert_equal expected, doc
851
- end
852
-
853
- def test_parse_plain
854
- doc = parse "it worked"
855
-
856
- expected = @RM::Document.new(
857
- @RM::Paragraph.new("it worked"))
858
-
859
- assert_equal expected, doc
860
- end
861
-
862
- def test_parse_reference_link_embedded_bracket
863
- doc = parse "With [embedded [brackets]] [b].\n\n[b]: /url/\n"
864
-
865
- expected =
866
- doc(
867
- para("With {embedded [brackets]}[/url/]."))
868
-
869
- assert_equal expected, doc
870
- end
871
-
872
- def test_parse_rule_dash
873
- doc = parse "- - -\n\n"
874
-
875
- expected = @RM::Document.new(@RM::Rule.new(1))
876
-
877
- assert_equal expected, doc
878
- end
879
-
880
- def test_parse_rule_underscore
881
- doc = parse "_ _ _\n\n"
882
-
883
- expected = @RM::Document.new(@RM::Rule.new(1))
884
-
885
- assert_equal expected, doc
886
- end
887
-
888
- def test_parse_rule_star
889
- doc = parse "* * *\n\n"
890
-
891
- expected = @RM::Document.new(@RM::Rule.new(1))
892
-
893
- assert_equal expected, doc
894
- end
895
-
896
- def test_parse_strong_star
897
- doc = parse "it **works**\n"
898
-
899
- expected = @RM::Document.new(
900
- @RM::Paragraph.new("it *works*"))
901
-
902
- assert_equal expected, doc
903
- end
904
-
905
- def test_parse_strong_underscore
906
- doc = parse "it __works__\n"
907
-
908
- expected = @RM::Document.new(
909
- @RM::Paragraph.new("it *works*"))
910
-
911
- assert_equal expected, doc
912
- end
913
-
914
- def test_parse_strong_emphasis_star
915
- doc = parse "it ***works***\n"
916
-
917
- expected = @RM::Document.new(
918
- @RM::Paragraph.new("it <b>_works_</b>"))
919
-
920
- assert_equal expected, doc
921
- end
922
-
923
- def test_parse_strong_emphasis_underscore
924
- doc = parse "it ___works___\n"
925
-
926
- expected = @RM::Document.new(
927
- @RM::Paragraph.new("it <b>_works_</b>"))
928
-
929
- assert_equal expected, doc
930
- end
931
-
932
- def test_parse_style
933
- @parser.css = true
934
-
935
- doc = parse "<style>h1 { color: red }</style>\n"
936
-
937
- expected = doc(
938
- @RM::Raw.new("<style>h1 { color: red }</style>"))
939
-
940
- assert_equal expected, doc
941
- end
942
-
943
- def test_parse_style_disabled
944
- doc = parse "<style>h1 { color: red }</style>\n"
945
-
946
- expected = doc()
947
-
948
- assert_equal expected, doc
949
- end
950
-
951
- def test_parse_verbatim
952
- doc = parse <<-MD
953
- text
954
- MD
955
-
956
- expected = doc(verb("text\n"))
957
-
958
- assert_equal expected, doc
959
- end
960
-
961
- def test_parse_verbatim_eof
962
- doc = parse " text"
963
-
964
- expected = doc(verb("text\n"))
965
-
966
- assert_equal expected, doc
967
- end
968
-
969
- def test_strong
970
- assert_equal '*word*', @parser.strong('word')
971
- assert_equal '<b>two words</b>', @parser.strong('two words')
972
- assert_equal '<b>_emphasis_</b>', @parser.strong('_emphasis_')
973
- end
974
-
975
- def parse text
976
- @parser.parse text
977
- end
978
-
979
- end
980
-