asciidoctor-html 1.0.1 → 1.0.3
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/CHANGELOG.md +8 -0
- data/assets/css/styles.css +2 -2
- data/lib/asciidoctor/html/highlightjs.rb +1 -0
- data/lib/asciidoctor/html/search.rb +12 -7
- data/lib/asciidoctor/html/template.rb +5 -2
- metadata +1 -1
@@ -11,7 +11,12 @@ module Asciidoctor
|
|
11
11
|
def search_page
|
12
12
|
content = <<~HTML
|
13
13
|
<div class="search-form-container">
|
14
|
-
<
|
14
|
+
<div id="search-form-spinner" class="d-flex justify-content-center">
|
15
|
+
<div class="spinner-border" role="status">
|
16
|
+
<span class="visually-hidden">Loading...</span>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
<form id="search-form" class="search-form hidden">
|
15
20
|
<input type="text" id="search-text" name="search-text" class="form-control search-box" placeholder="Search">
|
16
21
|
<button type="submit" class="btn btn-primary search-btn">Go</button>
|
17
22
|
</form>
|
@@ -20,8 +25,6 @@ module Asciidoctor
|
|
20
25
|
<h5 class="search-matches-title">Found <span id="search-nmatches">0 matches</span></h5>
|
21
26
|
<ul id="search-results" class="search-results list-group list-group-flush"></ul>
|
22
27
|
</div>
|
23
|
-
<script src="https://unpkg.com/lunr/lunr.js"></script>
|
24
|
-
<script>#{lunr_script}</script>
|
25
28
|
HTML
|
26
29
|
Template.html(
|
27
30
|
content,
|
@@ -31,7 +34,9 @@ module Asciidoctor
|
|
31
34
|
authors: display_authors,
|
32
35
|
date: @date,
|
33
36
|
chapsubheading: "Search",
|
34
|
-
langs: []
|
37
|
+
langs: [],
|
38
|
+
at_head_end: %(<script defer src="https://unpkg.com/lunr/lunr.js"></script>),
|
39
|
+
at_body_end: %(<script type="module">#{lunr_script}</script>)
|
35
40
|
)
|
36
41
|
end
|
37
42
|
|
@@ -161,14 +166,14 @@ module Asciidoctor
|
|
161
166
|
nmatches.textContent = n == 1 ? (n + ' match') : (n + ' matches');
|
162
167
|
resultsContainer.classList.remove('hidden');
|
163
168
|
}
|
169
|
+
document.getElementById('search-form-spinner').classList.add('hidden');
|
170
|
+
searchForm.classList.remove('hidden');
|
164
171
|
searchForm.addEventListener('submit', e => {
|
165
172
|
e.preventDefault();
|
166
173
|
const searchText = searchBox.value;
|
167
174
|
processSearchText(searchText);
|
168
175
|
});
|
169
|
-
|
170
|
-
searchBox.focus();
|
171
|
-
});
|
176
|
+
searchBox.focus();
|
172
177
|
})();
|
173
178
|
JS
|
174
179
|
end
|
@@ -148,12 +148,15 @@ module Asciidoctor
|
|
148
148
|
# - chapheading: String
|
149
149
|
# - chapsubheading: String
|
150
150
|
# - langs: Array[String]
|
151
|
+
# - at_head_end: String
|
152
|
+
# - at_body_end: String
|
151
153
|
def self.html(content, nav_items, opts = {})
|
152
154
|
nav = (nav_items.size > 1)
|
153
155
|
<<~HTML
|
154
156
|
<!DOCTYPE html>
|
155
157
|
<html lang="en">
|
156
158
|
#{head opts[:title], opts[:description], opts[:authors], opts[:langs]}
|
159
|
+
#{opts[:at_head_end]}
|
157
160
|
<body>
|
158
161
|
#{sidebar(nav_items) if nav}
|
159
162
|
<div id="page" class="page">
|
@@ -161,14 +164,14 @@ module Asciidoctor
|
|
161
164
|
#{header opts[:title], opts[:short_title]}
|
162
165
|
#{main content:, **opts}
|
163
166
|
</div> <!-- .page -->
|
167
|
+
<script>document.getElementById("cr-year").textContent = (new Date()).getFullYear();</script>
|
164
168
|
<script type="module">
|
165
|
-
document.getElementById("cr-year").textContent = (new Date()).getFullYear();
|
166
169
|
#{Highlightjs::PLUGIN}
|
167
|
-
hljs.highlightAll();
|
168
170
|
#{Popovers::POPOVERS}
|
169
171
|
#{Sidebar::TOGGLE if nav}
|
170
172
|
#{Scroll::SCROLL}
|
171
173
|
</script>
|
174
|
+
#{opts[:at_body_end]}
|
172
175
|
</body>
|
173
176
|
</html>
|
174
177
|
HTML
|