isodoc 3.7.21 → 3.7.23

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: f78d832952e372d48e705af0e68f1256a591ce795de69db5baea2eb670546e36
4
- data.tar.gz: 611959196a20f772f32a82d975c3e2db5378327ece1ff4013ac4267d8643f5f8
3
+ metadata.gz: 2b1e48dc9ed79bc03c0ad1a12af68a42bb5578647c8860a574df9c8636911fb8
4
+ data.tar.gz: 4a1fcaf6f8dae75fc2d15bc69a691efa537fdde1f56a8b84be8df32e0a1e826b
5
5
  SHA512:
6
- metadata.gz: 79afedd59e0dbd331bc7b62ddbb450596e85267d953cbdbc9be1f9cde78084ff29adbe977969eb1a06aa64fdef6af54ae1093f37e20dde004f087de68ff86217
7
- data.tar.gz: b6b3cf61467751cf58d77715fe62bbc5067bb84dfb7daed10fee83ed130cfa7f47db5eff882e7651a03671d7dd62ec8b4966c247023aa39c3cca4ea253f0c298
6
+ metadata.gz: 8e9b23211a5322bbb620a1cb7b3a74d173dab99a50ad1ae434fd363d1470ab0a61cdb6e41ebbd472dec57fe3548e290df647c4f3fab59ce2a68d3814fa6d3348
7
+ data.tar.gz: 97260e3c8b3aa1f48604772956ee32aca6429caa4265d4837f7818ae0c7e0887554541eda411193bd8c2edb965b8a05b3c3bde05a9c8213e3d726d37c9fcc189
@@ -137,10 +137,22 @@ module IsoDoc
137
137
  dest = docxml.at("//div[@id = 'toc']") or return
138
138
  if source = docxml.at("//div[@class = 'TOC']")
139
139
  dest << to_xml(source.remove.children)
140
+ toc_retarget_source_anchors(dest, source["id"])
140
141
  end
141
142
  dest
142
143
  end
143
144
 
145
+ # The ToC clause headings moved into the destination carry anchor
146
+ # permalinks minted by heading_anchors, pointing at the id of the
147
+ # ToC clause div that has just been removed. Retarget them at the
148
+ # destination the headings now live in, so they do not dangle.
149
+ def toc_retarget_source_anchors(dest, source_id)
150
+ dest.xpath(".//a[@class = 'anchor' or @class = 'header']" \
151
+ "[@href = '##{source_id}']").each do |a|
152
+ a["href"] = "##{dest['id']}"
153
+ end
154
+ end
155
+
144
156
  def html_toc_entries(docxml, path)
145
157
  headers = html_toc_entries_prep(docxml, path)
146
158
  path.each_with_index.with_object([]) do |(p, i), m|
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "3.7.21".freeze
2
+ VERSION = "3.7.23".freeze
3
3
  end
@@ -1,13 +1,17 @@
1
1
  module IsoDoc
2
2
  module WordFunction
3
3
  module Footnotes
4
+ # Word bookmark ids for _Toc and _Ref bookmarks. Minted from a
5
+ # document-scoped counter so that DOCX output is deterministic:
6
+ # identical input yields identical ids on every run (isodoc#923).
7
+ # The `%09d` shape keeps Word's _TocNNNNNNNNN convention.
4
8
  def bookmarkid
5
- ret = "X"
6
- until !@bookmarks_allocated[ret]
7
- ret = Random.rand(1000000000)
8
- end
9
+ @bookmarkid_counter ||= 0
10
+ ret = @bookmarkid_counter += 1
11
+ ret += 1 while @bookmarks_allocated[ret]
9
12
  @bookmarks_allocated[ret] = true
10
- sprintf "%09d", ret
13
+ @bookmarkid_counter = ret
14
+ format "%09d", ret
11
15
  end
12
16
 
13
17
  # Word footnote body id scheme: `ftn` prefix, no colon (Word bookmark
@@ -32,7 +32,7 @@ module IsoDoc
32
32
  end
33
33
 
34
34
  def word_toc_entry(toclevel, heading)
35
- bookmark = bookmarkid # Random.rand(1000000000)
35
+ bookmark = bookmarkid
36
36
  <<~TOC
37
37
  <p class="MsoToc#{toclevel}"><span class="MsoHyperlink"><span lang="EN-GB" style='mso-no-proof:yes'>
38
38
  <a href="#_Toc#{bookmark}">#{heading}<span lang="EN-GB" class="MsoTocTextSpan">
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isodoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.21
4
+ version: 3.7.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-25 00:00:00.000000000 Z
11
+ date: 2026-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64