isodoc 3.7.25 → 3.7.26
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 +4 -4
- data/lib/isodoc/presentation_function/autonum.rb +12 -5
- data/lib/isodoc/presentation_function/ids.rb +33 -7
- data/lib/isodoc/presentation_function/index.rb +4 -3
- data/lib/isodoc/presentation_function/refs.rb +1 -2
- data/lib/isodoc/presentation_function/terms.rb +3 -2
- data/lib/isodoc/presentation_function/title.rb +1 -1
- data/lib/isodoc/presentation_xml_convert.rb +2 -0
- data/lib/isodoc/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 981c1b0638a7137a7820962c95cde1ced5ef159fa309d5c9f60999a4b62743a5
|
|
4
|
+
data.tar.gz: d819ce6fd9b8cb2552652f20e8f5e59013795dbe1f73f1754610bfda7325cfdf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 15e00f5f1990e31e7bf46f9cb1bc8dc4fe2697ee75abe87e1bf08871e8766cb55334d350036e71c3cc0801c4ccd6df4ea392f7aed0c101ef6224498d83d134eb
|
|
7
|
+
data.tar.gz: f5073b2bd2a4ef3aedec9e3bffe6b7c9e24d667bab345a9943d1bd3499dba820f6eab6f58620f23e31373414fbdd768309d9abf310c9ca19a9db9214f604cbf4
|
|
@@ -22,17 +22,24 @@ module IsoDoc
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def prefix_name_prep(node, elem)
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
name = node.at(ns("./#{elem}"))
|
|
26
|
+
lbls = prefix_name_labels(node, elem, name)
|
|
27
|
+
name and name["id"] = lbls[:name]
|
|
27
28
|
ins = name || node.add_first_child("<sentinel/>").elements.first
|
|
28
29
|
node["unnumbered"] or
|
|
29
30
|
number = @xrefs.anchor(node["id"], :value, false)&.strip
|
|
30
31
|
[name, ins, lbls, number]
|
|
31
32
|
end
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
# the minted id addresses the name element when it exists; when it
|
|
35
|
+
# does not, the id goes unused, but a mint still takes place, so
|
|
36
|
+
# that mint ordering is stable regardless of document shape
|
|
37
|
+
def prefix_name_labels(node, elem, name)
|
|
38
|
+
if name
|
|
39
|
+
id = minted_id(Metanorma::Utils.contenthash(name), shaped: true)
|
|
40
|
+
else
|
|
41
|
+
id = minted_id("#{elem}\t#{node['id']}")
|
|
42
|
+
end
|
|
36
43
|
{ elem: node["id"], name: id }
|
|
37
44
|
end
|
|
38
45
|
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
+
require "digest"
|
|
2
|
+
|
|
1
3
|
module IsoDoc
|
|
2
4
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
|
3
|
-
def add_id_text
|
|
4
|
-
id
|
|
5
|
-
@new_ids[id] = nil
|
|
6
|
-
%(id="#{id}")
|
|
5
|
+
def add_id_text(content = nil)
|
|
6
|
+
%(id="#{minted_id(content)}")
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def add_id(elem)
|
|
10
10
|
elem["id"] and return
|
|
11
|
-
id =
|
|
12
|
-
elem["id"] = id
|
|
13
|
-
@new_ids[id] = nil
|
|
11
|
+
elem["id"] = minted_id(Metanorma::Utils.contenthash(elem), shaped: true)
|
|
14
12
|
end
|
|
15
13
|
|
|
16
14
|
def id_validate(docxml)
|
|
@@ -139,5 +137,33 @@ module IsoDoc
|
|
|
139
137
|
end
|
|
140
138
|
end
|
|
141
139
|
end
|
|
140
|
+
|
|
141
|
+
private
|
|
142
|
+
|
|
143
|
+
# Ids minted during Presentation XML conversion are derived from
|
|
144
|
+
# content at mint time, carrying the same MD5/UUID shaping as
|
|
145
|
+
# Metanorma::Utils.contenthash. They are therefore stable across
|
|
146
|
+
# runs of the same input, and contenthash_id_cleanup converges them
|
|
147
|
+
# unchanged in the steady state. Seeds recurring within one compile
|
|
148
|
+
# are disambiguated by a deterministic re-hash, so minted ids stay
|
|
149
|
+
# unique; call sites without content (inherited flavors) fall back
|
|
150
|
+
# to the deterministic mint ordinal.
|
|
151
|
+
def minted_id(seed, shaped: false)
|
|
152
|
+
count = @minted_seeds[seed] += 1
|
|
153
|
+
id = if count > 1
|
|
154
|
+
contenthash_str("#{seed}\t#{count}")
|
|
155
|
+
elsif shaped
|
|
156
|
+
seed
|
|
157
|
+
else
|
|
158
|
+
contenthash_str(seed.to_s)
|
|
159
|
+
end
|
|
160
|
+
@new_ids[id] = nil
|
|
161
|
+
id
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def contenthash_str(str)
|
|
165
|
+
Digest::MD5.hexdigest(str)
|
|
166
|
+
.sub(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, "_\\1-\\2-\\3-\\4-\\5")
|
|
167
|
+
end
|
|
142
168
|
end
|
|
143
169
|
end
|
|
@@ -8,8 +8,9 @@ module IsoDoc
|
|
|
8
8
|
if xml.at(ns("//index"))
|
|
9
9
|
i = xml.at(ns("//indexsect")) ||
|
|
10
10
|
xml.root.add_child(
|
|
11
|
-
"<indexsect #{add_id_text}>" \
|
|
12
|
-
"<fmt-title #{add_id_text
|
|
11
|
+
"<indexsect #{add_id_text(@i18n.index)}>" \
|
|
12
|
+
"<fmt-title #{add_id_text(@i18n.index)}>" \
|
|
13
|
+
"#{@i18n.index}</fmt-title></indexsect>",
|
|
13
14
|
).first
|
|
14
15
|
index = sort_indexterms(xml.xpath(ns("//index")),
|
|
15
16
|
xml.xpath(ns("//index-xref[@also = 'false']")),
|
|
@@ -88,7 +89,7 @@ module IsoDoc
|
|
|
88
89
|
end
|
|
89
90
|
|
|
90
91
|
def index_entries_head(head, entries, opt)
|
|
91
|
-
ret = "<li #{add_id_text}>#{head}"
|
|
92
|
+
ret = "<li #{add_id_text(head)}>#{head}"
|
|
92
93
|
xref = entries&.dig(:xref)&.join(", ")
|
|
93
94
|
see = index_entries_see(entries, :see)
|
|
94
95
|
also = index_entries_see(entries, :also)
|
|
@@ -211,8 +211,7 @@ module IsoDoc
|
|
|
211
211
|
ret = ident_fn(bib)
|
|
212
212
|
date_note = bibnote_extract(bib, "Unpublished-Status")
|
|
213
213
|
date_note.empty? and return ret
|
|
214
|
-
id =
|
|
215
|
-
@new_ids[id] = nil
|
|
214
|
+
id = minted_id(date_note.first.content)
|
|
216
215
|
<<~XML
|
|
217
216
|
#{ret}<fn id='#{id}' reference='#{id}'><p>#{date_note.first.content}</p></fn>
|
|
218
217
|
XML
|
|
@@ -87,9 +87,10 @@ module IsoDoc
|
|
|
87
87
|
|
|
88
88
|
def multidef(_elem, defn, fmt_defn)
|
|
89
89
|
ret = defn.each_with_object([]) do |f, m|
|
|
90
|
-
|
|
90
|
+
c = to_xml(semx_fmt_dup(f))
|
|
91
|
+
m << "<li #{add_id_text(c)}>#{c}</li>"
|
|
91
92
|
end
|
|
92
|
-
fmt_defn << "<ol #{add_id_text}>#{ret.join("\n")}</ol>"
|
|
93
|
+
fmt_defn << "<ol #{add_id_text(ret.join("\n"))}>#{ret.join("\n")}</ol>"
|
|
93
94
|
end
|
|
94
95
|
|
|
95
96
|
def singledef(_elem, defn, fmt_defn)
|
|
@@ -102,7 +102,7 @@ module IsoDoc
|
|
|
102
102
|
docxml.at(ns("//preface/clause[@type = 'toc']")) and return
|
|
103
103
|
ins = toc_title_insert_pt(docxml) or return
|
|
104
104
|
ins.previous = <<~CLAUSE
|
|
105
|
-
<clause type = 'toc' #{add_id_text}><fmt-title depth='1'>#{@i18n.table_of_contents}</fmt-title></clause>
|
|
105
|
+
<clause type = 'toc' #{add_id_text(@i18n.table_of_contents)}><fmt-title depth='1'>#{@i18n.table_of_contents}</fmt-title></clause>
|
|
106
106
|
CLAUSE
|
|
107
107
|
end
|
|
108
108
|
|
data/lib/isodoc/version.rb
CHANGED