rdoc 5.1.0 → 6.13.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 (179) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTING.rdoc +5 -6
  3. data/ExampleMarkdown.md +2 -0
  4. data/ExampleRDoc.rdoc +2 -0
  5. data/History.rdoc +68 -66
  6. data/LEGAL.rdoc +1 -1
  7. data/LICENSE.rdoc +2 -0
  8. data/README.rdoc +18 -6
  9. data/RI.md +842 -0
  10. data/TODO.rdoc +8 -7
  11. data/exe/rdoc +0 -1
  12. data/lib/rdoc/{alias.rb → code_object/alias.rb} +4 -12
  13. data/lib/rdoc/{anon_class.rb → code_object/anon_class.rb} +1 -2
  14. data/lib/rdoc/{any_method.rb → code_object/any_method.rb} +83 -26
  15. data/lib/rdoc/{attr.rb → code_object/attr.rb} +5 -9
  16. data/lib/rdoc/{class_module.rb → code_object/class_module.rb} +112 -24
  17. data/lib/rdoc/{constant.rb → code_object/constant.rb} +4 -5
  18. data/lib/rdoc/{context → code_object/context}/section.rb +13 -83
  19. data/lib/rdoc/{context.rb → code_object/context.rb} +69 -70
  20. data/lib/rdoc/{extend.rb → code_object/extend.rb} +1 -2
  21. data/lib/rdoc/{ghost_method.rb → code_object/ghost_method.rb} +1 -2
  22. data/lib/rdoc/{include.rb → code_object/include.rb} +1 -2
  23. data/lib/rdoc/{meta_method.rb → code_object/meta_method.rb} +1 -2
  24. data/lib/rdoc/{method_attr.rb → code_object/method_attr.rb} +22 -31
  25. data/lib/rdoc/{mixin.rb → code_object/mixin.rb} +1 -2
  26. data/lib/rdoc/{normal_class.rb → code_object/normal_class.rb} +4 -5
  27. data/lib/rdoc/{normal_module.rb → code_object/normal_module.rb} +2 -3
  28. data/lib/rdoc/{require.rb → code_object/require.rb} +2 -3
  29. data/lib/rdoc/{single_class.rb → code_object/single_class.rb} +6 -2
  30. data/lib/rdoc/{top_level.rb → code_object/top_level.rb} +22 -32
  31. data/lib/rdoc/code_object.rb +8 -41
  32. data/lib/rdoc/code_objects.rb +2 -3
  33. data/lib/rdoc/comment.rb +48 -41
  34. data/lib/rdoc/cross_reference.rb +77 -33
  35. data/lib/rdoc/encoding.rb +50 -38
  36. data/lib/rdoc/erb_partial.rb +2 -3
  37. data/lib/rdoc/erbio.rb +4 -5
  38. data/lib/rdoc/generator/darkfish.rb +178 -125
  39. data/lib/rdoc/generator/json_index.rb +9 -22
  40. data/lib/rdoc/generator/markup.rb +6 -17
  41. data/lib/rdoc/generator/pot/message_extractor.rb +4 -4
  42. data/lib/rdoc/generator/pot/po.rb +3 -3
  43. data/lib/rdoc/generator/pot/po_entry.rb +12 -12
  44. data/lib/rdoc/generator/pot.rb +4 -8
  45. data/lib/rdoc/generator/ri.rb +1 -2
  46. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +2 -2
  47. data/lib/rdoc/generator/template/darkfish/_head.rhtml +35 -12
  48. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +1 -5
  49. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +7 -7
  50. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +7 -7
  51. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +6 -6
  52. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +19 -10
  53. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +26 -6
  54. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +4 -9
  55. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +1 -1
  56. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
  57. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +27 -6
  58. data/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
  59. data/lib/rdoc/generator/template/darkfish/class.rhtml +125 -78
  60. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +430 -339
  61. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  62. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  63. data/lib/rdoc/generator/template/darkfish/index.rhtml +13 -13
  64. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +51 -92
  65. data/lib/rdoc/generator/template/darkfish/js/search.js +35 -34
  66. data/lib/rdoc/generator/template/darkfish/page.rhtml +5 -5
  67. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +10 -8
  68. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +20 -18
  69. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +32 -20
  70. data/lib/rdoc/generator/template/json_index/js/navigation.js +12 -49
  71. data/lib/rdoc/generator/template/json_index/js/searcher.js +6 -6
  72. data/lib/rdoc/generator.rb +6 -6
  73. data/lib/rdoc/i18n/locale.rb +1 -1
  74. data/lib/rdoc/i18n/text.rb +5 -5
  75. data/lib/rdoc/i18n.rb +4 -4
  76. data/lib/rdoc/known_classes.rb +6 -5
  77. data/lib/rdoc/markdown/entities.rb +1 -2
  78. data/lib/rdoc/markdown/literals.kpeg +1 -2
  79. data/lib/rdoc/markdown/literals.rb +99 -50
  80. data/lib/rdoc/markdown.kpeg +115 -58
  81. data/lib/rdoc/markdown.rb +1584 -902
  82. data/lib/rdoc/markup/attr_changer.rb +1 -2
  83. data/lib/rdoc/markup/attr_span.rb +9 -4
  84. data/lib/rdoc/markup/attribute_manager.rb +118 -57
  85. data/lib/rdoc/markup/attributes.rb +7 -8
  86. data/lib/rdoc/markup/blank_line.rb +1 -2
  87. data/lib/rdoc/markup/block_quote.rb +1 -2
  88. data/lib/rdoc/markup/document.rb +1 -2
  89. data/lib/rdoc/markup/formatter.rb +44 -37
  90. data/lib/rdoc/markup/hard_break.rb +1 -2
  91. data/lib/rdoc/markup/heading.rb +11 -6
  92. data/lib/rdoc/markup/include.rb +1 -2
  93. data/lib/rdoc/markup/indented_paragraph.rb +1 -2
  94. data/lib/rdoc/markup/list.rb +1 -2
  95. data/lib/rdoc/markup/list_item.rb +1 -2
  96. data/lib/rdoc/markup/paragraph.rb +1 -2
  97. data/lib/rdoc/markup/parser.rb +90 -48
  98. data/lib/rdoc/markup/pre_process.rb +38 -11
  99. data/lib/rdoc/markup/raw.rb +1 -2
  100. data/lib/rdoc/markup/regexp_handling.rb +40 -0
  101. data/lib/rdoc/markup/rule.rb +1 -2
  102. data/lib/rdoc/markup/table.rb +56 -0
  103. data/lib/rdoc/markup/to_ansi.rb +1 -2
  104. data/lib/rdoc/markup/to_bs.rb +30 -5
  105. data/lib/rdoc/markup/to_html.rb +95 -40
  106. data/lib/rdoc/markup/to_html_crossref.rb +108 -43
  107. data/lib/rdoc/markup/to_html_snippet.rb +13 -11
  108. data/lib/rdoc/markup/to_joined_paragraph.rb +6 -32
  109. data/lib/rdoc/markup/to_label.rb +11 -12
  110. data/lib/rdoc/markup/to_markdown.rb +13 -14
  111. data/lib/rdoc/markup/to_rdoc.rb +49 -31
  112. data/lib/rdoc/markup/to_table_of_contents.rb +2 -2
  113. data/lib/rdoc/markup/to_test.rb +1 -2
  114. data/lib/rdoc/markup/to_tt_only.rb +3 -4
  115. data/lib/rdoc/markup/verbatim.rb +1 -2
  116. data/lib/rdoc/markup.rb +64 -694
  117. data/lib/rdoc/options.rb +226 -44
  118. data/lib/rdoc/parser/c.rb +231 -246
  119. data/lib/rdoc/parser/changelog.rb +169 -23
  120. data/lib/rdoc/parser/markdown.rb +1 -3
  121. data/lib/rdoc/parser/prism_ruby.rb +1092 -0
  122. data/lib/rdoc/parser/rd.rb +1 -2
  123. data/lib/rdoc/parser/ripper_state_lex.rb +302 -0
  124. data/lib/rdoc/parser/ruby.rb +695 -478
  125. data/lib/rdoc/parser/ruby_tools.rb +33 -36
  126. data/lib/rdoc/parser/simple.rb +4 -4
  127. data/lib/rdoc/parser/text.rb +1 -2
  128. data/lib/rdoc/parser.rb +37 -42
  129. data/lib/rdoc/rd/block_parser.rb +708 -57
  130. data/lib/rdoc/rd/block_parser.ry +15 -11
  131. data/lib/rdoc/rd/inline.rb +5 -6
  132. data/lib/rdoc/rd/inline_parser.rb +787 -140
  133. data/lib/rdoc/rd/inline_parser.ry +1 -1
  134. data/lib/rdoc/rd.rb +4 -5
  135. data/lib/rdoc/rdoc.rb +72 -87
  136. data/lib/rdoc/ri/driver.rb +236 -152
  137. data/lib/rdoc/ri/formatter.rb +1 -1
  138. data/lib/rdoc/ri/paths.rb +4 -18
  139. data/lib/rdoc/ri/store.rb +1 -2
  140. data/lib/rdoc/ri/task.rb +2 -2
  141. data/lib/rdoc/ri.rb +5 -6
  142. data/lib/rdoc/rubygems_hook.rb +98 -20
  143. data/lib/rdoc/servlet.rb +30 -20
  144. data/lib/rdoc/stats/normal.rb +24 -18
  145. data/lib/rdoc/stats/quiet.rb +1 -2
  146. data/lib/rdoc/stats/verbose.rb +1 -3
  147. data/lib/rdoc/stats.rb +6 -7
  148. data/lib/rdoc/store.rb +84 -55
  149. data/lib/rdoc/task.rb +35 -10
  150. data/lib/rdoc/text.rb +40 -27
  151. data/lib/rdoc/token_stream.rb +56 -34
  152. data/lib/rdoc/tom_doc.rb +18 -19
  153. data/lib/rdoc/version.rb +10 -0
  154. data/lib/rdoc.rb +80 -56
  155. data/lib/rubygems_plugin.rb +23 -0
  156. data/man/ri.1 +247 -0
  157. metadata +45 -99
  158. data/.document +0 -5
  159. data/.gitignore +0 -13
  160. data/.travis.yml +0 -24
  161. data/Gemfile +0 -3
  162. data/RI.rdoc +0 -57
  163. data/Rakefile +0 -133
  164. data/bin/console +0 -7
  165. data/bin/setup +0 -6
  166. data/lib/gauntlet_rdoc.rb +0 -82
  167. data/lib/rdoc/generator/template/darkfish/.document +0 -0
  168. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +0 -19
  169. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +0 -9
  170. data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -4
  171. data/lib/rdoc/generator/template/json_index/.document +0 -1
  172. data/lib/rdoc/markup/formatter_test_case.rb +0 -764
  173. data/lib/rdoc/markup/inline.rb +0 -2
  174. data/lib/rdoc/markup/special.rb +0 -41
  175. data/lib/rdoc/markup/text_formatter_test_case.rb +0 -115
  176. data/lib/rdoc/ruby_lex.rb +0 -1367
  177. data/lib/rdoc/ruby_token.rb +0 -461
  178. data/lib/rdoc/test_case.rb +0 -204
  179. data/rdoc.gemspec +0 -57
@@ -2,13 +2,14 @@
2
2
 
3
3
  %% header {
4
4
  # coding: UTF-8
5
+ # frozen_string_literal: true
5
6
  # :markup: markdown
6
7
 
7
8
  ##
8
9
  # RDoc::Markdown as described by the [markdown syntax][syntax].
9
10
  #
10
11
  # To choose Markdown as your only default format see
11
- # RDoc::Options@Saved+Options for instructions on setting up a `.doc_options`
12
+ # RDoc::Options@Saved+Options for instructions on setting up a `.rdoc_options`
12
13
  # file to store your project default.
13
14
  #
14
15
  # ## Usage
@@ -84,6 +85,18 @@
84
85
  # : A little insect that is known
85
86
  # to enjoy picnics
86
87
  #
88
+ # ### Strike
89
+ #
90
+ # Example:
91
+ #
92
+ # ```
93
+ # This is ~~striked~~.
94
+ # ```
95
+ #
96
+ # Produces:
97
+ #
98
+ # This is ~~striked~~.
99
+ #
87
100
  # ### Github
88
101
  #
89
102
  # The #github extension enables a partial set of [Github Flavored Markdown]
@@ -163,9 +176,9 @@
163
176
  # The port to kpeg was performed by Eric Hodel and Evan Phoenix
164
177
  #
165
178
  # [dingus]: http://daringfireball.net/projects/markdown/dingus
166
- # [GFM]: http://github.github.com/github-flavored-markdown/
179
+ # [GFM]: https://github.github.com/gfm/
167
180
  # [pegmarkdown]: https://github.com/jgm/peg-markdown
168
- # [PHPE]: http://michelf.com/projects/php-markdown/extra/#def-list
181
+ # [PHPE]: https://michelf.ca/projects/php-markdown/extra/#def-list
169
182
  # [syntax]: http://daringfireball.net/projects/markdown/syntax
170
183
  #--
171
184
  # Last updated to jgm/peg-markdown commit 8f8fc22ef0
@@ -174,11 +187,11 @@
174
187
 
175
188
  %% {
176
189
 
177
- require 'rdoc'
178
- require 'rdoc/markup/to_joined_paragraph'
179
- require 'rdoc/markdown/entities'
190
+ require_relative '../rdoc'
191
+ require_relative 'markup/to_joined_paragraph'
192
+ require_relative 'markdown/entities'
180
193
 
181
- require 'rdoc/markdown/literals'
194
+ require_relative 'markdown/literals'
182
195
 
183
196
  ##
184
197
  # Supported extensions
@@ -193,6 +206,7 @@
193
206
  :github,
194
207
  :html,
195
208
  :notes,
209
+ :strike,
196
210
  ]
197
211
 
198
212
  # :section: Extensions
@@ -243,6 +257,11 @@
243
257
 
244
258
  extension :notes
245
259
 
260
+ ##
261
+ # Enables the strike extension
262
+
263
+ extension :strike
264
+
246
265
  # :section:
247
266
 
248
267
  ##
@@ -331,7 +350,7 @@
331
350
  # with the linking `text` (usually whitespace).
332
351
 
333
352
  def link_to content, label = content, text = nil
334
- raise 'enable notes extension' if
353
+ raise ParseError, 'enable notes extension' if
335
354
  content.start_with? '^' and label.equal? content
336
355
 
337
356
  if ref = @references[label] then
@@ -430,7 +449,7 @@
430
449
 
431
450
  @note_order.each_with_index do |ref, index|
432
451
  label = index + 1
433
- note = @footnotes[ref]
452
+ note = @footnotes[ref] or raise ParseError, "footnote [^#{ref}] not found"
434
453
 
435
454
  link = "{^#{label}}[rdoc-label:footmark-#{label}:foottext-#{label}] "
436
455
  note.parts.unshift link
@@ -466,6 +485,17 @@
466
485
  "<b>#{text}</b>"
467
486
  end
468
487
  end
488
+
489
+ ##
490
+ # Wraps `text` in strike markup for rdoc inline formatting
491
+
492
+ def strike text
493
+ if text =~ /\A[a-z\d.\/-]+\z/i then
494
+ "~#{text}~"
495
+ else
496
+ "<s>#{text}</s>"
497
+ end
498
+ end
469
499
  }
470
500
 
471
501
  root = Doc
@@ -476,6 +506,7 @@ Block = @BlankLine*
476
506
  ( BlockQuote
477
507
  | Verbatim
478
508
  | CodeFence
509
+ | Table
479
510
  | Note
480
511
  | Reference
481
512
  | HorizontalRule
@@ -494,27 +525,27 @@ Para = @NonindentSpace Inlines:a @BlankLine+
494
525
  Plain = Inlines:a
495
526
  { paragraph a }
496
527
 
497
- AtxInline = !@Newline !(@Sp? /#*/ @Sp @Newline) Inline
528
+ AtxInline = !@Newline !(@Sp /#*/ @Sp @Newline) Inline
498
529
 
499
530
  AtxStart = < /\#{1,6}/ >
500
531
  { text.length }
501
532
 
502
- AtxHeading = AtxStart:s @Sp? AtxInline+:a (@Sp? /#*/ @Sp)? @Newline
533
+ AtxHeading = AtxStart:s @Spacechar+ AtxInline+:a (@Sp /#*/ @Sp)? @Newline
503
534
  { RDoc::Markup::Heading.new(s, a.join) }
504
535
 
505
536
  SetextHeading = SetextHeading1 | SetextHeading2
506
537
 
507
- SetextBottom1 = /={3,}/ @Newline
538
+ SetextBottom1 = /={1,}/ @Newline
508
539
 
509
- SetextBottom2 = /-{3,}/ @Newline
540
+ SetextBottom2 = /-{1,}/ @Newline
510
541
 
511
542
  SetextHeading1 = &(@RawLine SetextBottom1)
512
- @StartList:a ( !@Endline Inline:b { a << b } )+ @Sp? @Newline
543
+ @StartList:a ( !@Endline Inline:b { a << b } )+ @Sp @Newline
513
544
  SetextBottom1
514
545
  { RDoc::Markup::Heading.new(1, a.join) }
515
546
 
516
547
  SetextHeading2 = &(@RawLine SetextBottom2)
517
- @StartList:a ( !@Endline Inline:b { a << b })+ @Sp? @Newline
548
+ @StartList:a ( !@Endline Inline:b { a << b })+ @Sp @Newline
518
549
  SetextBottom2
519
550
  { RDoc::Markup::Heading.new(2, a.join) }
520
551
 
@@ -733,6 +764,9 @@ HtmlBlockOpenScript = "<" Spnl ("script" | "SCRIPT") Spnl HtmlAttribute* ">"
733
764
  HtmlBlockCloseScript = "<" Spnl "/" ("script" | "SCRIPT") Spnl ">"
734
765
  HtmlBlockScript = HtmlBlockOpenScript (!HtmlBlockCloseScript .)* HtmlBlockCloseScript
735
766
 
767
+ HtmlBlockOpenHead = "<" Spnl ("head" | "HEAD") Spnl HtmlAttribute* ">"
768
+ HtmlBlockCloseHead = "<" Spnl "/" ("head" | "HEAD") Spnl ">"
769
+ HtmlBlockHead = HtmlBlockOpenHead (!HtmlBlockCloseHead .)* HtmlBlockCloseHead
736
770
 
737
771
  HtmlBlockInTags = HtmlAnchor
738
772
  | HtmlBlockAddress
@@ -768,6 +802,7 @@ HtmlBlockInTags = HtmlAnchor
768
802
  | HtmlBlockThead
769
803
  | HtmlBlockTr
770
804
  | HtmlBlockScript
805
+ | HtmlBlockHead
771
806
 
772
807
  HtmlBlock = < ( HtmlBlockInTags | HtmlComment | HtmlBlockSelfClosing | HtmlUnclosed) >
773
808
  @BlankLine+
@@ -862,7 +897,8 @@ StyleBlock = < InStyleTags >
862
897
  end }
863
898
 
864
899
  Inlines = ( !@Endline Inline:i { i }
865
- | @Endline:c &Inline { c } )+:chunks @Endline?
900
+ | @Endline:c !( &{ github? } Ticks3 /[^`\n]*$/ )
901
+ &Inline { c } )+:chunks @Endline?
866
902
  { chunks }
867
903
 
868
904
  Inline = Str
@@ -871,6 +907,7 @@ Inline = Str
871
907
  | @Space
872
908
  | Strong
873
909
  | Emph
910
+ | Strike
874
911
  | Image
875
912
  | Link
876
913
  | NoteReference
@@ -896,7 +933,7 @@ Entity = ( HexEntity | DecEntity | CharEntity ):a { a }
896
933
  Endline = @LineBreak | @TerminalEndline | @NormalEndline
897
934
 
898
935
  NormalEndline = @Sp @Newline !@BlankLine !">" !AtxStart
899
- !(Line /={3,}|-{3,}=/ @Newline)
936
+ !(Line /={1,}|-{1,}/ @Newline)
900
937
  { "\n" }
901
938
 
902
939
  TerminalEndline = @Sp @Newline @Eof
@@ -916,50 +953,47 @@ UlLine = < /_{4,}/ > { text } |
916
953
 
917
954
  Emph = EmphStar | EmphUl
918
955
 
919
- OneStarOpen = !StarLine "*" !@Spacechar !@Newline
920
- OneStarClose = !@Spacechar !@Newline Inline:a "*"
921
- { a }
956
+ Whitespace = @Spacechar | @Newline
922
957
 
923
- EmphStar = OneStarOpen
958
+ EmphStar = "*" !@Whitespace
924
959
  @StartList:a
925
- ( !OneStarClose Inline:l { a << l } )*
926
- OneStarClose:l { a << l }
960
+ ( !"*" Inline:b { a << b }
961
+ | StrongStar:b { a << b }
962
+ )+
963
+ "*"
927
964
  { emphasis a.join }
928
965
 
929
- OneUlOpen = !UlLine "_" !@Spacechar !@Newline
930
- OneUlClose = !@Spacechar !@Newline Inline:a "_" # !Alphanumeric # TODO check
931
- { a }
932
-
933
- EmphUl = OneUlOpen
966
+ EmphUl = "_" !@Whitespace
934
967
  @StartList:a
935
- ( !OneUlClose Inline:l { a << l } )*
936
- OneUlClose:l { a << l }
968
+ ( !"_" Inline:b { a << b }
969
+ | StrongUl:b { a << b }
970
+ )+
971
+ "_"
937
972
  { emphasis a.join }
938
973
 
939
974
  Strong = StrongStar | StrongUl
940
975
 
941
- TwoStarOpen = !StarLine "**" !@Spacechar !@Newline
942
- TwoStarClose = !@Spacechar !@Newline Inline:a "**" { a }
943
-
944
- StrongStar = TwoStarOpen
976
+ StrongStar = "**" !@Whitespace
945
977
  @StartList:a
946
- ( !TwoStarClose Inline:l { a << l } )*
947
- TwoStarClose:l { a << l }
978
+ ( !"**" Inline:b { a << b } )+
979
+ "**"
948
980
  { strong a.join }
949
981
 
950
- TwoUlOpen = !UlLine "__" !@Spacechar !@Newline
951
- TwoUlClose = !@Spacechar !@Newline Inline:a "__" # !Alphanumeric # TODO check
952
- { a }
982
+ StrongUl = "__" !@Whitespace
983
+ @StartList:a
984
+ ( !"__" Inline:b { a << b } )+
985
+ "__"
986
+ { strong a.join }
953
987
 
954
- StrongUl = TwoUlOpen
955
- @StartList:a
956
- ( !TwoUlClose Inline:i { a << i } )*
957
- TwoUlClose:l { a << l }
958
- { strong a.join }
988
+ Strike = &{ strike? }
989
+ "~~" !@Whitespace
990
+ @StartList:a
991
+ ( !"~~" Inline:b { a << b } )+
992
+ "~~"
993
+ { strike a.join }
959
994
 
960
- # TODO alt text support
961
- Image = "!" ( ExplicitLink | ReferenceLink ):a
962
- { "rdoc-image:#{a[/\[(.*)\]/, 1]}" }
995
+ Image = "!" ExplicitLinkWithLabel:a
996
+ { "rdoc-image:#{a[:link]}:#{a[:label]}" }
963
997
 
964
998
  Link = ExplicitLink | ReferenceLink | AutoLink
965
999
 
@@ -971,14 +1005,16 @@ ReferenceLinkDouble = Label:content < Spnl > !"[]" Label:label
971
1005
  ReferenceLinkSingle = Label:content < (Spnl "[]")? >
972
1006
  { link_to content, content, text }
973
1007
 
974
- ExplicitLink = Label:l Spnl "(" @Sp Source:s Spnl Title @Sp ")"
975
- { "{#{l}}[#{s}]" }
1008
+ ExplicitLink = ExplicitLinkWithLabel:a
1009
+ { "{#{a[:label]}}[#{a[:link]}]" }
1010
+
1011
+ ExplicitLinkWithLabel = Label:label "(" @Sp Source:link Spnl Title @Sp ")"
1012
+ { { label: label, link: link } }
976
1013
 
977
1014
  Source = ( "<" < SourceContents > ">" | < SourceContents > )
978
1015
  { text }
979
1016
 
980
1017
  SourceContents = ( ( !"(" !")" !">" Nonspacechar )+ | "(" SourceContents ")")*
981
- | ""
982
1018
 
983
1019
  Title = ( TitleSingle | TitleDouble | "" ):a
984
1020
  { a }
@@ -1068,7 +1104,7 @@ Eof = !.
1068
1104
  Nonspacechar = !@Spacechar !@Newline .
1069
1105
  Sp = @Spacechar*
1070
1106
  Spnl = @Sp (@Newline @Sp)?
1071
- SpecialChar = /[*_`&\[\]()<!#\\'"]/ | @ExtendedSpecialChar
1107
+ SpecialChar = /[~*_`&\[\]()<!#\\'"]/ | @ExtendedSpecialChar
1072
1108
  NormalChar = !( @SpecialChar | @Spacechar | @Newline ) .
1073
1109
  Digit = [0-9]
1074
1110
 
@@ -1077,7 +1113,6 @@ Alphanumeric = %literals.Alphanumeric
1077
1113
  AlphanumericAscii = %literals.AlphanumericAscii
1078
1114
  BOM = %literals.BOM
1079
1115
  Newline = %literals.Newline
1080
- NonAlphanumeric = %literals.NonAlphanumeric
1081
1116
  Spacechar = %literals.Spacechar
1082
1117
 
1083
1118
  HexEntity = /&#x/i < /[0-9a-fA-F]+/ > ";"
@@ -1102,7 +1137,7 @@ StartList = &.
1102
1137
  { [] }
1103
1138
 
1104
1139
  Line = @RawLine:a { a }
1105
- RawLine = ( < (!"\r" !"\n" .)* @Newline >
1140
+ RawLine = ( < /[^\r\n]*/ @Newline >
1106
1141
  | < .+ > @Eof ) { text }
1107
1142
 
1108
1143
  SkipBlock = HtmlBlock
@@ -1137,8 +1172,7 @@ InlineNote = &{ notes? }
1137
1172
  @StartList:a
1138
1173
  ( !"]" Inline:l { a << l } )+
1139
1174
  "]"
1140
- {
1141
- ref = [:inline, @note_order.length]
1175
+ { ref = [:inline, @note_order.length]
1142
1176
  @footnotes[ref] = paragraph a
1143
1177
 
1144
1178
  note_for ref
@@ -1147,7 +1181,7 @@ InlineNote = &{ notes? }
1147
1181
  Notes = ( Note | SkipBlock )*
1148
1182
 
1149
1183
  RawNoteBlock = @StartList:a
1150
- ( !@BlankLine OptionallyIndentedLine:l { a << l } )+
1184
+ ( !@BlankLine !RawNoteReference OptionallyIndentedLine:l { a << l } )+
1151
1185
  ( < @BlankLine* > { a << text } )
1152
1186
  { a }
1153
1187
 
@@ -1161,10 +1195,33 @@ CodeFence = &{ github? }
1161
1195
  @Newline
1162
1196
  )+ > Ticks3 @Sp @Newline*
1163
1197
  { verbatim = RDoc::Markup::Verbatim.new text
1164
- verbatim.format = format.intern if format
1198
+ verbatim.format = format.intern if format.instance_of?(String)
1165
1199
  verbatim
1166
1200
  }
1167
1201
 
1202
+ Table = &{ github? }
1203
+ TableHead:header TableLine:line TableRow+:body
1204
+ { table = RDoc::Markup::Table.new(header, line, body) }
1205
+
1206
+ TableHead = TableItem2+:items "|"? @Newline
1207
+ { items }
1208
+
1209
+ TableRow = ( ( TableItem:item1 TableItem2*:items { [item1, *items] } ):row | TableItem2+:row ) "|"? @Newline
1210
+ { row }
1211
+ TableItem2 = "|" TableItem
1212
+ TableItem = < /(?:\\.|[^|\n])+/ >
1213
+ { text.strip.gsub(/\\(.)/, '\1') }
1214
+
1215
+ TableLine = ( ( TableAlign:align1 TableAlign2*:aligns {[align1, *aligns] } ):line | TableAlign2+:line ) "|"? @Newline
1216
+ { line }
1217
+ TableAlign2 = "|" @Sp TableAlign
1218
+ TableAlign = < /:?-+:?/ > @Sp
1219
+ {
1220
+ text.start_with?(":") ?
1221
+ (text.end_with?(":") ? :center : :left) :
1222
+ (text.end_with?(":") ? :right : nil)
1223
+ }
1224
+
1168
1225
  DefinitionList = &{ definition_lists? }
1169
1226
  ( DefinitionListItem+:list )
1170
1227
  { RDoc::Markup::List.new :NOTE, *list.flatten }
@@ -1182,7 +1239,7 @@ DefinitionListItem = ( DefinitionListLabel+ ):label
1182
1239
  list_items
1183
1240
  }
1184
1241
 
1185
- DefinitionListLabel = StrChunk:label @Sp @Newline
1242
+ DefinitionListLabel = Inline:label @Sp @Newline
1186
1243
  { label }
1187
1244
 
1188
1245
  DefinitionListDefinition = @NonindentSpace ":" @Space Inlines:a @BlankLine+