asciidoctor-html 2.2.1 → 2.2.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.
@@ -9,7 +9,6 @@ require_relative "cref_inline_macro"
9
9
  require_relative "bi_inline_macro"
10
10
  require_relative "text_inline_macro"
11
11
  require_relative "subnav_block_macro"
12
- require_relative "reuse_block_macro"
13
12
  require_relative "book_template"
14
13
  require_relative "pagination"
15
14
  require_relative "search"
@@ -28,7 +27,6 @@ module Asciidoctor
28
27
  inline_macro TextInlineMacro
29
28
  inline_macro BiInlineMacro
30
29
  block_macro SubnavBlockMacro
31
- block_macro ReuseBlockMacro
32
30
  end
33
31
 
34
32
  DOCATTRS = {
@@ -17,17 +17,7 @@ module Asciidoctor
17
17
  include Figure
18
18
 
19
19
  def convert_embedded(node)
20
- result = [node.content]
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")
20
+ node.content
31
21
  end
32
22
 
33
23
  def convert_preamble(node)
@@ -41,8 +31,11 @@ module Asciidoctor
41
31
  classes = "section#{" flip" if level == 1}#{" #{node.role}" if node.role}"
42
32
  display_sectnum = Utils.display_sectnum(node, level) if show_sectnum
43
33
  title = "#{display_sectnum}#{node.title}"
44
- content = "#{Utils.heading node, title}#{node.content}"
45
- Utils.wrap_id_classes content, node.id, classes, :section
34
+ content = node.content
35
+ result = ["#{Utils.heading node, title}#{content}"]
36
+ footnotes = Utils.display_footnotes(node, content) if node.level == 1
37
+ result << footnotes if footnotes
38
+ Utils.wrap_id_classes result.join("\n"), node.id, classes, :section
46
39
  end
47
40
 
48
41
  def convert_floating_title(node)
@@ -92,25 +92,6 @@ module Asciidoctor
92
92
  }
93
93
  }
94
94
 
95
- function reuseElements() {
96
- focusEl.querySelectorAll(':scope > .flip.d-block .reuse').forEach(target => {
97
- const link = target && target.querySelector('a.reuse-link');
98
- if(!link) return;
99
-
100
- const source = document.getElementById(link.hash.substring(1));
101
- let reuse = source && source.parentElement;
102
- if(!reuse) return;
103
-
104
- if(!reuse.classList.contains('reuse')) {
105
- reuse = document.createElement('div');
106
- reuse.classList.add('reuse');
107
- source.replaceWith(reuse);
108
- }
109
- reuse.replaceChildren(...target.children);
110
- target.replaceChildren(source);
111
- });
112
- }
113
-
114
95
  function flip(e) {
115
96
  if(!page.classList.contains('multi')) {
116
97
  focusOnLoad();
@@ -147,8 +128,6 @@ module Asciidoctor
147
128
  }
148
129
  }
149
130
 
150
- reuseElements();
151
-
152
131
  nav.forEach(el => {
153
132
  const a = el.querySelector('a');
154
133
  a && a.hash && el.classList.toggle('active', id == a.hash.substring(1));
@@ -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
- assign_numeral! block, NUMBERED_CONTEXTS[context] unless context == :section
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
@@ -121,6 +121,33 @@ module Asciidoctor
121
121
  def self.reftext(node)
122
122
  node.reftext || (node.title unless node.inline?) || "[#{node.id}]" if node.id
123
123
  end
124
+
125
+ # index_filter: Hash(index => bool)
126
+ def self.display_footnotes(node, content)
127
+ footnotes = []
128
+ content.scan(/data-contentid="_footnotedef_(\d)"/) do |matches|
129
+ index = matches&.first&.to_i
130
+ fn = node.document.footnotes.select { |fn| fn.index == index }.first
131
+ next unless fn
132
+
133
+ footnotes << <<~HTML
134
+ <div class="fn-row">
135
+ <div class="fn-mark">#{fn.index}</div>
136
+ <div class="footnote" id="_footnotedef_#{fn.index}">#{fn.text}</div>
137
+ </div>
138
+ HTML
139
+ end
140
+ return if footnotes.empty?
141
+
142
+ <<~HTML
143
+ <div class="fn-wrapper">
144
+ <div class="footnote-separator"></div>
145
+ <div class="footnotes">
146
+ #{footnotes.join "\n"}
147
+ </div> <!-- .footnotes -->
148
+ </div> <!-- .fn-wrapper -->
149
+ HTML
150
+ end
124
151
  end
125
152
  end
126
153
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Asciidoctor
4
4
  module Html
5
- VERSION = "2.2.1"
5
+ VERSION = "2.2.3"
6
6
  end
7
7
  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.1
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ravi Rajani
@@ -126,7 +126,6 @@ files:
126
126
  - lib/asciidoctor/html/pagination.rb
127
127
  - lib/asciidoctor/html/popovers.rb
128
128
  - lib/asciidoctor/html/ref_tree_processor.rb
129
- - lib/asciidoctor/html/reuse_block_macro.rb
130
129
  - lib/asciidoctor/html/scroll.rb
131
130
  - lib/asciidoctor/html/search.rb
132
131
  - lib/asciidoctor/html/sidebar.rb
@@ -161,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
160
  - !ruby/object:Gem::Version
162
161
  version: '0'
163
162
  requirements: []
164
- rubygems_version: 3.6.7
163
+ rubygems_version: 3.6.9
165
164
  specification_version: 4
166
165
  summary: An AsciiDoc-to-HTML static site generator based on Asciidoctor.
167
166
  test_files: []
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "asciidoctor"
4
- require_relative "utils"
5
-
6
- module Asciidoctor
7
- module Html
8
- # Reuse blocks, especially useful in multi mode
9
- class ReuseBlockMacro < Asciidoctor::Extensions::BlockMacroProcessor
10
- use_dsl
11
-
12
- named :reuse
13
- name_positional_attributes "reftext"
14
-
15
- def process(parent, target, attrs)
16
- if target.empty?
17
- content = Utils.show_error "Missing target."
18
- else
19
- el = parent.document.catalog[:refs][target]
20
- reftext = el && (attrs["reftext"] || Utils.reftext(el))
21
- title = %(<div class="block-title">#{parent.apply_subs attrs["title"]}</div>) if attrs.include?("title")
22
- content = if reftext
23
- id = %( id="#{attrs["id"]}") if attrs.include?("id")
24
- classes = %( #{attrs["role"]}) if attrs.include?("role")
25
- <<~HTML
26
- <div#{id} class="reuse#{classes}">
27
- #{title}
28
- <p><a class="reuse-link" href="##{target}">#{reftext}</a></p>
29
- </div>
30
- HTML
31
- else
32
- Utils.show_error "Invalid ID."
33
- end
34
- end
35
- create_pass_block parent, content, attrs, subs: nil
36
- end
37
- end
38
- end
39
- end