asciidoctor-html 2.1.2 → 2.1.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.
@@ -38,7 +38,8 @@ module Asciidoctor
38
38
  "imagesdir" => IMG_PATH,
39
39
  "dollar" => "$",
40
40
  "parskip" => %(<span class="parskip"></span><br>),
41
- "notitle" => %(<span class="notitle">&nbsp;</span>)
41
+ "notitle" => %(<span class="notitle">&nbsp;</span>),
42
+ "br" => "<br>"
42
43
  }.freeze
43
44
 
44
45
  DEFAULT_OPTS = {
@@ -111,8 +111,6 @@ module Asciidoctor
111
111
  </div>
112
112
  #{opts[:content]}
113
113
  </div>
114
- #{opts[:paginator]}
115
- #{footer opts[:authors]}
116
114
  </main>
117
115
  HTML
118
116
  end
@@ -243,6 +241,8 @@ module Asciidoctor
243
241
  #{MENU_BTN if nav}
244
242
  #{header opts[:title], opts[:short_title], opts[:chapheading], opts[:has_subnav]}
245
243
  #{main content:, **opts}
244
+ #{opts[:paginator]}
245
+ #{footer opts[:authors]}
246
246
  </div> <!-- .page -->
247
247
  <script>document.getElementById("cr-year").textContent = (new Date()).getFullYear();</script>
248
248
  <script type="module">
@@ -165,24 +165,31 @@ module Asciidoctor
165
165
  end
166
166
 
167
167
  def convert_example(node)
168
- Utils.wrap_node_with_title node.content, node
168
+ Utils.wrap_node(Utils.display_title(node) + node.content, node)
169
169
  end
170
170
 
171
171
  def convert_image(node)
172
172
  content = display_figure node
173
- Utils.wrap_id_classes content, node.id, ["figbox", node.role].compact.join(" ")
173
+ classes = ["figbox", node.role]
174
+ Utils.wrap_live(
175
+ Utils.wrap_id_classes(content, node.id, classes.compact.join(" ")),
176
+ node.attr("live")
177
+ )
174
178
  end
175
179
 
176
180
  def convert_inline_image(node)
177
181
  target = node.target
178
182
  return read_svg_contents(node, target) if node.option?("inline")
179
183
 
180
- mark = node.parent.attr "mark"
184
+ parent = node.parent
185
+ mark = parent.attr "mark"
181
186
  title_attr = node.attr? "title"
182
187
  if mark # The image is part of a figlist
183
188
  title = node.attr("title") if title_attr
184
- %( #{display_image node, target}
185
- <figcaption><span class="li-mark">#{mark}</span>#{title}</figcaption>).gsub(/^ /, "")
189
+ caption = if title_attr || parent.context == :olist
190
+ %(\n <figcaption><span class="li-mark">#{mark}</span>#{title}</figcaption>)
191
+ end
192
+ %( #{display_image node, target}#{caption})
186
193
  else
187
194
  display_image node, target, title_attr:
188
195
  end
@@ -199,6 +206,8 @@ module Asciidoctor
199
206
  end
200
207
 
201
208
  def convert_ulist(node)
209
+ return convert_figlist(node) if node.style == "figlist"
210
+
202
211
  List.convert node, :ul
203
212
  end
204
213
 
@@ -264,7 +273,7 @@ module Asciidoctor
264
273
  width_attribute = %( width="#{tablewidth}%")
265
274
  end
266
275
  result = [%(<table#{Utils.id_class_attr_str node.id, classes.join(" ")}#{width_attribute}>)]
267
- unless node.option? "nocaption"
276
+ if Utils.show_title? node
268
277
  result << %(<caption class="table-title">#{Utils.display_title_prefix node}#{node.title}</caption>)
269
278
  end
270
279
  if node.attr("rowcount").positive? && node.attr?("cols")
@@ -23,18 +23,21 @@ module Asciidoctor
23
23
 
24
24
  def display_figure(node)
25
25
  target = node.attr "target"
26
- title = node.title? ? node.title : ""
26
+ title = node.title if node.title?
27
27
  image = display_image node, target
28
- caption = %( <figcaption>#{Utils.display_title_prefix node}#{title}</figcaption>)
29
- %(<figure>\n #{image}\n#{caption}\n</figure>)
28
+ caption = %( <figcaption>#{Utils.display_title_prefix node}#{title}</figcaption>\n) if Utils.show_title?(node)
29
+ %(<figure>\n #{image}\n#{caption}</figure>)
30
30
  end
31
31
 
32
32
  def convert_figlist(node)
33
+ tagname = node.context == :olist ? :ol : :ul
33
34
  result = node.items.map do |item|
34
35
  %(<li#{Utils.id_class_attr_str item.id, item.role}><figure>\n#{item.text}\n</figure></li>)
35
36
  end
36
- content = Utils.wrap_id_classes result.join("\n"), nil, "figlist", :ol
37
- title = %(<div class="figlist-title">#{Utils.display_title_prefix(node)}#{node.title}</div>)
37
+ content = Utils.wrap_id_classes result.join("\n"), nil, "figlist", tagname
38
+ title = if Utils.show_title?(node)
39
+ %(<div class="figlist-title">#{Utils.display_title_prefix(node)}#{node.title}</div>)
40
+ end
38
41
  classes = ["figlist-wrapper", node.role].compact.join(" ")
39
42
  Utils.wrap_id_classes %(#{content}#{title}), node.id, classes
40
43
  end
@@ -16,6 +16,7 @@ module Asciidoctor
16
16
  const sectsById = { "page": []};
17
17
 
18
18
  const page = document.getElementById('page');
19
+ const main = document.getElementById('main');
19
20
  const focusEl = document.getElementById('content-container');
20
21
  const searchForm = document.getElementById('search-form');
21
22
  const chapheading = page.querySelector('.chapheading');
@@ -45,7 +46,7 @@ module Asciidoctor
45
46
  function focusOnLoad() {
46
47
  if(searchForm) return;
47
48
 
48
- focusEl.focus({preventScroll: !page.classList.contains('presentation')});
49
+ focusEl.focus({preventScroll: true});
49
50
  }
50
51
 
51
52
  function updatePaginator(prev, next) {
@@ -86,7 +87,6 @@ module Asciidoctor
86
87
  } else if(chapPagination.prevChap) {
87
88
  prevPage.replaceWith(chapPagination.prevChap)
88
89
  }
89
- paginator.classList.toggle('visible', paginator.querySelector('a'));
90
90
  }
91
91
 
92
92
  function flip(e) {
@@ -132,14 +132,15 @@ module Asciidoctor
132
132
 
133
133
  ADHT.nudgeMenuBtn();
134
134
 
135
+ const scrollEl = page.classList.contains('presentation') ? main : page;
135
136
  if(target == section) {
136
- page.scrollTo({
137
+ scrollEl.scrollTo({
137
138
  top: 0,
138
139
  left: 0
139
140
  });
140
141
  } else {
141
142
  const rect = target.getBoundingClientRect()
142
- page.scrollTo({
143
+ scrollEl.scrollTo({
143
144
  top: rect.top + page.scrollTop,
144
145
  left: 0
145
146
  });
@@ -148,6 +149,7 @@ module Asciidoctor
148
149
  focusOnLoad();
149
150
  if(isPresentation) focusEl.dataset.flip = id;
150
151
  }
152
+
151
153
  flip();
152
154
 
153
155
  const dropdownItems = document.querySelectorAll('#viewmode-actions .dropdown-item');
@@ -192,6 +194,14 @@ module Asciidoctor
192
194
  }));
193
195
 
194
196
  page.classList.add('loaded');
197
+
198
+ // Chrome does not calculate viewport height correctly in standalone mode.
199
+ if(matchMedia('(display-mode: standalone)').matches &&
200
+ typeof visualViewport !== 'undefined'
201
+ ) {
202
+ page.style.height = visualViewport.height + 'px';
203
+ }
204
+
195
205
  ADHT.move = move;
196
206
  })();
197
207
  JS
@@ -64,7 +64,7 @@ module Asciidoctor
64
64
 
65
65
  const overlay = document.createElement('div');
66
66
  overlay.classList.add('copy-button');
67
- overlay.textContent = result.language.toUpperCase() + ' ';
67
+ // overlay.textContent = result.language.toUpperCase() + ' ';
68
68
 
69
69
  const copyButton = document.createElement('button');
70
70
  copyButton.classList.add('btn');
@@ -22,27 +22,28 @@ module Asciidoctor
22
22
  listing: "ltg-number"
23
23
  }.freeze
24
24
 
25
- def assign_numeral!(node, document, counter_name)
25
+ def assign_numeral!(node, counter_name)
26
+ document = node.document
26
27
  document.counters[counter_name] ||= 0
27
28
  node.numeral = (document.counters[counter_name] += 1)
28
29
  end
29
30
 
30
- def relative_numeral(node, document)
31
+ def relative_numeral(node)
31
32
  return "" unless node.numeral
32
33
 
33
- chapnum = document.attr "chapnum"
34
+ chapnum = node.document.attr "chapnum"
34
35
  has_prefix = chapnum && !chapnum.empty? && chapnum != "0"
35
36
  has_prefix ? "#{chapnum}.#{node.numeral}" : node.numeral.to_s
36
37
  end
37
38
 
38
- def process_numbered_block!(block, document)
39
+ def process_numbered_block!(block)
39
40
  context = block.context
40
41
  style = block.style
41
42
  context = :image if style == "figlist"
42
43
  env = env context, style
43
44
  block.set_attr("showcaption", true) unless context == :stem
44
- assign_numeral! block, document, NUMBERED_CONTEXTS[context] unless context == :section
45
- relative_numeral = relative_numeral block, document
45
+ assign_numeral! block, NUMBERED_CONTEXTS[context] unless context == :section
46
+ relative_numeral = relative_numeral block
46
47
 
47
48
  reftext = if context == :stem
48
49
  "(#{relative_numeral})"
@@ -53,6 +54,19 @@ module Asciidoctor
53
54
  block.set_attr "title-prefix", reftext
54
55
  end
55
56
 
57
+ def process_unnumbered_block!(block)
58
+ reftext = block.title? ? block.title : "[#{block.id}]"
59
+ block.set_attr "reftext", reftext
60
+ end
61
+
62
+ def process_block!(block)
63
+ if block.option? "unnumbered"
64
+ process_unnumbered_block! block
65
+ elsif process_numbered_block? block
66
+ process_numbered_block! block
67
+ end
68
+ end
69
+
56
70
  def env(context, style)
57
71
  case context
58
72
  when :image then "figure"
@@ -69,8 +83,6 @@ module Asciidoctor
69
83
  block.style == "figlist"
70
84
  when :stem, :listing
71
85
  block.option? "numbered"
72
- when :table
73
- !block.option? "nocaption"
74
86
  when :section
75
87
  block.numbered && block.level == 1
76
88
  else
@@ -236,7 +248,7 @@ module Asciidoctor
236
248
  tw = TreeWalker.new document
237
249
  while (block = tw.next_block)
238
250
  unless block.attr? "refprocessed"
239
- process_numbered_block!(block, document) if process_numbered_block?(block)
251
+ process_block! block
240
252
  if colist? block
241
253
  process_colist! block
242
254
  elsif (is_olist = olist? block) || (is_ulist = ulist? block)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Asciidoctor
4
4
  module Html
5
- VERSION = "2.1.2"
5
+ VERSION = "2.1.3"
6
6
  end
7
7
  end
@@ -37,7 +37,7 @@ module Minitest
37
37
  title = display_result_title name, failed, color
38
38
  pre = %([live=normal-faded,asciidoc]\n------\n#{adoc}\n------\n)
39
39
  fail = failed ? display_failure(@results[key].join("\n")) : ""
40
- %([##{id}]\n== #{title}\n\n#{pre}#{fail}\n\n#{adoc}\n\n)
40
+ %([##{id}.flex-grow-1]\n== #{title}\n\n#{pre}#{fail}\n\n#{adoc}\n\n)
41
41
  end
42
42
 
43
43
  def report_files(results, dirname)
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.2
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ravi Rajani