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.
- checksums.yaml +4 -4
- data/lib/rdoc/code_object/attr.rb +2 -1
- data/lib/rdoc/code_object/context/section.rb +26 -8
- data/lib/rdoc/code_object/context.rb +15 -4
- data/lib/rdoc/code_object/mixin.rb +3 -0
- data/lib/rdoc/code_object/top_level.rb +2 -0
- data/lib/rdoc/comment.rb +1 -1
- data/lib/rdoc/cross_reference.rb +1 -3
- data/lib/rdoc/generator/template/aliki/_head.rhtml +5 -0
- data/lib/rdoc/generator/template/aliki/class.rhtml +5 -5
- data/lib/rdoc/generator/template/aliki/css/rdoc.css +28 -36
- data/lib/rdoc/generator/template/aliki/js/aliki.js +8 -2
- data/lib/rdoc/generator/template/aliki/js/bash_highlighter.js +167 -0
- data/lib/rdoc/generator/template/aliki/js/search_controller.js +1 -1
- data/lib/rdoc/markdown.kpeg +21 -7
- data/lib/rdoc/markdown.rb +35 -21
- data/lib/rdoc/markup/formatter.rb +129 -106
- data/lib/rdoc/markup/heading.rb +2 -2
- data/lib/rdoc/markup/inline_parser.rb +312 -0
- data/lib/rdoc/markup/parser.rb +1 -1
- data/lib/rdoc/markup/to_ansi.rb +51 -4
- data/lib/rdoc/markup/to_bs.rb +22 -42
- data/lib/rdoc/markup/to_html.rb +152 -177
- data/lib/rdoc/markup/to_html_crossref.rb +38 -78
- data/lib/rdoc/markup/to_html_snippet.rb +62 -62
- data/lib/rdoc/markup/to_label.rb +20 -21
- data/lib/rdoc/markup/to_markdown.rb +61 -37
- data/lib/rdoc/markup/to_rdoc.rb +86 -26
- data/lib/rdoc/markup/to_test.rb +9 -1
- data/lib/rdoc/markup/to_tt_only.rb +10 -16
- data/lib/rdoc/markup.rb +8 -30
- data/lib/rdoc/parser/changelog.rb +21 -0
- data/lib/rdoc/parser/prism_ruby.rb +44 -32
- data/lib/rdoc/parser/ruby.rb +1 -1
- data/lib/rdoc/text.rb +29 -5
- data/lib/rdoc/version.rb +1 -1
- metadata +4 -7
- data/lib/rdoc/markup/attr_changer.rb +0 -22
- data/lib/rdoc/markup/attr_span.rb +0 -35
- data/lib/rdoc/markup/attribute_manager.rb +0 -432
- data/lib/rdoc/markup/attributes.rb +0 -70
- data/lib/rdoc/markup/regexp_handling.rb +0 -40
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1acd5d230eb6cc33e92e6ead29ef4edfd11d238750073c151197675b9d2ecef7
|
|
4
|
+
data.tar.gz: 765310288cb7611ae3990d238a894e9bd1e2d3431c2389c412f0a9407699a4ad
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
#
|
|
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 =
|
|
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
|
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
|
|
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
|
data/lib/rdoc/cross_reference.rb
CHANGED
|
@@ -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
|
|
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
|
|
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="
|
|
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="
|
|
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
|
-
|
|
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
|
-
|
|
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(--
|
|
1068
|
-
.c-type { color: var(--
|
|
1069
|
-
.c-macro { color: var(--
|
|
1070
|
-
.c-function { color: var(--
|
|
1071
|
-
.c-identifier { color: var(--
|
|
1072
|
-
.c-operator { color: var(--
|
|
1073
|
-
.c-preprocessor { color: var(--
|
|
1074
|
-
.c-value { color: var(--
|
|
1075
|
-
.c-string { color: var(--
|
|
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(--
|
|
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, '&')
|
|
12
|
+
.replace(/</g, '<')
|
|
13
|
+
.replace(/>/g, '>')
|
|
14
|
+
.replace(/"/g, '"')
|
|
15
|
+
.replace(/'/g, ''');
|
|
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.
|
|
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();
|
data/lib/rdoc/markdown.kpeg
CHANGED
|
@@ -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
|
|
1180
|
+
{ rdoc_escape([text.to_i(16)].pack('U')) }
|
|
1167
1181
|
DecEntity = "&#" < /[0-9]+/ > ";"
|
|
1168
|
-
{ [text.to_i].pack
|
|
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
|
|
1185
|
+
rdoc_escape(entity.pack('U*'))
|
|
1172
1186
|
else
|
|
1173
1187
|
"&#{text};"
|
|
1174
1188
|
end
|