isodoc 3.2.0 → 3.2.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: a3b8a9f7427b4df55cade247b1f292beb41b47d1ae684c9e1d3a7afe547c303f
4
- data.tar.gz: e7bd73e5b3a1078f67c9b4f959e0a0255d524a600757d064353ddd941c8165c7
3
+ metadata.gz: a1528432b5d869e42077b250498452e276bd3c774dbe55adbb375157c4c61f87
4
+ data.tar.gz: 16608e9fd9e1d2dd682667db8455bf63737d79e346f689c49c11628519f661e2
5
5
  SHA512:
6
- metadata.gz: 241e2e7855b90c61d4d17955125f3f2025a8b4bd986bc32192355e9eee1af51a931d039b07520bb1403ae0dac1b6b14d6969c62815be3d502935198efc9fb124
7
- data.tar.gz: f8a77cad3f2a0b46679c0cc980180911574b6e4d7649979c58bb29c7024c26c0a8b2ea380d60b97de62a29f85a71e2441291f0e00907789f7c999d0f1f67dc46
6
+ metadata.gz: 8c230460e11f2d68b5a844629947e8ee4fbdc4b23dd58d0ecbac85b2adaebeedf4fbde0b5eb434e51717449e3835cd202fefe5c7edfe217724cd5b41683e190b
7
+ data.tar.gz: 98fc8b60f2d0ebeddf9a2040fedba22b592e4af190cb055bb58c88fca0107daecfe9833c7552f76365a532591ea0e007ee6a228bbd41af21e25b9d5b5546871a
@@ -105,9 +105,9 @@ module IsoDoc
105
105
  table.at(".//tr").xpath("./td | ./th").each do |td|
106
106
  cols += (td["colspan"] ? td["colspan"].to_i : 1)
107
107
  end
108
- style =
109
- %{border-top:0pt;border-bottom:#{IsoDoc::Function::Table::SW} 1.5pt;}
110
- tfoot.add_child("<tr><td colspan='#{cols}' style='#{style}'/></tr>")
108
+ table["class"].nil? or # = plain table
109
+ s = "style='border-top:0pt;border-bottom:#{IsoDoc::Function::Table::SW} 1.5pt;'"
110
+ tfoot.add_child("<tr><td colspan='#{cols}' #{s}/></tr>")
111
111
  tfoot.xpath(".//td").last
112
112
  end
113
113
 
@@ -40,16 +40,28 @@ module IsoDoc
40
40
  end
41
41
  end
42
42
 
43
+ def bordered_table_style(node, klass)
44
+ bordered = "border-width:1px;border-spacing:0;"
45
+ (node["plain"] != "true" && (%w(modspec).include?(klass) || !klass)) or
46
+ bordered = ""
47
+ bordered
48
+ end
49
+
43
50
  def table_attrs(node)
44
- width = node["width"] ? "width:#{node['width']};" : nil
45
51
  c = node["class"]
46
- bordered = "border-width:1px;border-spacing:0;"
47
- (%w(modspec).include?(c) || !c) or bordered = ""
48
- style = node["style"] ? "" : "#{bordered}#{width}"
52
+ style = table_attrs_style(node, c)
49
53
  attr_code(id: node["id"],
50
- class: c || "MsoISOTable",
51
- style: "#{style}#{keep_style(node)}",
52
- title: node["alt"])
54
+ class: node["plain"] == "true" ? nil : (c || "MsoISOTable"),
55
+ style: style, title: node["alt"])
56
+ end
57
+
58
+ def table_attrs_style(node, klass)
59
+ width = node["width"] ? "width:#{node['width']};" : nil
60
+ bordered = bordered_table_style(node, klass)
61
+ style = node["style"] ? "" : "#{bordered}#{width}"
62
+ style += keep_style(node) || ""
63
+ style.empty? and style = nil
64
+ style
53
65
  end
54
66
 
55
67
  def tcaption(node, table)
@@ -125,6 +137,7 @@ module IsoDoc
125
137
  end
126
138
 
127
139
  def table_bordered?(node)
140
+ node.parent.parent["plain"] == "true" and return false
128
141
  c = node.parent.parent["class"]
129
142
  %w(modspec).include?(c) || !c
130
143
  end
@@ -1,5 +1,4 @@
1
1
  require "metanorma-utils"
2
- require_relative "../../nokogiri/xml/node"
3
2
 
4
3
  module IsoDoc
5
4
  module Function
@@ -96,7 +96,10 @@ module IsoDoc
96
96
 
97
97
  def table_attrs(node)
98
98
  ret = super
99
- node.at(ns("./colgroup")) and ret[:style] += "table-layout:fixed;"
99
+ if node.at(ns("./colgroup"))
100
+ ret[:style] ||= ""
101
+ ret[:style] += "table-layout:fixed;"
102
+ end
100
103
  ret
101
104
  end
102
105
 
@@ -30,7 +30,7 @@ module IsoDoc
30
30
  end
31
31
 
32
32
  def prefix_name_labels(node)
33
- @new_ids ||= {}
33
+ #@new_ids ||= {}
34
34
  id = "_#{UUIDTools::UUID.random_create}"
35
35
  @new_ids[id] = nil
36
36
  { elem: node["id"], name: id }
@@ -77,7 +77,6 @@ module IsoDoc
77
77
  end
78
78
 
79
79
  def provide_ids(docxml)
80
- @new_ids = {} # guids assigned within Presentation XML
81
80
  anchor_sanitise(docxml)
82
81
  populate_id(docxml)
83
82
  add_missing_id(docxml)
@@ -120,10 +119,12 @@ module IsoDoc
120
119
  end
121
120
 
122
121
  def add_new_contenthash_id(docxml, ids)
122
+ suffix = "" # for disambiguation in Metanorma Collections
123
+ docxml["document_suffix"] and suffix = "_#{docxml['document_suffix']}"
123
124
  %w(original-id id).each do |k|
124
125
  docxml.xpath("//*[@#{k}]").each do |x|
125
126
  ids.has_key?(x[k]) or next
126
- new_id = contenthash(x)
127
+ new_id = Metanorma::Utils::contenthash(x) + suffix
127
128
  ids[x[k]] = new_id
128
129
  x[k] = new_id
129
130
  end
@@ -134,17 +135,10 @@ module IsoDoc
134
135
  Metanorma::Utils::anchor_attributes(presxml: true).each do |e|
135
136
  docxml.xpath("//xmlns:#{e[0]}[@#{e[1]}]").each do |x|
136
137
  ids.has_key?(x[e[1]]) or next
137
- #require "debug"; binding.b unless ids[x[e[1]]]
138
138
  ids[x[e[1]]] or next
139
139
  x[e[1]] = ids[x[e[1]]]
140
140
  end
141
141
  end
142
142
  end
143
-
144
- # TODO duplicate of standoc
145
- def contenthash(elem)
146
- Digest::MD5.hexdigest("#{elem.path}////#{elem.text}")
147
- .sub(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, "_\\1-\\2-\\3-\\4-\\5")
148
- end
149
143
  end
150
144
  end
@@ -20,6 +20,7 @@ module IsoDoc
20
20
  def initialize(options)
21
21
  @format = :presentation
22
22
  @suffix = "presentation.xml"
23
+ @new_ids = {} # guids assigned within Presentation XML
23
24
  super
24
25
  end
25
26
 
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "3.2.0".freeze
2
+ VERSION = "3.2.1".freeze
3
3
  end
@@ -15,9 +15,10 @@ module IsoDoc
15
15
  table.at(".//tr").xpath("./td | ./th").each do |td|
16
16
  cols += (td["colspan"] ? td["colspan"].to_i : 1)
17
17
  end
18
- style = "border-top:0pt;mso-border-top-alt:0pt;" \
19
- "border-bottom:#{SW1} 1.5pt;mso-border-bottom-alt:#{SW1} 1.5pt;"
20
- tfoot.add_child("<tr><td colspan='#{cols}' style='#{style}'/></tr>")
18
+ table["plain"] == "true" or
19
+ s = "style='border-top:0pt;mso-border-top-alt:0pt;" \
20
+ "border-bottom:#{SW1} 1.5pt;mso-border-bottom-alt:#{SW1} 1.5pt;'"
21
+ tfoot.add_child("<tr><td colspan='#{cols}' #{s}/></tr>")
21
22
  tfoot.xpath(".//td").last
22
23
  end
23
24
 
@@ -72,7 +73,7 @@ module IsoDoc
72
73
 
73
74
  def table_attrs(node)
74
75
  c = node["class"]
75
- style = node["style"] ? '' : "border-spacing:0;border-width:1px;"
76
+ style = node["style"] || node["plain"] == "true" ? "" : "border-spacing:0;border-width:1px;"
76
77
  (%w(modspec).include?(c) || !c) or style = nil
77
78
  ret =
78
79
  { summary: node["summary"], width: node["width"],
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.2.0
4
+ version: 3.2.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: 2025-07-05 00:00:00.000000000 Z
11
+ date: 2025-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -488,7 +488,6 @@ files:
488
488
  - lib/metanorma/output/base.rb
489
489
  - lib/metanorma/output/utils.rb
490
490
  - lib/metanorma/output/xslfo.rb
491
- - lib/nokogiri/xml/node.rb
492
491
  - lib/relaton/render-isodoc/config.yml
493
492
  - lib/relaton/render-isodoc/general.rb
494
493
  homepage: https://github.com/metanorma/isodoc
@@ -1,14 +0,0 @@
1
- module Nokogiri
2
- module XML
3
- class Node
4
- def add_first_child(content)
5
- if children.empty?
6
- add_child(content)
7
- else
8
- children.first.previous = content
9
- end
10
- self
11
- end
12
- end
13
- end
14
- end