asciidoctor-html 2.2.2 → 2.2.4
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/.rubocop.yml +2 -2
- data/CHANGELOG.md +8 -0
- data/assets/css/jupyterlite-repl.css +1 -1
- data/assets/css/styles.css +2 -2
- data/lib/asciidoctor/html/converter.rb +12 -18
- data/lib/asciidoctor/html/list.rb +4 -1
- data/lib/asciidoctor/html/live.rb +18 -0
- data/lib/asciidoctor/html/ref_tree_processor.rb +2 -1
- data/lib/asciidoctor/html/subnav_block_macro.rb +2 -1
- data/lib/asciidoctor/html/utils.rb +27 -14
- data/lib/asciidoctor/html/version.rb +1 -1
- metadata +2 -2
|
@@ -7,6 +7,7 @@ require_relative "figure"
|
|
|
7
7
|
require_relative "table"
|
|
8
8
|
require_relative "tabs"
|
|
9
9
|
require_relative "jupyterlite"
|
|
10
|
+
require_relative "live"
|
|
10
11
|
|
|
11
12
|
module Asciidoctor
|
|
12
13
|
module Html
|
|
@@ -17,17 +18,7 @@ module Asciidoctor
|
|
|
17
18
|
include Figure
|
|
18
19
|
|
|
19
20
|
def convert_embedded(node)
|
|
20
|
-
|
|
21
|
-
if node.footnotes?
|
|
22
|
-
result << %(<div class="fn-wrapper">)
|
|
23
|
-
result << %(<div class="footnote-separator"></div><div class="footnotes">)
|
|
24
|
-
node.footnotes.each do |fn|
|
|
25
|
-
result << %(<div class="fn-row"><div class="fn-mark">#{fn.index}</div>)
|
|
26
|
-
result << %(<div class="footnote" id="_footnotedef_#{fn.index}">#{fn.text}</div></div>)
|
|
27
|
-
end
|
|
28
|
-
result << %(</div></div>)
|
|
29
|
-
end
|
|
30
|
-
result.join("\n")
|
|
21
|
+
node.content
|
|
31
22
|
end
|
|
32
23
|
|
|
33
24
|
def convert_preamble(node)
|
|
@@ -41,8 +32,11 @@ module Asciidoctor
|
|
|
41
32
|
classes = "section#{" flip" if level == 1}#{" #{node.role}" if node.role}"
|
|
42
33
|
display_sectnum = Utils.display_sectnum(node, level) if show_sectnum
|
|
43
34
|
title = "#{display_sectnum}#{node.title}"
|
|
44
|
-
content =
|
|
45
|
-
Utils.
|
|
35
|
+
content = node.content
|
|
36
|
+
result = ["#{Utils.heading node, title}#{content}"]
|
|
37
|
+
footnotes = Utils.display_footnotes(node, content) if node.level == 1
|
|
38
|
+
result << footnotes if footnotes
|
|
39
|
+
Utils.wrap_id_classes result.join("\n"), node.id, classes, :section
|
|
46
40
|
end
|
|
47
41
|
|
|
48
42
|
def convert_floating_title(node)
|
|
@@ -147,7 +141,7 @@ module Asciidoctor
|
|
|
147
141
|
end
|
|
148
142
|
title = Utils.display_title node
|
|
149
143
|
content = title + pre_open + node.content + pre_close
|
|
150
|
-
|
|
144
|
+
Live.wrap_live Utils.wrap_node(content, node), node.attr("live")
|
|
151
145
|
end
|
|
152
146
|
|
|
153
147
|
def convert_literal(node)
|
|
@@ -181,7 +175,7 @@ module Asciidoctor
|
|
|
181
175
|
def convert_image(node)
|
|
182
176
|
content = display_figure node
|
|
183
177
|
classes = ["figbox", node.role]
|
|
184
|
-
|
|
178
|
+
Live.wrap_live(
|
|
185
179
|
Utils.wrap_id_classes(content, node.id, classes.compact.join(" ")),
|
|
186
180
|
node.attr("live")
|
|
187
181
|
)
|
|
@@ -243,8 +237,8 @@ module Asciidoctor
|
|
|
243
237
|
result << "</dd>"
|
|
244
238
|
end
|
|
245
239
|
result << "</dl>\n"
|
|
246
|
-
|
|
247
|
-
|
|
240
|
+
Live.wrap_live(Utils.wrap_id_classes_with_title(result.join("\n"), node, node.id, "dlist-wrapper"),
|
|
241
|
+
node.attr("live"))
|
|
248
242
|
end
|
|
249
243
|
|
|
250
244
|
def convert_inline_anchor(node)
|
|
@@ -302,7 +296,7 @@ module Asciidoctor
|
|
|
302
296
|
end
|
|
303
297
|
result << "#{Table.display_rows(node)}</table>"
|
|
304
298
|
wrap_classes = "table-responsive#{" #{node.role}" if node.role}"
|
|
305
|
-
|
|
299
|
+
Live.wrap_live Utils.wrap_id_classes(result.join("\n"), nil, wrap_classes), node.attr("live")
|
|
306
300
|
end
|
|
307
301
|
end
|
|
308
302
|
end
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "utils"
|
|
4
|
+
require_relative "live"
|
|
5
|
+
|
|
3
6
|
module Asciidoctor
|
|
4
7
|
module Html
|
|
5
8
|
# Helper functions for the list conversion
|
|
@@ -26,7 +29,7 @@ module Asciidoctor
|
|
|
26
29
|
end
|
|
27
30
|
result << %(</#{tag_name}> <!-- .level-#{level} -->\n)
|
|
28
31
|
wrap_classes = %(list-wrapper#{" #{node.role}" if node.title? && node.role})
|
|
29
|
-
|
|
32
|
+
Live.wrap_live Utils.wrap_id_classes_with_title(result.join("\n"), node, node.id, wrap_classes), node.attr("live")
|
|
30
33
|
end
|
|
31
34
|
|
|
32
35
|
def self.display_list_item(item, inside: false)
|
|
@@ -135,6 +135,24 @@ module Asciidoctor
|
|
|
135
135
|
});
|
|
136
136
|
})();
|
|
137
137
|
JS
|
|
138
|
+
|
|
139
|
+
def self.wrap_live(content, live_attr)
|
|
140
|
+
return content unless live_attr
|
|
141
|
+
|
|
142
|
+
/\A(?<default>normal|faded|covered)-(?<live>faded|covered)\Z/ =~ live_attr
|
|
143
|
+
|
|
144
|
+
live_class = %(live-#{live || "faded"})
|
|
145
|
+
default_class = %(live-default-#{default || "normal"})
|
|
146
|
+
<<~HTML
|
|
147
|
+
<div class="live #{default_class} #{live_class}" data-reset="#{default_class}">
|
|
148
|
+
<div class="live-select">
|
|
149
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="live-icon" transform="scale(-1 1)" viewBox="0 0 512 512">
|
|
150
|
+
<path d="M403.623 242.703 226.443 8.728c-7.34-9.693-21.153-11.606-30.845-4.258-9.701 7.34-11.607 21.16-4.266 30.861l23.85 31.484c-50.984 22.605-111.261 5.426-111.261 5.426 27.887 45.796 77.341 56.749 92.622 59.093-28.271 33.774-45.388 77.234-45.396 124.674.023 66.872 33.936 125.966 85.396 160.969l-45.211 59.693c-7.341 9.701-5.435 23.52 4.266 30.869 9.692 7.333 23.505 5.427 30.845-4.258v-.008l177.18-233.982c5.942-7.856 5.942-18.74 0-26.588m-207.08 64.681c-9.393 0-17.011-23.013-17.011-51.406 0-28.363 7.618-51.377 17.011-51.377s17.01 23.014 17.01 51.377c0 28.393-7.618 51.406-17.01 51.406m66.587 74.482a152.3 152.3 0 0 1-35.857-33.036c19.5-9.846 34.02-47.632 34.02-92.852 0-45.189-14.52-82.968-34.005-92.822a151.7 151.7 0 0 1 35.842-33.006l95.32 125.858z" fill="currentColor"/>
|
|
151
|
+
</svg>
|
|
152
|
+
</div>
|
|
153
|
+
#{content}</div> <!-- .live -->
|
|
154
|
+
HTML
|
|
155
|
+
end
|
|
138
156
|
end
|
|
139
157
|
end
|
|
140
158
|
end
|
|
@@ -48,7 +48,8 @@ module Asciidoctor
|
|
|
48
48
|
context = :image if style == "figlist"
|
|
49
49
|
env = env context, style
|
|
50
50
|
block.set_attr("showcaption", true) unless context == :stem
|
|
51
|
-
|
|
51
|
+
counter_name = NUMBERED_CONTEXTS[context]
|
|
52
|
+
assign_numeral!(block, counter_name) if counter_name
|
|
52
53
|
relative_numeral = relative_numeral block
|
|
53
54
|
|
|
54
55
|
reftext = if context == :stem
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "asciidoctor"
|
|
4
4
|
require "pathname"
|
|
5
|
+
require_relative "live"
|
|
5
6
|
|
|
6
7
|
module Asciidoctor
|
|
7
8
|
module Html
|
|
@@ -28,7 +29,7 @@ module Asciidoctor
|
|
|
28
29
|
</nav>
|
|
29
30
|
</div>
|
|
30
31
|
HTML
|
|
31
|
-
content =
|
|
32
|
+
content = Live.wrap_live content, attrs["live"]
|
|
32
33
|
create_pass_block parent, content, attrs, subs: nil
|
|
33
34
|
end
|
|
34
35
|
end
|
|
@@ -86,20 +86,6 @@ module Asciidoctor
|
|
|
86
86
|
%(<span class="title-mark">#{sectnum}</span>)
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
-
def self.wrap_live(content, live_attr)
|
|
90
|
-
return content unless live_attr
|
|
91
|
-
|
|
92
|
-
/\A(?<default>normal|faded|covered)-(?<live>faded|covered)\Z/ =~ live_attr
|
|
93
|
-
|
|
94
|
-
live_class = %(live-#{live || "faded"})
|
|
95
|
-
default_class = %(live-default-#{default || "normal"})
|
|
96
|
-
<<~HTML
|
|
97
|
-
<div class="live #{default_class} #{live_class}" data-reset="#{default_class}">
|
|
98
|
-
<div class="live-select"><i class="bi bi-eye"></i></div>
|
|
99
|
-
#{content}</div> <!-- .live -->
|
|
100
|
-
HTML
|
|
101
|
-
end
|
|
102
|
-
|
|
103
89
|
def self.line_number_attr(line_number, live: false)
|
|
104
90
|
live ? %( data-line-number="#{line_number}") : ""
|
|
105
91
|
end
|
|
@@ -121,6 +107,33 @@ module Asciidoctor
|
|
|
121
107
|
def self.reftext(node)
|
|
122
108
|
node.reftext || (node.title unless node.inline?) || "[#{node.id}]" if node.id
|
|
123
109
|
end
|
|
110
|
+
|
|
111
|
+
# index_filter: Hash(index => bool)
|
|
112
|
+
def self.display_footnotes(node, content)
|
|
113
|
+
footnotes = []
|
|
114
|
+
content.scan(/data-contentid="_footnotedef_(\d)"/) do |matches|
|
|
115
|
+
index = matches&.first&.to_i
|
|
116
|
+
fn = node.document.footnotes.select { |fn| fn.index == index }.first
|
|
117
|
+
next unless fn
|
|
118
|
+
|
|
119
|
+
footnotes << <<~HTML
|
|
120
|
+
<div class="fn-row">
|
|
121
|
+
<div class="fn-mark">#{fn.index}</div>
|
|
122
|
+
<div class="footnote" id="_footnotedef_#{fn.index}">#{fn.text}</div>
|
|
123
|
+
</div>
|
|
124
|
+
HTML
|
|
125
|
+
end
|
|
126
|
+
return if footnotes.empty?
|
|
127
|
+
|
|
128
|
+
<<~HTML
|
|
129
|
+
<div class="fn-wrapper">
|
|
130
|
+
<div class="footnote-separator"></div>
|
|
131
|
+
<div class="footnotes">
|
|
132
|
+
#{footnotes.join "\n"}
|
|
133
|
+
</div> <!-- .footnotes -->
|
|
134
|
+
</div> <!-- .fn-wrapper -->
|
|
135
|
+
HTML
|
|
136
|
+
end
|
|
124
137
|
end
|
|
125
138
|
end
|
|
126
139
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: asciidoctor-html
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.2.
|
|
4
|
+
version: 2.2.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ravi Rajani
|
|
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
160
160
|
- !ruby/object:Gem::Version
|
|
161
161
|
version: '0'
|
|
162
162
|
requirements: []
|
|
163
|
-
rubygems_version: 3.6.
|
|
163
|
+
rubygems_version: 3.6.7
|
|
164
164
|
specification_version: 4
|
|
165
165
|
summary: An AsciiDoc-to-HTML static site generator based on Asciidoctor.
|
|
166
166
|
test_files: []
|