isodoc 2.4.3 → 2.4.4
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/class_utils.rb +5 -2
- data/lib/isodoc/function/section.rb +9 -9
- data/lib/isodoc/presentation_function/block.rb +18 -9
- data/lib/isodoc/presentation_function/math.rb +1 -1
- data/lib/isodoc/presentation_function/refs.rb +0 -2
- data/lib/isodoc/presentation_function/section.rb +1 -1
- data/lib/isodoc/presentation_function/sourcecode.rb +13 -5
- data/lib/isodoc/presentation_function/terms.rb +8 -9
- data/lib/isodoc/presentation_xml_convert.rb +7 -5
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/xref/xref_anchor.rb +5 -3
- data/lib/isodoc/xref/xref_gen.rb +24 -11
- data/lib/isodoc/xref/xref_sect_gen.rb +1 -0
- data/lib/isodoc/xref.rb +1 -1
- data/lib/isodoc-yaml/i18n-ar.yaml +1 -0
- data/lib/isodoc-yaml/i18n-de.yaml +1 -0
- data/lib/isodoc-yaml/i18n-en.yaml +1 -0
- data/lib/isodoc-yaml/i18n-es.yaml +1 -0
- data/lib/isodoc-yaml/i18n-fr.yaml +1 -0
- data/lib/isodoc-yaml/i18n-ru.yaml +1 -0
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
- data/lib/isodoc.rb +2 -1
- data/lib/relaton/{render → render-isodoc}/config.yml +0 -0
- data/lib/relaton/{render → render-isodoc}/general.rb +0 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a2cc598b5e8c9690a42329b2af309d75d281db2767adc8fc00eb21a498f69cf
|
4
|
+
data.tar.gz: 1026ad146597f3e93b46f035506f648e7775bb0cf3e846d6f578d2af029dfb1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5923a84bcb2fa4ba407eae39adf36202ebd07902ec425274641717d38b00daea3e035c9c8f12a936f1c6f4126e3d38db68a5184dfe63718adbe08b8c6ed4046d
|
7
|
+
data.tar.gz: 36a2d61a352858557db3c8f8f097b590842bf148b0ffaf48fcf3a5dd45f0781dcfe929000de3704427d9bde7c1a2c74458f931c0976356e4594bb510631c66c7
|
data/lib/isodoc/class_utils.rb
CHANGED
@@ -76,8 +76,11 @@ module IsoDoc
|
|
76
76
|
|
77
77
|
# node is at the start of sentence in a Metanorma XML context
|
78
78
|
def start_of_sentence(node)
|
79
|
-
prec =
|
80
|
-
|
79
|
+
prec = [] # all text nodes before node
|
80
|
+
nearest_block_parent(node).traverse do |x|
|
81
|
+
x == node and break
|
82
|
+
x.text? and prec << x
|
83
|
+
end
|
81
84
|
prec.empty? || /(?!<[^.].)\.\s+$/.match(prec.map(&:text).join)
|
82
85
|
end
|
83
86
|
end
|
@@ -58,7 +58,7 @@ module IsoDoc
|
|
58
58
|
num
|
59
59
|
end
|
60
60
|
|
61
|
-
TERM_CLAUSE = "//sections/terms | "\
|
61
|
+
TERM_CLAUSE = "//sections/terms | " \
|
62
62
|
"//sections/clause[descendant::terms]".freeze
|
63
63
|
|
64
64
|
def terms_defs(isoxml, out, num)
|
@@ -100,7 +100,7 @@ module IsoDoc
|
|
100
100
|
def introduction(isoxml, out)
|
101
101
|
f = isoxml.at(ns("//introduction")) || return
|
102
102
|
page_break(out)
|
103
|
-
out.div
|
103
|
+
out.div class: "Section3", id: f["id"] do |div|
|
104
104
|
clause_name(nil, f.at(ns("./title")), div, { class: "IntroTitle" })
|
105
105
|
f.elements.each do |e|
|
106
106
|
parse(e, div) unless e.name == "title"
|
@@ -122,7 +122,7 @@ module IsoDoc
|
|
122
122
|
f = isoxml.at(ns("//acknowledgements")) || return
|
123
123
|
title_attr = { class: "IntroTitle" }
|
124
124
|
page_break(out)
|
125
|
-
out.div
|
125
|
+
out.div class: "Section3", id: f["id"] do |div|
|
126
126
|
clause_name(nil, f&.at(ns("./title")), div, title_attr)
|
127
127
|
f.elements.each do |e|
|
128
128
|
parse(e, div) unless e.name == "title"
|
@@ -140,10 +140,10 @@ module IsoDoc
|
|
140
140
|
end
|
141
141
|
|
142
142
|
def preface(isoxml, out)
|
143
|
-
isoxml.xpath(ns("//preface/clause | //preface/references | "\
|
143
|
+
isoxml.xpath(ns("//preface/clause | //preface/references | " \
|
144
144
|
"//preface/definitions | //preface/terms")).each do |f|
|
145
145
|
page_break(out)
|
146
|
-
out.div
|
146
|
+
out.div class: "Section3", id: f["id"] do |div|
|
147
147
|
clause_name(nil, f&.at(ns("./title")), div, { class: "IntroTitle" })
|
148
148
|
f.elements.each do |e|
|
149
149
|
parse(e, div) unless e.name == "title"
|
@@ -174,7 +174,7 @@ module IsoDoc
|
|
174
174
|
def copyright_parse(node, out)
|
175
175
|
return if @bare
|
176
176
|
|
177
|
-
out.div
|
177
|
+
out.div class: "boilerplate-copyright" do |div|
|
178
178
|
node.children.each { |n| parse(n, div) }
|
179
179
|
end
|
180
180
|
end
|
@@ -182,7 +182,7 @@ module IsoDoc
|
|
182
182
|
def license_parse(node, out)
|
183
183
|
return if @bare
|
184
184
|
|
185
|
-
out.div
|
185
|
+
out.div class: "boilerplate-license" do |div|
|
186
186
|
node.children.each { |n| parse(n, div) }
|
187
187
|
end
|
188
188
|
end
|
@@ -190,7 +190,7 @@ module IsoDoc
|
|
190
190
|
def legal_parse(node, out)
|
191
191
|
return if @bare
|
192
192
|
|
193
|
-
out.div
|
193
|
+
out.div class: "boilerplate-legal" do |div|
|
194
194
|
node.children.each { |n| parse(n, div) }
|
195
195
|
end
|
196
196
|
end
|
@@ -198,7 +198,7 @@ module IsoDoc
|
|
198
198
|
def feedback_parse(node, out)
|
199
199
|
return if @bare
|
200
200
|
|
201
|
-
out.div
|
201
|
+
out.div class: "boilerplate-feedback" do |div|
|
202
202
|
node.children.each { |n| parse(n, div) }
|
203
203
|
end
|
204
204
|
end
|
@@ -15,8 +15,7 @@ module IsoDoc
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def prefix_name(node, delim, number, elem)
|
18
|
-
|
19
|
-
|
18
|
+
number.nil? || number.empty? and return
|
20
19
|
unless name = node.at(ns("./#{elem}"))
|
21
20
|
(node.children.empty? and node.add_child("<#{elem}></#{elem}>")) or
|
22
21
|
node.children.first.previous = "<#{elem}></#{elem}>"
|
@@ -54,12 +53,12 @@ module IsoDoc
|
|
54
53
|
end
|
55
54
|
|
56
55
|
def note1(elem)
|
57
|
-
elem.parent.name
|
56
|
+
%w(bibdata bibitem).include?(elem.parent.name) ||
|
57
|
+
elem["notag"] == "true" and return
|
58
58
|
n = @xrefs.get[elem["id"]]
|
59
|
-
lbl =
|
60
|
-
|
61
|
-
|
62
|
-
end
|
59
|
+
lbl = @i18n.note
|
60
|
+
(n.nil? || n[:label].nil? || n[:label].empty?) or
|
61
|
+
lbl = l10n("#{lbl} #{n[:label]}")
|
63
62
|
prefix_name(elem, "", lbl, "name")
|
64
63
|
end
|
65
64
|
|
@@ -68,8 +67,18 @@ module IsoDoc
|
|
68
67
|
end
|
69
68
|
|
70
69
|
def admonition1(elem)
|
71
|
-
|
72
|
-
|
70
|
+
if elem["type"] == "box"
|
71
|
+
admonition_numbered1(elem)
|
72
|
+
else
|
73
|
+
elem["notag"] == "true" || elem.at(ns("./name")) and return
|
74
|
+
prefix_name(elem, "", @i18n.admonition[elem["type"]]&.upcase, "name")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def admonition_numbered1(elem)
|
79
|
+
elem["unnumbered"] && !elem.at(ns("./name")) and return
|
80
|
+
n = @xrefs.anchor(elem["id"], :label, false)
|
81
|
+
prefix_name(elem, block_delim, l10n("#{@i18n.box} #{n}"), "name")
|
73
82
|
end
|
74
83
|
|
75
84
|
def recommendation(docxml)
|
@@ -106,7 +106,7 @@ module IsoDoc
|
|
106
106
|
def mathml_style_inherit(node)
|
107
107
|
node.at("./ancestor::xmlns:strong") or return
|
108
108
|
node.children =
|
109
|
-
"<mstyle
|
109
|
+
"<mstyle mathvariant='bold'>#{node.children.to_xml}</mstyle>"
|
110
110
|
end
|
111
111
|
|
112
112
|
def mathml_number_to_number(node)
|
@@ -17,7 +17,7 @@ module IsoDoc
|
|
17
17
|
level = @xrefs.anchor(elem["id"], :level, false) ||
|
18
18
|
(elem.ancestors("clause, annex").size + 1)
|
19
19
|
t = elem.at(ns("./title")) and t["depth"] = level
|
20
|
-
return if !elem.ancestors("boilerplate").empty? ||
|
20
|
+
return if !elem.ancestors("boilerplate, metanorma-extension").empty? ||
|
21
21
|
@suppressheadingnumbers || elem["unnumbered"]
|
22
22
|
|
23
23
|
lbl = @xrefs.anchor(elem["id"], :label,
|
@@ -1,16 +1,23 @@
|
|
1
1
|
module IsoDoc
|
2
2
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
3
3
|
def sourcehighlighter_css(docxml)
|
4
|
-
|
4
|
+
ret = custom_css(docxml)
|
5
|
+
ret.empty? and return
|
5
6
|
ins = docxml.at(ns("//metanorma-extension")) ||
|
6
7
|
docxml.at(ns("//bibdata")).after("<metanorma-extension/>").next_element
|
7
|
-
ins << "<source-highlighter-css>#{
|
8
|
+
ins << "<source-highlighter-css>#{ret}" \
|
8
9
|
"</source-highlighter-css>"
|
9
10
|
end
|
10
11
|
|
11
|
-
def
|
12
|
-
|
13
|
-
|
12
|
+
def custom_css(docxml)
|
13
|
+
ret = ""
|
14
|
+
@sourcehighlighter and
|
15
|
+
ret += File.read(File.join(File.dirname(__FILE__), "..", "base_style",
|
16
|
+
"rouge.css"))
|
17
|
+
a = docxml.at(ns("//metanorma-extension/" \
|
18
|
+
"clause[title = 'user-css']/sourcecode")) and
|
19
|
+
ret += "\n#{to_xml(a.children)}"
|
20
|
+
ret
|
14
21
|
end
|
15
22
|
|
16
23
|
def sourcehighlighter
|
@@ -109,6 +116,7 @@ module IsoDoc
|
|
109
116
|
Rouge::Lexer.find("plaintext"))
|
110
117
|
l = Rouge::Lexers::Escape.new(start: "{^^{", end: "}^^}", lang: lexer)
|
111
118
|
source = to_xml(elem.children).gsub(/</, "{^^{<").gsub(/>/, ">}^^}")
|
119
|
+
l.lang.reset!
|
112
120
|
l.lex(@c.decode(source))
|
113
121
|
end
|
114
122
|
|
@@ -56,23 +56,22 @@ module IsoDoc
|
|
56
56
|
def concept1_ref(_node, ref, opts)
|
57
57
|
ref.nil? and return
|
58
58
|
opts[:ref] == "false" and return ref.remove
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
"./descendant-or-self::xmlns:termref")
|
63
|
-
%w(xref eref).include? ref&.name and get_linkend(ref)
|
64
|
-
opts[:linkref] == "false" && %w(xref eref).include?(ref&.name) and
|
59
|
+
concept1_ref_content(ref)
|
60
|
+
%w(xref eref).include? ref.name and get_linkend(ref)
|
61
|
+
opts[:linkref] == "false" && %w(xref eref).include?(ref.name) and
|
65
62
|
ref.replace(ref.children)
|
66
63
|
end
|
67
64
|
|
68
65
|
def concept1_ref_content(ref)
|
66
|
+
prev = "["
|
67
|
+
foll = "]"
|
69
68
|
if non_locality_elems(ref).select do |c|
|
70
69
|
!c.text? || /\S/.match(c)
|
71
70
|
end.empty?
|
72
|
-
|
73
|
-
to_xml(ref)))
|
74
|
-
else ref.replace("[#{to_xml(ref)}]")
|
71
|
+
prev, foll = @i18n.term_defined_in.split("%")
|
75
72
|
end
|
73
|
+
ref.previous = prev
|
74
|
+
ref.next = foll
|
76
75
|
end
|
77
76
|
|
78
77
|
def related(docxml)
|
@@ -87,10 +87,11 @@ module IsoDoc
|
|
87
87
|
|
88
88
|
def semantic_xml_insert(xml)
|
89
89
|
@semantic_xml_insert or return
|
90
|
-
embed =
|
90
|
+
embed = embedable_semantic_xml(xml)
|
91
91
|
ins = metanorma_extension_insert_pt(xml)
|
92
92
|
ins = ins.at(ns("./metanorma")) || ins.add_child("<metanorma/>").first
|
93
|
-
ins
|
93
|
+
ins = ins.add_child("<source/>").first
|
94
|
+
ins << embed
|
94
95
|
end
|
95
96
|
|
96
97
|
def metanorma_extension_insert_pt(xml)
|
@@ -107,14 +108,15 @@ module IsoDoc
|
|
107
108
|
end
|
108
109
|
|
109
110
|
def embedable_semantic_xml_tags(xml)
|
110
|
-
Nokogiri::XML(to_xml(xml)
|
111
|
-
|
111
|
+
Nokogiri::XML(to_xml(xml)
|
112
|
+
.sub(/ xmlns=['"][^"']+['"]/, "")
|
113
|
+
.gsub(%r{(</?)([[:alpha:]])}, "\\1semantic__\\2")).root
|
112
114
|
end
|
113
115
|
|
114
116
|
def embedable_semantic_xml_attributes(xml)
|
115
117
|
Metanorma::Utils::anchor_attributes.each do |(tag_name, attr_name)|
|
116
118
|
tag_name == "*" or tag_name = "semantic__#{tag_name}"
|
117
|
-
xml.xpath(
|
119
|
+
xml.xpath("//#{tag_name}[@#{attr_name}]").each do |elem|
|
118
120
|
elem.attributes[attr_name].value =
|
119
121
|
"semantic__#{elem.attributes[attr_name].value}"
|
120
122
|
end
|
data/lib/isodoc/version.rb
CHANGED
@@ -4,10 +4,12 @@ module IsoDoc
|
|
4
4
|
module XrefGen
|
5
5
|
module Anchor
|
6
6
|
class SeenAnchor
|
7
|
-
|
8
|
-
|
9
|
-
def initialize
|
7
|
+
def initialize(xmldoc)
|
10
8
|
@seen = {}
|
9
|
+
# ignore all metanorma-extension ids
|
10
|
+
xmldoc.xpath("//xmlns:metanorma-extension//*[@id]").each do |x|
|
11
|
+
add(x["id"])
|
12
|
+
end
|
11
13
|
end
|
12
14
|
|
13
15
|
def seen(elem)
|
data/lib/isodoc/xref/xref_gen.rb
CHANGED
@@ -92,14 +92,15 @@ module IsoDoc
|
|
92
92
|
SECTIONS_XPATH
|
93
93
|
end
|
94
94
|
|
95
|
-
|
95
|
+
def child_asset_path(asset)
|
96
96
|
"./*[not(self::xmlns:clause) and not(self::xmlns:appendix) and " \
|
97
|
-
"not(self::xmlns:terms) and not(self::xmlns:definitions)]//xmlns:
|
98
|
-
"./xmlns:
|
97
|
+
"not(self::xmlns:terms) and not(self::xmlns:definitions)]//xmlns:X | " \
|
98
|
+
"./xmlns:X".gsub("X", asset)
|
99
|
+
end
|
99
100
|
|
100
101
|
def note_anchor_names(sections)
|
101
102
|
sections.each do |s|
|
102
|
-
notes = s.xpath(
|
103
|
+
notes = s.xpath(child_asset_path("note")) -
|
103
104
|
s.xpath(ns(".//figure//note | .//table//note"))
|
104
105
|
note_anchor_names1(notes, Counter.new)
|
105
106
|
note_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
|
@@ -116,17 +117,28 @@ module IsoDoc
|
|
116
117
|
end
|
117
118
|
end
|
118
119
|
|
119
|
-
CHILD_EXAMPLES_XPATH =
|
120
|
-
"./*[not(self::xmlns:clause) and not(self::xmlns:appendix) and " \
|
121
|
-
"not(self::xmlns:terms) and not(self::xmlns:definitions)]//" \
|
122
|
-
"xmlns:example | ./xmlns:example".freeze
|
123
|
-
|
124
120
|
CHILD_SECTIONS = "./clause | ./appendix | ./terms | ./definitions | " \
|
125
121
|
"./references".freeze
|
126
122
|
|
123
|
+
def admonition_anchor_names(sections)
|
124
|
+
sections.each do |s|
|
125
|
+
notes = s.xpath(child_asset_path("admonition[@type = 'box']"))
|
126
|
+
admonition_anchor_names1(notes, Counter.new)
|
127
|
+
admonition_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def admonition_anchor_names1(notes, counter)
|
132
|
+
notes.noblank.each do |n|
|
133
|
+
@anchors[n["id"]] ||=
|
134
|
+
anchor_struct(increment_label(notes, n, counter), n,
|
135
|
+
@labels["box"], "admonition", n["unnumbered"])
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
127
139
|
def example_anchor_names(sections)
|
128
140
|
sections.each do |s|
|
129
|
-
notes = s.xpath(
|
141
|
+
notes = s.xpath(child_asset_path("example"))
|
130
142
|
example_anchor_names1(notes, Counter.new)
|
131
143
|
example_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
|
132
144
|
end
|
@@ -154,7 +166,8 @@ module IsoDoc
|
|
154
166
|
end
|
155
167
|
end
|
156
168
|
|
157
|
-
def list_item_anchor_names(list, list_anchor, depth, prev_label,
|
169
|
+
def list_item_anchor_names(list, list_anchor, depth, prev_label,
|
170
|
+
refer_list)
|
158
171
|
c = Counter.new(list["start"] ? list["start"].to_i - 1 : 0)
|
159
172
|
list.xpath(ns("./li")).each do |li|
|
160
173
|
label = c.increment(li).listlabel(list, depth)
|
@@ -45,6 +45,7 @@ module IsoDoc
|
|
45
45
|
termexample_anchor_names(doc)
|
46
46
|
note_anchor_names(doc.xpath(ns("//table | //figure")))
|
47
47
|
note_anchor_names(doc.xpath(ns(sections_xpath)))
|
48
|
+
admonition_anchor_names(doc.xpath(ns(sections_xpath)))
|
48
49
|
example_anchor_names(doc.xpath(ns(sections_xpath)))
|
49
50
|
list_anchor_names(doc.xpath(ns(sections_xpath)))
|
50
51
|
deflist_anchor_names(doc.xpath(ns(sections_xpath)))
|
data/lib/isodoc/xref.rb
CHANGED
@@ -49,7 +49,6 @@ module IsoDoc
|
|
49
49
|
return nil if ident.nil? || ident.empty?
|
50
50
|
|
51
51
|
if warning && !@anchors[ident]
|
52
|
-
@seen ||= SeenAnchor.instance
|
53
52
|
@seen.seen(ident) or warn "No label has been processed for ID #{ident}"
|
54
53
|
@seen.add(ident)
|
55
54
|
return "[#{ident}]"
|
@@ -59,6 +58,7 @@ module IsoDoc
|
|
59
58
|
|
60
59
|
# extract names for all anchors, xref and label
|
61
60
|
def parse(docxml)
|
61
|
+
@seen = SeenAnchor.new(docxml)
|
62
62
|
amend_preprocess(docxml) if @parse_settings.empty?
|
63
63
|
initial_anchor_names(docxml)
|
64
64
|
back_anchor_names(docxml)
|
data/lib/isodoc.rb
CHANGED
@@ -7,10 +7,10 @@ require "base64"
|
|
7
7
|
require "mime/types"
|
8
8
|
require "image_size"
|
9
9
|
require "set"
|
10
|
-
require "pp"
|
11
10
|
require "html2doc"
|
12
11
|
require "liquid"
|
13
12
|
require "htmlentities"
|
13
|
+
require "relaton-render"
|
14
14
|
|
15
15
|
require "isodoc/common"
|
16
16
|
require "isodoc/convert"
|
@@ -24,6 +24,7 @@ require "isodoc/presentation_xml_convert"
|
|
24
24
|
require "isodoc/xref"
|
25
25
|
require "isodoc/i18n"
|
26
26
|
require "metanorma/output"
|
27
|
+
require "relaton/render-isodoc/general"
|
27
28
|
|
28
29
|
module IsoDoc
|
29
30
|
end
|
File without changes
|
File without changes
|
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.4.
|
4
|
+
version: 2.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciimath
|
@@ -494,8 +494,8 @@ files:
|
|
494
494
|
- lib/metanorma/output/base.rb
|
495
495
|
- lib/metanorma/output/utils.rb
|
496
496
|
- lib/metanorma/output/xslfo.rb
|
497
|
-
- lib/relaton/render/config.yml
|
498
|
-
- lib/relaton/render/general.rb
|
497
|
+
- lib/relaton/render-isodoc/config.yml
|
498
|
+
- lib/relaton/render-isodoc/general.rb
|
499
499
|
homepage: https://github.com/metanorma/isodoc
|
500
500
|
licenses:
|
501
501
|
- BSD-2-Clause
|