asciidoctor-html 2.2.4 → 2.2.6

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.
@@ -102,20 +102,25 @@ module Asciidoctor
102
102
 
103
103
  const href = location.hash;
104
104
  let id = href.substring(1);
105
- const target = document.getElementById(id);
105
+ let target = document.getElementById(id);
106
106
 
107
- if(!target) id = 'page';
108
-
109
- const isPresentation = page.classList.contains('presentation');
110
- document.querySelector('.breadcrumb').classList.toggle('d-block', id != 'page' && !isPresentation);
111
- document.querySelector('.chapauthors').classList.toggle('d-block', isPresentation);
107
+ if(!target) {
108
+ id = 'page';
109
+ target = page;
110
+ }
112
111
 
113
112
  let section = target && target.closest('.content-container > .section');
114
113
  if(section) {
115
114
  id = section.dataset.withSect;
116
115
  section = sectsById[id][0];
116
+ } else {
117
+ id = 'page';
117
118
  }
118
119
 
120
+ const isPresentation = page.classList.contains('presentation');
121
+ document.querySelector('.breadcrumb').classList.toggle('d-block', id != 'page' && !isPresentation);
122
+ document.querySelector('.chapauthors').classList.toggle('d-block', isPresentation);
123
+
119
124
  for(const key in sectsById) {
120
125
  if(key == id) {
121
126
  const firstSect = sectsById[key][0];
@@ -136,7 +141,7 @@ module Asciidoctor
136
141
  ADHT.nudgeMenuBtn();
137
142
 
138
143
  const scrollEl = isPresentation ? main : page;
139
- if(target == section) {
144
+ if(target == section || target == page) {
140
145
  scrollEl.scrollTo({
141
146
  top: 0,
142
147
  left: 0,
@@ -29,6 +29,12 @@ module Asciidoctor
29
29
  !scrolledOnce && scrollToElement();
30
30
  });
31
31
  addEventListener('hashchange', scrollToElement);
32
+ const clickableHSelector = [2, 3, 4].map(v => `section[id] > h${v}:first-child`).join(', ');
33
+ document.querySelectorAll(clickableHSelector).forEach(el => {
34
+ el.addEventListener('click', function() {
35
+ location.hash = el.parentElement.id;
36
+ });
37
+ });
32
38
  })();
33
39
  JS
34
40
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Asciidoctor
4
4
  module Html
5
- VERSION = "2.2.4"
5
+ VERSION = "2.2.6"
6
6
  end
7
7
  end
@@ -5,7 +5,7 @@ require "cgi"
5
5
 
6
6
  # Add class to Minitest module
7
7
  module Minitest
8
- # Custom reporter class that creates an HTML file in the docs folder
8
+ # Custom reporter class that creates an asciidoc file in the docs folder
9
9
  class HTMLReporter < AbstractReporter
10
10
  DOCS_DIR = "#{__dir__}/../../docs/asciidoc".freeze
11
11
  TESTS_DIR = "#{__dir__}/../../test/asciidoctor/html".freeze
@@ -59,7 +59,7 @@ module Minitest
59
59
  end
60
60
  end
61
61
 
62
- def self.plugin_html_init(_options)
62
+ def self.plugin_adoc_init(_options)
63
63
  reporter << HTMLReporter.new
64
64
  end
65
65
  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
4
+ version: 2.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ravi Rajani
@@ -137,7 +137,7 @@ files:
137
137
  - lib/asciidoctor/html/utils.rb
138
138
  - lib/asciidoctor/html/version.rb
139
139
  - lib/asciidoctor/html/webmanifest.rb
140
- - lib/minitest/html_plugin.rb
140
+ - lib/minitest/adoc_plugin.rb
141
141
  homepage: https://github.com/ravirajani/asciidoctor-html
142
142
  licenses:
143
143
  - MIT