rdoc 7.1.0 → 7.2.0

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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rdoc/code_object/attr.rb +2 -1
  3. data/lib/rdoc/code_object/context/section.rb +26 -8
  4. data/lib/rdoc/code_object/context.rb +15 -4
  5. data/lib/rdoc/code_object/mixin.rb +3 -0
  6. data/lib/rdoc/code_object/top_level.rb +2 -0
  7. data/lib/rdoc/comment.rb +1 -1
  8. data/lib/rdoc/cross_reference.rb +1 -3
  9. data/lib/rdoc/generator/template/aliki/_head.rhtml +5 -0
  10. data/lib/rdoc/generator/template/aliki/class.rhtml +5 -5
  11. data/lib/rdoc/generator/template/aliki/css/rdoc.css +28 -36
  12. data/lib/rdoc/generator/template/aliki/js/aliki.js +8 -2
  13. data/lib/rdoc/generator/template/aliki/js/bash_highlighter.js +167 -0
  14. data/lib/rdoc/generator/template/aliki/js/search_controller.js +1 -1
  15. data/lib/rdoc/markdown.kpeg +21 -7
  16. data/lib/rdoc/markdown.rb +35 -21
  17. data/lib/rdoc/markup/formatter.rb +129 -106
  18. data/lib/rdoc/markup/heading.rb +2 -2
  19. data/lib/rdoc/markup/inline_parser.rb +312 -0
  20. data/lib/rdoc/markup/parser.rb +1 -1
  21. data/lib/rdoc/markup/to_ansi.rb +51 -4
  22. data/lib/rdoc/markup/to_bs.rb +22 -42
  23. data/lib/rdoc/markup/to_html.rb +152 -177
  24. data/lib/rdoc/markup/to_html_crossref.rb +38 -78
  25. data/lib/rdoc/markup/to_html_snippet.rb +62 -62
  26. data/lib/rdoc/markup/to_label.rb +20 -21
  27. data/lib/rdoc/markup/to_markdown.rb +61 -37
  28. data/lib/rdoc/markup/to_rdoc.rb +86 -26
  29. data/lib/rdoc/markup/to_test.rb +9 -1
  30. data/lib/rdoc/markup/to_tt_only.rb +10 -16
  31. data/lib/rdoc/markup.rb +8 -30
  32. data/lib/rdoc/parser/changelog.rb +21 -0
  33. data/lib/rdoc/parser/prism_ruby.rb +44 -32
  34. data/lib/rdoc/parser/ruby.rb +1 -1
  35. data/lib/rdoc/text.rb +29 -5
  36. data/lib/rdoc/version.rb +1 -1
  37. metadata +4 -7
  38. data/lib/rdoc/markup/attr_changer.rb +0 -22
  39. data/lib/rdoc/markup/attr_span.rb +0 -35
  40. data/lib/rdoc/markup/attribute_manager.rb +0 -432
  41. data/lib/rdoc/markup/attributes.rb +0 -70
  42. data/lib/rdoc/markup/regexp_handling.rb +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c14913bad669603f9b9662966297c2e33b45af4500c9cd71bbff067da334ee1a
4
- data.tar.gz: 4e40f1f5b579891945cc7e365bf3977863eb9236eb9af872d870cb46317d191b
3
+ metadata.gz: 1acd5d230eb6cc33e92e6ead29ef4edfd11d238750073c151197675b9d2ecef7
4
+ data.tar.gz: 765310288cb7611ae3990d238a894e9bd1e2d3431c2389c412f0a9407699a4ad
5
5
  SHA512:
6
- metadata.gz: 3aadc0477ea9dd400c1128c512352745b7835171f998c89a83a2827190a41e171d6fa5b89e5c9a27da0bab76fa5492236f7ce13d59ce64970cd414abd9da806c
7
- data.tar.gz: a6949c4950b1fd69c8176330e1c6bedb4912281521f31f66d36b123e912d7fe2bf4736cfd0dae22ac8de939badd817bbd771f500bbc65f8041ab7939d43a3e14
6
+ metadata.gz: b3f79da244c49a5f13485ca9cec594aebd9cbcf9e2a8be2543aa186947ea645aac4ec783f4d3a19b9197ffa7b9e3df53e89dc774adf7ef4c394597c186039a76
7
+ data.tar.gz: c13a7678b03b25bbe56c854f7314fe50b8df2784d85d04b765294f5fd32baefb92a702e66233007689f1c4a65d7141c6e428af89e5953ce5e19976418e0fd76b
@@ -43,7 +43,8 @@ class RDoc::Attr < RDoc::MethodAttr
43
43
  # Add +an_alias+ as an attribute in +context+.
44
44
 
45
45
  def add_alias(an_alias, context)
46
- new_attr = self.class.new(text, an_alias.new_name, rw, comment, singleton: singleton)
46
+ access_type = an_alias.new_name.end_with?('=') ? 'W' : 'R'
47
+ new_attr = self.class.new(text, an_alias.new_name, access_type, comment, singleton: singleton)
47
48
  new_attr.record_location an_alias.file
48
49
  new_attr.visibility = self.visibility
49
50
  new_attr.is_alias_for = self
@@ -17,11 +17,6 @@ class RDoc::Context::Section
17
17
 
18
18
  MARSHAL_VERSION = 0 # :nodoc:
19
19
 
20
- ##
21
- # Section comment
22
-
23
- attr_reader :comment
24
-
25
20
  ##
26
21
  # Section comments
27
22
 
@@ -37,12 +32,18 @@ class RDoc::Context::Section
37
32
 
38
33
  attr_reader :title
39
34
 
35
+ ##
36
+ # The RDoc::Store for this object.
37
+
38
+ attr_reader :store
39
+
40
40
  ##
41
41
  # Creates a new section with +title+ and +comment+
42
42
 
43
- def initialize(parent, title, comment)
43
+ def initialize(parent, title, comment, store = nil)
44
44
  @parent = parent
45
45
  @title = title ? title.strip : title
46
+ @store = store
46
47
 
47
48
  @comments = []
48
49
 
@@ -151,7 +152,7 @@ class RDoc::Context::Section
151
152
  [
152
153
  MARSHAL_VERSION,
153
154
  @title,
154
- parse,
155
+ to_document,
155
156
  ]
156
157
  end
157
158
 
@@ -169,7 +170,7 @@ class RDoc::Context::Section
169
170
  # Parses +comment_location+ into an RDoc::Markup::Document composed of
170
171
  # multiple RDoc::Markup::Documents with their file set.
171
172
 
172
- def parse
173
+ def to_document
173
174
  RDoc::Markup::Document.new(*@comments.map(&:parse))
174
175
  end
175
176
 
@@ -182,6 +183,23 @@ class RDoc::Context::Section
182
183
  @title || 'Top Section'
183
184
  end
184
185
 
186
+ ##
187
+ # Section comment
188
+
189
+ def comment
190
+ return nil if @comments.empty?
191
+ RDoc::Comment.from_document(to_document)
192
+ end
193
+
194
+ def description
195
+ return '' if @comments.empty?
196
+ markup comment
197
+ end
198
+
199
+ def language
200
+ @comments.first&.language
201
+ end
202
+
185
203
  ##
186
204
  # Removes a comment from this section if it is from the same file as
187
205
  # +comment+
@@ -587,7 +587,7 @@ class RDoc::Context < RDoc::CodeObject
587
587
  if section = @sections[title] then
588
588
  section.add_comment comment if comment
589
589
  else
590
- section = Section.new self, title, comment
590
+ section = Section.new self, title, comment, @store
591
591
  @sections[title] = section
592
592
  end
593
593
 
@@ -785,7 +785,10 @@ class RDoc::Context < RDoc::CodeObject
785
785
  end
786
786
 
787
787
  ##
788
- # Find a module at a higher scope
788
+ # Tries to find a module at a higher scope.
789
+ # But parent is not always a higher module nesting scope, so the result is not correct.
790
+ # Parent chain can only represent last-opened nesting, and may be broken in some cases.
791
+ # PrismRuby parser stopped representing module nesting with parent chain at all.
789
792
 
790
793
  def find_enclosing_module_named(name)
791
794
  parent && parent.find_module_named(name)
@@ -860,15 +863,23 @@ class RDoc::Context < RDoc::CodeObject
860
863
  end
861
864
 
862
865
  ##
863
- # Find a module with +name+ using ruby's scoping rules
866
+ # Find a module with +name+ trying to using ruby's scoping rules.
867
+ # find_enclosing_module_named cannot use ruby's scoping so the result is not correct.
864
868
 
865
869
  def find_module_named(name)
866
- res = @modules[name] || @classes[name]
870
+ res = get_module_named(name)
867
871
  return res if res
868
872
  return self if self.name == name
869
873
  find_enclosing_module_named name
870
874
  end
871
875
 
876
+ # Get a module named +name+ in this context
877
+ # Don't look up for higher module nesting scopes. RDoc::Context doesn't have that information.
878
+
879
+ def get_module_named(name)
880
+ @modules[name] || @classes[name]
881
+ end
882
+
872
883
  ##
873
884
  # Look up +symbol+, first as a module, then as a local symbol.
874
885
 
@@ -71,6 +71,9 @@ class RDoc::Mixin < RDoc::CodeObject
71
71
  # lookup behavior.
72
72
  #
73
73
  # As of the beginning of October, 2011, no gem includes nonexistent modules.
74
+ #
75
+ # When mixin is created from RDoc::Parser::PrismRuby, module name is already a resolved full-path name.
76
+ #
74
77
 
75
78
  def module
76
79
  return @module if @module
@@ -149,6 +149,8 @@ class RDoc::TopLevel < RDoc::Context
149
149
  find_class_or_module(name)
150
150
  end
151
151
 
152
+ alias get_module_named find_module_named
153
+
152
154
  ##
153
155
  # Returns the relative name of this file
154
156
 
data/lib/rdoc/comment.rb CHANGED
@@ -6,7 +6,7 @@
6
6
  # Each comment may have a different markup format set by #format=. By default
7
7
  # 'rdoc' is used. The :markup: directive tells RDoc which format to use.
8
8
  #
9
- # See RDoc::MarkupReference@Directive+for+Specifying+RDoc+Source+Format.
9
+ # See {RDoc Markup Reference}[rdoc-ref:doc/markup_reference/rdoc.rdoc@Directive+for+Specifying+RDoc+Source+Format].
10
10
 
11
11
 
12
12
  class RDoc::Comment
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'markup/attribute_manager' # for PROTECT_ATTR
4
-
5
3
  ##
6
4
  # RDoc::CrossReference is a reusable way to create cross references for names.
7
5
 
@@ -33,7 +31,7 @@ class RDoc::CrossReference
33
31
  # See CLASS_REGEXP_STR
34
32
 
35
33
  METHOD_REGEXP_STR = /(
36
- (?!\d)[\w#{RDoc::Markup::AttributeManager::PROTECT_ATTR}]+[!?=]?|
34
+ (?!\d)[\w]+[!?=]?|
37
35
  %|=(?:==?|~)|![=~]|\[\]=?|<(?:<|=>?)?|>[>=]?|[-+!]@?|\*\*?|[\/%\`|&^~]
38
36
  )#{METHOD_ARGS_REGEXP_STR}/.source.delete("\n ").freeze
39
37
 
@@ -140,6 +140,11 @@
140
140
  defer
141
141
  ></script>
142
142
 
143
+ <script
144
+ src="<%= h asset_rel_prefix %>/js/bash_highlighter.js?v=<%= h RDoc::VERSION %>"
145
+ defer
146
+ ></script>
147
+
143
148
  <script
144
149
  src="<%= h asset_rel_prefix %>/js/aliki.js?v=<%= h RDoc::VERSION %>"
145
150
  defer
@@ -40,10 +40,10 @@
40
40
 
41
41
  <%- klass.each_section do |section, constants, attributes| %>
42
42
  <span id="<%= section.legacy_aref %>" class="legacy-anchor"></span>
43
- <section id="<%= section.aref %>" class="documentation-section anchor-link">
43
+ <section class="documentation-section anchor-link">
44
44
  <%- if section.title then %>
45
45
  <header class="documentation-section-title">
46
- <h2>
46
+ <h2 id="<%= section.aref %>">
47
47
  <a href="#<%= section.aref %>"><%= section.title %></a>
48
48
  </h2>
49
49
  </header>
@@ -58,7 +58,7 @@
58
58
  <%- unless constants.empty? then %>
59
59
  <section class="constants-list">
60
60
  <header>
61
- <h3 id="constants"><a href="#constants">Constants</a></h3>
61
+ <h3 id="<%= section.aref %>-constants"><a href="#<%= section.aref %>-constants">Constants</a></h3>
62
62
  </header>
63
63
  <dl>
64
64
  <%- constants.each do |const| %>
@@ -83,7 +83,7 @@
83
83
  <%- unless attributes.empty? then %>
84
84
  <section class="attribute-method-details method-section">
85
85
  <header>
86
- <h3 id="attributes"><a href="#attributes">Attributes</a></h3>
86
+ <h3 id="<%= section.aref %>-attributes"><a href="#<%= section.aref %>-attributes">Attributes</a></h3>
87
87
  </header>
88
88
 
89
89
  <%- attributes.each do |attrib| %>
@@ -118,7 +118,7 @@
118
118
  <%- next if methods.empty? %>
119
119
  <section id="<%= visibility %>-<%= type %>-<%= section.aref %>-method-details" class="method-section anchor-link">
120
120
  <header>
121
- <h3 id="<%= visibility %>-<%= type %>-methods"><a href="#<%= visibility %>-<%= type %>-methods"><%= visibility.to_s.capitalize %> <%= type.capitalize %> Methods</a></h3>
121
+ <h3 id="<%= visibility %>-<%= type %>-<%= section.aref %>-methods"><a href="#<%= visibility %>-<%= type %>-<%= section.aref %>-methods"><%= visibility.to_s.capitalize %> <%= type.capitalize %> Methods</a></h3>
122
122
  </header>
123
123
 
124
124
  <%- methods.each do |method| %>
@@ -39,24 +39,14 @@
39
39
  --color-neutral-800: #292524;
40
40
  --color-neutral-900: #1c1917;
41
41
 
42
- /* Code highlighting colors */
42
+ /* Code highlighting colors - neutral palette for all syntax highlighters */
43
43
  --code-blue: #1d4ed8;
44
44
  --code-green: #047857;
45
45
  --code-orange: #d97706;
46
46
  --code-purple: #7e22ce;
47
47
  --code-red: #dc2626;
48
-
49
- /* C syntax highlighting */
50
- --c-keyword: #b91c1c;
51
- --c-type: #0891b2;
52
- --c-macro: #ea580c;
53
- --c-function: #7c3aed;
54
- --c-identifier: #475569;
55
- --c-operator: #059669;
56
- --c-preprocessor: #a21caf;
57
- --c-value: #92400e;
58
- --c-string: #15803d;
59
- --c-comment: #78716c;
48
+ --code-cyan: #0891b2;
49
+ --code-gray: #78716c;
60
50
 
61
51
  /* Color Palette - Green (for success states) */
62
52
  --color-green-400: #4ade80;
@@ -186,24 +176,14 @@
186
176
 
187
177
  /* Dark Theme */
188
178
  [data-theme="dark"] {
189
- /* Code highlighting colors */
179
+ /* Code highlighting colors - neutral palette for all syntax highlighters */
190
180
  --code-blue: #93c5fd;
191
181
  --code-green: #34d399;
192
182
  --code-orange: #fbbf24;
193
183
  --code-purple: #c084fc;
194
184
  --code-red: #f87171;
195
-
196
- /* C syntax highlighting */
197
- --c-keyword: #f87171;
198
- --c-type: #22d3ee;
199
- --c-macro: #fb923c;
200
- --c-function: #a78bfa;
201
- --c-identifier: #94a3b8;
202
- --c-operator: #6ee7b7;
203
- --c-preprocessor: #e879f9;
204
- --c-value: #fcd34d;
205
- --c-string: #4ade80;
206
- --c-comment: #a8a29e;
185
+ --code-cyan: #22d3ee;
186
+ --code-gray: #a8a29e;
207
187
 
208
188
  /* Semantic Colors - Dark Theme */
209
189
  --color-text-primary: var(--color-neutral-50);
@@ -1064,18 +1044,30 @@ main h6 a:hover {
1064
1044
  [data-theme="dark"] .ruby-string { color: var(--code-green); }
1065
1045
 
1066
1046
  /* C Syntax Highlighting */
1067
- .c-keyword { color: var(--c-keyword); }
1068
- .c-type { color: var(--c-type); }
1069
- .c-macro { color: var(--c-macro); }
1070
- .c-function { color: var(--c-function); }
1071
- .c-identifier { color: var(--c-identifier); }
1072
- .c-operator { color: var(--c-operator); }
1073
- .c-preprocessor { color: var(--c-preprocessor); }
1074
- .c-value { color: var(--c-value); }
1075
- .c-string { color: var(--c-string); }
1047
+ .c-keyword { color: var(--code-red); }
1048
+ .c-type { color: var(--code-cyan); }
1049
+ .c-macro { color: var(--code-orange); }
1050
+ .c-function { color: var(--code-purple); }
1051
+ .c-identifier { color: var(--color-text-secondary); }
1052
+ .c-operator { color: var(--code-green); }
1053
+ .c-preprocessor { color: var(--code-purple); }
1054
+ .c-value { color: var(--code-orange); }
1055
+ .c-string { color: var(--code-green); }
1076
1056
 
1077
1057
  .c-comment {
1078
- color: var(--c-comment);
1058
+ color: var(--code-gray);
1059
+ font-style: italic;
1060
+ }
1061
+
1062
+ /* Shell Syntax Highlighting */
1063
+ .sh-prompt { color: var(--code-gray); }
1064
+ .sh-command { color: var(--code-blue); }
1065
+ .sh-option { color: var(--code-cyan); }
1066
+ .sh-string { color: var(--code-green); }
1067
+ .sh-envvar { color: var(--code-purple); }
1068
+
1069
+ .sh-comment {
1070
+ color: var(--code-gray);
1079
1071
  font-style: italic;
1080
1072
  }
1081
1073
 
@@ -70,8 +70,6 @@ function createSearchInstance(input, result) {
70
70
  window.location.href = result.firstChild.firstChild.href;
71
71
  }
72
72
 
73
- search.scrollIntoView = search.scrollInWindow;
74
-
75
73
  return search;
76
74
  }
77
75
 
@@ -96,6 +94,14 @@ function hookSearch() {
96
94
  }
97
95
  });
98
96
 
97
+ // Hide search results on Escape key on desktop too
98
+ document.addEventListener('keydown', (e) => {
99
+ if (e.key === 'Escape' && input.matches(":focus")) {
100
+ search.hide();
101
+ input.blur();
102
+ }
103
+ });
104
+
99
105
  // Show search results when focusing on input (if there's a query)
100
106
  input.addEventListener('focus', () => {
101
107
  if (input.value.trim()) {
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Client-side shell syntax highlighter for RDoc
3
+ * Highlights: $ prompts, commands, options, strings, env vars, comments
4
+ */
5
+
6
+ (function() {
7
+ 'use strict';
8
+
9
+ function escapeHtml(text) {
10
+ return text
11
+ .replace(/&/g, '&amp;')
12
+ .replace(/</g, '&lt;')
13
+ .replace(/>/g, '&gt;')
14
+ .replace(/"/g, '&quot;')
15
+ .replace(/'/g, '&#39;');
16
+ }
17
+
18
+ function wrap(className, text) {
19
+ return '<span class="' + className + '">' + escapeHtml(text) + '</span>';
20
+ }
21
+
22
+ function highlightLine(line) {
23
+ if (line.trim() === '') return escapeHtml(line);
24
+
25
+ var result = '';
26
+ var i = 0;
27
+ var len = line.length;
28
+
29
+ // Preserve leading whitespace
30
+ while (i < len && (line[i] === ' ' || line[i] === '\t')) {
31
+ result += escapeHtml(line[i++]);
32
+ }
33
+
34
+ // Check for $ prompt ($ followed by space or end of line)
35
+ if (line[i] === '$' && (line[i + 1] === ' ' || line[i + 1] === undefined)) {
36
+ result += wrap('sh-prompt', '$');
37
+ i++;
38
+ }
39
+
40
+ // Check for # comment at start
41
+ if (line[i] === '#') {
42
+ return result + wrap('sh-comment', line.slice(i));
43
+ }
44
+
45
+ var seenCommand = false;
46
+ var afterSpace = true;
47
+
48
+ while (i < len) {
49
+ var ch = line[i];
50
+
51
+ // Whitespace
52
+ if (ch === ' ' || ch === '\t') {
53
+ result += escapeHtml(ch);
54
+ i++;
55
+ afterSpace = true;
56
+ continue;
57
+ }
58
+
59
+ // Comment after whitespace
60
+ if (ch === '#' && afterSpace) {
61
+ result += wrap('sh-comment', line.slice(i));
62
+ break;
63
+ }
64
+
65
+ // Double-quoted string
66
+ if (ch === '"') {
67
+ var end = i + 1;
68
+ while (end < len && line[end] !== '"') {
69
+ if (line[end] === '\\' && end + 1 < len) end += 2;
70
+ else end++;
71
+ }
72
+ if (end < len) end++;
73
+ result += wrap('sh-string', line.slice(i, end));
74
+ i = end;
75
+ afterSpace = false;
76
+ continue;
77
+ }
78
+
79
+ // Single-quoted string
80
+ if (ch === "'") {
81
+ var end = i + 1;
82
+ while (end < len && line[end] !== "'") end++;
83
+ if (end < len) end++;
84
+ result += wrap('sh-string', line.slice(i, end));
85
+ i = end;
86
+ afterSpace = false;
87
+ continue;
88
+ }
89
+
90
+ // Environment variable (ALLCAPS=)
91
+ if (afterSpace && /[A-Z]/.test(ch)) {
92
+ var match = line.slice(i).match(/^[A-Z][A-Z0-9_]*=/);
93
+ if (match) {
94
+ result += wrap('sh-envvar', match[0]);
95
+ i += match[0].length;
96
+ // Read unquoted value
97
+ var valEnd = i;
98
+ while (valEnd < len && line[valEnd] !== ' ' && line[valEnd] !== '\t' && line[valEnd] !== '"' && line[valEnd] !== "'") valEnd++;
99
+ if (valEnd > i) {
100
+ result += escapeHtml(line.slice(i, valEnd));
101
+ i = valEnd;
102
+ }
103
+ afterSpace = false;
104
+ continue;
105
+ }
106
+ }
107
+
108
+ // Option (must be after whitespace)
109
+ if (ch === '-' && afterSpace) {
110
+ var match = line.slice(i).match(/^--?[a-zA-Z0-9_-]+(=[^"'\s]*)?/);
111
+ if (match) {
112
+ result += wrap('sh-option', match[0]);
113
+ i += match[0].length;
114
+ afterSpace = false;
115
+ continue;
116
+ }
117
+ }
118
+
119
+ // Command (first word: regular, ./path, ../path, ~/path, /abs/path, @scope/pkg)
120
+ if (!seenCommand && afterSpace) {
121
+ var isCmd = /[a-zA-Z0-9@~\/]/.test(ch) ||
122
+ (ch === '.' && (line[i + 1] === '/' || (line[i + 1] === '.' && line[i + 2] === '/')));
123
+ if (isCmd) {
124
+ var end = i;
125
+ while (end < len && line[end] !== ' ' && line[end] !== '\t') end++;
126
+ result += wrap('sh-command', line.slice(i, end));
127
+ i = end;
128
+ seenCommand = true;
129
+ afterSpace = false;
130
+ continue;
131
+ }
132
+ }
133
+
134
+ // Everything else
135
+ result += escapeHtml(ch);
136
+ i++;
137
+ afterSpace = false;
138
+ }
139
+
140
+ return result;
141
+ }
142
+
143
+ function highlightShell(code) {
144
+ return code.split('\n').map(highlightLine).join('\n');
145
+ }
146
+
147
+ function initHighlighting() {
148
+ var selectors = [
149
+ 'pre.bash', 'pre.sh', 'pre.shell', 'pre.console',
150
+ 'pre[data-language="bash"]', 'pre[data-language="sh"]',
151
+ 'pre[data-language="shell"]', 'pre[data-language="console"]'
152
+ ];
153
+
154
+ var blocks = document.querySelectorAll(selectors.join(', '));
155
+ blocks.forEach(function(block) {
156
+ if (block.getAttribute('data-highlighted') === 'true') return;
157
+ block.innerHTML = highlightShell(block.textContent);
158
+ block.setAttribute('data-highlighted', 'true');
159
+ });
160
+ }
161
+
162
+ if (document.readyState === 'loading') {
163
+ document.addEventListener('DOMContentLoaded', initHighlighting);
164
+ } else {
165
+ initHighlighting();
166
+ }
167
+ })();
@@ -96,7 +96,7 @@ SearchController.prototype = Object.assign({}, SearchNavigation, new function()
96
96
  this.current.classList.remove('search-selected');
97
97
  next.classList.add('search-selected');
98
98
  this.input.setAttribute('aria-activedescendant', next.getAttribute('id'));
99
- this.scrollIntoView(next, this.view);
99
+ this.scrollInElement(next, this.result);
100
100
  this.current = next;
101
101
  this.input.value = next.firstChild.firstChild.text;
102
102
  this.input.select();
@@ -303,6 +303,20 @@
303
303
  end
304
304
  end
305
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
+
306
320
  ##
307
321
  # :category: Extensions
308
322
  #
@@ -969,11 +983,11 @@ Space = @Spacechar+ { " " }
969
983
 
970
984
  Str = @StartList:a
971
985
  < @NormalChar+ > { a = text }
972
- ( StrChunk:c { a << c } )* { a }
986
+ ( StrChunk:c { a << c } )* { rdoc_escape(a) }
973
987
 
974
988
  StrChunk = < (@NormalChar | /_+/ &Alphanumeric)+ > { text }
975
989
 
976
- EscapedChar = "\\" !@Newline < /[:\\`|*_{}\[\]()#+.!><-]/ > { text }
990
+ EscapedChar = "\\" !@Newline < /[:\\`|*_{}\[\]()#+.!><-]/ > { rdoc_escape(text) }
977
991
 
978
992
  Entity = ( HexEntity | DecEntity | CharEntity ):a { a }
979
993
 
@@ -988,7 +1002,7 @@ TerminalEndline = @Sp @Newline @Eof
988
1002
  LineBreak = " " @NormalEndline { RDoc::Markup::HardBreak.new }
989
1003
 
990
1004
  Symbol = < @SpecialChar >
991
- { text }
1005
+ { rdoc_escape(text) }
992
1006
 
993
1007
  # This keeps the parser from getting bogged down on long strings of '*' or '_',
994
1008
  # or strings of '*' or '_' with space on each side:
@@ -1053,7 +1067,7 @@ ReferenceLinkSingle = Label:content < (Spnl "[]")? >
1053
1067
  { link_to content, content, text }
1054
1068
 
1055
1069
  ExplicitLink = ExplicitLinkWithLabel:a
1056
- { "{#{a[:label]}}[#{a[:link]}]" }
1070
+ { "{#{a[:label]}}[#{rdoc_link_url_escape(a[:link])}]" }
1057
1071
 
1058
1072
  ExplicitLinkWithLabel = Label:label "(" @Sp Source:link Spnl Title @Sp ")"
1059
1073
  { { label: label, link: link } }
@@ -1163,12 +1177,12 @@ Newline = %literals.Newline
1163
1177
  Spacechar = %literals.Spacechar
1164
1178
 
1165
1179
  HexEntity = /&#x/i < /[0-9a-fA-F]+/ > ";"
1166
- { [text.to_i(16)].pack 'U' }
1180
+ { rdoc_escape([text.to_i(16)].pack('U')) }
1167
1181
  DecEntity = "&#" < /[0-9]+/ > ";"
1168
- { [text.to_i].pack 'U' }
1182
+ { rdoc_escape([text.to_i].pack('U')) }
1169
1183
  CharEntity = "&" </[A-Za-z0-9]+/ > ";"
1170
1184
  { if entity = HTML_ENTITIES[text] then
1171
- entity.pack 'U*'
1185
+ rdoc_escape(entity.pack('U*'))
1172
1186
  else
1173
1187
  "&#{text};"
1174
1188
  end