isodoc 2.0.5.1 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7eac37329d91f52ffb48b04b35a58e9d5966ba1ef79492c7e1fd14f77490b81a
4
- data.tar.gz: e4e1fffbadb350529b5b8bcc4e3f8b13604fd9ceb982d935da33f61722ab1984
3
+ metadata.gz: 3633136f121834056746917a4af6b5c6b917365ffb941b0561a0941d16ccfb3a
4
+ data.tar.gz: d15461d2103ff7e43ee22c1afe80d4a4b4e0a240a76c3ee5afe11df47652ab72
5
5
  SHA512:
6
- metadata.gz: 7f64dbf601952d1e7141ddca015d6fe61e989efd1d751ee9e42575a78e818a3551c4cbb26f5890dc53a1a50c1e75c02deca03e26c64b3568e1f49b76985027c0
7
- data.tar.gz: fe336da69b2efe89d21299708b62f968109f4ff7be2973cdd6d4f92e56616ff79ee71c024a222794dfdabb7d67b8b50b7d7065f448704d6383f93639846fea20
6
+ metadata.gz: 047f237237096490e9a6380675f96d46e1de721025f17eb60a3140face2cfe794d649fb31d992bca7a63e863c42c6d79cd42fa0810c77f6bc09518d905b55fbf
7
+ data.tar.gz: 7cde47764db6a87866b4fe618550dc8412b85c32c90ea2e60a903083849b6e16325574d723dbb83948a8524062fa63b4c0eb19a50590f0fb3d46164962dc0368
@@ -0,0 +1,24 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: release
4
+
5
+ on:
6
+ workflow_dispatch:
7
+ inputs:
8
+ next_version:
9
+ description: |
10
+ Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
11
+ required: true
12
+ default: 'skip'
13
+ push:
14
+ tags: [ v* ]
15
+
16
+ jobs:
17
+ release:
18
+ uses: metanorma/metanorma-build-scripts/.github/workflows/rubygems-release.yml@main
19
+ with:
20
+ next_version: ${{ github.event.inputs.next_version }}
21
+ event_name: ${{ github.event_name }}
22
+ secrets:
23
+ rubygems-api-key: ${{ secrets.METANORMA_CI_RUBYGEMS_API_KEY }}
24
+
@@ -36,7 +36,7 @@ module IsoDoc::HtmlFunction
36
36
  def footnote_backlinks(docxml)
37
37
  seen = {}
38
38
  docxml.xpath('//a[@class = "FootnoteRef"]').each_with_index do |x, i|
39
- seen[x["href"]] and next or seen[x["href"]] = true
39
+ (seen[x["href"]] and next) or seen[x["href"]] = true
40
40
  fn = docxml.at(%<//*[@id = '#{x['href'].sub(/^#/, '')}']>) || next
41
41
  footnote_backlinks1(x, fn)
42
42
  x["id"] ||= "fnref:#{i + 1}"
@@ -5,10 +5,9 @@ module IsoDoc
5
5
  if a.at(ns("./name/completename"))
6
6
  ret << a.at(ns("./name/completename")).text
7
7
  else
8
- forenames = a.xpath(ns("./name/forename"))
9
- fn = forenames.each_with_object([]) { |f, m| m << f.text }
10
- surname = a&.at(ns("./name/surname"))&.text
11
- ret << "#{fn.join(' ')} #{surname}"
8
+ fn = a.xpath(ns("./name/forename"))
9
+ .each_with_object([]) { |f, m| m << f.text }
10
+ ret << "#{fn.join(' ')} #{a&.at(ns('./name/surname'))&.text}"
12
11
  end
13
12
  end
14
13
  end
@@ -50,7 +50,7 @@ module IsoDoc
50
50
  node["droploc"] = true
51
51
  ret = resolve_eref_connectives(eref_locality_stacks(refs, target,
52
52
  node))
53
- node["droploc"] = droploc
53
+ node.delete("droploc") unless droploc
54
54
  eref_localities1(target,
55
55
  refs.first.at(ns("./locality/@type")).text,
56
56
  l10n(ret[1..-1].join), nil, node, @lang)
@@ -114,14 +114,18 @@ module IsoDoc
114
114
  added.each { |a| m << a }
115
115
  next if i == refs.size - 1
116
116
 
117
- m << if r&.next_element&.name == "localityStack"
118
- r.next_element["connective"]
119
- else locality_delimiter(r)
120
- end
117
+ m << eref_locality_delimiter(r)
121
118
  end
122
119
  ret.empty? ? ret : [", "] + ret
123
120
  end
124
121
 
122
+ def eref_locality_delimiter(ref)
123
+ if ref&.next_element&.name == "localityStack"
124
+ ref.next_element["connective"]
125
+ else locality_delimiter(ref)
126
+ end
127
+ end
128
+
125
129
  def eref_locality_stack(ref, idx, target, node)
126
130
  ret = []
127
131
  if ref.name == "localityStack"
@@ -13,7 +13,7 @@ module IsoDoc
13
13
  super
14
14
  end
15
15
 
16
- def convert1(docxml, filename, dir)
16
+ def convert1(docxml, _filename, _dir)
17
17
  @xrefs.parse docxml
18
18
  info docxml, nil
19
19
  conversions(docxml)
@@ -76,11 +76,11 @@ module IsoDoc
76
76
  end
77
77
 
78
78
  def postprocess(result, filename, _dir)
79
- toXML(result, filename)
79
+ to_xml(result, filename)
80
80
  @files_to_delete.each { |f| FileUtils.rm_rf f }
81
81
  end
82
82
 
83
- def toXML(result, filename)
83
+ def to_xml(result, filename)
84
84
  File.open(filename, "w:UTF-8") { |f| f.write(result) }
85
85
  end
86
86
  end
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.0.5.1".freeze
2
+ VERSION = "2.0.6".freeze
3
3
  end
@@ -233,7 +233,7 @@ module IsoDoc
233
233
  end
234
234
 
235
235
  def suffix_url(url)
236
- return url if url.nil? || %r{^https?://}.match?(url)
236
+ return url if url.nil? || %r{^https?://|^#}.match?(url)
237
237
  return url unless File.extname(url).empty?
238
238
 
239
239
  url.sub(/#{File.extname(url)}$/, ".doc")
@@ -107,9 +107,8 @@ module IsoDoc
107
107
  x += 1
108
108
  end
109
109
  (r..(r + rs - 1)).each do |y2|
110
- (x..(x + cs - 1)).each do |x2|
111
- cells2d[y2][x2] = 1
112
- end
110
+ cells2d[y2].nil? and next
111
+ (x..(x + cs - 1)).each { |x2| cells2d[y2][x2] = 1 }
113
112
  end
114
113
  width = (x..(x + cs - 1)).each_with_object({ width: 0 }) do |z, m|
115
114
  m[:width] += w[z]
@@ -35,7 +35,7 @@ module IsoDoc
35
35
  @labels["termnote"].gsub(/%/, note.to_s)
36
36
  end
37
37
 
38
- def increment_label(elems, node, counter, increment = true)
38
+ def increment_label(elems, node, counter, increment: true)
39
39
  return "" if elems.size == 1 && !node["number"]
40
40
 
41
41
  counter.increment(node) if increment
@@ -62,10 +62,9 @@ module IsoDoc
62
62
  c = Counter.new
63
63
  examples.reject { |n| blank?(n["id"]) }.each do |n|
64
64
  c.increment(n)
65
- idx = increment_label(examples, n, c, false)
66
- @anchors[n["id"]] =
67
- anchor_struct(idx, n, @labels["example_xref"], "termexample",
68
- n["unnumbered"])
65
+ idx = increment_label(examples, n, c, increment: false)
66
+ @anchors[n["id"]] = anchor_struct(idx, n, @labels["example_xref"],
67
+ "termexample", n["unnumbered"])
69
68
  end
70
69
  end
71
70
  end
@@ -88,18 +87,23 @@ module IsoDoc
88
87
 
89
88
  def note_anchor_names(sections)
90
89
  sections.each do |s|
91
- c = Counter.new
92
- (notes = s.xpath(CHILD_NOTES_XPATH)).each do |n|
93
- next if @anchors[n["id"]] || n["id"].nil? || n["id"].empty?
94
-
95
- @anchors[n["id"]] =
96
- anchor_struct(increment_label(notes, n, c), n,
97
- @labels["note_xref"], "note", false)
98
- end
90
+ notes = s.xpath(CHILD_NOTES_XPATH) -
91
+ s.xpath(ns(".//figure//note | .//table//note"))
92
+ note_anchor_names1(notes, Counter.new)
99
93
  note_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
100
94
  end
101
95
  end
102
96
 
97
+ def note_anchor_names1(notes, counter)
98
+ notes.each do |n|
99
+ next if @anchors[n["id"]] || blank?(n["id"])
100
+
101
+ @anchors[n["id"]] =
102
+ anchor_struct(increment_label(notes, n, counter), n,
103
+ @labels["note_xref"], "note", false)
104
+ end
105
+ end
106
+
103
107
  CHILD_EXAMPLES_XPATH =
104
108
  "./*[not(self::xmlns:clause) and not(self::xmlns:appendix) and "\
105
109
  "not(self::xmlns:terms) and not(self::xmlns:definitions)]//"\
@@ -110,18 +114,22 @@ module IsoDoc
110
114
 
111
115
  def example_anchor_names(sections)
112
116
  sections.each do |s|
113
- c = Counter.new
114
- (notes = s.xpath(CHILD_EXAMPLES_XPATH)).each do |n|
115
- next if @anchors[n["id"]] || n["id"].nil? || n["id"].empty?
116
-
117
- @anchors[n["id"]] =
118
- anchor_struct(increment_label(notes, n, c), n,
119
- @labels["example_xref"], "example", n["unnumbered"])
120
- end
117
+ notes = s.xpath(CHILD_EXAMPLES_XPATH)
118
+ example_anchor_names1(notes, Counter.new)
121
119
  example_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
122
120
  end
123
121
  end
124
122
 
123
+ def example_anchor_names1(notes, counter)
124
+ notes.each do |n|
125
+ next if @anchors[n["id"]] || blank?(n["id"])
126
+
127
+ @anchors[n["id"]] =
128
+ anchor_struct(increment_label(notes, n, counter), n,
129
+ @labels["example_xref"], "example", n["unnumbered"])
130
+ end
131
+ end
132
+
125
133
  def list_anchor_names(sections)
126
134
  sections.each do |s|
127
135
  notes = s.xpath(ns(".//ol")) - s.xpath(ns(".//clause//ol")) -
@@ -155,17 +163,20 @@ module IsoDoc
155
163
  sections.each do |s|
156
164
  notes = s.xpath(ns(".//dl")) - s.xpath(ns(".//clause//dl")) -
157
165
  s.xpath(ns(".//appendix//dl")) - s.xpath(ns(".//dl//dl"))
158
- c = Counter.new
159
- notes.reject { |n| blank?(n["id"]) }.each do |n|
160
- @anchors[n["id"]] =
161
- anchor_struct(increment_label(notes, n, c), n,
162
- @labels["deflist"], "deflist", false)
163
- deflist_term_anchor_names(n, @anchors[n["id"]])
164
- end
166
+ deflist_anchor_names1(notes, Counter.new)
165
167
  deflist_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
166
168
  end
167
169
  end
168
170
 
171
+ def deflist_anchor_names1(notes, counter)
172
+ notes.reject { |n| blank?(n["id"]) }.each do |n|
173
+ @anchors[n["id"]] =
174
+ anchor_struct(increment_label(notes, n, counter), n,
175
+ @labels["deflist"], "deflist", false)
176
+ deflist_term_anchor_names(n, @anchors[n["id"]])
177
+ end
178
+ end
179
+
169
180
  def deflist_term_anchor_names(list, list_anchor)
170
181
  list.xpath(ns("./dt")).each do |li|
171
182
  label = l10n("#{list_anchor[:xref]}: #{dt2xreflabel(li)}")
@@ -2,7 +2,7 @@ require "metanorma"
2
2
 
3
3
  module IsoDoc
4
4
  class XslfoPdfConvert < ::IsoDoc::Convert
5
- # MN2PDF_OPTIONS = :mn2pdf
5
+ MN_OPTIONS_KEY = :mn2pdf
6
6
  MN2PDF_FONT_MANIFEST = :font_manifest
7
7
  MN2PDF_OPTIONS = { pdfencryptionlength: "--encryption-length",
8
8
  pdfownerpassword: "--owner-password",
@@ -43,7 +43,7 @@ module IsoDoc
43
43
 
44
44
  def pdf_options(_docxml)
45
45
  ret = {}
46
- font_manifest = @options[MN2PDF_FONT_MANIFEST] and
46
+ font_manifest = @options.dig(MN_OPTIONS_KEY, MN2PDF_FONT_MANIFEST) and
47
47
  ret[MN2PDF_FONT_MANIFEST] = font_manifest
48
48
  @aligncrosselements && !@aligncrosselements.empty? and
49
49
  ret["--param align-cross-elements="] =
@@ -1,10 +1,9 @@
1
-
2
1
  module Metanorma
3
2
  module Output
4
3
 
5
4
  class Base
6
5
 
7
- def convert(in_path, out_path)
6
+ def convert(_in_path, _out_path)
8
7
  raise "This is an abstract class"
9
8
  end
10
9
 
@@ -558,6 +558,49 @@ RSpec.describe IsoDoc do
558
558
  .convert("test", input, true)))).to be_equivalent_to xmlpp(doc)
559
559
  end
560
560
 
561
+ it "numbers notes in tables and figures separately from notes outside them" do
562
+ input = <<~INPUT
563
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
564
+ <preface><foreword>
565
+ <figure id="F"><note id="FB"><p>XYZ</p></note></figure>
566
+ <table id="T"><note id="TB"><p>XYZ</p></note></table>
567
+ <p id="A">ABC <note id="B"><p id="C">XYZ</p></note>
568
+ </foreword></preface>
569
+ </iso-standard>
570
+ INPUT
571
+ output = <<~OUTPUT
572
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
573
+ <preface>
574
+ <foreword displayorder='1'>
575
+ <figure id='F'>
576
+ <name>Figure 1</name>
577
+ <note id='FB'>
578
+ <name>NOTE</name>
579
+ <p>XYZ</p>
580
+ </note>
581
+ </figure>
582
+ <table id='T'>
583
+ <name>Table 1</name>
584
+ <note id='TB'>
585
+ <name>NOTE</name>
586
+ <p>XYZ</p>
587
+ </note>
588
+ </table>
589
+ <p id='A'>
590
+ ABC
591
+ <note id='B'>
592
+ <name>NOTE</name>
593
+ <p id='C'>XYZ</p>
594
+ </note>
595
+ </p>
596
+ </foreword>
597
+ </preface>
598
+ </iso-standard>
599
+ OUTPUT
600
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
601
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
602
+ end
603
+
561
604
  it "processes figures" do
562
605
  input = <<~INPUT
563
606
  <iso-standard xmlns="http://riboseinc.com/isoxml">
@@ -2208,7 +2208,7 @@ RSpec.describe IsoDoc do
2208
2208
  output = <<~OUTPUT
2209
2209
  <itu-standard xmlns='https://www.calconnect.org/standards/itu' type='presentation'>
2210
2210
  <p id='_'>
2211
- <eref type='inline' bibitemid='ref1' citeas='XYZ' droploc=''>
2211
+ <eref type='inline' bibitemid='ref1' citeas='XYZ'>
2212
2212
  <localityStack connective='from'>
2213
2213
  <locality type='clause'>
2214
2214
  <referenceFrom>3</referenceFrom>
@@ -2239,7 +2239,7 @@ RSpec.describe IsoDoc do
2239
2239
  </eref>
2240
2240
  text
2241
2241
  </p>
2242
- <eref type='inline' bibitemid='ref1' citeas='XYZ' droploc=''>
2242
+ <eref type='inline' bibitemid='ref1' citeas='XYZ'>
2243
2243
  <localityStack connective='and'>
2244
2244
  <locality type='clause'>
2245
2245
  <referenceFrom>3</referenceFrom>
@@ -2252,7 +2252,7 @@ RSpec.describe IsoDoc do
2252
2252
  </localityStack>
2253
2253
  XYZ, Clause 3 and 5
2254
2254
  </eref>
2255
- <eref type='inline' bibitemid='ref1' citeas='XYZ' droploc=''>
2255
+ <eref type='inline' bibitemid='ref1' citeas='XYZ'>
2256
2256
  <localityStack connective='and'>
2257
2257
  <locality type='clause'>
2258
2258
  <referenceFrom>3</referenceFrom>
@@ -2296,7 +2296,7 @@ RSpec.describe IsoDoc do
2296
2296
  </localityStack>
2297
2297
  text
2298
2298
  </eref>
2299
- <eref type='inline' bibitemid='ref1' citeas='XYZ' droploc=''>
2299
+ <eref type='inline' bibitemid='ref1' citeas='XYZ'>
2300
2300
  <localityStack connective='from'>
2301
2301
  <locality type='clause'>
2302
2302
  <referenceFrom>3</referenceFrom>
@@ -15,7 +15,7 @@ RSpec.describe IsoDoc do
15
15
  convert = IsoDoc::XslfoPdfConvert.new(
16
16
  {
17
17
  datauriimage: false,
18
- IsoDoc::XslfoPdfConvert::MN2PDF_OPTIONS => {
18
+ IsoDoc::XslfoPdfConvert::MN_OPTIONS_KEY => {
19
19
  IsoDoc::XslfoPdfConvert::MN2PDF_FONT_MANIFEST => nil,
20
20
  },
21
21
  },
@@ -32,8 +32,7 @@ RSpec.describe IsoDoc do
32
32
  convert = IsoDoc::XslfoPdfConvert.new(
33
33
  {
34
34
  datauriimage: false,
35
- IsoDoc::XslfoPdfConvert::MN2PDF_OPTIONS => mn2pdf_opts,
36
- font_manifest: "/tmp/manifest.yml",
35
+ IsoDoc::XslfoPdfConvert::MN_OPTIONS_KEY => mn2pdf_opts,
37
36
  },
38
37
  )
39
38
 
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: 2.0.5.1
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-07 00:00:00.000000000 Z
11
+ date: 2022-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath
@@ -372,6 +372,7 @@ extensions: []
372
372
  extra_rdoc_files: []
373
373
  files:
374
374
  - ".github/workflows/rake.yml"
375
+ - ".github/workflows/release.yml"
375
376
  - ".hound.yml"
376
377
  - ".oss-guides.rubocop.yml"
377
378
  - ".rubocop.yml"
@@ -534,7 +535,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
534
535
  - !ruby/object:Gem::Version
535
536
  version: '0'
536
537
  requirements: []
537
- rubygems_version: 3.2.32
538
+ rubygems_version: 3.3.9
538
539
  signing_key:
539
540
  specification_version: 4
540
541
  summary: Convert documents in IsoDoc into Word and HTML in AsciiDoc.