asciidoctor-html 2.0.3 → 2.1.1
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 +7 -4
- data/CHANGELOG.md +8 -0
- data/assets/css/jupyterlite.css +1 -0
- data/assets/css/styles.css +2 -2
- data/jupyterlite/.gitignore +116 -0
- data/jupyterlite/content/data/matplotlib.png +0 -0
- data/jupyterlite/content/pyodide/matplotlib.ipynb +113 -0
- data/jupyterlite/content/python.ipynb +721 -0
- data/jupyterlite/overrides.json +5 -0
- data/jupyterlite/repl/jupyter-lite.json +12 -0
- data/jupyterlite/requirements.txt +7 -0
- data/lib/asciidoctor/html/book.rb +9 -2
- data/lib/asciidoctor/html/book_template.rb +28 -16
- data/lib/asciidoctor/html/cli.rb +12 -2
- data/lib/asciidoctor/html/converter.rb +33 -12
- data/lib/asciidoctor/html/cref_inline_macro.rb +2 -2
- data/lib/asciidoctor/html/flip.rb +5 -8
- data/lib/asciidoctor/html/highlightjs.rb +6 -0
- data/lib/asciidoctor/html/jupyterlite.rb +64 -0
- data/lib/asciidoctor/html/list.rb +3 -2
- data/lib/asciidoctor/html/live.rb +140 -0
- data/lib/asciidoctor/html/ref_tree_processor.rb +31 -16
- data/lib/asciidoctor/html/subnav_block_macro.rb +1 -0
- data/lib/asciidoctor/html/table.rb +12 -3
- data/lib/asciidoctor/html/utils.rb +18 -0
- data/lib/asciidoctor/html/version.rb +1 -1
- data/lib/asciidoctor/html.rb +0 -1
- data/lib/minitest/html_plugin.rb +1 -1
- metadata +11 -1
|
@@ -41,7 +41,7 @@ module Asciidoctor
|
|
|
41
41
|
context = :image if style == "figlist"
|
|
42
42
|
env = env context, style
|
|
43
43
|
block.set_attr("showcaption", true) unless context == :stem
|
|
44
|
-
assign_numeral! block, document, NUMBERED_CONTEXTS[context]
|
|
44
|
+
assign_numeral! block, document, NUMBERED_CONTEXTS[context] unless context == :section
|
|
45
45
|
relative_numeral = relative_numeral block, document
|
|
46
46
|
|
|
47
47
|
reftext = if context == :stem
|
|
@@ -69,6 +69,10 @@ module Asciidoctor
|
|
|
69
69
|
block.style == "figlist"
|
|
70
70
|
when :stem, :listing
|
|
71
71
|
block.option? "numbered"
|
|
72
|
+
when :table
|
|
73
|
+
!block.option? "nocaption"
|
|
74
|
+
when :section
|
|
75
|
+
block.numbered && block.level == 1
|
|
72
76
|
else
|
|
73
77
|
NUMBERED_CONTEXTS.include? context
|
|
74
78
|
end
|
|
@@ -152,7 +156,7 @@ module Asciidoctor
|
|
|
152
156
|
end
|
|
153
157
|
block.set_attr "list-depth", depth
|
|
154
158
|
if flat_style
|
|
155
|
-
block.set_attr
|
|
159
|
+
block.set_attr "flat-style", true
|
|
156
160
|
else
|
|
157
161
|
offset = offset block
|
|
158
162
|
style = block.style
|
|
@@ -194,8 +198,9 @@ module Asciidoctor
|
|
|
194
198
|
register_reftext! item, mark
|
|
195
199
|
end
|
|
196
200
|
|
|
197
|
-
def process_source_code!(document, lang)
|
|
201
|
+
def process_source_code!(document, lang, linenums: false)
|
|
198
202
|
document.set_attr("source-langs", {}) unless document.attr?("source-langs")
|
|
203
|
+
document.set_attr("linenumbering", true) if !document.attr?("linenumbering") && linenums
|
|
199
204
|
langs = document.attr "source-langs"
|
|
200
205
|
langs[lang] = true unless Highlightjs::INCLUDED_LANGS.include?(lang)
|
|
201
206
|
end
|
|
@@ -225,29 +230,39 @@ module Asciidoctor
|
|
|
225
230
|
end
|
|
226
231
|
|
|
227
232
|
def process(document)
|
|
228
|
-
listdepth = 0
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
flat_idx = 0 # flat index for (pseudocode) list
|
|
233
|
+
listdepth = bulletdepth = flat_idx = 0
|
|
234
|
+
flat_style = live = false
|
|
235
|
+
line_number = 1
|
|
232
236
|
tw = TreeWalker.new document
|
|
233
237
|
while (block = tw.next_block)
|
|
234
238
|
unless block.attr? "refprocessed"
|
|
235
239
|
process_numbered_block!(block, document) if process_numbered_block?(block)
|
|
236
240
|
if colist? block
|
|
237
241
|
process_colist! block
|
|
238
|
-
elsif olist? block
|
|
239
|
-
if listdepth.zero?
|
|
242
|
+
elsif (is_olist = olist? block) || (is_ulist = ulist? block)
|
|
243
|
+
if is_olist && listdepth.zero?
|
|
240
244
|
flat_style = (block.style == "pseudocode")
|
|
241
245
|
flat_idx = offset block
|
|
242
246
|
end
|
|
243
|
-
process_olist!
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
+
process_olist!(block, listdepth, flat_style:) if is_olist
|
|
248
|
+
process_ulist!(block, bulletdepth) if is_ulist
|
|
249
|
+
if (listdepth + bulletdepth).zero?
|
|
250
|
+
live = block.attr?("live")
|
|
251
|
+
document.set_attr "live", true if live && !document.attr?("live")
|
|
252
|
+
line_number = offset(block) + 1
|
|
253
|
+
end
|
|
254
|
+
elsif (is_olist_item = olist_item? block) || ulist_item?(block)
|
|
255
|
+
if is_olist_item && flat_style
|
|
256
|
+
process_flat_item! block, flat_idx
|
|
257
|
+
flat_idx += 1
|
|
258
|
+
end
|
|
259
|
+
if live
|
|
260
|
+
block.set_attr "line-number", line_number
|
|
261
|
+
line_number += 1
|
|
262
|
+
end
|
|
247
263
|
elsif source_code? block
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
process_ulist! block, bulletdepth
|
|
264
|
+
linenums = block.option?("linenums") || block.attr?("live")
|
|
265
|
+
process_source_code! document, block.attr("language"), linenums:
|
|
251
266
|
end
|
|
252
267
|
block.set_attr "refprocessed", true
|
|
253
268
|
end
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "utils"
|
|
4
|
+
|
|
3
5
|
module Asciidoctor
|
|
4
6
|
module Html
|
|
5
7
|
# Helpers for the table conversion
|
|
6
8
|
module Table
|
|
7
|
-
def self.display_row(tsec, row)
|
|
8
|
-
result = ["<tr>"]
|
|
9
|
+
def self.display_row(tsec, row, line_number, live: false)
|
|
10
|
+
result = ["<tr#{Utils.line_number_attr line_number, live:}>"]
|
|
9
11
|
row.each do |cell|
|
|
10
12
|
cell_content = if tsec == :head
|
|
11
13
|
cell.text
|
|
@@ -31,10 +33,17 @@ module Asciidoctor
|
|
|
31
33
|
end
|
|
32
34
|
|
|
33
35
|
def self.display_rows(node)
|
|
36
|
+
line_number = 0
|
|
37
|
+
live = node.attr? "live"
|
|
34
38
|
node.rows.to_h.map do |tsec, rows|
|
|
35
39
|
next if rows.empty?
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
result = rows.map do |row|
|
|
42
|
+
show_lineno = live && tsec != :head
|
|
43
|
+
line_number += 1 if show_lineno
|
|
44
|
+
display_row(tsec, row, line_number, live: show_lineno)
|
|
45
|
+
end
|
|
46
|
+
"<t#{tsec}>\n#{result.join "\n"}\n</t#{tsec}>"
|
|
38
47
|
end.join("\n")
|
|
39
48
|
end
|
|
40
49
|
end
|
|
@@ -85,6 +85,24 @@ module Asciidoctor
|
|
|
85
85
|
end
|
|
86
86
|
%(<span class="title-mark">#{sectnum}</span>)
|
|
87
87
|
end
|
|
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
|
+
def self.line_number_attr(line_number, live: false)
|
|
104
|
+
live ? %( data-line-number="#{line_number}") : ""
|
|
105
|
+
end
|
|
88
106
|
end
|
|
89
107
|
end
|
|
90
108
|
end
|
data/lib/asciidoctor/html.rb
CHANGED
data/lib/minitest/html_plugin.rb
CHANGED
|
@@ -35,7 +35,7 @@ module Minitest
|
|
|
35
35
|
color = failed ? "danger" : "success"
|
|
36
36
|
id = "test-#{name.tr "_", "-"}"
|
|
37
37
|
title = display_result_title name, failed, color
|
|
38
|
-
pre = %([
|
|
38
|
+
pre = %([live=normal-faded,asciidoc]\n------\n#{adoc}\n------\n)
|
|
39
39
|
fail = failed ? display_failure(@results[key].join("\n")) : ""
|
|
40
40
|
%([##{id}]\n== #{title}\n\n#{pre}#{fail}\n\n#{adoc}\n\n)
|
|
41
41
|
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.
|
|
4
|
+
version: 2.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ravi Rajani
|
|
@@ -95,6 +95,7 @@ files:
|
|
|
95
95
|
- Rakefile
|
|
96
96
|
- assets/css/fonts/bootstrap-icons.woff
|
|
97
97
|
- assets/css/fonts/bootstrap-icons.woff2
|
|
98
|
+
- assets/css/jupyterlite.css
|
|
98
99
|
- assets/css/styles.css
|
|
99
100
|
- assets/favicon/android-chrome-192x192.png
|
|
100
101
|
- assets/favicon/android-chrome-512x512.png
|
|
@@ -103,6 +104,13 @@ files:
|
|
|
103
104
|
- assets/favicon/favicon-32x32.png
|
|
104
105
|
- assets/favicon/favicon.ico
|
|
105
106
|
- exe/adoctohtml
|
|
107
|
+
- jupyterlite/.gitignore
|
|
108
|
+
- jupyterlite/content/data/matplotlib.png
|
|
109
|
+
- jupyterlite/content/pyodide/matplotlib.ipynb
|
|
110
|
+
- jupyterlite/content/python.ipynb
|
|
111
|
+
- jupyterlite/overrides.json
|
|
112
|
+
- jupyterlite/repl/jupyter-lite.json
|
|
113
|
+
- jupyterlite/requirements.txt
|
|
106
114
|
- lib/asciidoctor/html.rb
|
|
107
115
|
- lib/asciidoctor/html/bi_inline_macro.rb
|
|
108
116
|
- lib/asciidoctor/html/book.rb
|
|
@@ -113,7 +121,9 @@ files:
|
|
|
113
121
|
- lib/asciidoctor/html/figure.rb
|
|
114
122
|
- lib/asciidoctor/html/flip.rb
|
|
115
123
|
- lib/asciidoctor/html/highlightjs.rb
|
|
124
|
+
- lib/asciidoctor/html/jupyterlite.rb
|
|
116
125
|
- lib/asciidoctor/html/list.rb
|
|
126
|
+
- lib/asciidoctor/html/live.rb
|
|
117
127
|
- lib/asciidoctor/html/pagination.rb
|
|
118
128
|
- lib/asciidoctor/html/popovers.rb
|
|
119
129
|
- lib/asciidoctor/html/ref_tree_processor.rb
|