rdoc 6.4.0 → 6.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.rdoc +1 -2
  3. data/LEGAL.rdoc +1 -1
  4. data/README.rdoc +2 -2
  5. data/TODO.rdoc +1 -1
  6. data/exe/rdoc +0 -1
  7. data/lib/rdoc/alias.rb +0 -1
  8. data/lib/rdoc/anon_class.rb +0 -1
  9. data/lib/rdoc/any_method.rb +17 -2
  10. data/lib/rdoc/attr.rb +0 -1
  11. data/lib/rdoc/class_module.rb +0 -1
  12. data/lib/rdoc/code_objects.rb +1 -2
  13. data/lib/rdoc/comment.rb +20 -41
  14. data/lib/rdoc/constant.rb +0 -1
  15. data/lib/rdoc/context/section.rb +2 -1
  16. data/lib/rdoc/context.rb +1 -3
  17. data/lib/rdoc/cross_reference.rb +17 -2
  18. data/lib/rdoc/encoding.rb +1 -6
  19. data/lib/rdoc/erb_partial.rb +0 -1
  20. data/lib/rdoc/erbio.rb +2 -7
  21. data/lib/rdoc/extend.rb +0 -1
  22. data/lib/rdoc/generator/darkfish.rb +2 -6
  23. data/lib/rdoc/generator/json_index.rb +2 -2
  24. data/lib/rdoc/generator/markup.rb +1 -2
  25. data/lib/rdoc/generator/ri.rb +0 -1
  26. data/lib/rdoc/generator/template/darkfish/_head.rhtml +10 -10
  27. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +27 -3
  28. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +22 -2
  29. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +1 -1
  30. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +25 -4
  31. data/lib/rdoc/generator/template/darkfish/class.rhtml +28 -20
  32. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +44 -7
  33. data/lib/rdoc/generator/template/darkfish/index.rhtml +1 -1
  34. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +14 -1
  35. data/lib/rdoc/generator/template/darkfish/js/search.js +4 -4
  36. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +7 -6
  37. data/lib/rdoc/generator/template/json_index/js/navigation.js +8 -8
  38. data/lib/rdoc/generator.rb +5 -5
  39. data/lib/rdoc/ghost_method.rb +0 -1
  40. data/lib/rdoc/i18n.rb +1 -1
  41. data/lib/rdoc/include.rb +0 -1
  42. data/lib/rdoc/known_classes.rb +5 -4
  43. data/lib/rdoc/markdown/entities.rb +0 -1
  44. data/lib/rdoc/markdown/literals.rb +98 -40
  45. data/lib/rdoc/markdown.kpeg +26 -19
  46. data/lib/rdoc/markdown.rb +326 -227
  47. data/lib/rdoc/markup/attr_changer.rb +0 -1
  48. data/lib/rdoc/markup/attr_span.rb +0 -1
  49. data/lib/rdoc/markup/attribute_manager.rb +29 -36
  50. data/lib/rdoc/markup/attributes.rb +0 -1
  51. data/lib/rdoc/markup/blank_line.rb +0 -1
  52. data/lib/rdoc/markup/block_quote.rb +0 -1
  53. data/lib/rdoc/markup/document.rb +0 -1
  54. data/lib/rdoc/markup/formatter.rb +0 -1
  55. data/lib/rdoc/markup/hard_break.rb +0 -1
  56. data/lib/rdoc/markup/heading.rb +0 -1
  57. data/lib/rdoc/markup/include.rb +0 -1
  58. data/lib/rdoc/markup/indented_paragraph.rb +0 -1
  59. data/lib/rdoc/markup/list.rb +0 -1
  60. data/lib/rdoc/markup/list_item.rb +0 -1
  61. data/lib/rdoc/markup/paragraph.rb +0 -1
  62. data/lib/rdoc/markup/parser.rb +12 -6
  63. data/lib/rdoc/markup/raw.rb +0 -1
  64. data/lib/rdoc/markup/regexp_handling.rb +0 -1
  65. data/lib/rdoc/markup/rule.rb +0 -1
  66. data/lib/rdoc/markup/to_ansi.rb +0 -1
  67. data/lib/rdoc/markup/to_html.rb +21 -16
  68. data/lib/rdoc/markup/to_html_crossref.rb +0 -1
  69. data/lib/rdoc/markup/to_html_snippet.rb +0 -1
  70. data/lib/rdoc/markup/to_joined_paragraph.rb +2 -3
  71. data/lib/rdoc/markup/to_label.rb +1 -2
  72. data/lib/rdoc/markup/to_markdown.rb +0 -1
  73. data/lib/rdoc/markup/to_rdoc.rb +3 -21
  74. data/lib/rdoc/markup/to_table_of_contents.rb +0 -1
  75. data/lib/rdoc/markup/to_test.rb +0 -1
  76. data/lib/rdoc/markup/to_tt_only.rb +0 -1
  77. data/lib/rdoc/markup/verbatim.rb +0 -1
  78. data/lib/rdoc/markup.rb +35 -667
  79. data/lib/rdoc/meta_method.rb +0 -1
  80. data/lib/rdoc/method_attr.rb +1 -2
  81. data/lib/rdoc/mixin.rb +0 -1
  82. data/lib/rdoc/normal_class.rb +1 -2
  83. data/lib/rdoc/normal_module.rb +1 -2
  84. data/lib/rdoc/options.rb +36 -20
  85. data/lib/rdoc/parser/c.rb +89 -101
  86. data/lib/rdoc/parser/changelog.rb +0 -1
  87. data/lib/rdoc/parser/markdown.rb +0 -2
  88. data/lib/rdoc/parser/rd.rb +0 -1
  89. data/lib/rdoc/parser/ripper_state_lex.rb +1 -1
  90. data/lib/rdoc/parser/ruby.rb +29 -14
  91. data/lib/rdoc/parser/ruby_tools.rb +0 -2
  92. data/lib/rdoc/parser/text.rb +0 -1
  93. data/lib/rdoc/parser.rb +19 -2
  94. data/lib/rdoc/rd/block_parser.rb +666 -12
  95. data/lib/rdoc/rd/block_parser.ry +13 -9
  96. data/lib/rdoc/rd/inline.rb +0 -1
  97. data/lib/rdoc/rd/inline_parser.rb +3 -1
  98. data/lib/rdoc/rd.rb +3 -4
  99. data/lib/rdoc/rdoc.rb +19 -7
  100. data/lib/rdoc/require.rb +0 -1
  101. data/lib/rdoc/ri/driver.rb +20 -86
  102. data/lib/rdoc/ri/store.rb +0 -1
  103. data/lib/rdoc/ri.rb +4 -5
  104. data/lib/rdoc/rubygems_hook.rb +1 -1
  105. data/lib/rdoc/servlet.rb +1 -1
  106. data/lib/rdoc/single_class.rb +5 -1
  107. data/lib/rdoc/stats/quiet.rb +0 -1
  108. data/lib/rdoc/stats/verbose.rb +0 -2
  109. data/lib/rdoc/stats.rb +3 -4
  110. data/lib/rdoc/store.rb +4 -4
  111. data/lib/rdoc/task.rb +31 -5
  112. data/lib/rdoc/token_stream.rb +0 -1
  113. data/lib/rdoc/top_level.rb +0 -1
  114. data/lib/rdoc/version.rb +3 -1
  115. data/lib/rdoc.rb +46 -46
  116. metadata +9 -11
  117. data/Gemfile +0 -12
  118. data/Rakefile +0 -107
  119. data/bin/console +0 -7
  120. data/bin/setup +0 -6
  121. data/rdoc.gemspec +0 -249
@@ -17,6 +17,14 @@ body {
17
17
  background: #fafafa;
18
18
  font-family: Lato, sans-serif;
19
19
  font-weight: 300;
20
+
21
+ /* Layout */
22
+ display: grid;
23
+ grid-template-columns: auto 1fr;
24
+ }
25
+
26
+ body > :last-child {
27
+ grid-column: 1 / 3;
20
28
  }
21
29
 
22
30
  h1 span,
@@ -181,17 +189,25 @@ table tr:nth-child(even) td {
181
189
  /* @group Top-Level Structure */
182
190
 
183
191
  nav {
184
- float: left;
185
- width: 260px;
186
192
  font-family: Helvetica, sans-serif;
187
193
  font-size: 14px;
188
194
  border-right: 1px solid #ccc;
195
+ position: sticky;
196
+ top: 0;
197
+ overflow: auto;
198
+
199
+ /* Layout */
200
+ width: 260px; /* fallback */
201
+ width: max(50px, 20vw);
202
+ min-width: 50px;
203
+ max-width: 80vw;
204
+ height: calc(100vh - 100px); /* reduce the footer height */
205
+ resize: horizontal;
189
206
  }
190
207
 
191
208
  main {
192
209
  display: block;
193
- margin: 0 2em 5em 260px;
194
- padding-left: 20px;
210
+ margin: 1em;
195
211
  min-width: 340px;
196
212
  font-size: 16px;
197
213
  }
@@ -210,7 +226,6 @@ main h6 {
210
226
  }
211
227
 
212
228
  #validator-badges {
213
- clear: both;
214
229
  margin: 1em 1em 2em;
215
230
  font-size: smaller;
216
231
  }
@@ -305,6 +320,28 @@ dl.note-list dt {
305
320
  background: url(../images/arrow_up.png) no-repeat right center;
306
321
  }
307
322
 
323
+ .nav-section details > summary {
324
+ display: block;
325
+ }
326
+
327
+ .nav-section details > summary::-webkit-details-marker {
328
+ display: none;
329
+ }
330
+
331
+ .nav-section details > summary::before {
332
+ content: "";
333
+ }
334
+
335
+ .nav-section details > summary::after {
336
+ content: "\25B6"; /* BLACK RIGHT-POINTING TRIANGLE */
337
+ font-size: 0.8em;
338
+ margin-left: 0.4em;
339
+ }
340
+
341
+ .nav-section details[open] > summary::after {
342
+ content: "\25BD"; /* WHITE DOWN-POINTING TRIANGLE */
343
+ }
344
+
308
345
  /* @end */
309
346
 
310
347
  /* @group Documentation Section */
@@ -482,7 +519,7 @@ main header h3 {
482
519
 
483
520
  main .method-source-code {
484
521
  max-height: 0;
485
- overflow: hidden;
522
+ overflow: auto;
486
523
  transition-duration: 200ms;
487
524
  transition-delay: 0ms;
488
525
  transition-property: all;
@@ -530,7 +567,7 @@ main .method-click-advice {
530
567
  line-height: 20px;
531
568
  background: url(../images/zoom.png) no-repeat right top;
532
569
  }
533
- main .method-heading:hover .method-click-advice {
570
+ main .method-header:hover .method-click-advice {
534
571
  visibility: visible;
535
572
  }
536
573
 
@@ -17,6 +17,6 @@
17
17
  main_page = @files.find { |f| f.full_name == @options.main_page } then %>
18
18
  <%= main_page.description %>
19
19
  <%- else -%>
20
- <p>This is the API documentation for <%= @title %>.
20
+ <p>This is the API documentation for <%= h @title %>.
21
21
  <%- end -%>
22
22
  </main>
@@ -54,7 +54,7 @@ function hookSearch() {
54
54
  var html = '';
55
55
 
56
56
  // TODO add relative path to <script> per-page
57
- html += '<p class="search-match"><a href="' + index_rel_prefix + result.path + '">' + this.hlt(result.title);
57
+ html += '<p class="search-match"><a href="' + index_rel_prefix + this.escapeHTML(result.path) + '">' + this.hlt(result.title);
58
58
  if (result.params)
59
59
  html += '<span class="params">' + result.params + '</span>';
60
60
  html += '</a>';
@@ -78,7 +78,20 @@ function hookSearch() {
78
78
  search.scrollIntoView = search.scrollInWindow;
79
79
  };
80
80
 
81
+ function hookFocus() {
82
+ document.addEventListener("keydown", (event) => {
83
+ if (document.activeElement.tagName === 'INPUT') {
84
+ return;
85
+ }
86
+ if (event.key === "/") {
87
+ event.preventDefault();
88
+ document.querySelector('#search-field').focus();
89
+ }
90
+ });
91
+ }
92
+
81
93
  document.addEventListener('DOMContentLoaded', function() {
82
94
  hookSourceViews();
83
95
  hookSearch();
96
+ hookFocus();
84
97
  });
@@ -15,9 +15,9 @@ Search.prototype = Object.assign({}, Navigation, new function() {
15
15
  this.init = function() {
16
16
  var _this = this;
17
17
  var observer = function(e) {
18
- switch(e.keyCode) {
19
- case 38: // Event.KEY_UP
20
- case 40: // Event.KEY_DOWN
18
+ switch(e.key) {
19
+ case 'ArrowUp':
20
+ case 'ArrowDown':
21
21
  return;
22
22
  }
23
23
  _this.search(_this.input.value);
@@ -101,7 +101,7 @@ Search.prototype = Object.assign({}, Navigation, new function() {
101
101
  }
102
102
 
103
103
  this.escapeHTML = function(html) {
104
- return html.replace(/[&<>]/g, function(c) {
104
+ return html.replace(/[&<>"`']/g, function(c) {
105
105
  return '&#' + c.charCodeAt(0) + ';';
106
106
  });
107
107
  }
@@ -8,14 +8,14 @@
8
8
  <ul>
9
9
  <%- simple_files.sort.each do |file| -%>
10
10
  <li class="file">
11
- <a href="<%= file.path %>"><%= h file.page_name %></a>
11
+ <a href="<%= h file.path %>"><%= h file.page_name %></a>
12
12
  <%
13
13
  # HACK table_of_contents should not exist on Document
14
14
  table = file.parse(file.comment).table_of_contents
15
15
  unless table.empty? then %>
16
16
  <ul>
17
17
  <%- table.each do |heading| -%>
18
- <li><a href="<%= file.path %>#<%= heading.aref %>"><%= heading.plain_html %></a>
18
+ <li><a href="<%= h file.path %>#<%= heading.aref %>"><%= heading.plain_html %></a>
19
19
  <%- end -%>
20
20
  </ul>
21
21
  <%- end -%>
@@ -36,8 +36,9 @@
36
36
  unless table.empty? then %>
37
37
  <ul>
38
38
  <%- table.each do |item| -%>
39
- <li><a href="<%= klass.path %>#<%= item.aref %>"><%= item.plain_html %></a>
40
- <%- end -%>
39
+ <%- label = item.respond_to?(:label) ? item.label(klass) : item.aref -%>
40
+ <li><a href="<%= klass.path %>#<%= label %>"><%= item.plain_html %></a>
41
+ <%- end -%>
41
42
  </ul>
42
43
  <%- end -%>
43
44
  </li>
@@ -46,9 +47,9 @@
46
47
 
47
48
  <h2 id="methods">Methods</h2>
48
49
  <ul>
49
- <%- @store.all_classes_and_modules.map do |mod|
50
+ <%- @store.all_classes_and_modules.flat_map do |mod|
50
51
  mod.method_list
51
- end.flatten.sort.each do |method| %>
52
+ end.sort.each do |method| %>
52
53
  <li class="method">
53
54
  <a href="<%= method.path %>"><%= h method.pretty_name %></a>
54
55
  &mdash;
@@ -23,24 +23,24 @@ Navigation = new function() {
23
23
 
24
24
  this.onkeydown = function(e) {
25
25
  if (!this.navigationActive) return;
26
- switch(e.keyCode) {
27
- case 37: //Event.KEY_LEFT:
26
+ switch(e.key) {
27
+ case 'ArrowLeft':
28
28
  if (this.moveLeft()) e.preventDefault();
29
29
  break;
30
- case 38: //Event.KEY_UP:
31
- if (e.keyCode == 38 || e.ctrlKey) {
30
+ case 'ArrowUp':
31
+ if (e.key == 'ArrowUp' || e.ctrlKey) {
32
32
  if (this.moveUp()) e.preventDefault();
33
33
  }
34
34
  break;
35
- case 39: //Event.KEY_RIGHT:
35
+ case 'ArrowRight':
36
36
  if (this.moveRight()) e.preventDefault();
37
37
  break;
38
- case 40: //Event.KEY_DOWN:
39
- if (e.keyCode == 40 || e.ctrlKey) {
38
+ case 'ArrowDown':
39
+ if (e.key == 'ArrowDown' || e.ctrlKey) {
40
40
  if (this.moveDown()) e.preventDefault();
41
41
  }
42
42
  break;
43
- case 13: //Event.KEY_RETURN:
43
+ case 'Enter':
44
44
  if (this.current) e.preventDefault();
45
45
  this.select(this.current);
46
46
  break;
@@ -41,11 +41,11 @@
41
41
 
42
42
  module RDoc::Generator
43
43
 
44
- autoload :Markup, 'rdoc/generator/markup'
44
+ autoload :Markup, "#{__dir__}/generator/markup"
45
45
 
46
- autoload :Darkfish, 'rdoc/generator/darkfish'
47
- autoload :JsonIndex, 'rdoc/generator/json_index'
48
- autoload :RI, 'rdoc/generator/ri'
49
- autoload :POT, 'rdoc/generator/pot'
46
+ autoload :Darkfish, "#{__dir__}/generator/darkfish"
47
+ autoload :JsonIndex, "#{__dir__}/generator/json_index"
48
+ autoload :RI, "#{__dir__}/generator/ri"
49
+ autoload :POT, "#{__dir__}/generator/pot"
50
50
 
51
51
  end
@@ -4,4 +4,3 @@
4
4
 
5
5
  class RDoc::GhostMethod < RDoc::AnyMethod
6
6
  end
7
-
data/lib/rdoc/i18n.rb CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  module RDoc::I18n
6
6
 
7
- autoload :Locale, 'rdoc/i18n/locale'
7
+ autoload :Locale, "#{__dir__}/i18n/locale"
8
8
  require_relative 'i18n/text'
9
9
 
10
10
  end
data/lib/rdoc/include.rb CHANGED
@@ -7,4 +7,3 @@
7
7
  class RDoc::Include < RDoc::Mixin
8
8
 
9
9
  end
10
-
@@ -25,6 +25,7 @@ module RDoc
25
25
  "rb_cObject" => "Object",
26
26
  "rb_cProc" => "Proc",
27
27
  "rb_cRange" => "Range",
28
+ "rb_cRefinement" => "Refinement",
28
29
  "rb_cRegexp" => "Regexp",
29
30
  "rb_cRubyVM" => "RubyVM",
30
31
  "rb_cSocket" => "Socket",
@@ -35,7 +36,7 @@ module RDoc
35
36
  "rb_cTime" => "Time",
36
37
  "rb_cTrueClass" => "TrueClass",
37
38
 
38
- "rb_eArgError" => "ArgError",
39
+ "rb_eArgError" => "ArgumentError",
39
40
  "rb_eEOFError" => "EOFError",
40
41
  "rb_eException" => "Exception",
41
42
  "rb_eFatal" => "fatal",
@@ -45,8 +46,8 @@ module RDoc
45
46
  "rb_eInterrupt" => "Interrupt",
46
47
  "rb_eLoadError" => "LoadError",
47
48
  "rb_eNameError" => "NameError",
48
- "rb_eNoMemError" => "NoMemError",
49
- "rb_eNotImpError" => "NotImpError",
49
+ "rb_eNoMemError" => "NoMemoryError",
50
+ "rb_eNotImpError" => "NotImplementedError",
50
51
  "rb_eRangeError" => "RangeError",
51
52
  "rb_eRuntimeError" => "RuntimeError",
52
53
  "rb_eScriptError" => "ScriptError",
@@ -57,7 +58,7 @@ module RDoc
57
58
  "rb_eSystemCallError" => "SystemCallError",
58
59
  "rb_eSystemExit" => "SystemExit",
59
60
  "rb_eTypeError" => "TypeError",
60
- "rb_eZeroDivError" => "ZeroDivError",
61
+ "rb_eZeroDivError" => "ZeroDivisionError",
61
62
 
62
63
  "rb_mComparable" => "Comparable",
63
64
  "rb_mEnumerable" => "Enumerable",
@@ -2129,4 +2129,3 @@ RDoc::Markdown::HTML_ENTITIES = {
2129
2129
  "zwj" => [0x0200D],
2130
2130
  "zwnj" => [0x0200C],
2131
2131
  }
2132
-
@@ -29,6 +29,7 @@ class RDoc::Markdown::Literals
29
29
  @result = nil
30
30
  @failed_rule = nil
31
31
  @failing_rule_offset = -1
32
+ @line_offsets = nil
32
33
 
33
34
  setup_foreign_grammar
34
35
  end
@@ -38,30 +39,83 @@ class RDoc::Markdown::Literals
38
39
  attr_accessor :result, :pos
39
40
 
40
41
  def current_column(target=pos)
41
- if c = string.rindex("\n", target-1)
42
- return target - c - 1
42
+ if string[target] == "\n" && (c = string.rindex("\n", target-1) || -1)
43
+ return target - c
44
+ elsif c = string.rindex("\n", target)
45
+ return target - c
43
46
  end
44
47
 
45
48
  target + 1
46
49
  end
47
50
 
48
- def current_line(target=pos)
49
- cur_offset = 0
50
- cur_line = 0
51
+ def position_line_offsets
52
+ unless @position_line_offsets
53
+ @position_line_offsets = []
54
+ total = 0
55
+ string.each_line do |line|
56
+ total += line.size
57
+ @position_line_offsets << total
58
+ end
59
+ end
60
+ @position_line_offsets
61
+ end
62
+
63
+ if [].respond_to? :bsearch_index
64
+ def current_line(target=pos)
65
+ if line = position_line_offsets.bsearch_index {|x| x > target }
66
+ return line + 1
67
+ elsif target == string.size
68
+ past_last = !string.empty? && string[-1]=="\n" ? 1 : 0
69
+ return position_line_offsets.size + past_last
70
+ end
71
+ raise "Target position #{target} is outside of string"
72
+ end
73
+ else
74
+ def current_line(target=pos)
75
+ if line = position_line_offsets.index {|x| x > target }
76
+ return line + 1
77
+ elsif target == string.size
78
+ past_last = !string.empty? && string[-1]=="\n" ? 1 : 0
79
+ return position_line_offsets.size + past_last
80
+ end
81
+ raise "Target position #{target} is outside of string"
82
+ end
83
+ end
51
84
 
52
- string.each_line do |line|
53
- cur_line += 1
54
- cur_offset += line.size
55
- return cur_line if cur_offset >= target
85
+ def current_character(target=pos)
86
+ if target < 0 || target > string.size
87
+ raise "Target position #{target} is outside of string"
88
+ elsif target == string.size
89
+ ""
90
+ else
91
+ string[target, 1]
56
92
  end
93
+ end
57
94
 
58
- -1
95
+ KpegPosInfo = Struct.new(:pos, :lno, :col, :line, :char)
96
+
97
+ def current_pos_info(target=pos)
98
+ l = current_line target
99
+ c = current_column target
100
+ ln = get_line(l-1)
101
+ chr = string[target,1]
102
+ KpegPosInfo.new(target, l, c, ln, chr)
59
103
  end
60
104
 
61
105
  def lines
62
- lines = []
63
- string.each_line { |l| lines << l }
64
- lines
106
+ string.lines
107
+ end
108
+
109
+ def get_line(no)
110
+ loff = position_line_offsets
111
+ if no < 0
112
+ raise "Line No is out of range: #{no} < 0"
113
+ elsif no >= loff.size
114
+ raise "Line No is out of range: #{no} >= #{loff.size}"
115
+ end
116
+ lend = loff[no]-1
117
+ lstart = no > 0 ? loff[no-1] : 0
118
+ string[lstart..lend]
65
119
  end
66
120
 
67
121
 
@@ -75,6 +129,7 @@ class RDoc::Markdown::Literals
75
129
  @string = string
76
130
  @string_size = string ? string.size : 0
77
131
  @pos = pos
132
+ @position_line_offsets = nil
78
133
  end
79
134
 
80
135
  def show_pos
@@ -99,30 +154,22 @@ class RDoc::Markdown::Literals
99
154
  end
100
155
 
101
156
  def failure_caret
102
- l = current_line @failing_rule_offset
103
- c = current_column @failing_rule_offset
104
-
105
- line = lines[l-1]
106
- "#{line}\n#{' ' * (c - 1)}^"
157
+ p = current_pos_info @failing_rule_offset
158
+ "#{p.line.chomp}\n#{' ' * (p.col - 1)}^"
107
159
  end
108
160
 
109
161
  def failure_character
110
- l = current_line @failing_rule_offset
111
- c = current_column @failing_rule_offset
112
- lines[l-1][c-1, 1]
162
+ current_character @failing_rule_offset
113
163
  end
114
164
 
115
165
  def failure_oneline
116
- l = current_line @failing_rule_offset
117
- c = current_column @failing_rule_offset
118
-
119
- char = lines[l-1][c-1, 1]
166
+ p = current_pos_info @failing_rule_offset
120
167
 
121
168
  if @failed_rule.kind_of? Symbol
122
169
  info = self.class::Rules[@failed_rule]
123
- "@#{l}:#{c} failed rule '#{info.name}', got '#{char}'"
170
+ "@#{p.lno}:#{p.col} failed rule '#{info.name}', got '#{p.char}'"
124
171
  else
125
- "@#{l}:#{c} failed rule '#{@failed_rule}', got '#{char}'"
172
+ "@#{p.lno}:#{p.col} failed rule '#{@failed_rule}', got '#{p.char}'"
126
173
  end
127
174
  end
128
175
 
@@ -135,10 +182,9 @@ class RDoc::Markdown::Literals
135
182
 
136
183
  def show_error(io=STDOUT)
137
184
  error_pos = @failing_rule_offset
138
- line_no = current_line(error_pos)
139
- col_no = current_column(error_pos)
185
+ p = current_pos_info(error_pos)
140
186
 
141
- io.puts "On line #{line_no}, column #{col_no}:"
187
+ io.puts "On line #{p.lno}, column #{p.col}:"
142
188
 
143
189
  if @failed_rule.kind_of? Symbol
144
190
  info = self.class::Rules[@failed_rule]
@@ -147,10 +193,9 @@ class RDoc::Markdown::Literals
147
193
  io.puts "Failed to match rule '#{@failed_rule}'"
148
194
  end
149
195
 
150
- io.puts "Got: #{string[error_pos,1].inspect}"
151
- line = lines[line_no-1]
152
- io.puts "=> #{line}"
153
- io.print(" " * (col_no + 3))
196
+ io.puts "Got: #{p.char.inspect}"
197
+ io.puts "=> #{p.line}"
198
+ io.print(" " * (p.col + 2))
154
199
  io.puts "^"
155
200
  end
156
201
 
@@ -163,6 +208,15 @@ class RDoc::Markdown::Literals
163
208
 
164
209
  attr_reader :failed_rule
165
210
 
211
+ def match_dot()
212
+ if @pos >= @string_size
213
+ return nil
214
+ end
215
+
216
+ @pos += 1
217
+ true
218
+ end
219
+
166
220
  def match_string(str)
167
221
  len = str.size
168
222
  if @string[pos,len] == str
@@ -183,24 +237,26 @@ class RDoc::Markdown::Literals
183
237
  end
184
238
 
185
239
  if "".respond_to? :ord
186
- def get_byte
240
+ def match_char_range(char_range)
187
241
  if @pos >= @string_size
188
242
  return nil
243
+ elsif !char_range.include?(@string[@pos].ord)
244
+ return nil
189
245
  end
190
246
 
191
- s = @string[@pos].ord
192
247
  @pos += 1
193
- s
248
+ true
194
249
  end
195
250
  else
196
- def get_byte
251
+ def match_char_range(char_range)
197
252
  if @pos >= @string_size
198
253
  return nil
254
+ elsif !char_range.include?(@string[@pos])
255
+ return nil
199
256
  end
200
257
 
201
- s = @string[@pos]
202
258
  @pos += 1
203
- s
259
+ true
204
260
  end
205
261
  end
206
262
 
@@ -259,6 +315,7 @@ class RDoc::Markdown::Literals
259
315
  end
260
316
 
261
317
  def apply_with_args(rule, *args)
318
+ @result = nil
262
319
  memo_key = [rule, args]
263
320
  if m = @memoizations[memo_key][@pos]
264
321
  @pos = m.pos
@@ -292,6 +349,7 @@ class RDoc::Markdown::Literals
292
349
  end
293
350
 
294
351
  def apply(rule)
352
+ @result = nil
295
353
  if m = @memoizations[rule][@pos]
296
354
  @pos = m.pos
297
355
  if !m.set
@@ -178,7 +178,7 @@
178
178
  # [dingus]: http://daringfireball.net/projects/markdown/dingus
179
179
  # [GFM]: https://github.github.com/gfm/
180
180
  # [pegmarkdown]: https://github.com/jgm/peg-markdown
181
- # [PHPE]: http://michelf.com/projects/php-markdown/extra/#def-list
181
+ # [PHPE]: https://michelf.ca/projects/php-markdown/extra/#def-list
182
182
  # [syntax]: http://daringfireball.net/projects/markdown/syntax
183
183
  #--
184
184
  # Last updated to jgm/peg-markdown commit 8f8fc22ef0
@@ -187,11 +187,11 @@
187
187
 
188
188
  %% {
189
189
 
190
- require 'rdoc'
191
- require 'rdoc/markup/to_joined_paragraph'
192
- require 'rdoc/markdown/entities'
190
+ require_relative '../rdoc'
191
+ require_relative 'markup/to_joined_paragraph'
192
+ require_relative 'markdown/entities'
193
193
 
194
- require 'rdoc/markdown/literals'
194
+ require_relative 'markdown/literals'
195
195
 
196
196
  ##
197
197
  # Supported extensions
@@ -449,7 +449,7 @@
449
449
 
450
450
  @note_order.each_with_index do |ref, index|
451
451
  label = index + 1
452
- note = @footnotes[ref]
452
+ note = @footnotes[ref] or raise ParseError, "footnote [^#{ref}] not found"
453
453
 
454
454
  link = "{^#{label}}[rdoc-label:footmark-#{label}:foottext-#{label}] "
455
455
  note.parts.unshift link
@@ -1135,7 +1135,7 @@ StartList = &.
1135
1135
  { [] }
1136
1136
 
1137
1137
  Line = @RawLine:a { a }
1138
- RawLine = ( < (!"\r" !"\n" .)* @Newline >
1138
+ RawLine = ( < /[^\r\n]*/ @Newline >
1139
1139
  | < .+ > @Eof ) { text }
1140
1140
 
1141
1141
  SkipBlock = HtmlBlock
@@ -1179,7 +1179,7 @@ InlineNote = &{ notes? }
1179
1179
  Notes = ( Note | SkipBlock )*
1180
1180
 
1181
1181
  RawNoteBlock = @StartList:a
1182
- ( !@BlankLine OptionallyIndentedLine:l { a << l } )+
1182
+ ( !@BlankLine !RawNoteReference OptionallyIndentedLine:l { a << l } )+
1183
1183
  ( < @BlankLine* > { a << text } )
1184
1184
  { a }
1185
1185
 
@@ -1198,19 +1198,26 @@ CodeFence = &{ github? }
1198
1198
  }
1199
1199
 
1200
1200
  Table = &{ github? }
1201
- TableRow:header TableLine:line TableRow+:body
1201
+ TableHead:header TableLine:line TableRow+:body
1202
1202
  { table = RDoc::Markup::Table.new(header, line, body) }
1203
1203
 
1204
- TableRow = TableItem+:row "|" @Newline
1205
- { row }
1206
- TableItem = "|" < (!"|" !@Newline .)+ >
1207
- { text.strip }
1208
-
1209
- TableLine = TableColumn+:line "|" @Newline
1210
- { line }
1211
- TableColumn = "|" < ( "-"+ ":"? | ":" "-"* ) >
1212
- { text.start_with?(":") ? :left :
1213
- text.end_with?(":") ? :right : nil
1204
+ TableHead = TableItem2+:items "|"? @Newline
1205
+ { items }
1206
+
1207
+ TableRow = ( ( TableItem:item1 TableItem2*:items { [item1, *items] } ):row | TableItem2+:row ) "|"? @Newline
1208
+ { row }
1209
+ TableItem2 = "|" TableItem
1210
+ TableItem = < /(?:\\.|[^|\n])+/ >
1211
+ { text.strip.gsub(/\\(.)/, '\1') }
1212
+
1213
+ TableLine = ( ( TableAlign:align1 TableAlign2*:aligns {[align1, *aligns] } ):line | TableAlign2+:line ) "|"? @Newline
1214
+ { line }
1215
+ TableAlign2 = "|" @Sp TableAlign
1216
+ TableAlign = < /:?-+:?/ > @Sp
1217
+ {
1218
+ text.start_with?(":") ?
1219
+ (text.end_with?(":") ? :center : :left) :
1220
+ (text.end_with?(":") ? :right : nil)
1214
1221
  }
1215
1222
 
1216
1223
  DefinitionList = &{ definition_lists? }