asciidoctor-html 2.1.0 → 2.1.2
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/jupyterlite.css +1 -0
- data/assets/css/styles.css +1 -1
- data/exe/build-jupyterlite +35 -0
- 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 +2 -0
- data/lib/asciidoctor/html/cli.rb +12 -2
- data/lib/asciidoctor/html/converter.rb +10 -1
- data/lib/asciidoctor/html/cref_inline_macro.rb +2 -2
- data/lib/asciidoctor/html/jupyterlite.rb +64 -0
- data/lib/asciidoctor/html/ref_tree_processor.rb +3 -1
- data/lib/asciidoctor/html/version.rb +1 -1
- data/lib/asciidoctor/html.rb +0 -1
- metadata +12 -1
|
@@ -31,6 +31,7 @@ module Asciidoctor
|
|
|
31
31
|
|
|
32
32
|
DOCATTRS = {
|
|
33
33
|
"sectids" => false,
|
|
34
|
+
"xrefstyle" => "short",
|
|
34
35
|
"stem" => "latexmath",
|
|
35
36
|
"hide-uri-scheme" => true,
|
|
36
37
|
"source-highlighter" => "highlight.js",
|
|
@@ -59,6 +60,7 @@ module Asciidoctor
|
|
|
59
60
|
# - short_title
|
|
60
61
|
# - authors
|
|
61
62
|
# - chapname
|
|
63
|
+
# - base_url
|
|
62
64
|
def initialize(opts = {})
|
|
63
65
|
opts = DEFAULT_OPTS.merge opts
|
|
64
66
|
@title = ERB::Escape.html_escape opts[:title]
|
data/lib/asciidoctor/html/cli.rb
CHANGED
|
@@ -8,6 +8,7 @@ require "psych"
|
|
|
8
8
|
require_relative "book"
|
|
9
9
|
require_relative "webmanifest"
|
|
10
10
|
require_relative "version"
|
|
11
|
+
require_relative "jupyterlite"
|
|
11
12
|
|
|
12
13
|
module Asciidoctor
|
|
13
14
|
module Html
|
|
@@ -53,10 +54,11 @@ module Asciidoctor
|
|
|
53
54
|
"#{config["srcdir"]}/#{f}"
|
|
54
55
|
end
|
|
55
56
|
end
|
|
57
|
+
config["jupyterlite"] = config["jupyterlite"] || false
|
|
56
58
|
config
|
|
57
59
|
end
|
|
58
60
|
|
|
59
|
-
def self.setup_outdir(srcdir, outdir)
|
|
61
|
+
def self.setup_outdir(srcdir, outdir, jupyterlite: false)
|
|
60
62
|
assets_out = "#{outdir}/#{ASSETS_PATH}"
|
|
61
63
|
FileUtils.mkdir_p assets_out unless File.directory?(assets_out)
|
|
62
64
|
%W[#{IMG_PATH} #{CSS_PATH} #{FAVICON_PATH}].each do |p|
|
|
@@ -76,6 +78,7 @@ module Asciidoctor
|
|
|
76
78
|
puts
|
|
77
79
|
FileUtils.cp_r "#{rootdir}/#{p}", assets_out
|
|
78
80
|
end
|
|
81
|
+
build_jupyterlite(rootdir, outdir) if jupyterlite
|
|
79
82
|
end
|
|
80
83
|
|
|
81
84
|
def self.generate_webmanifest(outdir, name, short_name)
|
|
@@ -95,6 +98,13 @@ module Asciidoctor
|
|
|
95
98
|
book_opts
|
|
96
99
|
end
|
|
97
100
|
|
|
101
|
+
def self.build_jupyterlite(rootdir, outdir)
|
|
102
|
+
jupyterlite_outdir = "#{outdir}/#{Jupyterlite::PATH}"
|
|
103
|
+
return if File.directory?(jupyterlite_outdir)
|
|
104
|
+
|
|
105
|
+
system %(#{rootdir}/exe/build-jupyterlite -o "#{jupyterlite_outdir}" "#{rootdir}/#{Jupyterlite::PATH}")
|
|
106
|
+
end
|
|
107
|
+
|
|
98
108
|
def self.run(opts = nil)
|
|
99
109
|
opts ||= parse_opts
|
|
100
110
|
if opts[:version]
|
|
@@ -105,7 +115,7 @@ module Asciidoctor
|
|
|
105
115
|
outdir = config["outdir"]
|
|
106
116
|
srcdir = config["srcdir"]
|
|
107
117
|
book_opts = generate_bookopts config
|
|
108
|
-
setup_outdir srcdir, outdir
|
|
118
|
+
setup_outdir srcdir, outdir, jupyterlite: config["jupyterlite"]
|
|
109
119
|
generate_webmanifest outdir, book_opts[:title], book_opts[:short_title]
|
|
110
120
|
book = Book.new book_opts
|
|
111
121
|
puts "Writing book to\n #{outdir}"
|
|
@@ -5,6 +5,7 @@ require_relative "list"
|
|
|
5
5
|
require_relative "utils"
|
|
6
6
|
require_relative "figure"
|
|
7
7
|
require_relative "table"
|
|
8
|
+
require_relative "jupyterlite"
|
|
8
9
|
|
|
9
10
|
module Asciidoctor
|
|
10
11
|
module Html
|
|
@@ -119,6 +120,14 @@ module Asciidoctor
|
|
|
119
120
|
end
|
|
120
121
|
|
|
121
122
|
def convert_listing(node)
|
|
123
|
+
if node.option? "jupyter"
|
|
124
|
+
return Utils.wrap_id_classes(
|
|
125
|
+
"#{Utils.display_title node}#{Jupyterlite.html node}",
|
|
126
|
+
node.id,
|
|
127
|
+
"jupyter-cell-wrapper"
|
|
128
|
+
)
|
|
129
|
+
end
|
|
130
|
+
|
|
122
131
|
nowrap = (node.option? "nowrap") || !(node.document.attr? "prewrap")
|
|
123
132
|
if node.style == "source"
|
|
124
133
|
classes = []
|
|
@@ -132,7 +141,7 @@ module Asciidoctor
|
|
|
132
141
|
pre_open = %(<pre#{%( class="nowrap") if nowrap}>)
|
|
133
142
|
pre_close = "</pre>"
|
|
134
143
|
end
|
|
135
|
-
title = Utils.display_title
|
|
144
|
+
title = Utils.display_title node
|
|
136
145
|
content = title + pre_open + node.content + pre_close
|
|
137
146
|
Utils.wrap_live Utils.wrap_node(content, node), node.attr("live")
|
|
138
147
|
end
|
|
@@ -28,8 +28,8 @@ module Asciidoctor
|
|
|
28
28
|
tag = path_tag.size > 1 ? path_tag[1] : "chapref"
|
|
29
29
|
doc_key = Pathname(path).sub_ext ""
|
|
30
30
|
text = attrs["text"] || %(<%= refs.dig("#{doc_key}", "#{tag}") || "[#{doc_key}][#{tag}]" %>)
|
|
31
|
-
|
|
32
|
-
href = "#{Pathname(path).sub_ext ".html"}#{
|
|
31
|
+
hashtag = "##{path_tag[1]}" if path_tag.size > 1
|
|
32
|
+
href = "#{Pathname(path).sub_ext ".html"}#{hashtag}"
|
|
33
33
|
create_anchor parent, text, type: :link, target: href
|
|
34
34
|
end
|
|
35
35
|
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Asciidoctor
|
|
4
|
+
module Html
|
|
5
|
+
# Constants for the jupyterlite library
|
|
6
|
+
module Jupyterlite
|
|
7
|
+
class << self
|
|
8
|
+
attr_accessor :cell_id
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
PATH = "jupyterlite"
|
|
12
|
+
REPL_PATH = "repl/index.html"
|
|
13
|
+
|
|
14
|
+
CONFIG = {
|
|
15
|
+
toolbar: true,
|
|
16
|
+
kernel: "python",
|
|
17
|
+
promptCellPosition: "left",
|
|
18
|
+
clearCellsOnExecute: true,
|
|
19
|
+
hideCodeInput: true,
|
|
20
|
+
clearCodeContentOnExecute: false,
|
|
21
|
+
showBanner: false,
|
|
22
|
+
execute: false
|
|
23
|
+
}.freeze
|
|
24
|
+
|
|
25
|
+
def self.repl_path_with_options(node)
|
|
26
|
+
query_string = ["code=#{URI.encode_uri_component node.content}"]
|
|
27
|
+
query_string << CONFIG.merge(
|
|
28
|
+
{ promptCellPosition: node.attr("prompt-position", "left") }
|
|
29
|
+
).map do |k, v|
|
|
30
|
+
value = if v == true
|
|
31
|
+
1
|
|
32
|
+
elsif v == false
|
|
33
|
+
0
|
|
34
|
+
else
|
|
35
|
+
v
|
|
36
|
+
end
|
|
37
|
+
"#{k}=#{URI.encode_uri_component value}"
|
|
38
|
+
end
|
|
39
|
+
"#{REPL_PATH}?#{query_string.join "&"}"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.html(node)
|
|
43
|
+
@cell_id += 1
|
|
44
|
+
cell_id = "jupyter-cell-frame-#{@cell_id}"
|
|
45
|
+
height_attr = %( style="height: #{node.attr("height")}px;") if node.attr?("height")
|
|
46
|
+
<<~HTML
|
|
47
|
+
<div id="#{cell_id}"#{height_attr} class="jupyter-cell"></div>
|
|
48
|
+
<script>
|
|
49
|
+
(function(){
|
|
50
|
+
const cell = document.getElementById('#{cell_id}');
|
|
51
|
+
addEventListener('load', () => {
|
|
52
|
+
const frame = document.createElement('iframe');
|
|
53
|
+
frame.src = '#{PATH}/#{repl_path_with_options node}';
|
|
54
|
+
frame.width = '100%';
|
|
55
|
+
frame.height = '100%';
|
|
56
|
+
cell.appendChild(frame);
|
|
57
|
+
});
|
|
58
|
+
})();
|
|
59
|
+
</script>
|
|
60
|
+
HTML
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -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
|
|
@@ -71,6 +71,8 @@ module Asciidoctor
|
|
|
71
71
|
block.option? "numbered"
|
|
72
72
|
when :table
|
|
73
73
|
!block.option? "nocaption"
|
|
74
|
+
when :section
|
|
75
|
+
block.numbered && block.level == 1
|
|
74
76
|
else
|
|
75
77
|
NUMBERED_CONTEXTS.include? context
|
|
76
78
|
end
|
data/lib/asciidoctor/html.rb
CHANGED
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.1.
|
|
4
|
+
version: 2.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ravi Rajani
|
|
@@ -83,6 +83,7 @@ email:
|
|
|
83
83
|
- ravi.inajar@gmail.com
|
|
84
84
|
executables:
|
|
85
85
|
- adoctohtml
|
|
86
|
+
- build-jupyterlite
|
|
86
87
|
extensions: []
|
|
87
88
|
extra_rdoc_files: []
|
|
88
89
|
files:
|
|
@@ -95,6 +96,7 @@ files:
|
|
|
95
96
|
- Rakefile
|
|
96
97
|
- assets/css/fonts/bootstrap-icons.woff
|
|
97
98
|
- assets/css/fonts/bootstrap-icons.woff2
|
|
99
|
+
- assets/css/jupyterlite.css
|
|
98
100
|
- assets/css/styles.css
|
|
99
101
|
- assets/favicon/android-chrome-192x192.png
|
|
100
102
|
- assets/favicon/android-chrome-512x512.png
|
|
@@ -103,6 +105,14 @@ files:
|
|
|
103
105
|
- assets/favicon/favicon-32x32.png
|
|
104
106
|
- assets/favicon/favicon.ico
|
|
105
107
|
- exe/adoctohtml
|
|
108
|
+
- exe/build-jupyterlite
|
|
109
|
+
- jupyterlite/.gitignore
|
|
110
|
+
- jupyterlite/content/data/matplotlib.png
|
|
111
|
+
- jupyterlite/content/pyodide/matplotlib.ipynb
|
|
112
|
+
- jupyterlite/content/python.ipynb
|
|
113
|
+
- jupyterlite/overrides.json
|
|
114
|
+
- jupyterlite/repl/jupyter-lite.json
|
|
115
|
+
- jupyterlite/requirements.txt
|
|
106
116
|
- lib/asciidoctor/html.rb
|
|
107
117
|
- lib/asciidoctor/html/bi_inline_macro.rb
|
|
108
118
|
- lib/asciidoctor/html/book.rb
|
|
@@ -113,6 +123,7 @@ files:
|
|
|
113
123
|
- lib/asciidoctor/html/figure.rb
|
|
114
124
|
- lib/asciidoctor/html/flip.rb
|
|
115
125
|
- lib/asciidoctor/html/highlightjs.rb
|
|
126
|
+
- lib/asciidoctor/html/jupyterlite.rb
|
|
116
127
|
- lib/asciidoctor/html/list.rb
|
|
117
128
|
- lib/asciidoctor/html/live.rb
|
|
118
129
|
- lib/asciidoctor/html/pagination.rb
|