asciidoctor-autoterm 1.0.5 → 1.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c8192a4a53f24ff15393cef22492236d6008e36cf26ca7a32b7effa0e72dccd
4
- data.tar.gz: c15610cd243fddd07394530cfc9ededc306e8c862f8fa85c3d9ff8b9786e7983
3
+ metadata.gz: c048e78c3879fd1f6499635746910ce0d10be44248308f9c3cd3e8a42dd0e273
4
+ data.tar.gz: 73c8ee930a26cd91a0c8e596877bbd62bda0751d1d78066521bdbe7721d19ff4
5
5
  SHA512:
6
- metadata.gz: dfd54fb234911200003f93a2ba8e6194662a989ea2619c48a3e77cf5985c631089903c374ef22639fdf7c654daa61d8a318c762425f1106a8b804e60d2442443
7
- data.tar.gz: 47b9476e439c8c0e3414738f0a69f95517fb9dd5da3feee2e72d5307d8aefe1e281cb56766b4578172b7ee1cb3603ce6a7d67d4a47891c9d7688792ffcb727a0
6
+ metadata.gz: af6a59f777c5c38859024888dffbcc5657cf159a9240daf1fdae69505a87aec7298ca24866bea236a9b5d27383a70afd0f0000ee0664eb5151c156080f69df2b
7
+ data.tar.gz: 4d2c0eb31572bfaad3d166e1f94500ba14d7f1d2732c81d94143e55e03e741adca3b55793771e2bd06cbc003940014276169f48c6ddb5863880ede2fcf167bef
data/CHANGELOG.adoc CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  All notable changes to `asciidoctor-autoterm` are documented here.
4
4
 
5
+ == 1.0.6 (2026-08-01)
6
+
7
+ * Fixed: `antora-extension/index.js` adds a `nav.adoc` entry tagged `role=hidden` for each stub page. Required for the Assembler's merge to include the stub in the fused PDF document; the 1.0.5 extension omitted it, so a page `xref` to `terminology.adoc`/`index-page.adoc` never resolved to an in-document PDF link. See README.adoc
8
+ * Fixed: `antora_processor.rb` finds the placeholder chapter `antora-extension/index.js` adds and mutates it in place into the real Terminology/Index section, instead of always appending a new one. Appending unconditionally left the placeholder as an empty, separately-ID'd chapter, so a correctly-resolved `xref` pointed at the empty placeholder, not the generated content. See README.adoc
9
+
5
10
  == 1.0.5 (2026-08-01)
6
11
 
7
12
  * Added: `antora-extension/index.js`, a companion Antora extension that registers publishable Terminology and Index stub pages so `xref` targets resolve. Published separately as `@baiyibai-asciidoctor/autoterm`; not shipped in the gem. See README.adoc
data/README.adoc CHANGED
@@ -91,7 +91,9 @@ More information on using the Index with Antora Assembler is available at these
91
91
 
92
92
  == Antora HTML Site: Resolving `xref` Targets for Terminology and Index
93
93
 
94
- `@baiyibai-asciidoctor/autoterm` is an Antora Node.js extension that assists asciidoctor-pdf and antora-assembler: it registers publishable Terminology and Index stub pages so `xref` targets to them resolve.
94
+ `@baiyibai-asciidoctor/autoterm` is an Antora Node.js extension that assists asciidoctor-pdf and antora-assembler.
95
+ It registers publishable Terminology and Index stub pages, each with a `nav.adoc` entry tagged `role=hidden`, so `xref` targets to them resolve and the Assembler's merge includes them in the same document.
96
+ Starting at 1.0.5, the gem's tree-processor finds each stub by its title and mutates it in place into the real section, instead of appending a duplicate.
95
97
  Wrap a source reference to either page in `ifdef::loader-assembler[]` and `endif::[]` so it renders only for the PDF build.
96
98
 
97
99
  [source,yaml]
@@ -101,3 +103,24 @@ antora:
101
103
  - require: '@baiyibai-asciidoctor/autoterm'
102
104
  ----
103
105
 
106
+ [IMPORTANT]
107
+ ====
108
+ `role=hidden` carries no built-in meaning for Antora or its default UI.
109
+ A consuming UI bundle's nav template MUST skip rendering an item carrying that role, or the stub pages appear in the HTML site's navigation.
110
+ For a Handlebars-based UI bundle derived from `@antora/ui-default`, wrap the item in `partials/nav-tree.hbs`:
111
+
112
+ [source,hbs]
113
+ ----
114
+ {{#unless (includes ./roles 'hidden')}}
115
+ <!-- existing <li> markup -->
116
+ {{/unless}}
117
+ ----
118
+
119
+ with an `includes` helper:
120
+
121
+ [source,js]
122
+ ----
123
+ module.exports = (arr, val) => Array.isArray(arr) && arr.includes(val)
124
+ ----
125
+ ====
126
+
@@ -1,14 +1,41 @@
1
1
  Asciidoctor::Extensions.register do
2
2
  tree_processor do
3
3
  process do |doc|
4
+ # A page xref to a real Antora page (xref:terminology.adoc[]) resolves to
5
+ # whatever section the Antora Assembler's rewriter computed for that page,
6
+ # not to a section this tree-processor creates fresh: the rewriter runs
7
+ # before this tree-processor, against a page that does not carry the real
8
+ # content yet. Creating a brand new section unconditionally, as this used
9
+ # to do, produces a second, differently-ID'd "Terminology"/"Index"
10
+ # section, leaving the fused page's own empty placeholder chapter in
11
+ # place with the ID any such xref actually resolves to.
12
+ #
13
+ # antora-extension/index.js registers that placeholder chapter (titled
14
+ # exactly "Terminology" / "Index") when include-terminology /
15
+ # include-index is set, so this tree-processor finds and mutates it in
16
+ # place instead of appending a new section, keeping it at the ID any
17
+ # page xref already resolved to. Standalone (non-Antora) usage, where no
18
+ # such placeholder exists, falls back to appending a new section as
19
+ # before.
4
20
  if doc.attributes['include-terminology'] == 'true'
5
- if (last_section = doc.sections.last)
21
+ if (existing = doc.find_by(context: :section) { |s| s.level == 1 && s.title == 'Terminology' }.first)
22
+ existing.sectname = 'index'
23
+ existing.special = true
24
+ existing.set_attr 'type', 'terminology'
25
+ existing.set_attr 'sectnums', nil
26
+ existing.numbered = false
27
+ elsif (last_section = doc.sections.last)
6
28
  terminology_section = create_section last_section.parent, 'Terminology', { 'style' => 'index', 'type' => 'terminology' }, numbered: false
7
29
  terminology_section.parent << terminology_section
8
30
  end
9
31
  end
10
32
  if doc.attributes['include-index'] == 'true'
11
- if (last_section = doc.sections.last)
33
+ if (existing = doc.find_by(context: :section) { |s| s.level == 1 && s.title == 'Index' }.first)
34
+ existing.sectname = 'index'
35
+ existing.special = true
36
+ existing.set_attr 'sectnums', nil
37
+ existing.numbered = false
38
+ elsif (last_section = doc.sections.last)
12
39
  index_section = create_section last_section.parent, 'Index', { 'style' => 'index' }, numbered: false
13
40
  index_section.parent << index_section
14
41
  end
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Autoterm
3
- VERSION = '1.0.5'
3
+ VERSION = '1.0.6'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-autoterm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - 白一百 baiyibai