metanorma-standoc 2.2.6 → 2.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isodoc/html/htmlstyle.css +6 -0
- data/lib/metanorma/standoc/base.rb +3 -5
- data/lib/metanorma/standoc/biblio.rng +5 -0
- data/lib/metanorma/standoc/cleanup.rb +17 -17
- data/lib/metanorma/standoc/cleanup_amend.rb +2 -2
- data/lib/metanorma/standoc/cleanup_biblio.rb +5 -4
- data/lib/metanorma/standoc/cleanup_maths.rb +12 -4
- data/lib/metanorma/standoc/cleanup_section.rb +19 -9
- data/lib/metanorma/standoc/cleanup_symbols.rb +14 -7
- data/lib/metanorma/standoc/cleanup_text.rb +10 -4
- data/lib/metanorma/standoc/cleanup_toc.rb +1 -2
- data/lib/metanorma/standoc/cleanup_xref.rb +58 -16
- data/lib/metanorma/standoc/inline.rb +27 -12
- data/lib/metanorma/standoc/isodoc.rng +47 -13
- data/lib/metanorma/standoc/ref_utility.rb +1 -0
- data/lib/metanorma/standoc/render.rb +12 -3
- data/lib/metanorma/standoc/section.rb +10 -3
- data/lib/metanorma/standoc/utils.rb +6 -1
- data/lib/metanorma/standoc/validate.rb +1 -1
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +5 -2
- metadata +4 -128
- data/.github/workflows/automerge.yml +0 -31
- data/.github/workflows/rake.yml +0 -15
- data/.github/workflows/release.yml +0 -24
- data/Rakefile +0 -8
- data/bin/rspec +0 -18
- data/spec/assets/a1.adoc +0 -8
- data/spec/assets/a2.adoc +0 -10
- data/spec/assets/a3.adoc +0 -9
- data/spec/assets/a3a.adoc +0 -7
- data/spec/assets/a4.adoc +0 -4
- data/spec/assets/boilerplate.xml +0 -4
- data/spec/assets/codes.yml +0 -695
- data/spec/assets/correct.png +0 -0
- data/spec/assets/corrupt.png +0 -0
- data/spec/assets/header.html +0 -7
- data/spec/assets/html-override.css +0 -1
- data/spec/assets/html.scss +0 -13
- data/spec/assets/htmlcover.html +0 -4
- data/spec/assets/htmlintro.html +0 -5
- data/spec/assets/i18n.yaml +0 -17
- data/spec/assets/iso.adoc +0 -10
- data/spec/assets/iso.headless.html +0 -33
- data/spec/assets/iso.xml +0 -8
- data/spec/assets/iso123.rxl +0 -107
- data/spec/assets/rice_image1.png +0 -0
- data/spec/assets/scripts.html +0 -3
- data/spec/assets/std.css +0 -2
- data/spec/assets/word-override.css +0 -1
- data/spec/assets/word.scss +0 -13
- data/spec/assets/wordcover.html +0 -3
- data/spec/assets/wordintro.html +0 -4
- data/spec/assets/xref_error.adoc +0 -8
- data/spec/examples/103_01_02.html +0 -247
- data/spec/examples/codes_table.html +0 -3174
- data/spec/examples/datamodel/address_class_profile.adoc +0 -5
- data/spec/examples/datamodel/address_class_profile.presentation.xml +0 -14
- data/spec/examples/datamodel/address_component_profile.adoc +0 -5
- data/spec/examples/datamodel/blank_definition_profile.adoc +0 -5
- data/spec/examples/datamodel/common_models_diagram.adoc +0 -5
- data/spec/examples/datamodel/models/models/AddressClassProfile.yml +0 -90
- data/spec/examples/datamodel/models/models/AddressComponentProfile.yml +0 -63
- data/spec/examples/datamodel/models/models/AddressComponentSpecification.yml +0 -15
- data/spec/examples/datamodel/models/models/AddressProfile.yml +0 -36
- data/spec/examples/datamodel/models/models/AttributeProfile.yml +0 -32
- data/spec/examples/datamodel/models/models/InterchangeAddressClassProfile.yml +0 -79
- data/spec/examples/datamodel/models/models/Localization copy.yml +0 -23
- data/spec/examples/datamodel/models/models/Localization.yml +0 -23
- data/spec/examples/datamodel/models/models/ProfileCompliantAddress.yml +0 -36
- data/spec/examples/datamodel/models/models/ProfileCompliantAddressComponent.yml +0 -15
- data/spec/examples/datamodel/models/models/Signature.yml +0 -20
- data/spec/examples/datamodel/models/models/SignatureBlankDefinition.yml +0 -20
- data/spec/examples/datamodel/models/models/TextDirectionCode copy.yml +0 -16
- data/spec/examples/datamodel/models/models/TextDirectionCode.yml +0 -16
- data/spec/examples/datamodel/models/models/Validity.yml +0 -14
- data/spec/examples/datamodel/models/models/iso19160-1/Address.yml +0 -22
- data/spec/examples/datamodel/models/models/iso19160-1/AddressComponent.yml +0 -2
- data/spec/examples/datamodel/models/style.uml.inc +0 -37
- data/spec/examples/datamodel/models/views/CommonModels.yml +0 -9
- data/spec/examples/datamodel/models/views/TopDown.yml +0 -62
- data/spec/examples/datamodel/top_down_diagram.adoc +0 -5
- data/spec/examples/english.yaml +0 -69
- data/spec/examples/iso_123_.xml +0 -46
- data/spec/examples/iso_123_all_parts.xml +0 -46
- data/spec/examples/iso_123_no_year_note.xml +0 -47
- data/spec/examples/iso_124_.xml +0 -42
- data/spec/examples/iso_216_.xml +0 -48
- data/spec/examples/iso_iec_12382_.xml +0 -49
- data/spec/examples/rice.adoc +0 -715
- data/spec/examples/rice.preview.html +0 -1877
- data/spec/examples/rice.sh +0 -4
- data/spec/examples/rice_images/rice_image1.png +0 -0
- data/spec/examples/rice_images/rice_image2.png +0 -0
- data/spec/examples/rice_images/rice_image3_1.png +0 -0
- data/spec/examples/rice_images/rice_image3_2.png +0 -0
- data/spec/examples/rice_images/rice_image3_3.png +0 -0
- data/spec/fixtures/action_schemaexpg1.svg +0 -122
- data/spec/fixtures/datamodel_description_sections_tree.xml +0 -327
- data/spec/fixtures/diagram_definitions.lutaml +0 -22
- data/spec/fixtures/macros_datamodel/address_class_profile.xml +0 -149
- data/spec/fixtures/macros_datamodel/address_component_profile.xml +0 -71
- data/spec/fixtures/macros_datamodel/blank_definition_profile.xml +0 -51
- data/spec/fixtures/macros_datamodel/common_models_diagram.xml +0 -7
- data/spec/fixtures/macros_datamodel/top_down_diagram.xml +0 -7
- data/spec/fixtures/test.exp +0 -121
- data/spec/fixtures/test.xmi +0 -9250
- data/spec/metanorma/base_spec.rb +0 -1125
- data/spec/metanorma/biblio_spec.rb +0 -1012
- data/spec/metanorma/blank_spec.rb +0 -37
- data/spec/metanorma/blocks_spec.rb +0 -1784
- data/spec/metanorma/cleanup_blocks_spec.rb +0 -1099
- data/spec/metanorma/cleanup_sections_spec.rb +0 -1849
- data/spec/metanorma/cleanup_spec.rb +0 -1931
- data/spec/metanorma/cleanup_terms_spec.rb +0 -1543
- data/spec/metanorma/datamodel/attributes_table_preprocessor_spec.rb +0 -111
- data/spec/metanorma/datamodel/diagram_preprocessor_spec.rb +0 -72
- data/spec/metanorma/inline_spec.rb +0 -785
- data/spec/metanorma/isobib_cache_spec.rb +0 -742
- data/spec/metanorma/lists_spec.rb +0 -232
- data/spec/metanorma/macros_concept_spec.rb +0 -1052
- data/spec/metanorma/macros_json2text_spec.rb +0 -10
- data/spec/metanorma/macros_plantuml_spec.rb +0 -402
- data/spec/metanorma/macros_spec.rb +0 -1183
- data/spec/metanorma/macros_yaml2text_spec.rb +0 -10
- data/spec/metanorma/processor_spec.rb +0 -96
- data/spec/metanorma/refs_spec.rb +0 -2807
- data/spec/metanorma/reqt_spec.rb +0 -130
- data/spec/metanorma/section_spec.rb +0 -1325
- data/spec/metanorma/table_spec.rb +0 -474
- data/spec/metanorma/validate_spec.rb +0 -886
- data/spec/spec_helper.rb +0 -290
- data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +0 -781
- data/spec/vcr_cassettes/bsi16341.yml +0 -486
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +0 -611
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +0 -149
- data/spec/vcr_cassettes/hide_refs.yml +0 -587
- data/spec/vcr_cassettes/isobib_get_123.yml +0 -149
- data/spec/vcr_cassettes/isobib_get_123_1.yml +0 -295
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +0 -385
- data/spec/vcr_cassettes/isobib_get_123_2.yml +0 -295
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +0 -149
- data/spec/vcr_cassettes/isobib_get_124.yml +0 -149
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +0 -367
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +0 -560
- data/spec/vcr_cassettes/std-link.yml +0 -149
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 243e174494c4a7ce6b3b8ca5d861feb72d045439ce32948b44af9c14f9180981
|
4
|
+
data.tar.gz: 40c2d970ccb90fdf19c77cd38d5e9e7c7626fa10c96050a0486a4697c3146624
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d957db18f3b90d596f69c048fa93c703e45736c23bbaa5787fd5111aaded043fd532a219187a4ff174067a3e456c0bfb48fea4e38d1c4705d6e97754a92ed26b
|
7
|
+
data.tar.gz: 7c37929c7115382a789348ee12041496f4fe10847c2aac893cd7f60ac3e0b413d63c5573dfd6dfadf6e58af5c5455bca09ca150fe0262f9e6324b6e064cfdabe
|
@@ -263,6 +263,12 @@ body {
|
|
263
263
|
padding-left: 30px; }
|
264
264
|
#toc .h3, #toc > ul > :is(.h1, .h2, .h3, .h4, .h5, .h6) .h3 {
|
265
265
|
padding-left: 50px; }
|
266
|
+
#toc .h4, #toc > ul > :is(.h1, .h2, .h3, .h4, .h5, .h6) .h4 {
|
267
|
+
padding-left: 70px; }
|
268
|
+
#toc .h5, #toc > ul > :is(.h1, .h2, .h3, .h4, .h5, .h6) .h5 {
|
269
|
+
padding-left: 90px; }
|
270
|
+
#toc .h6, #toc > ul > :is(.h1, .h2, .h3, .h4, .h5, .h6) .h6 {
|
271
|
+
padding-left: 110px; }
|
266
272
|
#toc .toc-active, #toc li:hover, #toc > ul > :is(.h1, .h2, .h3, .h4, .h5, .h6) .toc-active, #toc > ul > :is(.h1, .h2, .h3, .h4, .h5, .h6) li:hover {
|
267
273
|
background: #C70039;
|
268
274
|
box-shadow: inset -5px 0px 10px -5px #C70039 !important; }
|
@@ -41,6 +41,7 @@ module Metanorma
|
|
41
41
|
def init_vars
|
42
42
|
@fn_number ||= 0
|
43
43
|
@refids = Set.new
|
44
|
+
@anchor_alias = {}
|
44
45
|
@anchors = {}
|
45
46
|
@internal_eref_namespaces = []
|
46
47
|
@seen_headers = []
|
@@ -130,9 +131,7 @@ module Metanorma
|
|
130
131
|
|
131
132
|
def document1(node)
|
132
133
|
init(node)
|
133
|
-
ret = makexml(node)
|
134
|
-
.to_xml(encoding: "UTF-8", indent: 2,
|
135
|
-
save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
|
134
|
+
ret = to_xml(makexml(node))
|
136
135
|
outputs(node, ret) unless node.attr("nodoc") || !node.attr("docfile")
|
137
136
|
ret
|
138
137
|
end
|
@@ -163,8 +162,7 @@ module Metanorma
|
|
163
162
|
|
164
163
|
def clean_abort(msg, file = nil)
|
165
164
|
if file
|
166
|
-
doc =
|
167
|
-
save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
|
165
|
+
doc = to_xml(file)
|
168
166
|
File.open("#{@filename}.xml.abort", "w:UTF-8") { |f| f.write(doc) }
|
169
167
|
end
|
170
168
|
clean_exit
|
@@ -188,6 +188,11 @@
|
|
188
188
|
<value>adapter</value>
|
189
189
|
<value>translator</value>
|
190
190
|
<value>distributor</value>
|
191
|
+
<value>realizer</value>
|
192
|
+
<value>owner</value>
|
193
|
+
<value>authorizer</value>
|
194
|
+
<value>enabler</value>
|
195
|
+
<value>subject</value>
|
191
196
|
</choice>
|
192
197
|
</attribute>
|
193
198
|
<zeroOrMore>
|
@@ -27,31 +27,33 @@ module Metanorma
|
|
27
27
|
def cleanup(xmldoc)
|
28
28
|
element_name_cleanup(xmldoc)
|
29
29
|
passthrough_cleanup(xmldoc)
|
30
|
-
sections_cleanup(xmldoc)
|
30
|
+
sections_cleanup(xmldoc) # feeds: obligations_cleanup, toc_cleanup
|
31
31
|
obligations_cleanup(xmldoc)
|
32
32
|
para_index_cleanup(xmldoc)
|
33
33
|
block_index_cleanup(xmldoc)
|
34
34
|
table_cleanup(xmldoc)
|
35
35
|
formula_cleanup(xmldoc)
|
36
36
|
form_cleanup(xmldoc)
|
37
|
-
sourcecode_cleanup(xmldoc)
|
37
|
+
sourcecode_cleanup(xmldoc) # feeds: callout_cleanup
|
38
38
|
figure_cleanup(xmldoc)
|
39
|
+
requirement_cleanup(xmldoc) # feeds: xref_cleanup
|
39
40
|
element_name_cleanup(xmldoc)
|
40
|
-
ref_cleanup(xmldoc)
|
41
|
+
ref_cleanup(xmldoc) # feeds: bibitem_cleanup
|
41
42
|
note_cleanup(xmldoc)
|
42
43
|
clausebefore_cleanup(xmldoc)
|
43
44
|
floatingtitle_cleanup(xmldoc)
|
44
|
-
bibitem_cleanup(xmldoc)
|
45
|
+
bibitem_cleanup(xmldoc) # feeds: normref_cleanup, biblio_cleanup,
|
46
|
+
# reference_names, bpart_cleanup
|
45
47
|
normref_cleanup(xmldoc)
|
46
48
|
biblio_cleanup(xmldoc)
|
47
49
|
reference_names(xmldoc)
|
48
|
-
symbols_cleanup(xmldoc)
|
49
|
-
xref_cleanup(xmldoc)
|
50
|
-
concept_cleanup(xmldoc)
|
51
|
-
related_cleanup(xmldoc)
|
52
|
-
origin_cleanup(xmldoc)
|
50
|
+
symbols_cleanup(xmldoc) # feeds: termdef_cleanup
|
51
|
+
xref_cleanup(xmldoc) # feeds: concept_cleanup, origin_cleanup
|
52
|
+
concept_cleanup(xmldoc) # feeds: related_cleanup, termdef_cleanup
|
53
|
+
related_cleanup(xmldoc) # feeds: termdef_cleanup
|
54
|
+
origin_cleanup(xmldoc) # feeds: termdef_cleanup
|
53
55
|
bookmark_cleanup(xmldoc)
|
54
|
-
termdef_cleanup(xmldoc)
|
56
|
+
termdef_cleanup(xmldoc) # feeds: iev_cleanup, term_index_cleanup
|
55
57
|
RelatonIev::iev_cleanup(xmldoc, @bibdb)
|
56
58
|
element_name_cleanup(xmldoc)
|
57
59
|
term_index_cleanup(xmldoc)
|
@@ -61,10 +63,9 @@ module Metanorma
|
|
61
63
|
footnote_cleanup(xmldoc)
|
62
64
|
mathml_cleanup(xmldoc)
|
63
65
|
script_cleanup(xmldoc)
|
64
|
-
docidentifier_cleanup(xmldoc)
|
65
|
-
requirement_cleanup(xmldoc)
|
66
|
+
docidentifier_cleanup(xmldoc) # feeds: bibdata_cleanup
|
66
67
|
bibdata_cleanup(xmldoc)
|
67
|
-
svgmap_cleanup(xmldoc)
|
68
|
+
svgmap_cleanup(xmldoc) # feeds: img_cleanup
|
68
69
|
boilerplate_cleanup(xmldoc)
|
69
70
|
toc_cleanup(xmldoc)
|
70
71
|
metadata_cleanup(xmldoc)
|
@@ -128,8 +129,8 @@ module Metanorma
|
|
128
129
|
|
129
130
|
def variant_cleanup1(elem)
|
130
131
|
elem.xpath("./variant").each do |n|
|
131
|
-
if n.at_xpath("preceding-sibling::node()"\
|
132
|
-
"[not(self::text()[not(normalize-space())])][1]"\
|
132
|
+
if n.at_xpath("preceding-sibling::node()" \
|
133
|
+
"[not(self::text()[not(normalize-space())])][1]" \
|
133
134
|
"[self::variantwrap]")
|
134
135
|
n.previous_element << n
|
135
136
|
else
|
@@ -152,8 +153,7 @@ module Metanorma
|
|
152
153
|
def metadata_cleanup(xmldoc)
|
153
154
|
return if @metadata_attrs.nil? || @metadata_attrs.empty?
|
154
155
|
|
155
|
-
ins = xmldoc
|
156
|
-
xmldoc.at("//bibdata").after("<misc-container/>").next_element
|
156
|
+
ins = add_misc_container(xmldoc)
|
157
157
|
ins << @metadata_attrs
|
158
158
|
end
|
159
159
|
end
|
@@ -31,8 +31,8 @@ module Metanorma
|
|
31
31
|
amend.children = "<description>#{amend.children.to_xml}</description>"
|
32
32
|
return
|
33
33
|
end
|
34
|
-
pre = q
|
35
|
-
post = q
|
34
|
+
pre = q.xpath("./preceding-sibling::*")&.remove
|
35
|
+
post = q.xpath("./following-sibling::*")&.remove
|
36
36
|
pre.empty? or amend << "<description>#{pre.to_xml}</description>"
|
37
37
|
amend << q.remove
|
38
38
|
post.empty? or amend << "<description>#{post.to_xml}</description>"
|
@@ -49,7 +49,8 @@ module Metanorma
|
|
49
49
|
def span_preprocess1(span, ret)
|
50
50
|
case span[:key]
|
51
51
|
when "uri", "docid"
|
52
|
-
|
52
|
+
val = link_unwrap(Nokogiri::XML.fragment(span[:val])).to_xml
|
53
|
+
ret[span[:key].to_sym] << { type: span[:type], val: val }
|
53
54
|
when "date"
|
54
55
|
ret[span[:key].to_sym] << { type: span[:type] || "published",
|
55
56
|
val: span[:val] }
|
@@ -151,16 +152,16 @@ module Metanorma
|
|
151
152
|
{ volume: "volume", issue: "issue", pages: "page" }.each do |k, v|
|
152
153
|
spans[k]&.each { |s| ret += span_to_extent(s, v) }
|
153
154
|
end
|
154
|
-
ret
|
155
|
+
"<extent>#{ret}</extent>"
|
155
156
|
end
|
156
157
|
|
157
158
|
def span_to_extent(span, key)
|
158
159
|
values = span.split(/[-–]/)
|
159
|
-
ret = "<
|
160
|
+
ret = "<locality type='#{key}'>" \
|
160
161
|
"<referenceFrom>#{values[0]}</referenceFrom>"
|
161
162
|
values[1] and
|
162
163
|
ret += "<referenceTo>#{values[1]}</referenceTo>"
|
163
|
-
"#{ret}</locality
|
164
|
+
"#{ret}</locality>"
|
164
165
|
end
|
165
166
|
|
166
167
|
def span_to_docid(span, key)
|
@@ -8,16 +8,24 @@ module Metanorma
|
|
8
8
|
"<amathstem>#{@c.decode($1)}</amathstem>"
|
9
9
|
end
|
10
10
|
text = Html2Doc.new({})
|
11
|
-
.asciimath_to_mathml(text, ["<amathstem>", "</amathstem>"]
|
12
|
-
|
11
|
+
.asciimath_to_mathml(text, ["<amathstem>", "</amathstem>"],
|
12
|
+
retain_asciimath: true)
|
13
|
+
asciimath2mathml_wrap(text)
|
14
|
+
end
|
15
|
+
|
16
|
+
def asciimath2mathml_wrap(text)
|
17
|
+
x = Nokogiri::XML(text)
|
13
18
|
x.xpath("//*[local-name() = 'math'][not(parent::stem)]").each do |y|
|
14
19
|
y.wrap("<stem type='MathML'></stem>")
|
15
20
|
end
|
16
|
-
x.
|
21
|
+
x.xpath("//stem").each do |y|
|
22
|
+
y.next_element&.name == "asciimath" and y << y.next_element
|
23
|
+
end
|
24
|
+
to_xml(x)
|
17
25
|
end
|
18
26
|
|
19
27
|
def xml_unescape_mathml(xml)
|
20
|
-
return if xml.children.any?
|
28
|
+
return if xml.children.any?(&:element?)
|
21
29
|
|
22
30
|
math = xml.text.gsub(/</, "<").gsub(/>/, ">")
|
23
31
|
.gsub(/"/, '"').gsub(/'/, "'").gsub(/&/, "&")
|
@@ -8,7 +8,7 @@ module Metanorma
|
|
8
8
|
module Standoc
|
9
9
|
module Cleanup
|
10
10
|
def make_preface(xml, sect)
|
11
|
-
if xml.at("//foreword | //introduction | //acknowledgements | "\
|
11
|
+
if xml.at("//foreword | //introduction | //acknowledgements | " \
|
12
12
|
"//*[@preface]")
|
13
13
|
preface = sect.add_previous_sibling("<preface/>").first
|
14
14
|
f = xml.at("//foreword") and preface.add_child f.remove
|
@@ -33,21 +33,24 @@ module Metanorma
|
|
33
33
|
abstract = xml.at("//abstract[not(ancestor::bibitem)]").remove
|
34
34
|
preface.prepend_child abstract.remove
|
35
35
|
bibabstract = bibabstract_location(xml)
|
36
|
-
|
37
|
-
dupabstract.traverse { |n| n.remove_attribute("id") }
|
38
|
-
dupabstract.remove_attribute("language")
|
39
|
-
dupabstract.remove_attribute("script")
|
40
|
-
dupabstract&.at("./title")&.remove
|
41
|
-
bibabstract.next = dupabstract
|
36
|
+
bibabstract.next = clean_abstract(abstract.dup)
|
42
37
|
end
|
43
38
|
end
|
44
39
|
|
40
|
+
def clean_abstract(dupabstract)
|
41
|
+
dupabstract.traverse { |n| n.remove_attribute("id") }
|
42
|
+
dupabstract.remove_attribute("language")
|
43
|
+
dupabstract.remove_attribute("script")
|
44
|
+
dupabstract.at("./title")&.remove
|
45
|
+
dupabstract
|
46
|
+
end
|
47
|
+
|
45
48
|
def bibabstract_location(xml)
|
46
49
|
xml.at("//bibdata/script") || xml.at("//bibdata/language") ||
|
47
50
|
xml.at("//bibdata/contributor[not(following-sibling::contributor)]") ||
|
48
51
|
xml.at("//bibdata/date[not(following-sibling::date)]") ||
|
49
52
|
xml.at("//docnumber") ||
|
50
|
-
xml.at("//bibdata/docidentifier"\
|
53
|
+
xml.at("//bibdata/docidentifier" \
|
51
54
|
"[not(following-sibling::docidentifier)]") ||
|
52
55
|
xml.at("//bibdata/uri[not(following-sibling::uri)]") ||
|
53
56
|
xml.at("//bibdata/title[not(following-sibling::title)]")
|
@@ -111,6 +114,7 @@ module Metanorma
|
|
111
114
|
end
|
112
115
|
|
113
116
|
def sections_cleanup(xml)
|
117
|
+
misccontainer_cleanup(xml)
|
114
118
|
sections_order_cleanup(xml)
|
115
119
|
sections_level_cleanup(xml)
|
116
120
|
sections_names_cleanup(xml)
|
@@ -118,6 +122,12 @@ module Metanorma
|
|
118
122
|
change_clauses(xml)
|
119
123
|
end
|
120
124
|
|
125
|
+
def misccontainer_cleanup(xml)
|
126
|
+
m = xml.at("//misc-container-clause") or return
|
127
|
+
ins = add_misc_container(xml)
|
128
|
+
ins << m.remove.children
|
129
|
+
end
|
130
|
+
|
121
131
|
def single_clause_annex(xml)
|
122
132
|
xml.xpath("//annex").each do |a|
|
123
133
|
single_clause_annex1(a)
|
@@ -131,7 +141,7 @@ module Metanorma
|
|
131
141
|
end
|
132
142
|
|
133
143
|
def obligations_cleanup_info(xml)
|
134
|
-
xml.xpath("//foreword | //introduction | //acknowledgements | "\
|
144
|
+
xml.xpath("//foreword | //introduction | //acknowledgements | " \
|
135
145
|
"//references | //preface//clause").each do |r|
|
136
146
|
r["obligation"] = "informative"
|
137
147
|
end
|
@@ -5,18 +5,25 @@ module Metanorma
|
|
5
5
|
# letter (x, x_m, x_1, xa); we use colon to force that sort order.
|
6
6
|
# Numbers sort *after* letters; we use thorn to force that sort order.
|
7
7
|
def symbol_key(sym)
|
8
|
-
|
9
|
-
key.traverse do |n|
|
10
|
-
n.name == "math" and
|
11
|
-
n.replace(grkletters(MathML2AsciiMath.m2a(n.to_xml)))
|
12
|
-
end
|
13
|
-
ret = Nokogiri::XML(key.to_xml)
|
14
|
-
@c.decode(ret.text.downcase)
|
8
|
+
@c.decode(asciimath_key(sym).text.downcase)
|
15
9
|
.gsub(/[\[\]{}<>()]/, "").gsub(/\s/m, "")
|
16
10
|
.gsub(/[[:punct:]]|[_^]/, ":\\0").gsub(/`/, "")
|
17
11
|
.gsub(/[0-9]+/, "þ\\0")
|
18
12
|
end
|
19
13
|
|
14
|
+
def asciimath_key(sym)
|
15
|
+
key = sym.dup
|
16
|
+
key.traverse do |n|
|
17
|
+
if n.name == "math"
|
18
|
+
n.children = @c.encode(
|
19
|
+
@c.decode(grkletters(MathML2AsciiMath.m2a(n.to_xml))), :basic
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
key.xpath(".//asciimath").each(&:remove)
|
24
|
+
Nokogiri::XML(key.to_xml)
|
25
|
+
end
|
26
|
+
|
20
27
|
def grkletters(text)
|
21
28
|
text.gsub(/\b(alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|
|
22
29
|
lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|
|
@@ -35,7 +35,8 @@ module Metanorma
|
|
35
35
|
end
|
36
36
|
|
37
37
|
IGNORE_QUOTES_ELEMENTS =
|
38
|
-
%w(pre tt sourcecode stem figure bibdata passthrough
|
38
|
+
%w(pre tt sourcecode stem asciimath figure bibdata passthrough
|
39
|
+
identifier).freeze
|
39
40
|
|
40
41
|
def uninterrupt_quotes_around_xml_skip(elem)
|
41
42
|
!(/\A['"]/.match?(elem.text) &&
|
@@ -100,9 +101,14 @@ module Metanorma
|
|
100
101
|
|
101
102
|
def dumbquote_cleanup(xmldoc)
|
102
103
|
xmldoc.traverse do |n|
|
103
|
-
next unless n.text?
|
104
|
-
|
105
|
-
n.replace(n.text.gsub(/(?<=\p{Alnum})\u2019(?=\p{Alpha})/, "'")) # .
|
104
|
+
next unless n.text? && /\u2019/.match?(n.text)
|
105
|
+
|
106
|
+
# n.replace(n.text.gsub(/(?<=\p{Alnum})\u2019(?=\p{Alpha})/, "'")) # .
|
107
|
+
n.replace(@c.encode(
|
108
|
+
@c.decode(n.text)
|
109
|
+
.gsub(/(?<=\p{Alnum})\u2019(?=\p{Alpha})/, "'"),
|
110
|
+
:basic, :hexadecimal
|
111
|
+
))
|
106
112
|
end
|
107
113
|
end
|
108
114
|
end
|
@@ -80,8 +80,7 @@ module Metanorma
|
|
80
80
|
def toc_metadata(xmldoc)
|
81
81
|
return unless @htmltoclevels || @doctoclevels || @toclevels
|
82
82
|
|
83
|
-
ins = xmldoc
|
84
|
-
xmldoc.at("//bibdata").after("<misc-container/>").next_element
|
83
|
+
ins = add_misc_container(xmldoc)
|
85
84
|
toc_metadata1(ins)
|
86
85
|
end
|
87
86
|
|
@@ -20,10 +20,11 @@ module Metanorma
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def extract_localities(elem)
|
23
|
-
|
23
|
+
elem.children.empty? and return
|
24
|
+
f = elem.children.first
|
24
25
|
f.text? or return
|
25
26
|
head = f.remove.text
|
26
|
-
tail = elem
|
27
|
+
tail = elem.children.remove
|
27
28
|
extract_localities1(elem, head)
|
28
29
|
tail and elem << tail
|
29
30
|
end
|
@@ -45,7 +46,7 @@ module Metanorma
|
|
45
46
|
ref =
|
46
47
|
match[:ref] ? "<referenceFrom>#{tq match[:ref]}</referenceFrom>" : ""
|
47
48
|
refto = match[:to] ? "<referenceTo>#{tq match[:to]}</referenceTo>" : ""
|
48
|
-
stack.add_child("<locality type='#{locality_label(match)}'>#{ref}"\
|
49
|
+
stack.add_child("<locality type='#{locality_label(match)}'>#{ref}" \
|
49
50
|
"#{refto}</locality>")
|
50
51
|
end
|
51
52
|
|
@@ -67,7 +68,8 @@ module Metanorma
|
|
67
68
|
/^locality:/.match?(loc) ? loc : loc&.downcase
|
68
69
|
end
|
69
70
|
|
70
|
-
def xref_to_eref(elem)
|
71
|
+
def xref_to_eref(elem, name)
|
72
|
+
elem.name = name
|
71
73
|
elem["bibitemid"] = elem["target"]
|
72
74
|
if ref = @anchors&.dig(elem["target"], :xref)
|
73
75
|
elem["citeas"] = @c.decode(ref)
|
@@ -75,21 +77,56 @@ module Metanorma
|
|
75
77
|
elem["citeas"] = ""
|
76
78
|
xref_to_eref1(elem)
|
77
79
|
end
|
78
|
-
elem.delete("target")
|
79
|
-
extract_localities(elem)
|
80
|
+
elem.delete("target").delete("style")
|
81
|
+
extract_localities(elem)
|
80
82
|
end
|
81
83
|
|
82
84
|
def xref_to_eref1(elem)
|
83
85
|
@internal_eref_namespaces.include?(elem["type"]) or
|
84
86
|
@log.add("Crossreferences", elem,
|
85
|
-
"#{elem['target']} does not have a corresponding "\
|
87
|
+
"#{elem['target']} does not have a corresponding " \
|
86
88
|
"anchor ID in the bibliography!")
|
87
89
|
end
|
88
90
|
|
89
91
|
def xref_cleanup(xmldoc)
|
92
|
+
anchor_alias(xmldoc)
|
90
93
|
xref_compound_cleanup(xmldoc)
|
91
94
|
xref_cleanup1(xmldoc)
|
92
95
|
xref_compound_wrapup(xmldoc)
|
96
|
+
eref_stack(xmldoc)
|
97
|
+
end
|
98
|
+
|
99
|
+
def eref_stack(xmldoc)
|
100
|
+
xmldoc.xpath("//eref[eref]").each do |e|
|
101
|
+
e.name = "erefstack"
|
102
|
+
e.delete("bibitemid")
|
103
|
+
e.delete("citeas")
|
104
|
+
e.xpath("./eref").each do |e1|
|
105
|
+
e1["type"] = e["type"]
|
106
|
+
end
|
107
|
+
e.delete("type")
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def anchor_alias(xmldoc)
|
112
|
+
t = xmldoc.at("//misc-container/table[@id = " \
|
113
|
+
"'_misccontainer_anchor_aliases']") or return
|
114
|
+
key = ""
|
115
|
+
t.xpath("./tbody/tr").each do |tr|
|
116
|
+
tr.xpath("./td | ./th").each_with_index do |td, i|
|
117
|
+
if i.zero? then key = td.text
|
118
|
+
else anchor_alias1(key, td)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def anchor_alias1(key, elem)
|
125
|
+
id = elem.text.strip
|
126
|
+
id.empty? and elem.at("./link") and
|
127
|
+
id = elem.at("./link/@target")&.text
|
128
|
+
(key && !id.empty?) or return
|
129
|
+
@anchor_alias[id] = key
|
93
130
|
end
|
94
131
|
|
95
132
|
def xref_compound_cleanup(xmldoc)
|
@@ -128,12 +165,12 @@ module Metanorma
|
|
128
165
|
|
129
166
|
def xref_cleanup1(xmldoc)
|
130
167
|
xmldoc.xpath("//xref").each do |x|
|
131
|
-
|
168
|
+
%r{:(?!//)}.match?(x["target"]) and xref_to_internal_eref(x)
|
132
169
|
next unless x.name == "xref"
|
133
170
|
|
134
171
|
if refid? x["target"]
|
135
|
-
x
|
136
|
-
|
172
|
+
xref_to_eref(x, "eref")
|
173
|
+
elsif @anchor_alias[x["target"]] then xref_alias(x)
|
137
174
|
else x.delete("type")
|
138
175
|
end
|
139
176
|
end
|
@@ -144,17 +181,22 @@ module Metanorma
|
|
144
181
|
unless a.size < 2 || a[0].empty? || a[1].empty?
|
145
182
|
elem["target"] = "#{a[0]}_#{a[1]}"
|
146
183
|
a.size > 2 and
|
147
|
-
elem.children = %{anchor="#{a[2..-1].join}",#{elem
|
184
|
+
elem.children = %{anchor="#{a[2..-1].join}",#{elem.children&.text}}
|
148
185
|
elem["type"] = a[0]
|
149
186
|
@internal_eref_namespaces << a[0]
|
150
|
-
elem
|
151
|
-
xref_to_eref(elem)
|
187
|
+
xref_to_eref(elem, "eref")
|
152
188
|
end
|
153
189
|
end
|
154
190
|
|
191
|
+
def xref_alias(elem)
|
192
|
+
elem["style"] == "id" && elem.text.strip.empty? and
|
193
|
+
elem << elem["target"]
|
194
|
+
elem["target"] = @anchor_alias[elem["target"]]
|
195
|
+
end
|
196
|
+
|
155
197
|
def quotesource_cleanup(xmldoc)
|
156
198
|
xmldoc.xpath("//quote/source | //terms/source").each do |x|
|
157
|
-
xref_to_eref(x)
|
199
|
+
xref_to_eref(x, "source")
|
158
200
|
end
|
159
201
|
end
|
160
202
|
|
@@ -165,9 +207,9 @@ module Metanorma
|
|
165
207
|
xmldoc.xpath("//origin").each do |x|
|
166
208
|
x["citeas"] = @anchors&.dig(x["bibitemid"], :xref) or
|
167
209
|
@log.add("Crossreferences", x,
|
168
|
-
"#{x['bibitemid']} does not have a corresponding anchor "\
|
210
|
+
"#{x['bibitemid']} does not have a corresponding anchor " \
|
169
211
|
"ID in the bibliography!")
|
170
|
-
extract_localities(x)
|
212
|
+
extract_localities(x)
|
171
213
|
end
|
172
214
|
end
|
173
215
|
end
|
@@ -40,30 +40,44 @@ module Metanorma
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def inline_anchor_xref_attrs(node)
|
43
|
-
|
43
|
+
text = concatenate_attributes_to_xref_text(node)
|
44
|
+
m = inline_anchor_xref_match(text)
|
44
45
|
t = node.target.gsub(/^#/, "").gsub(%r{(\.xml|\.adoc)(#.*$)}, "\\2")
|
45
|
-
m.nil? and return { target: t, type: "inline", text:
|
46
|
-
|
47
|
-
case: m[:case]&.sub(/%$/, ""),
|
48
|
-
style: m[:style]&.sub(/^style=/, "")&.sub(/%$/, "") || @xrefstyle,
|
49
|
-
droploc: m[:drop].nil? && m[:drop2].nil? ? nil : true,
|
50
|
-
text: inline_anchor_xref_text(m, node),
|
51
|
-
hidden: m[:hidden] }
|
46
|
+
m.nil? and return { target: t, type: "inline", text: text }
|
47
|
+
inline_anchor_xref_attrs1(m, t, text)
|
52
48
|
end
|
53
49
|
|
54
|
-
def
|
50
|
+
def concatenate_attributes_to_xref_text(node)
|
51
|
+
node.attributes.each_with_object([]) do |(k, v), m|
|
52
|
+
next if %w(path fragment refid).include?(k)
|
53
|
+
|
54
|
+
m << "#{k}=#{v}%"
|
55
|
+
end.map { |x| x.sub(/%+/, "%") }.join + (node.text || "")
|
56
|
+
end
|
57
|
+
|
58
|
+
def inline_anchor_xref_attrs1(match, target, text)
|
59
|
+
{ target: target,
|
60
|
+
type: match[:fn].nil? ? "inline" : "footnote",
|
61
|
+
case: match[:case]&.sub(/%$/, ""),
|
62
|
+
style: match[:style]&.sub(/^style=/, "")&.sub(/%$/, "") || @xrefstyle,
|
63
|
+
droploc: match[:drop].nil? && match[:drop2].nil? ? nil : true,
|
64
|
+
text: inline_anchor_xref_text(match, text),
|
65
|
+
hidden: match[:hidden] }
|
66
|
+
end
|
67
|
+
|
68
|
+
def inline_anchor_xref_match(text)
|
55
69
|
/^(?:hidden%(?<hidden>[^,]+),?)?
|
56
70
|
(?<style>style=[^%]+%)?
|
57
71
|
(?<drop>droploc%)?(?<case>capital%|lowercase%)?(?<drop2>droploc%)?
|
58
|
-
(?<fn>fn:?\s*)?(?<text>.*)$/x.match
|
72
|
+
(?<fn>fn:?\s*)?(?<text>.*)$/x.match text
|
59
73
|
end
|
60
74
|
|
61
|
-
def inline_anchor_xref_text(match,
|
75
|
+
def inline_anchor_xref_text(match, text)
|
62
76
|
if %i[case fn drop drop2 hidden style].any? do |x|
|
63
77
|
!match[x].nil?
|
64
78
|
end
|
65
79
|
match[:text]
|
66
|
-
else
|
80
|
+
else text
|
67
81
|
end
|
68
82
|
end
|
69
83
|
|
@@ -160,6 +174,7 @@ module Metanorma
|
|
160
174
|
.elements[0]
|
161
175
|
math.delete("alttext")
|
162
176
|
s.parent.children = math
|
177
|
+
s << "<latexmath>#{text}</latexmath>"
|
163
178
|
end
|
164
179
|
end
|
165
180
|
|