metanorma-standoc 3.3.0 → 3.3.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 +4 -4
- data/lib/isodoc/html/htmlstyle.css +2 -2
- data/lib/isodoc/html/htmlstyle.scss +1 -1
- data/lib/metanorma/{standoc/cleanup_amend.rb → cleanup/amend.rb} +1 -1
- data/lib/metanorma/{standoc/cleanup_asciibib.rb → cleanup/asciibib.rb} +1 -1
- data/lib/metanorma/{standoc/cleanup_attachment.rb → cleanup/attachment.rb} +1 -1
- data/lib/metanorma/{standoc/cleanup_bibdata.rb → cleanup/bibdata.rb} +4 -2
- data/lib/metanorma/{standoc/cleanup_bibitem.rb → cleanup/bibitem.rb} +11 -9
- data/lib/metanorma/{standoc/cleanup_block.rb → cleanup/block.rb} +3 -3
- data/lib/metanorma/{standoc/cleanup_boilerplate.rb → cleanup/boilerplate.rb} +8 -11
- data/lib/metanorma/{standoc/cleanup_boilerplate_liquid.rb → cleanup/boilerplate_liquid.rb} +1 -1
- data/lib/metanorma/{standoc → cleanup}/cleanup.rb +130 -105
- data/lib/metanorma/{standoc/cleanup_dochistory.rb → cleanup/dochistory.rb} +2 -2
- data/lib/metanorma/{standoc/cleanup_footnotes.rb → cleanup/footnotes.rb} +1 -1
- data/lib/metanorma/{standoc/cleanup_image.rb → cleanup/image.rb} +2 -2
- data/lib/metanorma/{standoc/cleanup_index.rb → cleanup/index.rb} +1 -1
- data/lib/metanorma/{standoc/cleanup_inline.rb → cleanup/inline.rb} +1 -1
- data/lib/metanorma/cleanup/log.rb +41 -0
- data/lib/metanorma/{standoc/cleanup_maths.rb → cleanup/maths.rb} +2 -2
- data/lib/metanorma/{standoc/cleanup_mathvariant.rb → cleanup/mathvariant.rb} +1 -1
- data/lib/metanorma/{standoc → cleanup}/merge_bibitems.rb +1 -1
- data/lib/metanorma/cleanup/metadata.rb +54 -0
- data/lib/metanorma/{standoc/cleanup_ref.rb → cleanup/ref.rb} +5 -4
- data/lib/metanorma/{standoc/cleanup_reqt.rb → cleanup/reqt.rb} +2 -2
- data/lib/metanorma/{standoc/cleanup_review.rb → cleanup/review.rb} +1 -1
- data/lib/metanorma/{standoc/cleanup_section.rb → cleanup/section.rb} +2 -2
- data/lib/metanorma/{standoc/cleanup_section_names.rb → cleanup/section_names.rb} +1 -1
- data/lib/metanorma/{standoc → cleanup}/spans_to_bibitem.rb +1 -1
- data/lib/metanorma/{standoc → cleanup}/spans_to_bibitem_preprocessing.rb +1 -1
- data/lib/metanorma/{standoc/cleanup_symbols.rb → cleanup/symbols.rb} +2 -2
- data/lib/metanorma/{standoc/cleanup_table.rb → cleanup/table.rb} +1 -1
- data/lib/metanorma/{standoc/term_lookup_cleanup.rb → cleanup/term_lookup.rb} +1 -1
- data/lib/metanorma/{standoc/cleanup_terms.rb → cleanup/terms.rb} +3 -3
- data/lib/metanorma/{standoc/cleanup_terms_boilerplate.rb → cleanup/terms_boilerplate.rb} +1 -6
- data/lib/metanorma/{standoc/cleanup_terms_designations.rb → cleanup/terms_designations.rb} +1 -1
- data/lib/metanorma/{standoc/cleanup_text.rb → cleanup/text.rb} +1 -6
- data/lib/metanorma/{standoc/cleanup_toc.rb → cleanup/toc.rb} +10 -8
- data/lib/metanorma/{standoc/cleanup_xref.rb → cleanup/xref.rb} +2 -2
- data/lib/metanorma/{standoc/cleanup_xref_localities.rb → cleanup/xref_localities.rb} +1 -1
- data/lib/metanorma/{standoc → converter}/base.rb +38 -17
- data/lib/metanorma/{standoc → converter}/converter.rb +11 -4
- data/lib/metanorma/converter/date_utils.rb +52 -0
- data/lib/metanorma/{standoc → converter}/front.rb +1 -0
- data/lib/metanorma/{standoc → converter}/init.rb +34 -11
- data/lib/metanorma/{standoc → converter}/isolated_converter.rb +1 -1
- data/lib/metanorma/{standoc → converter}/ref.rb +1 -1
- data/lib/metanorma/{standoc → converter}/ref_queue.rb +6 -0
- data/lib/metanorma/{standoc → converter}/utils.rb +8 -15
- data/lib/metanorma/{standoc → converter}/version.rb +1 -1
- data/lib/metanorma/standoc.rb +1 -1
- data/lib/metanorma/{standoc → validate}/basicdoc.rng +5 -1
- data/lib/metanorma/validate/image.rb +190 -0
- data/lib/metanorma/validate/schema.rb +149 -0
- data/lib/metanorma/validate/section.rb +81 -0
- data/lib/metanorma/validate/table.rb +97 -0
- data/lib/metanorma/validate/term.rb +137 -0
- data/lib/metanorma/{standoc → validate}/validate.rb +60 -16
- data/lib/metanorma-standoc.rb +2 -2
- data/lib/nokogiri/xml/builder.rb +16 -0
- data/metanorma-standoc.gemspec +1 -1
- metadata +94 -90
- data/lib/metanorma/standoc/validate_image.rb +0 -182
- data/lib/metanorma/standoc/validate_schema.rb +0 -144
- data/lib/metanorma/standoc/validate_section.rb +0 -79
- data/lib/metanorma/standoc/validate_table.rb +0 -95
- data/lib/metanorma/standoc/validate_term.rb +0 -135
- /data/lib/metanorma/{standoc → converter}/anchor.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/blocks.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/blocks_examples.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/blocks_image.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/blocks_notes_examples.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/front_committee.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/front_contributor.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/front_ext.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/front_organisation.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/front_title.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/inline.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/lists.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/localbib.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/log.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/macros.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/macros_embed.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/macros_form.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/macros_inline.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/macros_link.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/macros_nosub.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/macros_note.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/macros_number.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/macros_terms.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/processor.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/ref_sect.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/ref_utility.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/regex.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/render.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/reqt.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/section.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/sectiontype.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/table.rb +0 -0
- /data/lib/metanorma/{standoc → converter}/terms.rb +0 -0
- /data/lib/metanorma/{standoc → validate}/biblio-standoc.rng +0 -0
- /data/lib/metanorma/{standoc → validate}/biblio.rng +0 -0
- /data/lib/metanorma/{standoc → validate}/isodoc-compile.rng +0 -0
- /data/lib/metanorma/{standoc → validate}/isodoc.rng +0 -0
- /data/lib/metanorma/{standoc → validate}/reqt.rng +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8ebe9c752511841d783fa0d9820ee7bd26448703e6990bbd406ae0d92ab35417
|
|
4
|
+
data.tar.gz: b6e82ef1d270969216902f745314145917cbdc376fe92fe11b76964cdd8bb6f1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7b35e03b90cf332d1c100003d1e5bd72a524ffb085eb3b85428ebaac975f51d69562404e31f761894b22d51a9245be804f27a6e230299ed904ab497ebfc1d3c5
|
|
7
|
+
data.tar.gz: 29a42e39bbc67f18b07d557f32da4dbd3a6747f913108b4cfa2a74f610484cfd114d127e78fe8b21e4bf45ef255de955947967402f78d4f4cf3bfb07b77a6694
|
|
@@ -624,7 +624,7 @@ body pre * {
|
|
|
624
624
|
}
|
|
625
625
|
}
|
|
626
626
|
|
|
627
|
-
div.figure
|
|
627
|
+
div.figure figcaption {
|
|
628
628
|
font-weight: 700;
|
|
629
629
|
font-size: 1em;
|
|
630
630
|
text-align: center;
|
|
@@ -1071,7 +1071,7 @@ table table.plain, table table.plain th, table table.plain td {
|
|
|
1071
1071
|
font-size: 0.95em;
|
|
1072
1072
|
}
|
|
1073
1073
|
|
|
1074
|
-
|
|
1074
|
+
table > caption {
|
|
1075
1075
|
text-align: center;
|
|
1076
1076
|
margin-top: 2.5em;
|
|
1077
1077
|
font-weight: 400;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Metanorma
|
|
2
2
|
module Standoc
|
|
3
|
-
module
|
|
3
|
+
module Bibdata
|
|
4
4
|
def bibdata_cleanup(xmldoc)
|
|
5
5
|
bibdata_anchor_cleanup(xmldoc)
|
|
6
6
|
bibdata_docidentifier_cleanup(xmldoc)
|
|
@@ -120,7 +120,7 @@ module Metanorma
|
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
def hdr2bibitem(hdr)
|
|
123
|
-
xml = isolated_asciidoctor_convert(hdr[:text],
|
|
123
|
+
xml = @conv.isolated_asciidoctor_convert(hdr[:text],
|
|
124
124
|
backend: hdr2bibitem_type(hdr),
|
|
125
125
|
header_footer: true)
|
|
126
126
|
b = Nokogiri::XML(xml).at("//xmlns:bibdata")
|
|
@@ -222,6 +222,8 @@ module Metanorma
|
|
|
222
222
|
p.nil? || p.text.strip.empty? and c.remove
|
|
223
223
|
end
|
|
224
224
|
end
|
|
225
|
+
|
|
226
|
+
def docidentifier_cleanup(xmldoc); end
|
|
225
227
|
end
|
|
226
228
|
end
|
|
227
229
|
end
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
require_relative "
|
|
1
|
+
require_relative "attachment"
|
|
2
2
|
|
|
3
3
|
module Metanorma
|
|
4
4
|
module Standoc
|
|
5
|
-
module
|
|
5
|
+
module Bibitem
|
|
6
|
+
include Attachment
|
|
7
|
+
|
|
6
8
|
def formattedref_spans(xmldoc)
|
|
7
9
|
xmldoc.xpath("//bibitem[formattedref//span]").each do |b|
|
|
8
10
|
ret = new_bibitem_from_formattedref_spans(b)
|
|
@@ -14,7 +16,7 @@ module Metanorma
|
|
|
14
16
|
end
|
|
15
17
|
|
|
16
18
|
def new_bibitem_from_formattedref_spans(bib)
|
|
17
|
-
ret = SpansToBibitem.new(bib).convert
|
|
19
|
+
ret = Metanorma::Standoc::Cleanup::SpansToBibitem.new(bib).convert
|
|
18
20
|
ret.err.each do |e|
|
|
19
21
|
@log.add(e[:fatal] ? "STANDOC_52" : "STANDOC_53",
|
|
20
22
|
bib, params: [e[:msg]])
|
|
@@ -26,7 +28,7 @@ module Metanorma
|
|
|
26
28
|
merge_bibitem_from_formattedref_span_attrs(bib, new)
|
|
27
29
|
if bib.at("./title") && bib["amend"]
|
|
28
30
|
# there already is a fetched record here: merge
|
|
29
|
-
bib.children = MergeBibitems
|
|
31
|
+
bib.children = Metanorma::Standoc::Cleanup::MergeBibitems
|
|
30
32
|
.new(bib.to_xml, new.to_xml).merge.to_noko.children
|
|
31
33
|
elsif bib.at("./title") # replace record
|
|
32
34
|
bib.children = new.children.to_xml
|
|
@@ -135,11 +137,11 @@ module Metanorma
|
|
|
135
137
|
def fetch_local_bibitem(xmldoc)
|
|
136
138
|
xmldoc.xpath("//bibitem[formattedref][uri[@type = 'citation']]")
|
|
137
139
|
.each do |b|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
uri = b&.at("./uri[@type = 'citation']")&.text
|
|
141
|
+
bibitem = read_local_bibitem(uri) or next
|
|
142
|
+
bibitem["id"] = b["id"]
|
|
143
|
+
bibitem["anchor"] = b["anchor"]
|
|
144
|
+
b.replace(bibitem)
|
|
143
145
|
end
|
|
144
146
|
end
|
|
145
147
|
|
|
@@ -3,7 +3,7 @@ require "htmlentities"
|
|
|
3
3
|
|
|
4
4
|
module Metanorma
|
|
5
5
|
module Standoc
|
|
6
|
-
module
|
|
6
|
+
module Block
|
|
7
7
|
def para_cleanup(xmldoc)
|
|
8
8
|
["//p[not(ancestor::bibdata)]", "//ol[not(ancestor::bibdata)]",
|
|
9
9
|
"//ul[not(ancestor::bibdata)]", "//quote[not(ancestor::bibdata)]",
|
|
@@ -187,9 +187,9 @@ module Metanorma
|
|
|
187
187
|
source_markup_prep(node).each_slice(4).map.with_object([]) do |a, acc|
|
|
188
188
|
acc << safe_noko(a[0], node.document)
|
|
189
189
|
a.size == 4 or next
|
|
190
|
-
acc << isolated_asciidoctor_convert(
|
|
190
|
+
acc << @conv.isolated_asciidoctor_convert(
|
|
191
191
|
"{blank} #{a[2]}", doctype: :inline,
|
|
192
|
-
backend: backend&.to_sym || :standoc
|
|
192
|
+
backend: @conv.backend&.to_sym || :standoc
|
|
193
193
|
).strip
|
|
194
194
|
end.join
|
|
195
195
|
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
require_relative "
|
|
2
|
-
require_relative "
|
|
1
|
+
require_relative "terms_boilerplate"
|
|
2
|
+
require_relative "boilerplate_liquid"
|
|
3
3
|
|
|
4
4
|
module Metanorma
|
|
5
5
|
module Standoc
|
|
6
|
-
module
|
|
6
|
+
module Boilerplate
|
|
7
7
|
def norm_ref_preface(ref, isodoc)
|
|
8
8
|
ins = norm_ref_boilerplate_insert_location(ref)
|
|
9
9
|
ins2 = norm_ref_process_boilerplate_note(ref)
|
|
@@ -37,13 +37,9 @@ module Metanorma
|
|
|
37
37
|
ref.at("./title")
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
NORM_REF =
|
|
41
|
-
"//bibliography/references[@normative = 'true'][not(@hidden)] | " \
|
|
42
|
-
"//bibliography/clause[.//references[@normative = 'true']]".freeze
|
|
43
|
-
|
|
44
40
|
def dup_with_namespace(elem)
|
|
45
41
|
ret = elem.dup
|
|
46
|
-
ret.add_namespace(nil, xml_namespace)
|
|
42
|
+
ret.add_namespace(nil, @conv.xml_namespace)
|
|
47
43
|
ret
|
|
48
44
|
end
|
|
49
45
|
|
|
@@ -52,7 +48,8 @@ module Metanorma
|
|
|
52
48
|
# in termdef_boilerplate_insert and initial_boilerplate
|
|
53
49
|
xmldoc.at("//metanorma-extension/semantic-metadata/" \
|
|
54
50
|
"headless[text() = 'true']") and return nil
|
|
55
|
-
@isodoc ||= isodoc(@lang, @script, @locale)
|
|
51
|
+
@isodoc ||= @conv.isodoc(@lang, @script, @locale)
|
|
52
|
+
@i18n = @isodoc.i18n
|
|
56
53
|
isodoc_bibdata_parse(xmldoc)
|
|
57
54
|
@isodoc
|
|
58
55
|
end
|
|
@@ -189,7 +186,7 @@ module Metanorma
|
|
|
189
186
|
end
|
|
190
187
|
|
|
191
188
|
def boilerplate_file_restructure(file)
|
|
192
|
-
ret = adoc2xml(file, backend.to_sym)
|
|
189
|
+
ret = adoc2xml(file, @conv.backend.to_sym)
|
|
193
190
|
boilerplate_xml_cleanup(ret)
|
|
194
191
|
ret.name = "boilerplate"
|
|
195
192
|
boilerplate_top_elements(ret)
|
|
@@ -198,7 +195,7 @@ module Metanorma
|
|
|
198
195
|
|
|
199
196
|
def boilerplate_snippet_convert(adoc, isodoc)
|
|
200
197
|
b = isodoc.populate_template(adoc, nil)
|
|
201
|
-
ret = boilerplate_xml_cleanup(adoc2xml(b, backend.to_sym))
|
|
198
|
+
ret = boilerplate_xml_cleanup(adoc2xml(b, @conv.backend.to_sym))
|
|
202
199
|
@i18n.l10n(ret.children.to_xml, @lang, @script).strip
|
|
203
200
|
end
|
|
204
201
|
|
|
@@ -1,32 +1,139 @@
|
|
|
1
1
|
require "nokogiri"
|
|
2
2
|
require "pathname"
|
|
3
3
|
require "html2doc"
|
|
4
|
-
require_relative "cleanup_block"
|
|
5
|
-
require_relative "cleanup_table"
|
|
6
|
-
require_relative "cleanup_footnotes"
|
|
7
|
-
require_relative "cleanup_ref"
|
|
8
|
-
require_relative "cleanup_asciibib"
|
|
9
|
-
require_relative "cleanup_boilerplate"
|
|
10
|
-
require_relative "cleanup_bibdata"
|
|
11
|
-
require_relative "cleanup_section"
|
|
12
|
-
require_relative "cleanup_index"
|
|
13
|
-
require_relative "cleanup_terms"
|
|
14
|
-
require_relative "cleanup_symbols"
|
|
15
|
-
require_relative "cleanup_xref"
|
|
16
|
-
require_relative "cleanup_inline"
|
|
17
|
-
require_relative "cleanup_amend"
|
|
18
|
-
require_relative "cleanup_maths"
|
|
19
|
-
require_relative "cleanup_image"
|
|
20
|
-
require_relative "cleanup_reqt"
|
|
21
|
-
require_relative "cleanup_text"
|
|
22
|
-
require_relative "cleanup_toc"
|
|
23
|
-
require_relative "cleanup_review"
|
|
24
|
-
require_relative "cleanup_dochistory"
|
|
25
4
|
require "relaton_iev"
|
|
5
|
+
require "forwardable"
|
|
6
|
+
require_relative "attachment"
|
|
7
|
+
require_relative "block"
|
|
8
|
+
require_relative "table"
|
|
9
|
+
require_relative "footnotes"
|
|
10
|
+
require_relative "ref"
|
|
11
|
+
require_relative "asciibib"
|
|
12
|
+
require_relative "boilerplate"
|
|
13
|
+
require_relative "bibdata"
|
|
14
|
+
require_relative "bibitem"
|
|
15
|
+
require_relative "section"
|
|
16
|
+
require_relative "section_names"
|
|
17
|
+
require_relative "index"
|
|
18
|
+
require_relative "terms"
|
|
19
|
+
require_relative "symbols"
|
|
20
|
+
require_relative "xref"
|
|
21
|
+
require_relative "inline"
|
|
22
|
+
require_relative "amend"
|
|
23
|
+
require_relative "maths"
|
|
24
|
+
require_relative "metadata"
|
|
25
|
+
require_relative "image"
|
|
26
|
+
require_relative "reqt"
|
|
27
|
+
require_relative "text"
|
|
28
|
+
require_relative "toc"
|
|
29
|
+
require_relative "review"
|
|
30
|
+
require_relative "dochistory"
|
|
31
|
+
require_relative "terms_designations"
|
|
32
|
+
require_relative "merge_bibitems"
|
|
33
|
+
require_relative "spans_to_bibitem"
|
|
34
|
+
require_relative "spans_to_bibitem_preprocessing"
|
|
35
|
+
require_relative "log"
|
|
26
36
|
|
|
27
37
|
module Metanorma
|
|
28
38
|
module Standoc
|
|
29
|
-
|
|
39
|
+
class Cleanup
|
|
40
|
+
extend Forwardable
|
|
41
|
+
|
|
42
|
+
attr_reader :log, :files_to_delete
|
|
43
|
+
|
|
44
|
+
# XPath expressions for boilerplate insertion
|
|
45
|
+
NORM_REF =
|
|
46
|
+
"//bibliography/references[@normative = 'true'][not(@hidden)] | " \
|
|
47
|
+
"//bibliography/clause[.//references[@normative = 'true']]".freeze
|
|
48
|
+
|
|
49
|
+
TERM_CLAUSE =
|
|
50
|
+
"//sections//terms[not(.//ancestor::clause[@type = 'terms'])] | " \
|
|
51
|
+
"//sections/clause[descendant::terms][@type = 'terms'] | " \
|
|
52
|
+
"//sections/clause[not(@type = 'terms')]//terms".freeze
|
|
53
|
+
|
|
54
|
+
# Use metaprogramming to copy instance variables from converter
|
|
55
|
+
def copied_instance_variables
|
|
56
|
+
%i[
|
|
57
|
+
datauriattachment datauriimage local_log isodoc anchors localdir c
|
|
58
|
+
refids sourcecode_markup_start sourcecode_markup_end smartquotes
|
|
59
|
+
toclevels htmltoclevels doctoclevels pdftoclevels stage_published
|
|
60
|
+
numberfmt_default svg_conform_profile dataurimaxsize index_terms
|
|
61
|
+
boilerplateauthority embed_hdr embed_id erefstyle originstyle
|
|
62
|
+
xrefstyle blockunnumbered keepasciimath numberfmt_formula
|
|
63
|
+
numberfmt_prof sort_biblio reqt_models default_requirement_model
|
|
64
|
+
document_scheme
|
|
65
|
+
]
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def initialize(converter)
|
|
69
|
+
@conv= converter
|
|
70
|
+
@anchor_alias = {}
|
|
71
|
+
@internal_eref_namespaces = []
|
|
72
|
+
|
|
73
|
+
# Shadow instance variables from converter (attributes/accessors)
|
|
74
|
+
@log = converter.log
|
|
75
|
+
@bibdb = converter.bibdb
|
|
76
|
+
@lang = converter.lang
|
|
77
|
+
@script = converter.script
|
|
78
|
+
@libdir = converter.libdir
|
|
79
|
+
@locale = converter.locale
|
|
80
|
+
@novalid = converter.novalid
|
|
81
|
+
@output_dir = converter.output_dir
|
|
82
|
+
@filename = converter.filename
|
|
83
|
+
@files_to_delete = converter.files_to_delete
|
|
84
|
+
|
|
85
|
+
copied_instance_variables.each do |var|
|
|
86
|
+
instance_variable_set("@#{var}",
|
|
87
|
+
converter.instance_variable_get("@#{var}"))
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Special handling for derived values
|
|
91
|
+
@i18n = @isodoc&.i18n
|
|
92
|
+
|
|
93
|
+
# Reuse converter's relaton_log instead of creating a new one
|
|
94
|
+
@relaton_log = converter.relaton_log
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def to_xml(xml)
|
|
98
|
+
@conv.to_xml(xml)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
class << self
|
|
102
|
+
attr_accessor :_file
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def self.inherited(konv) # rubocop:disable Lint/MissingSuper
|
|
106
|
+
konv._file = caller_locations(1..1).first.absolute_path
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Include all cleanup modules
|
|
110
|
+
include Attachment
|
|
111
|
+
include Block
|
|
112
|
+
include Table
|
|
113
|
+
include Footnotes
|
|
114
|
+
include Ref
|
|
115
|
+
include Asciibib
|
|
116
|
+
include Boilerplate
|
|
117
|
+
include Bibdata
|
|
118
|
+
include Bibitem
|
|
119
|
+
include Section
|
|
120
|
+
include SectionNames
|
|
121
|
+
include Index
|
|
122
|
+
include Terms
|
|
123
|
+
include Symbols
|
|
124
|
+
include Xref
|
|
125
|
+
include Inline
|
|
126
|
+
include Amend
|
|
127
|
+
include Maths
|
|
128
|
+
include Image
|
|
129
|
+
include Reqt
|
|
130
|
+
include Text
|
|
131
|
+
include Toc
|
|
132
|
+
include Review
|
|
133
|
+
include Dochistory
|
|
134
|
+
include TermsDesignations
|
|
135
|
+
include Metadata
|
|
136
|
+
|
|
30
137
|
def cleanup(xmldoc)
|
|
31
138
|
@doctype = xmldoc.at("//bibdata/ext/doctype")&.text
|
|
32
139
|
element_name_cleanup(xmldoc)
|
|
@@ -58,7 +165,7 @@ module Metanorma
|
|
|
58
165
|
clausebefore_cleanup(xmldoc) # feeeds: floatingtitle_cleanup
|
|
59
166
|
floatingtitle_cleanup(xmldoc)
|
|
60
167
|
bibitem_cleanup(xmldoc) # feeds: normref_cleanup, biblio_cleanup,
|
|
61
|
-
# reference_names, bpart_cleanup
|
|
168
|
+
# reference_names, bpart_cleanup, attachment_cleanup
|
|
62
169
|
normref_cleanup(xmldoc)
|
|
63
170
|
biblio_cleanup(xmldoc)
|
|
64
171
|
reference_names(xmldoc)
|
|
@@ -108,46 +215,6 @@ module Metanorma
|
|
|
108
215
|
xmldoc
|
|
109
216
|
end
|
|
110
217
|
|
|
111
|
-
def relaton_iev_cleanup(xmldoc)
|
|
112
|
-
_, err = RelatonIev::iev_cleanup(xmldoc, @bibdb)
|
|
113
|
-
err.each do |e|
|
|
114
|
-
@log.add("RELATON_5", nil, params: e)
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
RELATON_SEVERITIES =
|
|
119
|
-
{ "INFO": "RELATON_4", "WARN": "RELATON_3", "ERROR": "RELATON_2",
|
|
120
|
-
"FATAL": "RELATON_1", "UNKNOWN": "RELATON_4" }.freeze
|
|
121
|
-
|
|
122
|
-
def relaton_log_cleanup(_xmldoc)
|
|
123
|
-
@relaton_log or return
|
|
124
|
-
@relaton_log.rewind
|
|
125
|
-
@relaton_log.string.split(/(?<=})\n(?={)/).each do |l|
|
|
126
|
-
e = JSON.parse(l)
|
|
127
|
-
relaton_log_add?(e) and
|
|
128
|
-
@log.add(RELATON_SEVERITIES[e["severity"].to_sym], e["key"],
|
|
129
|
-
params: [e["message"]])
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
def relaton_log_add?(entry)
|
|
134
|
-
entry["message"].include?("Fetching from") and return false
|
|
135
|
-
entry["message"].include?("Downloaded index from") and return false
|
|
136
|
-
entry["message"].start_with?("Found:") or return true
|
|
137
|
-
id = /^Found: `(.+)`$/.match(entry["message"]) or return true
|
|
138
|
-
#entry["key"].end_with?(id[1]) and return false
|
|
139
|
-
#true
|
|
140
|
-
!relaton_key_eqv?(entry["key"], id[1])
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
def relaton_key_eqv?(sought, found)
|
|
144
|
-
sought = sought.sub(" (all parts)", "").sub(/:(19|20)\d\d$/, "")
|
|
145
|
-
found = found.sub(" (all parts)", "").sub(/:(19|20)\d\d$/, "")
|
|
146
|
-
sought.end_with?(found)
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
def docidentifier_cleanup(xmldoc); end
|
|
150
|
-
|
|
151
218
|
TEXT_ELEMS =
|
|
152
219
|
%w{status language script version author name callout phone email
|
|
153
220
|
street city state country postcode identifier referenceFrom surname
|
|
@@ -172,48 +239,6 @@ module Metanorma
|
|
|
172
239
|
def element_name_cleanup(xmldoc)
|
|
173
240
|
xmldoc.traverse { |n| n.name = n.name.tr("_", "-") }
|
|
174
241
|
end
|
|
175
|
-
|
|
176
|
-
def metadata_cleanup(xmldoc)
|
|
177
|
-
bibdata_published(xmldoc) # feeds: bibdata_cleanup,
|
|
178
|
-
# docidentifier_cleanup (in generic: template)
|
|
179
|
-
(@metadata_attrs.nil? || @metadata_attrs.empty?) and return
|
|
180
|
-
ins = add_misc_container(xmldoc)
|
|
181
|
-
ins << @metadata_attrs
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
def pres_metadata_cleanup(xmldoc)
|
|
185
|
-
@isodoc ||= isodoc(@lang, @script, @locale)
|
|
186
|
-
isodoc_bibdata_parse(xmldoc)
|
|
187
|
-
xmldoc.xpath("//presentation-metadata/* | //semantic-metadata/*")
|
|
188
|
-
.each do |x|
|
|
189
|
-
/\{\{|\{%/.match?(x) or next
|
|
190
|
-
x.children = @isodoc.populate_template(to_xml(x.children), nil)
|
|
191
|
-
end
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
def metadata_cleanup_final(xmldoc)
|
|
195
|
-
root = nil
|
|
196
|
-
%w(semantic presentation).each do |k|
|
|
197
|
-
xmldoc.xpath("//#{k}-metadata").each_with_index do |x, i|
|
|
198
|
-
if i.zero? then root = x
|
|
199
|
-
else
|
|
200
|
-
root << x.remove.elements
|
|
201
|
-
end
|
|
202
|
-
end
|
|
203
|
-
end
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
def annotation_cleanup(xmldoc)
|
|
207
|
-
ret = xmldoc.xpath("//annotation[@type = 'ignore-log']")
|
|
208
|
-
.each_with_object([]) do |ann, m|
|
|
209
|
-
error_ids = Array(csv_split(ann.text || "", ","))
|
|
210
|
-
m << { from: ann["from"], to: ann["to"], error_ids: error_ids }
|
|
211
|
-
ann
|
|
212
|
-
end
|
|
213
|
-
config = @log.suppress_log
|
|
214
|
-
config[:locations] += ret
|
|
215
|
-
@log.suppress_log = config
|
|
216
|
-
end
|
|
217
242
|
end
|
|
218
243
|
end
|
|
219
244
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Metanorma
|
|
2
2
|
module Standoc
|
|
3
|
-
module
|
|
3
|
+
module Dochistory
|
|
4
4
|
def bib_relation_insert_pt(xmldoc)
|
|
5
5
|
ins = nil
|
|
6
6
|
%w(relation copyright status abstract script language note version
|
|
@@ -81,7 +81,7 @@ module Metanorma
|
|
|
81
81
|
|
|
82
82
|
def amend_description(yaml)
|
|
83
83
|
a = yaml["description"] or return ""
|
|
84
|
-
out = adoc2xml(a, backend.to_sym)
|
|
84
|
+
out = adoc2xml(a, @conv.backend.to_sym)
|
|
85
85
|
"<description>#{out.children.to_xml}</description>"
|
|
86
86
|
end
|
|
87
87
|
|
|
@@ -3,7 +3,7 @@ require "crass"
|
|
|
3
3
|
|
|
4
4
|
module Metanorma
|
|
5
5
|
module Standoc
|
|
6
|
-
module
|
|
6
|
+
module Image
|
|
7
7
|
def svgmap_cleanup(xmldoc)
|
|
8
8
|
svgmap_moveattrs(xmldoc)
|
|
9
9
|
svgmap_populate(xmldoc)
|
|
@@ -86,7 +86,7 @@ module Metanorma
|
|
|
86
86
|
def svg_classupdate(xmldoc)
|
|
87
87
|
xmldoc.xpath("//m:svg[m:style]", "m" => SVG_NS)
|
|
88
88
|
.each_with_index do |s, i|
|
|
89
|
-
|
|
89
|
+
svg_classupdate1(s, s.at("./m:style", "m" => SVG_NS), i)
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
92
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Metanorma
|
|
2
|
+
module Standoc
|
|
3
|
+
class Cleanup
|
|
4
|
+
def relaton_iev_cleanup(xmldoc)
|
|
5
|
+
_, err = RelatonIev::iev_cleanup(xmldoc, @bibdb)
|
|
6
|
+
err.each do |e|
|
|
7
|
+
@log.add("RELATON_5", nil, params: e)
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
RELATON_SEVERITIES =
|
|
12
|
+
{ "INFO": "RELATON_4", "WARN": "RELATON_3", "ERROR": "RELATON_2",
|
|
13
|
+
"FATAL": "RELATON_1", "UNKNOWN": "RELATON_4" }.freeze
|
|
14
|
+
|
|
15
|
+
def relaton_log_cleanup(_xmldoc)
|
|
16
|
+
@relaton_log or return
|
|
17
|
+
@relaton_log.rewind
|
|
18
|
+
@relaton_log.string.split(/(?<=})\n(?={)/).each do |l|
|
|
19
|
+
e = JSON.parse(l)
|
|
20
|
+
relaton_log_add?(e) and
|
|
21
|
+
@log.add(RELATON_SEVERITIES[e["severity"].to_sym], e["key"],
|
|
22
|
+
params: [e["message"]])
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def relaton_log_add?(entry)
|
|
27
|
+
entry["message"].include?("Fetching from") and return false
|
|
28
|
+
entry["message"].include?("Downloaded index from") and return false
|
|
29
|
+
entry["message"].start_with?("Found:") or return true
|
|
30
|
+
id = /^Found: `(.+)`$/.match(entry["message"]) or return true
|
|
31
|
+
!relaton_key_eqv?(entry["key"], id[1])
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def relaton_key_eqv?(sought, found)
|
|
35
|
+
sought = sought.sub(" (all parts)", "").sub(/:(19|20)\d\d$/, "")
|
|
36
|
+
found = found.sub(" (all parts)", "").sub(/:(19|20)\d\d$/, "")
|
|
37
|
+
sought.end_with?(found)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|