isodoc 1.8.3.2 → 2.0.0.1

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: a491aebbf7d96bbb11f6bd7129c7219c5b8a369a2dbb68526d4e96ab404844ea
4
- data.tar.gz: 774fad3f626285e163ce640d73e1eec0467db607ea8ce96ea2c7df29c12d7d3b
3
+ metadata.gz: 3cf2e2e18bcb28744fc2f4cf2525267935dc981281ab4642c7b0e57ea8b68b6d
4
+ data.tar.gz: 12f9afbb69bd5e9903dd15ace22e5a3357520dfc8c58e4a316bc8e92a42e34bb
5
5
  SHA512:
6
- metadata.gz: b0b41b09f83e226704f423400471cc34747252cb8adc8d796d9ca3f1eee5e1302fd4f07d94a93b60059766962b3263c773197f51975fea59f255e84c08cffde6
7
- data.tar.gz: ae011856532563358213949b61f4797779fbeb531f65ae3ad5a41f1b4b1904b01a7c43734980113ff54db90246413a422294d20f231f5f7b2778f36d9abf08af
6
+ metadata.gz: b3996461e5a31740161f1bf08c0305b7e9faa229f263da26deaaf9fd50924c9cb39f2eaffacf4b6e69992a197d81c10b130a82b06d0c630917b3c22b34eca615
7
+ data.tar.gz: 7c3a9fe8073d10c915e56f06bf973b6e7dfbd2e6296604598d93b90267496f74ebf5cbb2bcfd970eafafc0c808dc69e9273b0a1e1975a459e32993bfe0f57de6
@@ -10,34 +10,6 @@ on:
10
10
 
11
11
  jobs:
12
12
  rake:
13
- name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
14
- runs-on: ${{ matrix.os }}
15
- continue-on-error: ${{ matrix.experimental }}
16
- strategy:
17
- fail-fast: false
18
- matrix:
19
- ruby: [ '3.0', '2.7', '2.6', '2.5' ]
20
- os: [ ubuntu-latest, windows-latest, macos-latest ]
21
- experimental: [ false ]
22
- steps:
23
- - uses: actions/checkout@master
24
-
25
- - uses: ruby/setup-ruby@v1
26
- with:
27
- ruby-version: ${{ matrix.ruby }}
28
- bundler-cache: true
29
-
30
- - uses: metanorma/metanorma-build-scripts/inkscape-setup-action@master
31
-
32
- - run: bundle exec rake
33
-
34
- tests-passed:
35
- needs: rake
36
- runs-on: ubuntu-latest
37
- steps:
38
- - uses: peter-evans/repository-dispatch@v1
39
- with:
40
- token: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
41
- repository: ${{ github.repository }}
42
- event-type: tests-passed
43
- client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
13
+ uses: metanorma/metanorma-build-scripts/.github/workflows/inkscape-rake.yml@main
14
+ secrets:
15
+ pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
data/Gemfile CHANGED
@@ -10,4 +10,3 @@ if File.exist? "Gemfile.devel"
10
10
  eval File.read("Gemfile.devel"), nil, "Gemfile.devel" # rubocop:disable Security/Eval
11
11
  end
12
12
 
13
- gem "reline", "~> 0.2.8.pre.11"
@@ -68,6 +68,12 @@ code *, pre *, tt *, kbd *, samp * {
68
68
  font-family: {{monospacefont}} !important;
69
69
  font-variant-ligatures: none; }
70
70
 
71
+ p code, dt code, li code, label code, legend code, caption code, th code, td code,
72
+ p tt, dt tt, li tt, label tt, legend tt, caption tt, th tt, td tt,
73
+ p kbd, dt kbd, li kbd, label kbd, legend kbd, caption kbd, th kbd, td kbd,
74
+ p samp, dt samp, li samp, label samp, legend samp, caption samp, th samp, td samp {
75
+ font-size: {{monospacefontsize}}; }
76
+
71
77
  article, aside, details, figcaption, figure,
72
78
  footer, header, hgroup, menu, nav, section {
73
79
  display: block; }
@@ -79,6 +85,9 @@ table {
79
85
  h1, h2, h3, h4, h5, h6 {
80
86
  font-family: {{headerfont}}; }
81
87
 
88
+ .h1, .h2, .h3, .h4, .h5, .h6 {
89
+ font-family: {{headerfont}}; }
90
+
82
91
  blockquote, q {
83
92
  quotes: none; }
84
93
  blockquote:before, blockquote:after, q:before, q:after {
@@ -68,6 +68,12 @@ code *, pre *, tt *, kbd *, samp * {
68
68
  font-family: {{monospacefont}} !important;
69
69
  font-variant-ligatures: none; }
70
70
 
71
+ p code, dt code, li code, label code, legend code, caption code, th code, td code,
72
+ p tt, dt tt, li tt, label tt, legend tt, caption tt, th tt, td tt,
73
+ p kbd, dt kbd, li kbd, label kbd, legend kbd, caption kbd, th kbd, td kbd,
74
+ p samp, dt samp, li samp, label samp, legend samp, caption samp, th samp, td samp {
75
+ font-size: {{monospacefontsize}}; }
76
+
71
77
  article, aside, details, figcaption, figure,
72
78
  footer, header, hgroup, menu, nav, section {
73
79
  display: block; }
@@ -79,6 +85,9 @@ table {
79
85
  h1, h2, h3, h4, h5, h6 {
80
86
  font-family: {{headerfont}}; }
81
87
 
88
+ .h1, .h2, .h3, .h4, .h5, .h6 {
89
+ font-family: {{headerfont}}; }
90
+
82
91
  blockquote, q {
83
92
  quotes: none; }
84
93
  blockquote:before, blockquote:after, q:before, q:after {
@@ -74,6 +74,13 @@ code *, pre *, tt *, kbd *, samp * {
74
74
  font-variant-ligatures: none;
75
75
  }
76
76
 
77
+ p code, dt code, li code, label code, legend code, caption code, th code, td code,
78
+ p tt, dt tt, li tt, label tt, legend tt, caption tt, th tt, td tt,
79
+ p kbd, dt kbd, li kbd, label kbd, legend kbd, caption kbd, th kbd, td kbd,
80
+ p samp, dt samp, li samp, label samp, legend samp, caption samp, th samp, td samp {
81
+ font-size: $monospacefontsize;
82
+ }
83
+
77
84
  article, aside, details, figcaption, figure,
78
85
  footer, header, hgroup, menu, nav, section {
79
86
  display: block;
@@ -88,6 +95,10 @@ h1, h2, h3, h4, h5, h6 {
88
95
  font-family: $headerfont;
89
96
  }
90
97
 
98
+ .h1, .h2, .h3, .h4, .h5, .h6 {
99
+ font-family: $headerfont;
100
+ }
101
+
91
102
  blockquote, q {
92
103
  quotes: none;
93
104
 
@@ -28,25 +28,37 @@ module IsoDoc
28
28
  Liquid::Template.parse(doc)
29
29
  end
30
30
 
31
- def case_strict(text, casing, script)
31
+ def case_strict(text, casing, script, firstonly: true)
32
32
  return text unless %w(Latn Cyrl Grek Armn).include?(script)
33
33
 
34
- letters = text.chars
34
+ seen = false
35
+ text.split(/(\s+)/).map do |w|
36
+ letters = w.chars
37
+ case_strict1(letters, casing) if !seen || !firstonly
38
+ seen ||= /\S/.match?(w)
39
+ letters.join
40
+ end.join
41
+ end
42
+
43
+ def case_strict1(letters, casing)
44
+ return letters if letters.empty?
45
+
35
46
  case casing
36
47
  when "capital" then letters.first.upcase!
37
48
  when "lowercase" then letters.first.downcase!
49
+ when "allcaps" then letters.map(&:upcase!)
38
50
  end
39
- letters.join
40
51
  end
41
52
 
42
- def case_with_markup(linkend, casing, script)
53
+ def case_with_markup(linkend, casing, script, firstonly: true)
43
54
  seen = false
44
55
  xml = Nokogiri::XML("<root>#{linkend}</root>")
45
56
  xml.traverse do |b|
46
57
  next unless b.text? && !seen
47
58
 
48
- b.replace(Common::case_strict(b.text, casing, script))
49
- seen = true
59
+ b.replace(Common::case_strict(b.text, casing, script,
60
+ firstonly: firstonly))
61
+ seen = true if firstonly
50
62
  end
51
63
  xml.root.children.to_xml
52
64
  end
@@ -5,6 +5,7 @@ require "fileutils"
5
5
  require "tempfile"
6
6
  require_relative "i18n"
7
7
  require_relative "css"
8
+ require "securerandom"
8
9
 
9
10
  module IsoDoc
10
11
  class Convert < ::IsoDoc::Common
@@ -103,10 +104,16 @@ module IsoDoc
103
104
  @fn_bookmarks = {}
104
105
  @baseassetpath = options[:baseassetpath]
105
106
  @aligncrosselements = options[:aligncrosselements]
107
+ @tmpimagedir_suffix = tmpimagedir_suffix
108
+ @tmpfilesdir_suffix = tmpfilesdir_suffix
106
109
  end
107
110
 
108
111
  def tmpimagedir_suffix
109
- "_images"
112
+ "_#{SecureRandom.hex(8)}_images"
113
+ end
114
+
115
+ def tmpfilesdir_suffix
116
+ "_#{SecureRandom.hex(8)}_files"
110
117
  end
111
118
 
112
119
  def html_doc_path(*file)
@@ -174,10 +174,13 @@ module IsoDoc
174
174
  end
175
175
  end
176
176
 
177
- def para_class(_node)
177
+ def para_class(node)
178
178
  classtype = nil
179
179
  classtype = "MsoCommentText" if in_comment
180
180
  classtype = "Sourcecode" if @annotation
181
+ if node["type"] == "floating-title"
182
+ classtype = "h#{node['depth']}"
183
+ end
181
184
  classtype
182
185
  end
183
186
 
@@ -14,27 +14,28 @@ module IsoDoc
14
14
  def nonstd_bibitem(list, bib, ordinal, biblio)
15
15
  list.p **attr_code(iso_bibitem_entry_attrs(bib, biblio)) do |ref|
16
16
  ids = bibitem_ref_code(bib)
17
- identifiers = render_identifier(ids)
18
- if biblio then ref_entry_code(ref, ordinal, identifiers, ids)
17
+ idents = render_identifier(ids)
18
+ if biblio then ref_entry_code(ref, ordinal, idents, ids)
19
19
  else
20
- ref << (identifiers[0] || identifiers[1]).to_s
21
- ref << ", #{identifiers[1]}" if identifiers[0] && identifiers[1]
20
+ ref << (idents[:ordinal] || idents[:metanorma] || idents[:sdo]).to_s
21
+ ref << ", #{idents[sdo]}" if idents[:ordinal] && idents[:sdo]
22
22
  end
23
- ref << ", " unless biblio && !identifiers[1]
23
+ ref << ", " unless biblio && !idents[:sdo]
24
24
  reference_format(bib, ref)
25
25
  end
26
26
  end
27
27
 
28
28
  def std_bibitem_entry(list, bib, ordinal, biblio)
29
29
  list.p **attr_code(iso_bibitem_entry_attrs(bib, biblio)) do |ref|
30
- identifiers = render_identifier(bibitem_ref_code(bib))
31
- if biblio then ref_entry_code(ref, ordinal, identifiers, nil)
30
+ idents = render_identifier(bibitem_ref_code(bib))
31
+ if biblio then ref_entry_code(ref, ordinal, idents, nil)
32
32
  else
33
- ref << (identifiers[0] || identifiers[1]).to_s
34
- ref << ", #{identifiers[1]}" if identifiers[0] && identifiers[1]
33
+ ref << (idents[:ordinal] || idents[:metanorma] || idents[:sdo]).to_s
34
+ ref << ", #{idents[:sdo]}" if (idents[:ordinal] ||
35
+ idents[:metanorma]) && idents[:sdo]
35
36
  end
36
37
  date_note_process(bib, ref)
37
- ref << ", " unless biblio && !identifiers[1]
38
+ ref << ", " unless biblio && !idents[:sdo]
38
39
  reference_format(bib, ref)
39
40
  end
40
41
  end
@@ -42,13 +43,15 @@ module IsoDoc
42
43
  # if ids is just a number, only use that ([1] Non-Standard)
43
44
  # else, use both ordinal, as prefix, and ids
44
45
  def ref_entry_code(ref, ordinal, ids, _id)
45
- prefix_bracketed_ref(ref, ids[0] || "[#{ordinal}]")
46
- ids[1] and ref << (ids[1]).to_s
46
+ prefix_bracketed_ref(ref, ids[:ordinal] || ids[:metanorma] ||
47
+ "[#{ordinal}]")
48
+ ids[:sdo] and ref << (ids[:sdo]).to_s
47
49
  end
48
50
 
49
51
  def pref_ref_code(bib)
50
52
  bib.at(ns("./docidentifier[not(@type = 'DOI' or @type = 'metanorma' "\
51
- "or @type = 'ISSN' or @type = 'ISBN' or "\
53
+ "or @type = 'metanorma-ordinal' or "\
54
+ "@type = 'ISSN' or @type = 'ISBN' or "\
52
55
  "@type = 'rfc-anchor')]"))
53
56
  end
54
57
 
@@ -58,11 +61,12 @@ module IsoDoc
58
61
  id1 = pref_ref_code(bib)
59
62
  id2 = bib.at(ns("./docidentifier[@type = 'DOI' or @type = 'ISSN' or "\
60
63
  "@type = 'ISBN']"))
61
- return [id, id1, id2] if id || id1 || id2
64
+ id3 = bib.at(ns("./docidentifier[@type = 'metanorma-ordinal']"))
65
+ return [id, id1, id2, id3] if id || id1 || id2 || id3
62
66
 
63
67
  id = Nokogiri::XML::Node.new("docidentifier", bib.document)
64
68
  id << "(NO ID)"
65
- [nil, id, nil]
69
+ [nil, id, nil, nil]
66
70
  end
67
71
 
68
72
  def bracket_if_num(num)
@@ -74,10 +78,15 @@ module IsoDoc
74
78
  num
75
79
  end
76
80
 
81
+ def unbracket(ident)
82
+ ident&.text&.sub(/^\[/, "")&.sub(/\]$/, "")
83
+ end
84
+
77
85
  def render_identifier(ident)
78
- [bracket_if_num(ident[0]),
79
- ident[1].nil? ? nil : ident[1].text.sub(/^\[/, "").sub(/\]$/, ""),
80
- ident[2].nil? ? nil : ident[2].text.sub(/^\[/, "").sub(/\]$/, "")]
86
+ { metanorma: bracket_if_num(ident[0]),
87
+ sdo: unbracket(ident[1]),
88
+ doi: unbracket(ident[2]),
89
+ ordinal: bracket_if_num(ident[3]) }
81
90
  end
82
91
 
83
92
  def docid_prefix(prefix, docid)
@@ -89,7 +98,7 @@ module IsoDoc
89
98
  def omit_docid_prefix(prefix)
90
99
  return true if prefix.nil? || prefix.empty?
91
100
 
92
- %w(ISO IEC IEV ITU W3C csd metanorma repository rfc-anchor)
101
+ %w(ISO IEC IEV ITU W3C csd metanorma repository metanorma-ordinal)
93
102
  .include? prefix
94
103
  end
95
104
 
@@ -133,7 +142,7 @@ module IsoDoc
133
142
  end
134
143
  end
135
144
 
136
- def is_standard(bib)
145
+ def standard?(bib)
137
146
  ret = false
138
147
  drop = %w(metanorma DOI ISSN ISBN)
139
148
  bib.xpath(ns("./docidentifier")).each do |id|
@@ -151,7 +160,7 @@ module IsoDoc
151
160
  next if implicit_reference(b)
152
161
 
153
162
  i += 1
154
- if is_standard(b) then std_bibitem_entry(div, b, i, biblio)
163
+ if standard?(b) then std_bibitem_entry(div, b, i, biblio)
155
164
  else nonstd_bibitem(div, b, i, biblio)
156
165
  end
157
166
  else
@@ -166,7 +175,7 @@ module IsoDoc
166
175
  end
167
176
 
168
177
  def norm_ref(isoxml, out, num)
169
- f = isoxml.at(ns(norm_ref_xpath)) and f["hidden"] != "true" or
178
+ (f = isoxml.at(ns(norm_ref_xpath)) and f["hidden"] != "true") or
170
179
  return num
171
180
  out.div do |div|
172
181
  num = num + 1
@@ -186,7 +195,7 @@ module IsoDoc
186
195
  end
187
196
 
188
197
  def bibliography(isoxml, out)
189
- f = isoxml.at(ns(bibliography_xpath)) and f["hidden"] != "true" or
198
+ (f = isoxml.at(ns(bibliography_xpath)) and f["hidden"] != "true") or
190
199
  return
191
200
  page_break(out)
192
201
  out.div do |div|
@@ -76,7 +76,12 @@ module IsoDoc
76
76
  end
77
77
  end
78
78
 
79
- def variant_title(_node, _out); end
79
+ def variant_title(node, out)
80
+ out.p **attr_code(style: "display:none;",
81
+ class: "variant-title-#{node['type']}") do |p|
82
+ node.children.each { |c| parse(c, p) }
83
+ end
84
+ end
80
85
  end
81
86
  end
82
87
  end
@@ -30,7 +30,7 @@ module IsoDoc
30
30
  end
31
31
 
32
32
  def init_dir(filename, debug)
33
- dir = "#{filename}_files"
33
+ dir = "#{filename}#{@tmpfilesdir_suffix}"
34
34
  unless debug
35
35
  Dir.mkdir(dir, 0o777) unless File.exists?(dir)
36
36
  FileUtils.rm_rf "#{dir}/*"
@@ -40,11 +40,11 @@ module IsoDoc
40
40
 
41
41
  # tmp image dir is same directory as @filename
42
42
  def tmpimagedir
43
- @filename + tmpimagedir_suffix
43
+ @filename + @tmpimagedir_suffix
44
44
  end
45
45
 
46
46
  def rel_tmpimagedir
47
- Pathname.new(@filename).basename.to_s + tmpimagedir_suffix
47
+ Pathname.new(@filename).basename.to_s + @tmpimagedir_suffix
48
48
  end
49
49
 
50
50
  # isodoc.css overrides any CSS injected by Html2Doc, which
@@ -129,6 +129,7 @@ module IsoDoc
129
129
 
130
130
  def header_strip(hdr)
131
131
  h1 = to_xhtml_fragment(hdr.to_s.gsub(%r{<br\s*/>}, " ")
132
+ .gsub(%r{</?p(\s[^>]+)?>}, "")
132
133
  .gsub(/<\/?h[123456][^>]*>/, "").gsub(/<\/?b[^>]*>/, "").dup)
133
134
  h1.traverse do |x|
134
135
  if x.name == "span" && /mso-tab-count/.match(x["style"])
@@ -142,9 +143,9 @@ module IsoDoc
142
143
 
143
144
  def header_strip_elem?(elem)
144
145
  elem.name == "img" ||
145
- elem.name == "span" && elem["class"] == "MsoCommentReference" ||
146
- elem.name == "a" && elem["class"] == "FootnoteRef" ||
147
- elem.name == "span" && /mso-bookmark/.match(elem["style"])
146
+ (elem.name == "span" && elem["class"] == "MsoCommentReference") ||
147
+ (elem.name == "a" && elem["class"] == "FootnoteRef") ||
148
+ (elem.name == "span" && /mso-bookmark/.match(elem["style"]))
148
149
  end
149
150
 
150
151
  def liquid(doc)
@@ -192,12 +193,6 @@ module IsoDoc
192
193
  save_dataimage(img["src"], false)
193
194
  when %r{^([A-Z]:)?/}
194
195
  img["src"]
195
- =begin
196
- if /^data:/.match? img["src"]
197
- save_dataimage(img["src"], false)
198
- elsif %r{^([A-Z]:)?/}.match? img["src"]
199
- img["src"]
200
- =end
201
196
  else
202
197
  File.join(@localdir, img["src"])
203
198
  end
@@ -213,12 +208,16 @@ module IsoDoc
213
208
  application/x-msmetafile image/x-xbitmap).include? type
214
209
  end
215
210
 
216
- def cleanup_entities(text)
211
+ def cleanup_entities(text, is_xml: true)
217
212
  c = HTMLEntities.new
218
- text.split(/([<>])/).each_slice(4).map do |a|
219
- a[0] = c.encode(c.decode(a[0]), :hexadecimal)
220
- a
221
- end.join
213
+ if is_xml
214
+ text.split(/([<>])/).each_slice(4).map do |a|
215
+ a[0] = c.encode(c.decode(a[0]), :hexadecimal)
216
+ a
217
+ end.join
218
+ else
219
+ c.encode(c.decode(text), :hexadecimal)
220
+ end
222
221
  end
223
222
 
224
223
  def external_path(path)
@@ -10,7 +10,7 @@ module IsoDoc
10
10
  include HtmlFunction::Html
11
11
 
12
12
  def tmpimagedir_suffix
13
- "_headlessimages"
13
+ "_#{SecureRandom.hex(8)}_headlessimages"
14
14
  end
15
15
 
16
16
  def initialize(options)
@@ -13,7 +13,7 @@ module IsoDoc
13
13
  include HtmlFunction::Html
14
14
 
15
15
  def tmpimagedir_suffix
16
- "_htmlimages"
16
+ "_#{SecureRandom.hex(8)}_htmlimages"
17
17
  end
18
18
 
19
19
  def initialize(options)
@@ -122,8 +122,10 @@ module IsoDoc
122
122
  end
123
123
 
124
124
  def html_toc_entry(level, header)
125
+ content = header.at("./following-sibling::p"\
126
+ "[@class = 'variant-title-toc']") || header
125
127
  %(<li class="#{level}"><a href="##{header['id']}">\
126
- #{header_strip(header)}</a></li>)
128
+ #{header_strip(content)}</a></li>)
127
129
  end
128
130
 
129
131
  def toclevel_classes
@@ -144,7 +146,7 @@ module IsoDoc
144
146
  idx = docxml.at("//div[@id = 'toc']") or return docxml
145
147
  toc = "<ul>"
146
148
  path = toclevel_classes.map do |l|
147
- "//main//#{l}[not(@class = 'TermNum')][not(@class = 'noTOC')][text()]"
149
+ "//main//#{l}#{toc_exclude_class}"
148
150
  end
149
151
  docxml.xpath(path.join(" | ")).each_with_index do |h, tocidx|
150
152
  h["id"] ||= "toc#{tocidx}"
@@ -154,6 +156,11 @@ module IsoDoc
154
156
  docxml
155
157
  end
156
158
 
159
+ def toc_exclude_class
160
+ "[not(@class = 'TermNum')][not(@class = 'noTOC')]"\
161
+ "[string-length(normalize-space(.))>0]"
162
+ end
163
+
157
164
  # presupposes that the image source is local
158
165
  def move_images(docxml)
159
166
  FileUtils.rm_rf tmpimagedir
data/lib/isodoc/i18n.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "yaml"
2
+ require_relative "function/utils"
2
3
 
3
4
  module IsoDoc
4
5
  class I18n
@@ -17,7 +18,7 @@ module IsoDoc
17
18
  end
18
19
  ret
19
20
  when Array then ret.map { |n| normalise_hash(n) }
20
- when String then ret.unicode_normalize(:nfc)
21
+ when String then cleanup_entities(ret.unicode_normalize(:nfc))
21
22
  else ret
22
23
  end
23
24
  end
@@ -96,8 +97,9 @@ module IsoDoc
96
97
  xml.traverse do |n|
97
98
  next unless n.text?
98
99
 
99
- n.replace(n.text.gsub(/ /, "").gsub(/:/, ":").gsub(/,/, "、")
100
- .gsub(/\(/, "").gsub(/\)/, "").gsub(/\[/, "【").gsub(/\]/, ""))
100
+ n.replace(cleanup_entities(n.text.gsub(/ /, "").gsub(/:/, ":")
101
+ .gsub(/,/, "").gsub(/\(/, "").gsub(/\)/, "")
102
+ .gsub(/\[/, "【").gsub(/\]/, "】"), is_xml: false))
101
103
  end
102
104
  xml.to_xml.gsub(/<b>/, "").gsub("</b>", "").gsub(/<\?[^>]+>/, "")
103
105
  end
@@ -111,6 +113,7 @@ module IsoDoc
111
113
  l10n(names[0..-2].join(", ") + " #{andword} #{names[-1]}", @lang, @script)
112
114
  end
113
115
 
116
+ include Function::Utils
114
117
  # module_function :l10n
115
118
  end
116
119
  end
@@ -20,7 +20,7 @@ module IsoDoc
20
20
  end
21
21
 
22
22
  def tmpimagedir_suffix
23
- "_pdfimages"
23
+ "_#{SecureRandom.hex(8)}_pdfimages"
24
24
  end
25
25
 
26
26
  def convert(input_filename, file = nil, debug = false, output_filename = nil)
@@ -10,12 +10,6 @@ module IsoDoc
10
10
  "</localized-strings>"
11
11
  end
12
12
 
13
- def docid_prefixes(docxml)
14
- docxml.xpath(ns("//references/bibitem/docidentifier")).each do |i|
15
- i.children = @xrefs.klass.docid_prefix(i["type"], i.text)
16
- end
17
- end
18
-
19
13
  def address_precompose(bib)
20
14
  bib.xpath(ns("//bibdata//address")).each do |b|
21
15
  next if b.at(ns("./formattedAddress"))
@@ -19,6 +19,22 @@ module IsoDoc
19
19
  prefix_name(elem, "<tab/>", "#{lbl}#{clausedelim}", "title")
20
20
  end
21
21
 
22
+ def floattitle(docxml)
23
+ docxml.xpath(ns("//clause | //annex | //appendix | //introduction | "\
24
+ "//foreword | //preface/abstract | //acknowledgements | "\
25
+ "//terms | //definitions | //references"))
26
+ .each do |f|
27
+ floattitle1(f)
28
+ end
29
+ end
30
+
31
+ def floattitle1(elem)
32
+ elem.xpath(ns(".//floating-title")).each do |p|
33
+ p.name = "p"
34
+ p["type"] = "floating-title"
35
+ end
36
+ end
37
+
22
38
  def annex(docxml)
23
39
  docxml.xpath(ns("//annex")).each do |f|
24
40
  annex1(f)
@@ -44,7 +60,29 @@ module IsoDoc
44
60
  prefix_name(elem, "", "#{lbl}#{clausedelim}", "name")
45
61
  end
46
62
 
47
- def references(docxml); end
63
+ def references(docxml)
64
+ bibliography_bibitem_number(docxml)
65
+ end
66
+
67
+ def bibliography_bibitem_number_skip(bibitem)
68
+ @xrefs.klass.implicit_reference(bibitem) ||
69
+ bibitem.at(ns(".//docidentifier[@type = 'metanorma']")) ||
70
+ bibitem.at(ns(".//docidentifier[@type = 'metanorma-ordinal']"))
71
+ # || @xrefs.klass.standard?(bibitem)
72
+ end
73
+
74
+ def bibliography_bibitem_number(docxml)
75
+ i = 0
76
+ docxml.xpath(ns("//references[@normative = 'false']/bibitem")).each do |b|
77
+ next if bibliography_bibitem_number_skip(b)
78
+
79
+ i += 1
80
+ id = b.at(ns(".//docidentifier"))
81
+ id.previous =
82
+ "<docidentifier type='metanorma-ordinal'>[#{i}]</docidentifier>"
83
+ end
84
+ @xrefs.references docxml
85
+ end
48
86
 
49
87
  def docid_prefixes(docxml)
50
88
  docxml.xpath(ns("//references/bibitem/docidentifier")).each do |i|
@@ -86,9 +124,7 @@ module IsoDoc
86
124
  display_order_xpath(docxml, "//indexsect", i)
87
125
  end
88
126
 
89
- def clausetitle(docxml)
90
- docxml.xpath(ns("//variant-title[@type = 'toc']")).each(&:remove)
91
- end
127
+ def clausetitle(docxml); end
92
128
 
93
129
  def toc(docxml)
94
130
  docxml.xpath(ns("//toc//xref[text()]")).each do |x|