mega-max-hub 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. checksums.yaml +7 -0
  2. data/mega-max-hub.gemspec +11 -0
  3. data/rdoc-8.0.0/CONTRIBUTING.md +195 -0
  4. data/rdoc-8.0.0/CVE-2013-0256.rdoc +49 -0
  5. data/rdoc-8.0.0/History.rdoc +1668 -0
  6. data/rdoc-8.0.0/LEGAL.rdoc +56 -0
  7. data/rdoc-8.0.0/LICENSE.rdoc +63 -0
  8. data/rdoc-8.0.0/README.md +236 -0
  9. data/rdoc-8.0.0/RI.md +842 -0
  10. data/rdoc-8.0.0/TODO.rdoc +60 -0
  11. data/rdoc-8.0.0/doc/markup_reference/markdown.md +659 -0
  12. data/rdoc-8.0.0/doc/markup_reference/rdoc.rdoc +1169 -0
  13. data/rdoc-8.0.0/exe/rdoc +43 -0
  14. data/rdoc-8.0.0/exe/ri +12 -0
  15. data/rdoc-8.0.0/lib/rdoc/code_object/alias.rb +98 -0
  16. data/rdoc-8.0.0/lib/rdoc/code_object/any_method.rb +387 -0
  17. data/rdoc-8.0.0/lib/rdoc/code_object/attr.rb +178 -0
  18. data/rdoc-8.0.0/lib/rdoc/code_object/class_module.rb +969 -0
  19. data/rdoc-8.0.0/lib/rdoc/code_object/constant.rb +221 -0
  20. data/rdoc-8.0.0/lib/rdoc/code_object/context/section.rb +182 -0
  21. data/rdoc-8.0.0/lib/rdoc/code_object/context.rb +1238 -0
  22. data/rdoc-8.0.0/lib/rdoc/code_object/extend.rb +9 -0
  23. data/rdoc-8.0.0/lib/rdoc/code_object/include.rb +9 -0
  24. data/rdoc-8.0.0/lib/rdoc/code_object/method_attr.rb +417 -0
  25. data/rdoc-8.0.0/lib/rdoc/code_object/mixin.rb +123 -0
  26. data/rdoc-8.0.0/lib/rdoc/code_object/normal_class.rb +92 -0
  27. data/rdoc-8.0.0/lib/rdoc/code_object/normal_module.rb +73 -0
  28. data/rdoc-8.0.0/lib/rdoc/code_object/require.rb +51 -0
  29. data/rdoc-8.0.0/lib/rdoc/code_object/single_class.rb +30 -0
  30. data/rdoc-8.0.0/lib/rdoc/code_object/top_level.rb +286 -0
  31. data/rdoc-8.0.0/lib/rdoc/code_object.rb +393 -0
  32. data/rdoc-8.0.0/lib/rdoc/code_objects.rb +5 -0
  33. data/rdoc-8.0.0/lib/rdoc/comment.rb +353 -0
  34. data/rdoc-8.0.0/lib/rdoc/cross_reference.rb +215 -0
  35. data/rdoc-8.0.0/lib/rdoc/encoding.rb +120 -0
  36. data/rdoc-8.0.0/lib/rdoc/erb_partial.rb +18 -0
  37. data/rdoc-8.0.0/lib/rdoc/erbio.rb +37 -0
  38. data/rdoc-8.0.0/lib/rdoc/generator/aliki.rb +200 -0
  39. data/rdoc-8.0.0/lib/rdoc/generator/darkfish.rb +824 -0
  40. data/rdoc-8.0.0/lib/rdoc/generator/json_index.rb +284 -0
  41. data/rdoc-8.0.0/lib/rdoc/generator/markup.rb +196 -0
  42. data/rdoc-8.0.0/lib/rdoc/generator/pot/message_extractor.rb +68 -0
  43. data/rdoc-8.0.0/lib/rdoc/generator/pot/po.rb +84 -0
  44. data/rdoc-8.0.0/lib/rdoc/generator/pot/po_entry.rb +141 -0
  45. data/rdoc-8.0.0/lib/rdoc/generator/pot.rb +94 -0
  46. data/rdoc-8.0.0/lib/rdoc/generator/ri.rb +30 -0
  47. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/DESIGN.md +536 -0
  48. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +8 -0
  49. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_footer.rhtml +23 -0
  50. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_head.rhtml +163 -0
  51. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
  52. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_icons.rhtml +208 -0
  53. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +16 -0
  54. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +15 -0
  55. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +27 -0
  56. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +27 -0
  57. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
  58. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +41 -0
  59. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +67 -0
  60. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
  61. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +21 -0
  62. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
  63. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/class.rhtml +230 -0
  64. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/css/rdoc.css +2181 -0
  65. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/index.rhtml +22 -0
  66. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/aliki.js +513 -0
  67. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/bash_highlighter.js +167 -0
  68. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
  69. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/search_controller.js +129 -0
  70. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
  71. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
  72. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
  73. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/page.rhtml +18 -0
  74. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +14 -0
  75. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/servlet_root.rhtml +65 -0
  76. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
  77. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_head.rhtml +43 -0
  78. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +5 -0
  79. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +17 -0
  80. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +17 -0
  81. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +16 -0
  82. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +21 -0
  83. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
  84. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +32 -0
  85. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +6 -0
  86. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +15 -0
  87. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
  88. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +39 -0
  89. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
  90. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/class.rhtml +220 -0
  91. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
  92. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/css/rdoc.css +701 -0
  93. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
  94. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
  95. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
  96. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
  97. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  98. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  99. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  100. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  101. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
  102. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
  103. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bug.png +0 -0
  104. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
  105. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
  106. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
  107. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
  108. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  109. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
  110. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif +0 -0
  111. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png +0 -0
  112. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
  113. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
  114. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
  115. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
  116. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
  117. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
  118. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  119. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
  120. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
  121. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
  122. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
  123. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
  124. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/index.rhtml +24 -0
  125. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/js/darkfish.js +140 -0
  126. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/js/search.js +120 -0
  127. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/page.rhtml +19 -0
  128. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +21 -0
  129. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +65 -0
  130. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +72 -0
  131. data/rdoc-8.0.0/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
  132. data/rdoc-8.0.0/lib/rdoc/generator/template/json_index/js/searcher.js +271 -0
  133. data/rdoc-8.0.0/lib/rdoc/generator.rb +52 -0
  134. data/rdoc-8.0.0/lib/rdoc/i18n/locale.rb +102 -0
  135. data/rdoc-8.0.0/lib/rdoc/i18n/text.rb +126 -0
  136. data/rdoc-8.0.0/lib/rdoc/i18n.rb +10 -0
  137. data/rdoc-8.0.0/lib/rdoc/known_classes.rb +74 -0
  138. data/rdoc-8.0.0/lib/rdoc/markdown/entities.rb +2131 -0
  139. data/rdoc-8.0.0/lib/rdoc/markdown/literals.kpeg +21 -0
  140. data/rdoc-8.0.0/lib/rdoc/markdown/literals.rb +454 -0
  141. data/rdoc-8.0.0/lib/rdoc/markdown.kpeg +1315 -0
  142. data/rdoc-8.0.0/lib/rdoc/markdown.rb +16865 -0
  143. data/rdoc-8.0.0/lib/rdoc/markup/blank_line.rb +29 -0
  144. data/rdoc-8.0.0/lib/rdoc/markup/block_quote.rb +14 -0
  145. data/rdoc-8.0.0/lib/rdoc/markup/document.rb +164 -0
  146. data/rdoc-8.0.0/lib/rdoc/markup/element.rb +21 -0
  147. data/rdoc-8.0.0/lib/rdoc/markup/formatter.rb +285 -0
  148. data/rdoc-8.0.0/lib/rdoc/markup/hard_break.rb +34 -0
  149. data/rdoc-8.0.0/lib/rdoc/markup/heading.rb +170 -0
  150. data/rdoc-8.0.0/lib/rdoc/markup/include.rb +42 -0
  151. data/rdoc-8.0.0/lib/rdoc/markup/indented_paragraph.rb +47 -0
  152. data/rdoc-8.0.0/lib/rdoc/markup/inline_parser.rb +312 -0
  153. data/rdoc-8.0.0/lib/rdoc/markup/list.rb +101 -0
  154. data/rdoc-8.0.0/lib/rdoc/markup/list_item.rb +99 -0
  155. data/rdoc-8.0.0/lib/rdoc/markup/paragraph.rb +28 -0
  156. data/rdoc-8.0.0/lib/rdoc/markup/parser.rb +585 -0
  157. data/rdoc-8.0.0/lib/rdoc/markup/pre_process.rb +317 -0
  158. data/rdoc-8.0.0/lib/rdoc/markup/raw.rb +66 -0
  159. data/rdoc-8.0.0/lib/rdoc/markup/rule.rb +20 -0
  160. data/rdoc-8.0.0/lib/rdoc/markup/table.rb +64 -0
  161. data/rdoc-8.0.0/lib/rdoc/markup/to_ansi.rb +144 -0
  162. data/rdoc-8.0.0/lib/rdoc/markup/to_bs.rb +86 -0
  163. data/rdoc-8.0.0/lib/rdoc/markup/to_html.rb +682 -0
  164. data/rdoc-8.0.0/lib/rdoc/markup/to_html_crossref.rb +261 -0
  165. data/rdoc-8.0.0/lib/rdoc/markup/to_html_snippet.rb +287 -0
  166. data/rdoc-8.0.0/lib/rdoc/markup/to_joined_paragraph.rb +41 -0
  167. data/rdoc-8.0.0/lib/rdoc/markup/to_label.rb +84 -0
  168. data/rdoc-8.0.0/lib/rdoc/markup/to_markdown.rb +215 -0
  169. data/rdoc-8.0.0/lib/rdoc/markup/to_rdoc.rb +421 -0
  170. data/rdoc-8.0.0/lib/rdoc/markup/to_table_of_contents.rb +88 -0
  171. data/rdoc-8.0.0/lib/rdoc/markup/to_test.rb +77 -0
  172. data/rdoc-8.0.0/lib/rdoc/markup/to_tt_only.rb +107 -0
  173. data/rdoc-8.0.0/lib/rdoc/markup/verbatim.rb +83 -0
  174. data/rdoc-8.0.0/lib/rdoc/markup.rb +219 -0
  175. data/rdoc-8.0.0/lib/rdoc/options.rb +1412 -0
  176. data/rdoc-8.0.0/lib/rdoc/parser/c.rb +1227 -0
  177. data/rdoc-8.0.0/lib/rdoc/parser/changelog.rb +379 -0
  178. data/rdoc-8.0.0/lib/rdoc/parser/markdown.rb +22 -0
  179. data/rdoc-8.0.0/lib/rdoc/parser/rbs.rb +275 -0
  180. data/rdoc-8.0.0/lib/rdoc/parser/rd.rb +22 -0
  181. data/rdoc-8.0.0/lib/rdoc/parser/ruby.rb +1266 -0
  182. data/rdoc-8.0.0/lib/rdoc/parser/ruby_colorizer.rb +253 -0
  183. data/rdoc-8.0.0/lib/rdoc/parser/simple.rb +44 -0
  184. data/rdoc-8.0.0/lib/rdoc/parser/text.rb +11 -0
  185. data/rdoc-8.0.0/lib/rdoc/parser.rb +298 -0
  186. data/rdoc-8.0.0/lib/rdoc/rbs_helper.rb +186 -0
  187. data/rdoc-8.0.0/lib/rdoc/rd/block_parser.rb +1706 -0
  188. data/rdoc-8.0.0/lib/rdoc/rd/block_parser.ry +643 -0
  189. data/rdoc-8.0.0/lib/rdoc/rd/inline.rb +71 -0
  190. data/rdoc-8.0.0/lib/rdoc/rd/inline_parser.rb +1854 -0
  191. data/rdoc-8.0.0/lib/rdoc/rd/inline_parser.ry +593 -0
  192. data/rdoc-8.0.0/lib/rdoc/rd.rb +99 -0
  193. data/rdoc-8.0.0/lib/rdoc/rdoc.rb +724 -0
  194. data/rdoc-8.0.0/lib/rdoc/ri/driver.rb +1572 -0
  195. data/rdoc-8.0.0/lib/rdoc/ri/formatter.rb +6 -0
  196. data/rdoc-8.0.0/lib/rdoc/ri/paths.rb +171 -0
  197. data/rdoc-8.0.0/lib/rdoc/ri/servlet.rb +452 -0
  198. data/rdoc-8.0.0/lib/rdoc/ri/store.rb +6 -0
  199. data/rdoc-8.0.0/lib/rdoc/ri/task.rb +71 -0
  200. data/rdoc-8.0.0/lib/rdoc/ri.rb +21 -0
  201. data/rdoc-8.0.0/lib/rdoc/rubygems_hook.rb +327 -0
  202. data/rdoc-8.0.0/lib/rdoc/server.rb +460 -0
  203. data/rdoc-8.0.0/lib/rdoc/stats/normal.rb +58 -0
  204. data/rdoc-8.0.0/lib/rdoc/stats/quiet.rb +59 -0
  205. data/rdoc-8.0.0/lib/rdoc/stats/verbose.rb +44 -0
  206. data/rdoc-8.0.0/lib/rdoc/stats.rb +484 -0
  207. data/rdoc-8.0.0/lib/rdoc/store.rb +1205 -0
  208. data/rdoc-8.0.0/lib/rdoc/task.rb +355 -0
  209. data/rdoc-8.0.0/lib/rdoc/text.rb +244 -0
  210. data/rdoc-8.0.0/lib/rdoc/token_stream.rb +104 -0
  211. data/rdoc-8.0.0/lib/rdoc/tom_doc.rb +257 -0
  212. data/rdoc-8.0.0/lib/rdoc/version.rb +10 -0
  213. data/rdoc-8.0.0/lib/rdoc.rb +239 -0
  214. data/rdoc-8.0.0/lib/rubygems_plugin.rb +14 -0
  215. data/rdoc-8.0.0/man/ri.1 +249 -0
  216. data/rdoc-8.0.0/rdoc-logo.svg +43 -0
  217. data/rdoc-8.0.0/rdoc.gemspec +74 -0
  218. metadata +256 -0
@@ -0,0 +1,1315 @@
1
+ %% name = RDoc::Markdown
2
+
3
+ %% header {
4
+ # coding: UTF-8
5
+ # frozen_string_literal: true
6
+ # :markup: markdown
7
+
8
+ ##
9
+ # RDoc::Markdown as described by the [markdown syntax][syntax].
10
+ #
11
+ # To choose Markdown as your only default format see
12
+ # RDoc::Options@Saved+Options for instructions on setting up a `.rdoc_options`
13
+ # file to store your project default.
14
+ #
15
+ # ## Usage
16
+ #
17
+ # Here is a brief example of using this parse to read a markdown file by hand.
18
+ #
19
+ # data = File.read("README.md")
20
+ # formatter = RDoc::Markup::ToHtml.new(RDoc::Options.new, nil)
21
+ # html = RDoc::Markdown.parse(data).accept(formatter)
22
+ #
23
+ # # do something with html
24
+ #
25
+ # ## Extensions
26
+ #
27
+ # The following markdown extensions are supported by the parser, but not all
28
+ # are used in RDoc output by default.
29
+ #
30
+ # ### RDoc
31
+ #
32
+ # The RDoc Markdown parser has the following built-in behaviors that cannot be
33
+ # disabled.
34
+ #
35
+ # Underscores embedded in words are never interpreted as emphasis. (While the
36
+ # [markdown dingus][dingus] emphasizes in-word underscores, neither the
37
+ # Markdown syntax nor MarkdownTest mention this behavior.)
38
+ #
39
+ # For HTML output, RDoc always auto-links bare URLs.
40
+ #
41
+ # ### Break on Newline
42
+ #
43
+ # The break_on_newline extension converts all newlines into hard line breaks
44
+ # as in [Github Flavored Markdown][GFM]. This extension is disabled by
45
+ # default.
46
+ #
47
+ # ### CSS
48
+ #
49
+ # The #css extension enables CSS blocks to be included in the output, but they
50
+ # are not used for any built-in RDoc output format. This extension is disabled
51
+ # by default.
52
+ #
53
+ # Example:
54
+ #
55
+ # <style type="text/css">
56
+ # h1 { font-size: 3em }
57
+ # </style>
58
+ #
59
+ # ### Definition Lists
60
+ #
61
+ # The definition_lists extension allows definition lists using the [PHP
62
+ # Markdown Extra syntax][PHPE], but only one label and definition are supported
63
+ # at this time. This extension is enabled by default.
64
+ #
65
+ # Example:
66
+ #
67
+ # ```
68
+ # cat
69
+ # : A small furry mammal
70
+ # that seems to sleep a lot
71
+ #
72
+ # ant
73
+ # : A little insect that is known
74
+ # to enjoy picnics
75
+ #
76
+ # ```
77
+ #
78
+ # Produces:
79
+ #
80
+ # cat
81
+ # : A small furry mammal
82
+ # that seems to sleep a lot
83
+ #
84
+ # ant
85
+ # : A little insect that is known
86
+ # to enjoy picnics
87
+ #
88
+ # ### Strike
89
+ #
90
+ # Example:
91
+ #
92
+ # ```
93
+ # This is ~~striked~~.
94
+ # ```
95
+ #
96
+ # Produces:
97
+ #
98
+ # This is ~~striked~~.
99
+ #
100
+ # ### Github
101
+ #
102
+ # The #github extension enables a partial set of [Github Flavored Markdown]
103
+ # [GFM]. This extension is enabled by default.
104
+ #
105
+ # Supported github extensions include:
106
+ #
107
+ # #### Fenced code blocks
108
+ #
109
+ # Use ` ``` ` around a block of code instead of indenting it four spaces.
110
+ #
111
+ # #### Syntax highlighting
112
+ #
113
+ # Use ` ``` ruby ` as the start of a code fence to add syntax highlighting.
114
+ # (Currently only `ruby` syntax is supported).
115
+ #
116
+ # ### HTML
117
+ #
118
+ # Enables raw HTML to be included in the output. This extension is enabled by
119
+ # default.
120
+ #
121
+ # Example:
122
+ #
123
+ # <table>
124
+ # ...
125
+ # </table>
126
+ #
127
+ # ### Notes
128
+ #
129
+ # The #notes extension enables footnote support. This extension is enabled by
130
+ # default.
131
+ #
132
+ # Example:
133
+ #
134
+ # Here is some text[^1] including an inline footnote ^[for short footnotes]
135
+ #
136
+ # ...
137
+ #
138
+ # [^1]: With the footnote text down at the bottom
139
+ #
140
+ # Produces:
141
+ #
142
+ # Here is some text[^1] including an inline footnote ^[for short footnotes]
143
+ #
144
+ # [^1]: With the footnote text down at the bottom
145
+ #
146
+ # ## Limitations
147
+ #
148
+ # * Link titles are not used
149
+ # * Footnotes are collapsed into a single paragraph
150
+ #
151
+ # ## Author
152
+ #
153
+ # This markdown parser is a port to kpeg from [peg-markdown][pegmarkdown] by
154
+ # John MacFarlane.
155
+ #
156
+ # It is used under the MIT license:
157
+ #
158
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
159
+ # of this software and associated documentation files (the "Software"), to deal
160
+ # in the Software without restriction, including without limitation the rights
161
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
162
+ # copies of the Software, and to permit persons to whom the Software is
163
+ # furnished to do so, subject to the following conditions:
164
+ #
165
+ # The above copyright notice and this permission notice shall be included in
166
+ # all copies or substantial portions of the Software.
167
+ #
168
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
169
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
170
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
171
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
172
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
173
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
174
+ # THE SOFTWARE.
175
+ #
176
+ # The port to kpeg was performed by Eric Hodel and Evan Phoenix
177
+ #
178
+ # [dingus]: http://daringfireball.net/projects/markdown/dingus
179
+ # [GFM]: https://github.github.com/gfm/
180
+ # [pegmarkdown]: https://github.com/jgm/peg-markdown
181
+ # [PHPE]: https://michelf.ca/projects/php-markdown/extra/#def-list
182
+ # [syntax]: http://daringfireball.net/projects/markdown/syntax
183
+ #--
184
+ # Last updated to jgm/peg-markdown commit 8f8fc22ef0
185
+
186
+ }
187
+
188
+ %% {
189
+
190
+ require_relative '../rdoc'
191
+ require_relative 'markup/to_joined_paragraph'
192
+ require_relative 'markdown/entities'
193
+
194
+ require_relative 'markdown/literals'
195
+
196
+ ##
197
+ # Supported extensions
198
+
199
+ EXTENSIONS = []
200
+
201
+ ##
202
+ # Extensions enabled by default
203
+
204
+ DEFAULT_EXTENSIONS = [
205
+ :definition_lists,
206
+ :github,
207
+ :html,
208
+ :notes,
209
+ :strike,
210
+ ]
211
+
212
+ # :section: Extensions
213
+
214
+ ##
215
+ # Creates extension methods for the `name` extension to enable and disable
216
+ # the extension and to query if they are active.
217
+
218
+ def self.extension name
219
+ EXTENSIONS << name
220
+
221
+ define_method "#{name}?" do
222
+ extension? name
223
+ end
224
+
225
+ define_method "#{name}=" do |enable|
226
+ extension name, enable
227
+ end
228
+ end
229
+
230
+ ##
231
+ # Converts all newlines into hard breaks
232
+
233
+ extension :break_on_newline
234
+
235
+ ##
236
+ # Allow style blocks
237
+
238
+ extension :css
239
+
240
+ ##
241
+ # Allow PHP Markdown Extras style definition lists
242
+
243
+ extension :definition_lists
244
+
245
+ ##
246
+ # Allow Github Flavored Markdown
247
+
248
+ extension :github
249
+
250
+ ##
251
+ # Allow HTML
252
+
253
+ extension :html
254
+
255
+ ##
256
+ # Enables the notes extension
257
+
258
+ extension :notes
259
+
260
+ ##
261
+ # Enables the strike extension
262
+
263
+ extension :strike
264
+
265
+ # :section:
266
+
267
+ ##
268
+ # Parses the `markdown` document into an RDoc::Document using the default
269
+ # extensions.
270
+
271
+ def self.parse markdown
272
+ parser = new
273
+
274
+ parser.parse markdown
275
+ end
276
+
277
+ # TODO remove when kpeg 0.10 is released
278
+ alias orig_initialize initialize # :nodoc:
279
+
280
+ ##
281
+ # Creates a new markdown parser that enables the given +extensions+.
282
+
283
+ def initialize extensions = DEFAULT_EXTENSIONS, debug = false
284
+ @debug = debug
285
+ @formatter = RDoc::Markup::ToJoinedParagraph.new
286
+ @extensions = extensions
287
+
288
+ @references = nil
289
+ @unlinked_references = nil
290
+
291
+ @footnotes = nil
292
+ @note_order = nil
293
+ end
294
+
295
+ ##
296
+ # Wraps `text` in emphasis for rdoc inline formatting
297
+
298
+ def emphasis text
299
+ if text =~ /\A[a-z\d.\/]+\z/i then
300
+ "_#{text}_"
301
+ else
302
+ "<em>#{text}</em>"
303
+ end
304
+ end
305
+
306
+ # Escape character that has special meaning in RDoc format.
307
+ # To allow rdoc-styled link used in markdown format for now, bracket and brace are not escaped.
308
+
309
+ def rdoc_escape(text)
310
+ text.gsub(/[*+<\\_]/) {|s| "\\#{s}" }
311
+ end
312
+
313
+ # Escape link url that contains brackets.
314
+ # Brackets needs escape because link url will be surrounded by `[]` in RDoc format.
315
+
316
+ def rdoc_link_url_escape(text)
317
+ text.gsub(/[\[\]\\]/) {|s| "\\#{s}" }
318
+ end
319
+
320
+ ##
321
+ # :category: Extensions
322
+ #
323
+ # Is the extension `name` enabled?
324
+
325
+ def extension? name
326
+ @extensions.include? name
327
+ end
328
+
329
+ ##
330
+ # :category: Extensions
331
+ #
332
+ # Enables or disables the extension with `name`
333
+
334
+ def extension name, enable
335
+ if enable then
336
+ @extensions |= [name]
337
+ else
338
+ @extensions -= [name]
339
+ end
340
+ end
341
+
342
+ ##
343
+ # Parses `text` in a clone of this parser. This is used for handling nested
344
+ # lists the same way as markdown_parser.
345
+
346
+ def inner_parse text # :nodoc:
347
+ parser = clone
348
+
349
+ parser.setup_parser text, @debug
350
+
351
+ parser.peg_parse
352
+
353
+ doc = parser.result
354
+
355
+ doc.accept @formatter
356
+
357
+ doc.parts
358
+ end
359
+
360
+ ##
361
+ # Finds a link reference for `label` and creates a new link to it with
362
+ # `content` as the link text. If `label` was not encountered in the
363
+ # reference-gathering parser pass the label and content are reconstructed
364
+ # with the linking `text` (usually whitespace).
365
+
366
+ def link_to content, label = content, text = nil
367
+ raise ParseError, 'enable notes extension' if
368
+ content.start_with? '^' and label.equal? content
369
+
370
+ if ref = @references[label] then
371
+ "{#{content}}[#{ref}]"
372
+ elsif label.equal? content then
373
+ "[#{content}]#{text}"
374
+ else
375
+ "[#{content}]#{text}[#{label}]"
376
+ end
377
+ end
378
+
379
+ ##
380
+ # Creates an RDoc::Markup::ListItem by parsing the `unparsed` content from
381
+ # the first parsing pass.
382
+
383
+ def list_item_from unparsed
384
+ parsed = inner_parse unparsed.join
385
+ RDoc::Markup::ListItem.new nil, *parsed
386
+ end
387
+
388
+ ##
389
+ # Stores `label` as a note and fills in previously unknown note references.
390
+
391
+ def note label
392
+ #foottext = "rdoc-label:foottext-#{label}:footmark-#{label}"
393
+
394
+ #ref.replace foottext if ref = @unlinked_notes.delete(label)
395
+
396
+ @notes[label] = foottext
397
+
398
+ #"{^1}[rdoc-label:footmark-#{label}:foottext-#{label}] "
399
+ end
400
+
401
+ ##
402
+ # Creates a new link for the footnote `reference` and adds the reference to
403
+ # the note order list for proper display at the end of the document.
404
+
405
+ def note_for ref
406
+ return unless @note_order
407
+
408
+ @note_order << ref
409
+
410
+ label = @note_order.length
411
+
412
+ "{*#{label}}[rdoc-label:foottext-#{label}:footmark-#{label}]"
413
+ end
414
+
415
+ ##
416
+ # The internal kpeg parse method
417
+
418
+ alias peg_parse parse # :nodoc:
419
+
420
+ ##
421
+ # Creates an RDoc::Markup::Paragraph from `parts` and including
422
+ # extension-specific behavior
423
+
424
+ def paragraph parts
425
+ parts = parts.map do |part|
426
+ if "\n" == part then
427
+ RDoc::Markup::HardBreak.new
428
+ else
429
+ part
430
+ end
431
+ end if break_on_newline?
432
+
433
+ RDoc::Markup::Paragraph.new(*parts)
434
+ end
435
+
436
+ ##
437
+ # Parses `markdown` into an RDoc::Document
438
+
439
+ def parse markdown
440
+ @references = {}
441
+ @unlinked_references = {}
442
+
443
+ markdown += "\n\n"
444
+
445
+ setup_parser markdown, @debug
446
+ peg_parse 'References'
447
+
448
+ if notes? then
449
+ @footnotes = {}
450
+
451
+ setup_parser markdown, @debug
452
+ peg_parse 'Notes'
453
+
454
+ # using note_order on the first pass would be a bug
455
+ @note_order = []
456
+ end
457
+
458
+ setup_parser markdown, @debug
459
+ peg_parse
460
+
461
+ doc = result
462
+
463
+ if notes? and not @footnotes.empty? then
464
+ doc << RDoc::Markup::Rule.new(1)
465
+
466
+ @note_order.each_with_index do |ref, index|
467
+ label = index + 1
468
+ note = @footnotes[ref] or raise ParseError, "footnote [^#{ref}] not found"
469
+
470
+ link = "{^#{label}}[rdoc-label:footmark-#{label}:foottext-#{label}] "
471
+ note.parts.unshift link
472
+
473
+ doc << note
474
+ end
475
+ end
476
+
477
+ doc.accept @formatter
478
+
479
+ doc
480
+ end
481
+
482
+ ##
483
+ # Stores `label` as a reference to `link` and fills in previously unknown
484
+ # link references.
485
+
486
+ def reference label, link
487
+ if ref = @unlinked_references.delete(label) then
488
+ ref.replace link
489
+ end
490
+
491
+ @references[label] = link
492
+ end
493
+
494
+ ##
495
+ # Wraps `text` in strong markup for rdoc inline formatting
496
+
497
+ def strong text
498
+ if text =~ /\A[a-z\d.\/-]+\z/i then
499
+ "*#{text}*"
500
+ else
501
+ "<b>#{text}</b>"
502
+ end
503
+ end
504
+
505
+ ##
506
+ # Wraps `text` in strike markup for rdoc inline formatting
507
+
508
+ def strike text
509
+ "<del>#{text}</del>"
510
+ end
511
+
512
+ ##
513
+ # Wraps `text` in code markup for rdoc inline formatting
514
+
515
+ def code text
516
+ # trim even spaces
517
+ text = $2 while /\A( +|\t+)(.*)\1\z/ =~ text
518
+ # escape unescaped backslash at the end
519
+ backslash_at_end = "\\" if /(?<!\\)(?:\\\\)*\\\z/.match?(text)
520
+ "<code>#{text}#{backslash_at_end}</code>"
521
+ end
522
+
523
+ ##
524
+ # Parses inline markdown in table cells
525
+
526
+ def parse_table_cells(table)
527
+ # Parse header cells
528
+ table.header = table.header.map { |cell| parse_cell_inline(cell) }
529
+
530
+ # Parse body cells
531
+ table.body = table.body.map do |row|
532
+ row.map { |cell| parse_cell_inline(cell) }
533
+ end
534
+
535
+ table
536
+ end
537
+
538
+ ##
539
+ # Parses inline markdown in a single table cell
540
+
541
+ def parse_cell_inline(text)
542
+ return text if text.nil? || text.empty?
543
+
544
+ # Create a new parser instance for the cell
545
+ cell_parser = RDoc::Markdown.new(@extensions, @debug)
546
+
547
+ # Parse the cell content
548
+ doc = cell_parser.parse(text)
549
+
550
+ # Extract the parsed content
551
+ if doc && doc.parts && !doc.parts.empty?
552
+ para = doc.parts.first
553
+ if para.is_a?(RDoc::Markup::Paragraph)
554
+ para.parts.join
555
+ else
556
+ text
557
+ end
558
+ else
559
+ text
560
+ end
561
+ end
562
+ }
563
+
564
+ root = Doc
565
+
566
+ Doc = BOM? Block*:a { RDoc::Markup::Document.new(*a.compact) }
567
+
568
+ Block = @BlankLine*
569
+ ( BlockQuote
570
+ | Verbatim
571
+ | CodeFence
572
+ | Table
573
+ | Note
574
+ | Reference
575
+ | HorizontalRule
576
+ | Heading
577
+ | OrderedList
578
+ | BulletList
579
+ | DefinitionList
580
+ | HtmlBlock
581
+ | StyleBlock
582
+ | Para
583
+ | Plain )
584
+
585
+ Para = @NonindentSpace Inlines:a @BlankLine+
586
+ { paragraph a }
587
+
588
+ Plain = Inlines:a
589
+ { paragraph a }
590
+
591
+ AtxInline = !@Newline !(@Sp /#*/ @Sp @Newline) Inline
592
+
593
+ AtxStart = < /\#{1,6}/ >
594
+ { text.length }
595
+
596
+ AtxHeading = AtxStart:s @Spacechar+ AtxInline+:a (@Sp /#*/ @Sp)? @Newline
597
+ { RDoc::Markup::Heading.new(s, a.join) }
598
+
599
+ SetextHeading = SetextHeading1 | SetextHeading2
600
+
601
+ SetextBottom1 = /={1,}/ @Newline
602
+
603
+ SetextBottom2 = /-{1,}/ @Newline
604
+
605
+ SetextHeading1 = &(@RawLine SetextBottom1)
606
+ @StartList:a ( !@Endline Inline:b { a << b } )+ @Sp @Newline
607
+ SetextBottom1
608
+ { RDoc::Markup::Heading.new(1, a.join) }
609
+
610
+ SetextHeading2 = &(@RawLine SetextBottom2)
611
+ @StartList:a ( !@Endline Inline:b { a << b })+ @Sp @Newline
612
+ SetextBottom2
613
+ { RDoc::Markup::Heading.new(2, a.join) }
614
+
615
+ Heading = SetextHeading | AtxHeading
616
+
617
+ BlockQuote = BlockQuoteRaw:a
618
+ { RDoc::Markup::BlockQuote.new(*a) }
619
+
620
+ BlockQuoteRaw = @StartList:a
621
+ (( ">" " "? Line:l { a << l } )
622
+ ( !">" !@BlankLine !(AtxStart @Spacechar) !Bullet !Enumerator !( &{ github? } Ticks3 ) Line:c { a << c } )*
623
+ ( ">" @BlankLine:n { a << n } )*
624
+ )+
625
+ { inner_parse a.join }
626
+
627
+ NonblankIndentedLine = !@BlankLine IndentedLine
628
+
629
+ VerbatimChunk = @BlankLine*:a
630
+ NonblankIndentedLine+:b
631
+ { a.concat b }
632
+
633
+ Verbatim = VerbatimChunk+:a
634
+ { RDoc::Markup::Verbatim.new(*a.flatten) }
635
+
636
+ HorizontalRule = @NonindentSpace
637
+ ( "*" @Sp "*" @Sp "*" (@Sp "*")*
638
+ | "-" @Sp "-" @Sp "-" (@Sp "-")*
639
+ | "_" @Sp "_" @Sp "_" (@Sp "_")*)
640
+ @Sp @Newline @BlankLine+
641
+ { RDoc::Markup::Rule.new 1 }
642
+
643
+ Bullet = !HorizontalRule @NonindentSpace /[+*-]/ @Spacechar+
644
+
645
+ BulletList = &Bullet (ListTight | ListLoose):a
646
+ { RDoc::Markup::List.new(:BULLET, *a) }
647
+
648
+ ListTight = ListItemTight+:a
649
+ @BlankLine* !(Bullet | Enumerator)
650
+ { a }
651
+
652
+ ListLoose = @StartList:a
653
+ ( ListItem:b @BlankLine* { a << b } )+
654
+ { a }
655
+
656
+ ListItem = ( Bullet | Enumerator )
657
+ @StartList:a
658
+ ListBlock:b { a << b }
659
+ ( ListContinuationBlock:c { a.push(*c) } )*
660
+ { list_item_from a }
661
+
662
+ ListItemTight =
663
+ ( Bullet | Enumerator )
664
+ ListBlock:a
665
+ ( !@BlankLine
666
+ ListContinuationBlock:b { a.push(*b) } )*
667
+ !ListContinuationBlock
668
+ { list_item_from a }
669
+
670
+ ListBlock = !@BlankLine Line:a
671
+ ListBlockLine*:c
672
+ { [a, *c] }
673
+
674
+ ListContinuationBlock = @StartList:a
675
+ ( @BlankLine*
676
+ { a << "\n" } )
677
+ ( Indent
678
+ ListBlock:b { a.concat b } )+
679
+ { a }
680
+
681
+ Enumerator = @NonindentSpace [0-9]+ "." @Spacechar+
682
+
683
+ OrderedList = &Enumerator (ListTight | ListLoose):a
684
+ { RDoc::Markup::List.new(:NUMBER, *a) }
685
+
686
+ ListBlockLine = !@BlankLine
687
+ !( Indent? (Bullet | Enumerator) )
688
+ !HorizontalRule
689
+ OptionallyIndentedLine
690
+
691
+ # Parsers for different kinds of block-level HTML content.
692
+ # This is repetitive due to constraints of PEG grammar.
693
+
694
+ HtmlOpenAnchor = "<" Spnl ("a" | "A") Spnl HtmlAttribute* ">"
695
+ HtmlCloseAnchor = "<" Spnl "/" ("a" | "A") Spnl ">"
696
+ HtmlAnchor = HtmlOpenAnchor (HtmlAnchor | !HtmlCloseAnchor .)* HtmlCloseAnchor
697
+
698
+ HtmlBlockOpenAddress = "<" Spnl ("address" | "ADDRESS") Spnl HtmlAttribute* ">"
699
+ HtmlBlockCloseAddress = "<" Spnl "/" ("address" | "ADDRESS") Spnl ">"
700
+ HtmlBlockAddress = HtmlBlockOpenAddress (HtmlBlockAddress | !HtmlBlockCloseAddress .)* HtmlBlockCloseAddress
701
+
702
+ HtmlBlockOpenBlockquote = "<" Spnl ("blockquote" | "BLOCKQUOTE") Spnl HtmlAttribute* ">"
703
+ HtmlBlockCloseBlockquote = "<" Spnl "/" ("blockquote" | "BLOCKQUOTE") Spnl ">"
704
+ HtmlBlockBlockquote = HtmlBlockOpenBlockquote (HtmlBlockBlockquote | !HtmlBlockCloseBlockquote .)* HtmlBlockCloseBlockquote
705
+
706
+ HtmlBlockOpenCenter = "<" Spnl ("center" | "CENTER") Spnl HtmlAttribute* ">"
707
+ HtmlBlockCloseCenter = "<" Spnl "/" ("center" | "CENTER") Spnl ">"
708
+ HtmlBlockCenter = HtmlBlockOpenCenter (HtmlBlockCenter | !HtmlBlockCloseCenter .)* HtmlBlockCloseCenter
709
+
710
+ HtmlBlockOpenDir = "<" Spnl ("dir" | "DIR") Spnl HtmlAttribute* ">"
711
+ HtmlBlockCloseDir = "<" Spnl "/" ("dir" | "DIR") Spnl ">"
712
+ HtmlBlockDir = HtmlBlockOpenDir (HtmlBlockDir | !HtmlBlockCloseDir .)* HtmlBlockCloseDir
713
+
714
+ HtmlBlockOpenDiv = "<" Spnl ("div" | "DIV") Spnl HtmlAttribute* ">"
715
+ HtmlBlockCloseDiv = "<" Spnl "/" ("div" | "DIV") Spnl ">"
716
+ HtmlBlockDiv = HtmlBlockOpenDiv (HtmlBlockDiv | !HtmlBlockCloseDiv .)* HtmlBlockCloseDiv
717
+
718
+ HtmlBlockOpenDl = "<" Spnl ("dl" | "DL") Spnl HtmlAttribute* ">"
719
+ HtmlBlockCloseDl = "<" Spnl "/" ("dl" | "DL") Spnl ">"
720
+ HtmlBlockDl = HtmlBlockOpenDl (HtmlBlockDl | !HtmlBlockCloseDl .)* HtmlBlockCloseDl
721
+
722
+ HtmlBlockOpenFieldset = "<" Spnl ("fieldset" | "FIELDSET") Spnl HtmlAttribute* ">"
723
+ HtmlBlockCloseFieldset = "<" Spnl "/" ("fieldset" | "FIELDSET") Spnl ">"
724
+ HtmlBlockFieldset = HtmlBlockOpenFieldset (HtmlBlockFieldset | !HtmlBlockCloseFieldset .)* HtmlBlockCloseFieldset
725
+
726
+ HtmlBlockOpenForm = "<" Spnl ("form" | "FORM") Spnl HtmlAttribute* ">"
727
+ HtmlBlockCloseForm = "<" Spnl "/" ("form" | "FORM") Spnl ">"
728
+ HtmlBlockForm = HtmlBlockOpenForm (HtmlBlockForm | !HtmlBlockCloseForm .)* HtmlBlockCloseForm
729
+
730
+ HtmlBlockOpenH1 = "<" Spnl ("h1" | "H1") Spnl HtmlAttribute* ">"
731
+ HtmlBlockCloseH1 = "<" Spnl "/" ("h1" | "H1") Spnl ">"
732
+ HtmlBlockH1 = HtmlBlockOpenH1 (HtmlBlockH1 | !HtmlBlockCloseH1 .)* HtmlBlockCloseH1
733
+
734
+ HtmlBlockOpenH2 = "<" Spnl ("h2" | "H2") Spnl HtmlAttribute* ">"
735
+ HtmlBlockCloseH2 = "<" Spnl "/" ("h2" | "H2") Spnl ">"
736
+ HtmlBlockH2 = HtmlBlockOpenH2 (HtmlBlockH2 | !HtmlBlockCloseH2 .)* HtmlBlockCloseH2
737
+
738
+ HtmlBlockOpenH3 = "<" Spnl ("h3" | "H3") Spnl HtmlAttribute* ">"
739
+ HtmlBlockCloseH3 = "<" Spnl "/" ("h3" | "H3") Spnl ">"
740
+ HtmlBlockH3 = HtmlBlockOpenH3 (HtmlBlockH3 | !HtmlBlockCloseH3 .)* HtmlBlockCloseH3
741
+
742
+ HtmlBlockOpenH4 = "<" Spnl ("h4" | "H4") Spnl HtmlAttribute* ">"
743
+ HtmlBlockCloseH4 = "<" Spnl "/" ("h4" | "H4") Spnl ">"
744
+ HtmlBlockH4 = HtmlBlockOpenH4 (HtmlBlockH4 | !HtmlBlockCloseH4 .)* HtmlBlockCloseH4
745
+
746
+ HtmlBlockOpenH5 = "<" Spnl ("h5" | "H5") Spnl HtmlAttribute* ">"
747
+ HtmlBlockCloseH5 = "<" Spnl "/" ("h5" | "H5") Spnl ">"
748
+ HtmlBlockH5 = HtmlBlockOpenH5 (HtmlBlockH5 | !HtmlBlockCloseH5 .)* HtmlBlockCloseH5
749
+
750
+ HtmlBlockOpenH6 = "<" Spnl ("h6" | "H6") Spnl HtmlAttribute* ">"
751
+ HtmlBlockCloseH6 = "<" Spnl "/" ("h6" | "H6") Spnl ">"
752
+ HtmlBlockH6 = HtmlBlockOpenH6 (HtmlBlockH6 | !HtmlBlockCloseH6 .)* HtmlBlockCloseH6
753
+
754
+ HtmlBlockOpenMenu = "<" Spnl ("menu" | "MENU") Spnl HtmlAttribute* ">"
755
+ HtmlBlockCloseMenu = "<" Spnl "/" ("menu" | "MENU") Spnl ">"
756
+ HtmlBlockMenu = HtmlBlockOpenMenu (HtmlBlockMenu | !HtmlBlockCloseMenu .)* HtmlBlockCloseMenu
757
+
758
+ HtmlBlockOpenNoframes = "<" Spnl ("noframes" | "NOFRAMES") Spnl HtmlAttribute* ">"
759
+ HtmlBlockCloseNoframes = "<" Spnl "/" ("noframes" | "NOFRAMES") Spnl ">"
760
+ HtmlBlockNoframes = HtmlBlockOpenNoframes (HtmlBlockNoframes | !HtmlBlockCloseNoframes .)* HtmlBlockCloseNoframes
761
+
762
+ HtmlBlockOpenNoscript = "<" Spnl ("noscript" | "NOSCRIPT") Spnl HtmlAttribute* ">"
763
+ HtmlBlockCloseNoscript = "<" Spnl "/" ("noscript" | "NOSCRIPT") Spnl ">"
764
+ HtmlBlockNoscript = HtmlBlockOpenNoscript (HtmlBlockNoscript | !HtmlBlockCloseNoscript .)* HtmlBlockCloseNoscript
765
+
766
+ HtmlBlockOpenOl = "<" Spnl ("ol" | "OL") Spnl HtmlAttribute* ">"
767
+ HtmlBlockCloseOl = "<" Spnl "/" ("ol" | "OL") Spnl ">"
768
+ HtmlBlockOl = HtmlBlockOpenOl (HtmlBlockOl | !HtmlBlockCloseOl .)* HtmlBlockCloseOl
769
+
770
+ HtmlBlockOpenP = "<" Spnl ("p" | "P") Spnl HtmlAttribute* ">"
771
+ HtmlBlockCloseP = "<" Spnl "/" ("p" | "P") Spnl ">"
772
+ HtmlBlockP = HtmlBlockOpenP (HtmlBlockP | !HtmlBlockCloseP .)* HtmlBlockCloseP
773
+
774
+ HtmlBlockOpenPre = "<" Spnl ("pre" | "PRE") Spnl HtmlAttribute* ">"
775
+ HtmlBlockClosePre = "<" Spnl "/" ("pre" | "PRE") Spnl ">"
776
+ HtmlBlockPre = HtmlBlockOpenPre (HtmlBlockPre | !HtmlBlockClosePre .)* HtmlBlockClosePre
777
+
778
+ HtmlBlockOpenTable = "<" Spnl ("table" | "TABLE") Spnl HtmlAttribute* ">"
779
+ HtmlBlockCloseTable = "<" Spnl "/" ("table" | "TABLE") Spnl ">"
780
+ HtmlBlockTable = HtmlBlockOpenTable (HtmlBlockTable | !HtmlBlockCloseTable .)* HtmlBlockCloseTable
781
+
782
+ HtmlBlockOpenUl = "<" Spnl ("ul" | "UL") Spnl HtmlAttribute* ">"
783
+ HtmlBlockCloseUl = "<" Spnl "/" ("ul" | "UL") Spnl ">"
784
+ HtmlBlockUl = HtmlBlockOpenUl (HtmlBlockUl | !HtmlBlockCloseUl .)* HtmlBlockCloseUl
785
+
786
+ HtmlBlockOpenDd = "<" Spnl ("dd" | "DD") Spnl HtmlAttribute* ">"
787
+ HtmlBlockCloseDd = "<" Spnl "/" ("dd" | "DD") Spnl ">"
788
+ HtmlBlockDd = HtmlBlockOpenDd (HtmlBlockDd | !HtmlBlockCloseDd .)* HtmlBlockCloseDd
789
+
790
+ HtmlBlockOpenDt = "<" Spnl ("dt" | "DT") Spnl HtmlAttribute* ">"
791
+ HtmlBlockCloseDt = "<" Spnl "/" ("dt" | "DT") Spnl ">"
792
+ HtmlBlockDt = HtmlBlockOpenDt (HtmlBlockDt | !HtmlBlockCloseDt .)* HtmlBlockCloseDt
793
+
794
+ HtmlBlockOpenFrameset = "<" Spnl ("frameset" | "FRAMESET") Spnl HtmlAttribute* ">"
795
+ HtmlBlockCloseFrameset = "<" Spnl "/" ("frameset" | "FRAMESET") Spnl ">"
796
+ HtmlBlockFrameset = HtmlBlockOpenFrameset (HtmlBlockFrameset | !HtmlBlockCloseFrameset .)* HtmlBlockCloseFrameset
797
+
798
+ HtmlBlockOpenLi = "<" Spnl ("li" | "LI") Spnl HtmlAttribute* ">"
799
+ HtmlBlockCloseLi = "<" Spnl "/" ("li" | "LI") Spnl ">"
800
+ HtmlBlockLi = HtmlBlockOpenLi (HtmlBlockLi | !HtmlBlockCloseLi .)* HtmlBlockCloseLi
801
+
802
+ HtmlBlockOpenTbody = "<" Spnl ("tbody" | "TBODY") Spnl HtmlAttribute* ">"
803
+ HtmlBlockCloseTbody = "<" Spnl "/" ("tbody" | "TBODY") Spnl ">"
804
+ HtmlBlockTbody = HtmlBlockOpenTbody (HtmlBlockTbody | !HtmlBlockCloseTbody .)* HtmlBlockCloseTbody
805
+
806
+ HtmlBlockOpenTd = "<" Spnl ("td" | "TD") Spnl HtmlAttribute* ">"
807
+ HtmlBlockCloseTd = "<" Spnl "/" ("td" | "TD") Spnl ">"
808
+ HtmlBlockTd = HtmlBlockOpenTd (HtmlBlockTd | !HtmlBlockCloseTd .)* HtmlBlockCloseTd
809
+
810
+ HtmlBlockOpenTfoot = "<" Spnl ("tfoot" | "TFOOT") Spnl HtmlAttribute* ">"
811
+ HtmlBlockCloseTfoot = "<" Spnl "/" ("tfoot" | "TFOOT") Spnl ">"
812
+ HtmlBlockTfoot = HtmlBlockOpenTfoot (HtmlBlockTfoot | !HtmlBlockCloseTfoot .)* HtmlBlockCloseTfoot
813
+
814
+ HtmlBlockOpenTh = "<" Spnl ("th" | "TH") Spnl HtmlAttribute* ">"
815
+ HtmlBlockCloseTh = "<" Spnl "/" ("th" | "TH") Spnl ">"
816
+ HtmlBlockTh = HtmlBlockOpenTh (HtmlBlockTh | !HtmlBlockCloseTh .)* HtmlBlockCloseTh
817
+
818
+ HtmlBlockOpenThead = "<" Spnl ("thead" | "THEAD") Spnl HtmlAttribute* ">"
819
+ HtmlBlockCloseThead = "<" Spnl "/" ("thead" | "THEAD") Spnl ">"
820
+ HtmlBlockThead = HtmlBlockOpenThead (HtmlBlockThead | !HtmlBlockCloseThead .)* HtmlBlockCloseThead
821
+
822
+ HtmlBlockOpenTr = "<" Spnl ("tr" | "TR") Spnl HtmlAttribute* ">"
823
+ HtmlBlockCloseTr = "<" Spnl "/" ("tr" | "TR") Spnl ">"
824
+ HtmlBlockTr = HtmlBlockOpenTr (HtmlBlockTr | !HtmlBlockCloseTr .)* HtmlBlockCloseTr
825
+
826
+ HtmlBlockOpenScript = "<" Spnl ("script" | "SCRIPT") Spnl HtmlAttribute* ">"
827
+ HtmlBlockCloseScript = "<" Spnl "/" ("script" | "SCRIPT") Spnl ">"
828
+ HtmlBlockScript = HtmlBlockOpenScript (!HtmlBlockCloseScript .)* HtmlBlockCloseScript
829
+
830
+ HtmlBlockOpenHead = "<" Spnl ("head" | "HEAD") Spnl HtmlAttribute* ">"
831
+ HtmlBlockCloseHead = "<" Spnl "/" ("head" | "HEAD") Spnl ">"
832
+ HtmlBlockHead = HtmlBlockOpenHead (!HtmlBlockCloseHead .)* HtmlBlockCloseHead
833
+
834
+ HtmlBlockInTags = HtmlAnchor
835
+ | HtmlBlockAddress
836
+ | HtmlBlockBlockquote
837
+ | HtmlBlockCenter
838
+ | HtmlBlockDir
839
+ | HtmlBlockDiv
840
+ | HtmlBlockDl
841
+ | HtmlBlockFieldset
842
+ | HtmlBlockForm
843
+ | HtmlBlockH1
844
+ | HtmlBlockH2
845
+ | HtmlBlockH3
846
+ | HtmlBlockH4
847
+ | HtmlBlockH5
848
+ | HtmlBlockH6
849
+ | HtmlBlockMenu
850
+ | HtmlBlockNoframes
851
+ | HtmlBlockNoscript
852
+ | HtmlBlockOl
853
+ | HtmlBlockP
854
+ | HtmlBlockPre
855
+ | HtmlBlockTable
856
+ | HtmlBlockUl
857
+ | HtmlBlockDd
858
+ | HtmlBlockDt
859
+ | HtmlBlockFrameset
860
+ | HtmlBlockLi
861
+ | HtmlBlockTbody
862
+ | HtmlBlockTd
863
+ | HtmlBlockTfoot
864
+ | HtmlBlockTh
865
+ | HtmlBlockThead
866
+ | HtmlBlockTr
867
+ | HtmlBlockScript
868
+ | HtmlBlockHead
869
+
870
+ HtmlBlock = < ( HtmlBlockInTags | HtmlComment | HtmlBlockSelfClosing | HtmlUnclosed) >
871
+ @BlankLine+
872
+ { if html? then
873
+ RDoc::Markup::Raw.new text
874
+ end }
875
+
876
+ HtmlUnclosed = "<" Spnl HtmlUnclosedType Spnl HtmlAttribute* Spnl ">"
877
+
878
+ HtmlUnclosedType = "HR" | "hr"
879
+
880
+ HtmlBlockSelfClosing = "<" Spnl HtmlBlockType Spnl HtmlAttribute* "/" Spnl ">"
881
+
882
+ HtmlBlockType = "ADDRESS" |
883
+ "BLOCKQUOTE" |
884
+ "CENTER" |
885
+ "DD" |
886
+ "DIR" |
887
+ "DIV" |
888
+ "DL" |
889
+ "DT" |
890
+ "FIELDSET" |
891
+ "FORM" |
892
+ "FRAMESET" |
893
+ "H1" |
894
+ "H2" |
895
+ "H3" |
896
+ "H4" |
897
+ "H5" |
898
+ "H6" |
899
+ "HR" |
900
+ "ISINDEX" |
901
+ "LI" |
902
+ "MENU" |
903
+ "NOFRAMES" |
904
+ "NOSCRIPT" |
905
+ "OL" |
906
+ "P" |
907
+ "PRE" |
908
+ "SCRIPT" |
909
+ "TABLE" |
910
+ "TBODY" |
911
+ "TD" |
912
+ "TFOOT" |
913
+ "TH" |
914
+ "THEAD" |
915
+ "TR" |
916
+ "UL" |
917
+ "address" |
918
+ "blockquote" |
919
+ "center" |
920
+ "dd" |
921
+ "dir" |
922
+ "div" |
923
+ "dl" |
924
+ "dt" |
925
+ "fieldset" |
926
+ "form" |
927
+ "frameset" |
928
+ "h1" |
929
+ "h2" |
930
+ "h3" |
931
+ "h4" |
932
+ "h5" |
933
+ "h6" |
934
+ "hr" |
935
+ "isindex" |
936
+ "li" |
937
+ "menu" |
938
+ "noframes" |
939
+ "noscript" |
940
+ "ol" |
941
+ "p" |
942
+ "pre" |
943
+ "script" |
944
+ "table" |
945
+ "tbody" |
946
+ "td" |
947
+ "tfoot" |
948
+ "th" |
949
+ "thead" |
950
+ "tr" |
951
+ "ul"
952
+
953
+ StyleOpen = "<" Spnl ("style" | "STYLE") Spnl HtmlAttribute* ">"
954
+ StyleClose = "<" Spnl "/" ("style" | "STYLE") Spnl ">"
955
+ InStyleTags = StyleOpen (!StyleClose .)* StyleClose
956
+ StyleBlock = < InStyleTags >
957
+ @BlankLine*
958
+ { if css? then
959
+ RDoc::Markup::Raw.new text
960
+ end }
961
+
962
+ Inlines = ( !@Endline Inline:i { i }
963
+ | @Endline:c !( &{ github? } Ticks3 /[^`\n]*$/ )
964
+ &Inline { c } )+:chunks @Endline?
965
+ { chunks }
966
+
967
+ Inline = Str
968
+ | @Endline
969
+ | UlOrStarLine
970
+ | @Space
971
+ | Strong
972
+ | Emph
973
+ | Strike
974
+ | Image
975
+ | Link
976
+ | NoteReference
977
+ | InlineNote
978
+ | Code
979
+ | RawHtml
980
+ | StrippedComment
981
+ | Entity
982
+ | EscapedChar
983
+ | Symbol
984
+
985
+ Space = @Spacechar+ { " " }
986
+
987
+ Str = @StartList:a
988
+ < @NormalChar+ > { a = text }
989
+ ( StrChunk:c { a << c } )* { rdoc_escape(a) }
990
+
991
+ StrChunk = < (@NormalChar | /_+/ &Alphanumeric)+ > { text }
992
+
993
+ EscapedChar = "\\" !@Newline < /[:\\`|*_{}\[\]()#+.!><-]/ > { rdoc_escape(text) }
994
+
995
+ Entity = ( HexEntity | DecEntity | CharEntity ):a { a }
996
+
997
+ Endline = @LineBreak | @TerminalEndline | @NormalEndline
998
+
999
+ NormalEndline = @Sp @Newline !@BlankLine !">" !AtxStart
1000
+ !(Line /={1,}|-{1,}/ @Newline)
1001
+ { "\n" }
1002
+
1003
+ TerminalEndline = @Sp @Newline @Eof
1004
+
1005
+ LineBreak = " " @NormalEndline { RDoc::Markup::HardBreak.new }
1006
+
1007
+ Symbol = < @SpecialChar >
1008
+ { rdoc_escape(text) }
1009
+
1010
+ # This keeps the parser from getting bogged down on long strings of '*' or '_',
1011
+ # or strings of '*' or '_' with space on each side:
1012
+ UlOrStarLine = (UlLine | StarLine):a { a }
1013
+ StarLine = < /\*{4,}/ > { text } |
1014
+ < @Spacechar /\*+/ &@Spacechar > { text }
1015
+ UlLine = < /_{4,}/ > { text } |
1016
+ < @Spacechar /_+/ &@Spacechar > { text }
1017
+
1018
+ Emph = EmphStar | EmphUl
1019
+
1020
+ Whitespace = @Spacechar | @Newline
1021
+
1022
+ EmphStar = "*" !@Whitespace
1023
+ @StartList:a
1024
+ ( !"*" Inline:b { a << b }
1025
+ | StrongStar:b { a << b }
1026
+ )+
1027
+ "*"
1028
+ { emphasis a.join }
1029
+
1030
+ EmphUl = "_" !@Whitespace
1031
+ @StartList:a
1032
+ ( !"_" Inline:b { a << b }
1033
+ | StrongUl:b { a << b }
1034
+ )+
1035
+ "_"
1036
+ { emphasis a.join }
1037
+
1038
+ Strong = StrongStar | StrongUl
1039
+
1040
+ StrongStar = "**" !@Whitespace
1041
+ @StartList:a
1042
+ ( !"**" Inline:b { a << b } )+
1043
+ "**"
1044
+ { strong a.join }
1045
+
1046
+ StrongUl = "__" !@Whitespace
1047
+ @StartList:a
1048
+ ( !"__" Inline:b { a << b } )+
1049
+ "__"
1050
+ { strong a.join }
1051
+
1052
+ Strike = &{ strike? }
1053
+ "~~" !@Whitespace
1054
+ @StartList:a
1055
+ ( !"~~" Inline:b { a << b } )+
1056
+ "~~"
1057
+ { strike a.join }
1058
+
1059
+ Image = "!" ExplicitLinkWithLabel:a
1060
+ { "rdoc-image:#{a[:link]}:#{a[:label]}" }
1061
+
1062
+ Link = ExplicitLink | ReferenceLink | AutoLink
1063
+
1064
+ ReferenceLink = ReferenceLinkDouble | ReferenceLinkSingle
1065
+
1066
+ ReferenceLinkDouble = Label:content < Spnl > !"[]" Label:label
1067
+ { link_to content, label, text }
1068
+
1069
+ ReferenceLinkSingle = Label:content < (Spnl "[]")? >
1070
+ { link_to content, content, text }
1071
+
1072
+ ExplicitLink = ExplicitLinkWithLabel:a
1073
+ { "{#{a[:label]}}[#{rdoc_link_url_escape(a[:link])}]" }
1074
+
1075
+ ExplicitLinkWithLabel = Label:label "(" @Sp Source:link Spnl Title @Sp ")"
1076
+ { { label: label, link: link } }
1077
+
1078
+ Source = ( "<" < SourceContents > ">" | < SourceContents > )
1079
+ { text }
1080
+
1081
+ SourceContents = ( ( !"(" !")" !">" Nonspacechar )+ | "(" SourceContents ")")*
1082
+
1083
+ Title = ( TitleSingle | TitleDouble | "" ):a
1084
+ { a }
1085
+
1086
+ TitleSingle = "'" ( !( "'" @Sp ( ")" | @Newline ) ) . )* "'"
1087
+
1088
+ TitleDouble = "\"" ( !( "\"" @Sp ( ")" | @Newline ) ) . )* "\""
1089
+
1090
+ AutoLink = AutoLinkUrl | AutoLinkEmail
1091
+
1092
+ AutoLinkUrl = "<" < /[A-Za-z]+/ "://" ( !@Newline !">" . )+ > ">"
1093
+ { text }
1094
+
1095
+ AutoLinkEmail = "<" ("mailto:")? < /[\w+.\/!%~$-]+/i "@" ( !@Newline !">" . )+ > ">"
1096
+ { "mailto:#{text}" }
1097
+
1098
+ Reference = @NonindentSpace !"[]"
1099
+ Label:label ":" Spnl RefSrc:link RefTitle @BlankLine+
1100
+ { # TODO use title
1101
+ reference label, link
1102
+ nil
1103
+ }
1104
+
1105
+ Label = "[" ( !"^" &{ notes? } | &. &{ !notes? } )
1106
+ @StartList:a
1107
+ ( !"]" Inline:l { a << l } )*
1108
+ "]"
1109
+ { a.join.gsub(/\s+/, ' ') }
1110
+
1111
+ RefSrc = < Nonspacechar+ > { text }
1112
+
1113
+ RefTitle = ( RefTitleSingle | RefTitleDouble | RefTitleParens | EmptyTitle )
1114
+
1115
+ EmptyTitle = ""
1116
+
1117
+ RefTitleSingle = Spnl "'" < ( !( "'" @Sp @Newline | @Newline ) . )* > "'" { text }
1118
+
1119
+ RefTitleDouble = Spnl "\"" < ( !("\"" @Sp @Newline | @Newline) . )* > "\"" { text }
1120
+
1121
+ RefTitleParens = Spnl "(" < ( !(")" @Sp @Newline | @Newline) . )* > ")" { text }
1122
+
1123
+ References = ( Reference | SkipBlock )*
1124
+
1125
+ Ticks1 = "`" !"`"
1126
+ Ticks2 = "``" !"`"
1127
+ Ticks3 = "```" !"`"
1128
+ Ticks4 = "````" !"`"
1129
+ Ticks5 = "`````" !"`"
1130
+
1131
+ Code = ( Ticks1 < (
1132
+ ( !"`" Nonspacechar )+ | !Ticks1 /`+/ |
1133
+ !Ticks1 ( @Spacechar | @Newline !@BlankLine )
1134
+ )+ > Ticks1 |
1135
+ Ticks2 < (
1136
+ ( !"`" Nonspacechar )+ |
1137
+ !Ticks2 /`+/ |
1138
+ !Ticks2 ( @Spacechar | @Newline !@BlankLine )
1139
+ )+ > Ticks2 |
1140
+ Ticks3 < (
1141
+ ( !"`" Nonspacechar )+ |
1142
+ !Ticks3 /`+/ |
1143
+ !Ticks3 ( @Spacechar | @Newline !@BlankLine )
1144
+ )+ > Ticks3 |
1145
+ Ticks4 < (
1146
+ ( !"`" Nonspacechar )+ |
1147
+ !Ticks4 /`+/ |
1148
+ !Ticks4 ( @Spacechar | @Newline !@BlankLine )
1149
+ )+ > Ticks4 |
1150
+ Ticks5 < (
1151
+ ( !"`" Nonspacechar )+ |
1152
+ !Ticks5 /`+/ |
1153
+ !Ticks5 ( @Spacechar | @Newline !@BlankLine )
1154
+ )+ > Ticks5
1155
+ )
1156
+ { code text }
1157
+
1158
+ RawHtml = < HtmlBlockScript | HtmlTag > { html? ? text : '' }
1159
+ StrippedComment = HtmlComment { '' }
1160
+
1161
+ BlankLine = @Sp @Newline { "\n" }
1162
+
1163
+ Quoted = "\"" (!"\"" .)* "\"" | "'" (!"'" .)* "'"
1164
+ HtmlAttribute = (AlphanumericAscii | "-")+ Spnl ("=" Spnl (Quoted | (!">" Nonspacechar)+))? Spnl
1165
+ HtmlComment = "<!--" (!"-->" .)* "-->"
1166
+ HtmlTag = "<" Spnl "/"? AlphanumericAscii+ Spnl HtmlAttribute* "/"? Spnl ">"
1167
+ Eof = !.
1168
+ Nonspacechar = !@Spacechar !@Newline .
1169
+ Sp = @Spacechar*
1170
+ Spnl = @Sp (@Newline @Sp)?
1171
+ SpecialChar = /[~*_`&\[\]()<!#\\'"]/ | @ExtendedSpecialChar
1172
+ NormalChar = !( @SpecialChar | @Spacechar | @Newline ) .
1173
+ Digit = [0-9]
1174
+
1175
+ %literals = RDoc::Markdown::Literals
1176
+ Alphanumeric = %literals.Alphanumeric
1177
+ AlphanumericAscii = %literals.AlphanumericAscii
1178
+ BOM = %literals.BOM
1179
+ Newline = %literals.Newline
1180
+ Spacechar = %literals.Spacechar
1181
+
1182
+ HexEntity = /&#x/i < /[0-9a-fA-F]+/ > ";"
1183
+ { rdoc_escape([text.to_i(16)].pack('U')) }
1184
+ DecEntity = "&#" < /[0-9]+/ > ";"
1185
+ { rdoc_escape([text.to_i].pack('U')) }
1186
+ CharEntity = "&" </[A-Za-z0-9]+/ > ";"
1187
+ { if entity = HTML_ENTITIES[text] then
1188
+ rdoc_escape(entity.pack('U*'))
1189
+ else
1190
+ "&#{text};"
1191
+ end
1192
+ }
1193
+
1194
+ NonindentSpace = / {0,3}/
1195
+ Indent = /\t| /
1196
+ IndentedLine = Indent Line
1197
+ OptionallyIndentedLine = Indent? Line
1198
+
1199
+ # StartList starts a list data structure that can be added to with cons:
1200
+ StartList = &.
1201
+ { [] }
1202
+
1203
+ Line = @RawLine:a { a }
1204
+ RawLine = ( < /[^\r\n]*/ @Newline >
1205
+ | < .+ > @Eof ) { text }
1206
+
1207
+ SkipBlock = HtmlBlock
1208
+ | ( !"#" !SetextBottom1 !SetextBottom2 !@BlankLine @RawLine )+
1209
+ @BlankLine*
1210
+ | @BlankLine+
1211
+ | @RawLine
1212
+
1213
+ # Syntax extensions
1214
+
1215
+ ExtendedSpecialChar = &{ notes? } ( "^" )
1216
+
1217
+ NoteReference = &{ notes? }
1218
+ RawNoteReference:ref
1219
+ { note_for ref }
1220
+
1221
+ RawNoteReference = "[^" < ( !@Newline !"]" . )+ > "]" { text }
1222
+
1223
+ # TODO multiple paragraphs for a footnote
1224
+ Note = &{ notes? }
1225
+ @NonindentSpace RawNoteReference:ref ":" @Sp
1226
+ @StartList:a
1227
+ RawNoteBlock:i { a.concat i }
1228
+ ( &Indent RawNoteBlock:i { a.concat i } )*
1229
+ { @footnotes[ref] = paragraph a
1230
+
1231
+ nil
1232
+ }
1233
+
1234
+ InlineNote = &{ notes? }
1235
+ "^["
1236
+ @StartList:a
1237
+ ( !"]" Inline:l { a << l } )+
1238
+ "]"
1239
+ { if @note_order
1240
+ ref = [:inline, @note_order.length]
1241
+ @footnotes[ref] = paragraph a
1242
+
1243
+ note_for ref
1244
+ end
1245
+ }
1246
+
1247
+ Notes = ( Note | SkipBlock )*
1248
+
1249
+ RawNoteBlock = @StartList:a
1250
+ ( !@BlankLine !RawNoteReference OptionallyIndentedLine:l { a << l } )+
1251
+ ( < @BlankLine* > { a << text } )
1252
+ { a }
1253
+
1254
+ # Markdown extensions added by RDoc follow
1255
+
1256
+ CodeFence = &{ github? }
1257
+ Ticks3 (@Sp StrChunk:format)? @Sp @Newline? < (
1258
+ ( !"`" Nonspacechar )+ |
1259
+ !Ticks3 /`+/ |
1260
+ Spacechar |
1261
+ @Newline
1262
+ )+ > Ticks3 @Sp @Newline*
1263
+ { verbatim = RDoc::Markup::Verbatim.new text
1264
+ verbatim.format = format.intern if format.instance_of?(String)
1265
+ verbatim
1266
+ }
1267
+
1268
+ Table = &{ github? }
1269
+ TableHead:header TableLine:line TableRow+:body
1270
+ {
1271
+ table = RDoc::Markup::Table.new(header, line, body)
1272
+ parse_table_cells(table)
1273
+ }
1274
+
1275
+ TableHead = TableItem2+:items "|"? @Newline
1276
+ { items }
1277
+
1278
+ TableRow = ( ( TableItem:item1 TableItem2+:items { [item1, *items] } ):row | TableItem2+:row ) "|"? @Newline
1279
+ { row }
1280
+ TableItem2 = "|" TableItem
1281
+ TableItem = < /(?:\\.|[^|\n])+/ >
1282
+ { text.strip.gsub(/\\([|])/, '\1') }
1283
+
1284
+ TableLine = ( ( TableAlign:align1 TableAlign2+:aligns {[align1, *aligns] } ):line | TableAlign2+:line ) "|"? @Newline
1285
+ { line }
1286
+ TableAlign2 = "|" @Sp TableAlign
1287
+ TableAlign = < /:?-+:?/ > @Sp
1288
+ {
1289
+ text.start_with?(":") ?
1290
+ (text.end_with?(":") ? :center : :left) :
1291
+ (text.end_with?(":") ? :right : nil)
1292
+ }
1293
+
1294
+ DefinitionList = &{ definition_lists? }
1295
+ ( DefinitionListItem+:list )
1296
+ { RDoc::Markup::List.new :NOTE, *list.flatten }
1297
+
1298
+ DefinitionListItem = ( DefinitionListLabel+ ):label
1299
+ ( DefinitionListDefinition+ ):defns
1300
+ { list_items = []
1301
+ list_items <<
1302
+ RDoc::Markup::ListItem.new(label, defns.shift)
1303
+
1304
+ list_items.concat defns.map { |defn|
1305
+ RDoc::Markup::ListItem.new nil, defn
1306
+ } unless list_items.empty?
1307
+
1308
+ list_items
1309
+ }
1310
+
1311
+ DefinitionListLabel = Inline:label @Sp @Newline
1312
+ { label }
1313
+
1314
+ DefinitionListDefinition = @NonindentSpace ":" @Space Inlines:a @BlankLine+
1315
+ { paragraph a }