isodoc 2.0.5.2 → 2.0.6.1

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: '099aeb3456fabbcbd95076b6ccb9826997871b9d85ff079fc04aadf82a491a80'
4
- data.tar.gz: 4002cee22c77b7a64f69864f3a67990cdfedddd458f95e86921ff132a804fe10
3
+ metadata.gz: c32b98e8156bdafb3ad6549d179b6607cc7811bf67191cf0ee736b6c72d5360f
4
+ data.tar.gz: 63236257e5e7f511e6cfe2ea9ff5c7a12dd2059be3bc588c50f15c8946e4a01d
5
5
  SHA512:
6
- metadata.gz: 5342970e267f7a1b8c259d7c06c8cd27e5600cc0ff4d33033f5d8e5206d335050dd4d6f989f68220d8adc0966483f26c30e472b51cacbe93268ddbd24c42e1c7
7
- data.tar.gz: 0f03dd6d85ada4c98a13b0a1bfe6c86b19d0dc5d02fc759a334d560eeed1ad7642a2c25c1442610187206d41a24aa058db3e16fb6f7a96d0e19ed6752a244290
6
+ metadata.gz: 58a629b21dee494368d7ad6c9f25fc3ac01ccb5f70b82674843cefdcb0959c484f770174ccb9ce75e52f4d4f906918fe1f390405dafd91119c945bade6ff716b
7
+ data.tar.gz: 11332100db734b1fd700ecfe164fb80ae0fd4be9843c6e48ffac4ea2c0d2d1ef4c417cb9e78c1a5d9cbae68294acac7f98fcb8365c10808a38153fae1f1dd2dd
@@ -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
+
@@ -32,7 +32,7 @@ module IsoDoc
32
32
  def init_dir(filename, debug)
33
33
  dir = "#{filename}#{@tmpfilesdir_suffix}"
34
34
  unless debug
35
- Dir.mkdir(dir, 0o777) unless File.exists?(dir)
35
+ Dir.mkdir(dir, 0o777) unless File.exist?(dir)
36
36
  FileUtils.rm_rf "#{dir}/*"
37
37
  end
38
38
  dir
@@ -24,7 +24,7 @@ module IsoDoc
24
24
 
25
25
  def convert(filename, file = nil, debug = false, output_filename = nil)
26
26
  ret = super
27
- Dir.exists?(tmpimagedir) and Dir["#{tmpimagedir}/*"].empty? and
27
+ Dir.exist?(tmpimagedir) and Dir["#{tmpimagedir}/*"].empty? and
28
28
  FileUtils.rm_r tmpimagedir
29
29
  ret
30
30
  end
@@ -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
@@ -64,7 +64,7 @@ module IsoDoc
64
64
  def svg_to_emf(node)
65
65
  uri = svg_to_emf_uri(node)
66
66
  ret = svg_to_emf_filename(uri)
67
- File.exists?(ret) and return ret
67
+ File.exist?(ret) and return ret
68
68
  exe = inkscape_installed? or raise "Inkscape missing in PATH, unable" \
69
69
  "to convert EMF to SVG. Aborting."
70
70
  uri = Metanorma::Utils::external_path uri
@@ -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.2".freeze
2
+ VERSION = "2.0.6.1".freeze
3
3
  end
@@ -206,7 +206,7 @@ module IsoDoc
206
206
 
207
207
  out.p { |p| p << @i18n.where }
208
208
  parse(deflist, out)
209
- out.parent.at("./table")["class"] = "formula_dl"
209
+ t = out.parent.at("./table") and t["class"] = "formula_dl"
210
210
  end
211
211
 
212
212
  def formula_parse1(node, out)
@@ -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">
@@ -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.2
4
+ version: 2.0.6.1
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-22 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.