asciidoctor-html 0.1.13 → 0.1.14
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 +5 -0
- data/lib/asciidoctor/html/book.rb +24 -9
- data/lib/asciidoctor/html/cli.rb +1 -1
- data/lib/asciidoctor/html/template.rb +9 -9
- data/lib/minitest/html_plugin.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dba7beae0de1e89eb5790f3e1ef26a8ba816ce8e72de48aff55e77bc598fe651
|
4
|
+
data.tar.gz: 39a7aa0f11198636f83d1763dc8d1852cbccb08f39a088eebdf19fe62542379b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee7c1fefccfc2d4d40feeb26cc4500e9df7cf33975270471b4967377acfdb6b8751344197e40f9846136de4c0e8207bfa3afa4be9f3d5b3699a8217184989237
|
7
|
+
data.tar.gz: 6a1b1726c17e09a65c4240cd01bb146ad5d7bc84ef78dbbd03bef4e41816340b64a424627d89dca9771807fce6f7b718638c6806585b1b118a9dfc65cf15fad8
|
data/CHANGELOG.md
CHANGED
@@ -17,8 +17,7 @@ module Asciidoctor
|
|
17
17
|
# A book is a collection of documents with cross referencing
|
18
18
|
# supported via the cref macro.
|
19
19
|
class Book
|
20
|
-
attr_reader :title, :
|
21
|
-
:refs, :templates
|
20
|
+
attr_reader :title, :chapname, :refs, :templates
|
22
21
|
|
23
22
|
Asciidoctor::Extensions.register do
|
24
23
|
tree_processor RefTreeProcessor
|
@@ -39,7 +38,6 @@ module Asciidoctor
|
|
39
38
|
|
40
39
|
DEFAULT_OPTS = {
|
41
40
|
title: "Untitled Book",
|
42
|
-
author: "Anonymous Author",
|
43
41
|
chapname: "Chapter"
|
44
42
|
}.freeze
|
45
43
|
|
@@ -54,16 +52,14 @@ module Asciidoctor
|
|
54
52
|
# opts:
|
55
53
|
# - title
|
56
54
|
# - short_title
|
57
|
-
# -
|
58
|
-
# - date
|
55
|
+
# - authors
|
59
56
|
# - se_id
|
60
57
|
# - chapname
|
61
58
|
def initialize(opts = {})
|
62
59
|
opts = DEFAULT_OPTS.merge opts
|
63
60
|
@title = ERB::Escape.html_escape opts[:title]
|
64
61
|
@short_title = ERB::Escape.html_escape opts[:short_title]
|
65
|
-
@
|
66
|
-
@date = opts.include?(:date) ? Date.parse(opts[:date]) : Date.today
|
62
|
+
@authors = opts[:authors]
|
67
63
|
@se_id = opts[:se_id]
|
68
64
|
@base_url = opts[:base_url]
|
69
65
|
@chapname = opts[:chapname]
|
@@ -118,7 +114,7 @@ module Asciidoctor
|
|
118
114
|
nav_items,
|
119
115
|
title: @title,
|
120
116
|
short_title: @short_title,
|
121
|
-
|
117
|
+
authors: display_authors,
|
122
118
|
date: @date,
|
123
119
|
chapsubheading: "Search",
|
124
120
|
langs: []
|
@@ -198,6 +194,25 @@ module Asciidoctor
|
|
198
194
|
node.reftext || (node.title unless node.inline?) || "[#{node.id}]" if node.id
|
199
195
|
end
|
200
196
|
|
197
|
+
def display_authors(doc)
|
198
|
+
authors = doc.authors.map do |author|
|
199
|
+
doc.sub_replacements author.name
|
200
|
+
end
|
201
|
+
|
202
|
+
if authors.empty? && @authors
|
203
|
+
authors = @authors.map do |author|
|
204
|
+
ERB::Escape.html_escape author
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
return if authors.empty?
|
209
|
+
|
210
|
+
[
|
211
|
+
authors[0..-2].join(", "),
|
212
|
+
authors[-1]
|
213
|
+
].reject(&:empty?).join(" and ")
|
214
|
+
end
|
215
|
+
|
201
216
|
def outline(doc)
|
202
217
|
items = []
|
203
218
|
doc.sections.each do |section|
|
@@ -241,7 +256,7 @@ module Asciidoctor
|
|
241
256
|
nav_items,
|
242
257
|
title: @title,
|
243
258
|
short_title: @short_title,
|
244
|
-
|
259
|
+
authors: display_authors(doc),
|
245
260
|
date: @date,
|
246
261
|
description: doc.attr("description"),
|
247
262
|
chapheading: tdata.chapheading,
|
data/lib/asciidoctor/html/cli.rb
CHANGED
@@ -85,7 +85,7 @@ module Asciidoctor
|
|
85
85
|
|
86
86
|
def self.generate_bookopts(config)
|
87
87
|
book_opts = {}
|
88
|
-
%i[title short_title
|
88
|
+
%i[title short_title authors se_id base_url chapname].each do |opt|
|
89
89
|
key = opt.to_s
|
90
90
|
book_opts[opt] = config[key] if config.include?(key)
|
91
91
|
end
|
@@ -50,7 +50,7 @@ module Asciidoctor
|
|
50
50
|
# - chapheading: String
|
51
51
|
# - chapsubheading: String
|
52
52
|
# - content: String
|
53
|
-
# -
|
53
|
+
# - authors: String
|
54
54
|
# - date: Date
|
55
55
|
def self.main(opts)
|
56
56
|
<<~HTML
|
@@ -59,7 +59,7 @@ module Asciidoctor
|
|
59
59
|
#{%(<h1 class="chapheading">#{opts[:chapheading]}</h1>) if opts[:chapheading]}
|
60
60
|
<h1 class="chaptitle">#{opts[:chapsubheading]}</h1>
|
61
61
|
#{opts[:content]}
|
62
|
-
#{footer opts[:
|
62
|
+
#{footer opts[:authors]}
|
63
63
|
</div>
|
64
64
|
</main>
|
65
65
|
HTML
|
@@ -92,10 +92,10 @@ module Asciidoctor
|
|
92
92
|
HTML
|
93
93
|
end
|
94
94
|
|
95
|
-
def self.footer(
|
95
|
+
def self.footer(authors)
|
96
96
|
<<~HTML
|
97
97
|
<footer class="footer">
|
98
|
-
<div class="footer-left">©
|
98
|
+
<div class="footer-left">© <span id="cr-year"></span> #{authors}</div>
|
99
99
|
<div class="footer-right">Built with
|
100
100
|
<a href="https://github.com/ravirajani/asciidoctor-html">asciidoctor-html</a>
|
101
101
|
</div>
|
@@ -109,13 +109,13 @@ module Asciidoctor
|
|
109
109
|
end.join("\n ")
|
110
110
|
end
|
111
111
|
|
112
|
-
def self.head(title, description,
|
112
|
+
def self.head(title, description, authors, langs)
|
113
113
|
<<~HTML
|
114
114
|
<head>
|
115
115
|
<meta charset="utf-8">
|
116
116
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
117
117
|
#{%(<meta name="description" content="#{description}">) if description}
|
118
|
-
#{%(<meta name="author" content="#{
|
118
|
+
#{%(<meta name="author" content="#{authors}">) if authors}
|
119
119
|
<title>#{title}</title>
|
120
120
|
<link rel="apple-touch-icon" sizes="180x180" href="#{FAVICON_PATH}/apple-touch-icon.png">
|
121
121
|
<link rel="icon" type="image/png" sizes="32x32" href="#{FAVICON_PATH}/favicon-32x32.png">
|
@@ -143,9 +143,8 @@ module Asciidoctor
|
|
143
143
|
# opts:
|
144
144
|
# - title: String
|
145
145
|
# - short_title: String
|
146
|
-
# -
|
146
|
+
# - authors: String
|
147
147
|
# - description: String
|
148
|
-
# - date: Date
|
149
148
|
# - chapheading: String
|
150
149
|
# - chapsubheading: String
|
151
150
|
# - langs: Array[String]
|
@@ -154,7 +153,7 @@ module Asciidoctor
|
|
154
153
|
<<~HTML
|
155
154
|
<!DOCTYPE html>
|
156
155
|
<html lang="en">
|
157
|
-
#{head opts[:title], opts[:description], opts[:
|
156
|
+
#{head opts[:title], opts[:description], opts[:authors], opts[:langs]}
|
158
157
|
<body>
|
159
158
|
#{sidebar(nav_items) if nav}
|
160
159
|
<div id="page" class="page">
|
@@ -163,6 +162,7 @@ module Asciidoctor
|
|
163
162
|
#{main content:, **opts}
|
164
163
|
</div> <!-- .page -->
|
165
164
|
<script type="module">
|
165
|
+
document.getElementById("cr-year").textContent = (new Date()).getFullYear();
|
166
166
|
#{Highlightjs::PLUGIN}
|
167
167
|
hljs.highlightAll();
|
168
168
|
#{Popovers::POPOVERS}
|
data/lib/minitest/html_plugin.rb
CHANGED
@@ -55,7 +55,7 @@ module Minitest
|
|
55
55
|
Pathname(TESTS_DIR).children.reject { |f| f.file? || f.basename.to_s.start_with?("_") }.sort.each do |pn|
|
56
56
|
report_files results, pn
|
57
57
|
end
|
58
|
-
adoc = %(= Test Results\
|
58
|
+
adoc = %(= Test Results\nRavi Rajani\n#{time}\n#{results.join "\n"})
|
59
59
|
File.write("#{DOCS_DIR}/tests.adoc", adoc)
|
60
60
|
Asciidoctor::Html::CLI.run({ "config-file": CONFIG_FILE, watch: false })
|
61
61
|
end
|