metanorma-iso 1.3.20 → 1.3.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +10 -10
- data/.github/workflows/ubuntu.yml +11 -11
- data/.github/workflows/windows.yml +11 -12
- data/Gemfile +2 -0
- data/README.adoc +3 -2
- data/lib/asciidoctor/iso/base.rb +17 -1
- data/lib/asciidoctor/iso/biblio.rng +131 -46
- data/lib/asciidoctor/iso/cleanup.rb +19 -2
- data/lib/asciidoctor/iso/front.rb +116 -17
- data/lib/asciidoctor/iso/isodoc.rng +32 -4
- data/lib/asciidoctor/iso/isostandard-amd.rng +98 -0
- data/lib/asciidoctor/iso/isostandard.rng +10 -0
- data/lib/asciidoctor/iso/macros.rb +21 -0
- data/lib/asciidoctor/iso/section.rb +18 -32
- data/lib/asciidoctor/iso/term_lookup_cleanup.rb +90 -0
- data/lib/asciidoctor/iso/validate.rb +41 -21
- data/lib/asciidoctor/iso/validate_section.rb +2 -2
- data/lib/asciidoctor/iso/validate_style.rb +1 -1
- data/lib/isodoc/iso/base_convert.rb +57 -41
- data/lib/isodoc/iso/html/header.html +5 -5
- data/lib/isodoc/iso/html/html_iso_titlepage.html +18 -18
- data/lib/isodoc/iso/html/isodoc.scss +28 -28
- data/lib/isodoc/iso/html/scripts.html +23 -21
- data/lib/isodoc/iso/html/style-human.scss +259 -423
- data/lib/isodoc/iso/html/style-iso.scss +151 -382
- data/lib/isodoc/iso/html/word_iso_titlepage.html +23 -2
- data/lib/isodoc/iso/html/wordstyle.scss +66 -39
- data/lib/isodoc/iso/html_convert.rb +7 -9
- data/lib/isodoc/iso/iso.international-standard.xsl +4386 -0
- data/lib/isodoc/iso/metadata.rb +48 -22
- data/lib/isodoc/iso/pdf_convert.rb +32 -0
- data/lib/metanorma-iso.rb +1 -0
- data/lib/metanorma/iso/processor.rb +13 -1
- data/lib/metanorma/iso/version.rb +1 -1
- data/spec/asciidoctor-iso/amd_spec.rb +318 -0
- data/spec/asciidoctor-iso/base_spec.rb +37 -17
- data/spec/asciidoctor-iso/blocks_spec.rb +21 -9
- data/spec/asciidoctor-iso/cleanup_spec.rb +203 -175
- data/spec/asciidoctor-iso/inline_spec.rb +2 -1
- data/spec/asciidoctor-iso/macros_spec.rb +273 -0
- data/spec/asciidoctor-iso/refs_spec.rb +7 -4
- data/spec/asciidoctor-iso/section_spec.rb +8 -8
- data/spec/asciidoctor-iso/validate_spec.rb +1 -1
- data/spec/assets/iso.xml +64 -1
- data/spec/isodoc/blocks_spec.rb +115 -0
- data/spec/isodoc/i18n_spec.rb +12 -20
- data/spec/isodoc/inline_spec.rb +2 -2
- data/spec/isodoc/iso_spec.rb +1 -1
- data/spec/isodoc/metadata_spec.rb +13 -4
- data/spec/isodoc/postproc_spec.rb +13 -112
- data/spec/isodoc/ref_spec.rb +4 -4
- data/spec/isodoc/section_spec.rb +8 -12
- data/spec/isodoc/table_spec.rb +24 -24
- data/spec/isodoc/terms_spec.rb +2 -2
- data/spec/isodoc/xref_spec.rb +19 -19
- data/spec/metanorma/processor_spec.rb +2 -2
- data/spec/spec_helper.rb +13 -1
- metadata +9 -3
- data/asciidoctor-iso.gemspec.old +0 -50
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'asciidoctor/extensions'
|
4
|
+
|
5
|
+
module Asciidoctor
|
6
|
+
module Iso
|
7
|
+
# Macro to transform `term[X,Y]` into em, termxref xml
|
8
|
+
class TermRefInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
9
|
+
use_dsl
|
10
|
+
|
11
|
+
named :term
|
12
|
+
name_positional_attributes 'name', 'termxref'
|
13
|
+
using_format :short
|
14
|
+
|
15
|
+
def process(_parent, _target, attrs)
|
16
|
+
termref = attrs['termxref'] || attrs['name']
|
17
|
+
"<em>#{attrs['name']}</em> (<termxref>#{termref}</termxref>)"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -4,38 +4,12 @@ require "uri"
|
|
4
4
|
module Asciidoctor
|
5
5
|
module ISO
|
6
6
|
class Converter < Standoc::Converter
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
when "patent notice" then patent_notice_parse(xml, node)
|
14
|
-
when "scope" then scope_parse(a, xml, node)
|
15
|
-
when "normative references" then norm_ref_parse(a, xml, node)
|
16
|
-
when "terms and definitions"
|
17
|
-
@term_def = true
|
18
|
-
term_def_parse(a, xml, node, true)
|
19
|
-
@term_def = false
|
20
|
-
when "symbols and abbreviated terms"
|
21
|
-
symbols_parse(a, xml, node)
|
22
|
-
when "acknowledgements"
|
23
|
-
acknowledgements_parse(a, xml, node)
|
24
|
-
when "bibliography" then bibliography_parse(a, xml, node)
|
25
|
-
else
|
26
|
-
if @term_def then term_def_subclause_parse(a, xml, node)
|
27
|
-
elsif @biblio then bibliography_parse(a, xml, node)
|
28
|
-
elsif node.attr("style") == "bibliography"
|
29
|
-
bibliography_parse(a, xml, node)
|
30
|
-
elsif node.attr("style") == "appendix" && node.level == 1
|
31
|
-
annex_parse(a, xml, node)
|
32
|
-
elsif node.option? "appendix"
|
33
|
-
appendix_parse(a, xml, node)
|
34
|
-
else
|
35
|
-
clause_parse(a, xml, node)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end.join("\n")
|
7
|
+
def clause_parse(attrs, xml, node)
|
8
|
+
title = node&.attr("heading")&.downcase ||
|
9
|
+
node.title.gsub(/<[^>]+>/, "").downcase
|
10
|
+
title == "scope" and return scope_parse(attrs, xml, node)
|
11
|
+
node.option? "appendix" and return appendix_parse(attrs, xml, node)
|
12
|
+
super
|
39
13
|
end
|
40
14
|
|
41
15
|
def appendix_parse(attrs, xml, node)
|
@@ -61,6 +35,18 @@ module Asciidoctor
|
|
61
35
|
xml_section << content
|
62
36
|
end
|
63
37
|
end
|
38
|
+
|
39
|
+
def section_attributes(node)
|
40
|
+
super.merge(
|
41
|
+
change: @amd ? node.attr("change") : nil,
|
42
|
+
locality: @amd ? node.attr("locality") : nil,
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
def sectiontype(node, level = true)
|
47
|
+
return nil if @amd
|
48
|
+
super
|
49
|
+
end
|
64
50
|
end
|
65
51
|
end
|
66
52
|
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true.
|
2
|
+
|
3
|
+
module Asciidoctor
|
4
|
+
module ISO
|
5
|
+
# Intelligent term lookup xml modifier
|
6
|
+
# Lookup all `term` and `calause` tags and replace `termxref` tags with
|
7
|
+
# `xref`:target tag
|
8
|
+
class TermLookupCleanup
|
9
|
+
AUTOMATIC_GENERATED_ID_REGEXP = /\A_/
|
10
|
+
EXISTING_TERM_REGEXP = /\Aterm-/
|
11
|
+
|
12
|
+
attr_reader :xmldoc, :termlookup, :log
|
13
|
+
|
14
|
+
def initialize(xmldoc, log)
|
15
|
+
@xmldoc = xmldoc
|
16
|
+
@log = log
|
17
|
+
@termlookup = {}
|
18
|
+
end
|
19
|
+
|
20
|
+
def call
|
21
|
+
@termlookup = replace_automatic_generated_ids_terms
|
22
|
+
set_termxref_tags_target
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def set_termxref_tags_target
|
28
|
+
xmldoc.xpath('//termxref').each do |node|
|
29
|
+
target = normalize_ref_id(node.text)
|
30
|
+
if termlookup[target].nil?
|
31
|
+
remove_missing_ref(node, target)
|
32
|
+
next
|
33
|
+
end
|
34
|
+
|
35
|
+
modify_ref_node(node, target)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def remove_missing_ref(node, target)
|
40
|
+
log.add('AsciiDoc Input',
|
41
|
+
node,
|
42
|
+
%(Error: Term reference in `term[#{target}]` missing: \
|
43
|
+
"#{target}" is not defined in document))
|
44
|
+
# Term ref have parentess around it - (ref),
|
45
|
+
# if no target remove parentes and render as text
|
46
|
+
node.next.remove
|
47
|
+
term_name_node = node.previous.previous
|
48
|
+
term_name_node.remove
|
49
|
+
node.previous.remove
|
50
|
+
node.add_previous_sibling(term_name_node.text)
|
51
|
+
node.remove
|
52
|
+
end
|
53
|
+
|
54
|
+
def modify_ref_node(node, target)
|
55
|
+
node.name = 'xref'
|
56
|
+
node['target'] = termlookup[target]
|
57
|
+
node.children.remove
|
58
|
+
node.remove_attribute('defaultref')
|
59
|
+
end
|
60
|
+
|
61
|
+
def replace_automatic_generated_ids_terms
|
62
|
+
xmldoc.xpath('//term').each.with_object({}) do |term_node, res|
|
63
|
+
next if AUTOMATIC_GENERATED_ID_REGEXP.match(term_node['id']).nil?
|
64
|
+
|
65
|
+
normalize_id_and_memorize(term_node, res, './preferred')
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def normalize_id_and_memorize(term_node, res_table, text_selector)
|
70
|
+
term_text = normalize_ref_id(term_node.at(text_selector).text)
|
71
|
+
term_node['id'] = unique_text_id(term_text)
|
72
|
+
res_table[term_text] = term_node['id']
|
73
|
+
end
|
74
|
+
|
75
|
+
def normalize_ref_id(text)
|
76
|
+
text.downcase.gsub(/[[:space:]]/, '-')
|
77
|
+
end
|
78
|
+
|
79
|
+
def unique_text_id(text)
|
80
|
+
return "term-#{text}" if xmldoc.at("//*[@id = 'term-#{text}']").nil?
|
81
|
+
|
82
|
+
(1..Float::INFINITY).lazy.each do |index|
|
83
|
+
if xmldoc.at("//*[@id = 'term-#{text}-#{index}']").nil?
|
84
|
+
break("term-#{text}-#{index}")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -24,12 +24,14 @@ module Asciidoctor
|
|
24
24
|
def isosubgroup_validate(root)
|
25
25
|
root.xpath("//technical-committee/@type").each do |t|
|
26
26
|
unless %w{TC PC JTC JPC}.include? t.text
|
27
|
-
@log.add("Document Attributes", nil,
|
27
|
+
@log.add("Document Attributes", nil,
|
28
|
+
"invalid technical committee type #{t}")
|
28
29
|
end
|
29
30
|
end
|
30
31
|
root.xpath("//subcommittee/@type").each do |t|
|
31
32
|
unless %w{SC JSC}.include? t.text
|
32
|
-
@log.add("Document Attributes", nil,
|
33
|
+
@log.add("Document Attributes", nil,
|
34
|
+
"invalid subcommittee type #{t}")
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
@@ -39,10 +41,12 @@ module Asciidoctor
|
|
39
41
|
root.xpath("//xref").each do |t|
|
40
42
|
# does not deal with preceding text marked up
|
41
43
|
preceding = t.at("./preceding-sibling::text()[last()]")
|
42
|
-
next unless !preceding.nil? &&
|
44
|
+
next unless !preceding.nil? &&
|
45
|
+
/\b(see| refer to)\s*$/mi.match(preceding)
|
43
46
|
(target = root.at("//*[@id = '#{t['target']}']")) || next
|
44
47
|
if target&.at("./ancestor-or-self::*[@obligation = 'normative']")
|
45
|
-
@log.add("Style", t,
|
48
|
+
@log.add("Style", t,
|
49
|
+
"'see #{t['target']}' is pointing to a normative section")
|
46
50
|
end
|
47
51
|
end
|
48
52
|
end
|
@@ -51,25 +55,28 @@ module Asciidoctor
|
|
51
55
|
def see_erefs_validate(root)
|
52
56
|
root.xpath("//eref").each do |t|
|
53
57
|
preceding = t.at("./preceding-sibling::text()[last()]")
|
54
|
-
next unless !preceding.nil? &&
|
58
|
+
next unless !preceding.nil? &&
|
59
|
+
/\b(see|refer to)\s*$/mi.match(preceding)
|
55
60
|
unless target = root.at("//*[@id = '#{t['bibitemid']}']")
|
56
|
-
@log.add("Bibliography", t,
|
61
|
+
@log.add("Bibliography", t,
|
62
|
+
"'#{t} is not pointing to a real reference")
|
57
63
|
next
|
58
64
|
end
|
59
|
-
if target.at("./ancestor::references"
|
60
|
-
|
61
|
-
|
65
|
+
if target.at("./ancestor::references[@normative = 'true']")
|
66
|
+
@log.add("Style", t,
|
67
|
+
"'see #{t}' is pointing to a normative reference")
|
62
68
|
end
|
63
69
|
end
|
64
70
|
end
|
65
71
|
|
66
72
|
# ISO/IEC DIR 2, 10.4
|
67
73
|
def locality_erefs_validate(root)
|
68
|
-
root.xpath("//eref[locality]").each do |t|
|
74
|
+
root.xpath("//eref[descendant::locality]").each do |t|
|
69
75
|
if /^(ISO|IEC)/.match t["citeas"]
|
70
76
|
unless /:[ ]?(\d+{4}|–)$/.match t["citeas"]
|
71
|
-
@log.add("Style", t,
|
72
|
-
|
77
|
+
@log.add("Style", t,
|
78
|
+
"undated reference #{t['citeas']} should not contain "\
|
79
|
+
"specific elements")
|
73
80
|
end
|
74
81
|
end
|
75
82
|
end
|
@@ -106,32 +113,37 @@ module Asciidoctor
|
|
106
113
|
doctype = xmldoc&.at("//bibdata/ext/doctype")&.text
|
107
114
|
%w(international-standard technical-specification technical-report
|
108
115
|
publicly-available-specification international-workshop-agreement
|
109
|
-
guide).include? doctype or
|
110
|
-
@log.add("Document Attributes", nil,
|
116
|
+
guide amendment technical-corrigendum).include? doctype or
|
117
|
+
@log.add("Document Attributes", nil,
|
118
|
+
"#{doctype} is not a recognised document type")
|
111
119
|
end
|
112
120
|
|
113
121
|
def script_validate(xmldoc)
|
114
122
|
script = xmldoc&.at("//bibdata/script")&.text
|
115
123
|
script == "Latn" or
|
116
|
-
@log.add("Document Attributes", nil,
|
124
|
+
@log.add("Document Attributes", nil,
|
125
|
+
"#{script} is not a recognised script")
|
117
126
|
end
|
118
127
|
|
119
128
|
def stage_validate(xmldoc)
|
120
129
|
stage = xmldoc&.at("//bibdata/status/stage")&.text
|
121
130
|
%w(00 10 20 30 40 50 60 90 95).include? stage or
|
122
|
-
@log.add("Document Attributes", nil,
|
131
|
+
@log.add("Document Attributes", nil,
|
132
|
+
"#{stage} is not a recognised stage")
|
123
133
|
end
|
124
134
|
|
125
135
|
def substage_validate(xmldoc)
|
126
136
|
substage = xmldoc&.at("//bibdata/status/substage")&.text or return
|
127
137
|
%w(00 20 60 90 92 93 98 99).include? substage or
|
128
|
-
@log.add("Document Attributes", nil,
|
138
|
+
@log.add("Document Attributes", nil,
|
139
|
+
"#{substage} is not a recognised substage")
|
129
140
|
end
|
130
141
|
|
131
142
|
def iteration_validate(xmldoc)
|
132
143
|
iteration = xmldoc&.at("//bibdata/status/iteration")&.text or return
|
133
144
|
/^\d+/.match(iteration) or
|
134
|
-
@log.add("Document Attributes", nil,
|
145
|
+
@log.add("Document Attributes", nil,
|
146
|
+
"#{iteration} is not a recognised iteration")
|
135
147
|
end
|
136
148
|
|
137
149
|
def bibdata_validate(doc)
|
@@ -163,15 +175,23 @@ module Asciidoctor
|
|
163
175
|
found = true if /^ISO DATE:/.match n.text
|
164
176
|
end
|
165
177
|
found or
|
166
|
-
@log.add("Style", b,
|
167
|
-
|
178
|
+
@log.add("Style", b,
|
179
|
+
"Reference #{b&.at("./@id")&.text} does not have an "\
|
180
|
+
"associated footnote indicating unpublished status")
|
168
181
|
end
|
169
182
|
end
|
170
183
|
|
171
184
|
def validate(doc)
|
172
185
|
content_validate(doc)
|
186
|
+
doctype = doc&.at("//bibdata/ext/doctype")&.text
|
187
|
+
schema = case doctype
|
188
|
+
when "amendment", "technical-corrigendum" # @amd
|
189
|
+
"isostandard-amd.rng"
|
190
|
+
else
|
191
|
+
"isostandard.rng"
|
192
|
+
end
|
173
193
|
schema_validate(formattedstr_strip(doc.dup),
|
174
|
-
File.join(File.dirname(__FILE__),
|
194
|
+
File.join(File.dirname(__FILE__), schema))
|
175
195
|
end
|
176
196
|
end
|
177
197
|
end
|
@@ -22,7 +22,7 @@ module Asciidoctor
|
|
22
22
|
|
23
23
|
# ISO/IEC DIR 2, 15.4
|
24
24
|
def normref_validate(root)
|
25
|
-
f = root.at("//references[
|
25
|
+
f = root.at("//references[@normative = 'true']") || return
|
26
26
|
f.at("./references | ./clause") &&
|
27
27
|
@log.add("Style", f, "normative references contains subclauses")
|
28
28
|
end
|
@@ -168,7 +168,7 @@ module Asciidoctor
|
|
168
168
|
"//li[not(p)] | //dt | //dd[not(p)] | //td[not(p)] | //th[not(p)]".freeze
|
169
169
|
|
170
170
|
NORM_BIBITEMS =
|
171
|
-
"//references[
|
171
|
+
"//references[@normative = 'true']/bibitem".freeze
|
172
172
|
|
173
173
|
# ISO/IEC DIR 2, 10.2
|
174
174
|
def norm_bibitem_style(root)
|
@@ -8,7 +8,7 @@ module Asciidoctor
|
|
8
8
|
def extract_text(node)
|
9
9
|
return "" if node.nil?
|
10
10
|
node1 = Nokogiri::XML.fragment(node.to_s)
|
11
|
-
node1.xpath("//link | //locality").each(&:remove)
|
11
|
+
node1.xpath("//link | //locality | //localityStack").each(&:remove)
|
12
12
|
ret = ""
|
13
13
|
node1.traverse { |x| ret += x.text if x.text? }
|
14
14
|
ret
|
@@ -9,6 +9,34 @@ module IsoDoc
|
|
9
9
|
@meta = Metadata.new(lang, script, labels)
|
10
10
|
end
|
11
11
|
|
12
|
+
def convert1(docxml, filename, dir)
|
13
|
+
doctype = docxml&.at(ns("//bibdata/ext/doctype"))&.text
|
14
|
+
@amd = %w(amendment technical-corrigendum).include? doctype
|
15
|
+
if @amd
|
16
|
+
@oldsuppressheadingnumbers = @suppressheadingnumbers
|
17
|
+
@suppressheadingnumbers = true
|
18
|
+
end
|
19
|
+
super
|
20
|
+
end
|
21
|
+
|
22
|
+
def annex(isoxml, out)
|
23
|
+
@amd and @suppressheadingnumbers = @oldsuppressheadingnumbers
|
24
|
+
super
|
25
|
+
@amd and @suppressheadingnumbers = true
|
26
|
+
end
|
27
|
+
|
28
|
+
def anchor_names(docxml)
|
29
|
+
if @amd
|
30
|
+
back_anchor_names(docxml)
|
31
|
+
note_anchor_names(docxml.xpath(ns("//annex//table | //annex//figure")))
|
32
|
+
note_anchor_names(docxml.xpath(ns("//annex")))
|
33
|
+
example_anchor_names(docxml.xpath(ns("//annex")))
|
34
|
+
list_anchor_names(docxml.xpath(ns("//annex")))
|
35
|
+
else
|
36
|
+
super
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
12
40
|
def implicit_reference(b)
|
13
41
|
b&.at(ns("./docidentifier"))&.text == "IEV"
|
14
42
|
end
|
@@ -21,11 +49,7 @@ module IsoDoc
|
|
21
49
|
out.div **{ class: "Section3", id: f["id"] } do |div|
|
22
50
|
clause_name(num, @introduction_lbl, div, title_attr)
|
23
51
|
f.elements.each do |e|
|
24
|
-
|
25
|
-
e.elements.each { |e1| parse(e1, div) }
|
26
|
-
else
|
27
|
-
parse(e, div) unless e.name == "title"
|
28
|
-
end
|
52
|
+
parse(e, div) unless e.name == "title"
|
29
53
|
end
|
30
54
|
end
|
31
55
|
end
|
@@ -91,9 +115,9 @@ module IsoDoc
|
|
91
115
|
end
|
92
116
|
end
|
93
117
|
|
94
|
-
def eref_localities1_zh(target, type, from, to)
|
118
|
+
def eref_localities1_zh(target, type, from, to, delim)
|
95
119
|
subsection = from&.text&.match(/\./)
|
96
|
-
ret = type == "list" ? "" :
|
120
|
+
ret = (delim == ";") ? ";" : (type == "list") ? "" : delim
|
97
121
|
ret += " 第#{from.text}" if from
|
98
122
|
ret += "–#{to}" if to
|
99
123
|
loc = (@locality[type] || type.sub(/^locality:/, "").capitalize )
|
@@ -103,11 +127,11 @@ module IsoDoc
|
|
103
127
|
ret
|
104
128
|
end
|
105
129
|
|
106
|
-
def eref_localities1(target, type, from, to, lang = "en")
|
130
|
+
def eref_localities1(target, type, from, to, delim, lang = "en")
|
107
131
|
subsection = from&.text&.match(/\./)
|
108
132
|
type = type.downcase
|
109
|
-
return l10n(eref_localities1_zh(target, type, from, to)) if lang == "zh"
|
110
|
-
ret = type == "list" ? "" :
|
133
|
+
return l10n(eref_localities1_zh(target, type, from, to, delim)) if lang == "zh"
|
134
|
+
ret = (delim == ";") ? ";" : (type == "list") ? "" : delim
|
111
135
|
loc = @locality[type] || type.sub(/^locality:/, "").capitalize
|
112
136
|
ret += " #{loc}" unless subsection && type == "clause" ||
|
113
137
|
type == "list" || target.match(/^IEV$|^IEC 60050-/)
|
@@ -170,6 +194,15 @@ module IsoDoc
|
|
170
194
|
end
|
171
195
|
end
|
172
196
|
|
197
|
+
def insertall_after_here(node, insert, name)
|
198
|
+
node.children.each do |n|
|
199
|
+
next unless n.name == name
|
200
|
+
insert.next = n.remove
|
201
|
+
insert = n
|
202
|
+
end
|
203
|
+
insert
|
204
|
+
end
|
205
|
+
|
173
206
|
def termexamples_before_termnotes(node)
|
174
207
|
return unless node.at(ns("./termnote")) && node.at(ns("./termexample"))
|
175
208
|
return unless insert = node.at(ns("./definition"))
|
@@ -177,23 +210,19 @@ module IsoDoc
|
|
177
210
|
insert = insertall_after_here(node, insert, "termnote")
|
178
211
|
end
|
179
212
|
|
180
|
-
def
|
213
|
+
def termdef_parse(node, out)
|
181
214
|
termexamples_before_termnotes(node)
|
182
|
-
|
183
|
-
node.children.each { |c| parse(c, p) }
|
184
|
-
end
|
215
|
+
super
|
185
216
|
end
|
186
217
|
|
187
218
|
def clausedelim
|
188
219
|
""
|
189
220
|
end
|
190
221
|
|
191
|
-
def
|
192
|
-
|
193
|
-
ref =
|
194
|
-
|
195
|
-
!/^\[.*\]$/.match(ref)
|
196
|
-
ref
|
222
|
+
def reference_names(ref)
|
223
|
+
super
|
224
|
+
@anchors[ref["id"]] = { xref: @anchors[ref["id"]][:xref].
|
225
|
+
sub(/ \(All Parts\)/i, "") }
|
197
226
|
end
|
198
227
|
|
199
228
|
def table_footnote_reference_format(a)
|
@@ -207,23 +236,10 @@ module IsoDoc
|
|
207
236
|
|
208
237
|
def cleanup(docxml)
|
209
238
|
super
|
210
|
-
remove_internal_hyperlinks(docxml)
|
211
239
|
table_th_center(docxml)
|
212
240
|
docxml
|
213
241
|
end
|
214
242
|
|
215
|
-
def remove_internal_hyperlinks(docxml)
|
216
|
-
docxml.xpath("//a[@href]").each do |a|
|
217
|
-
next unless /^#/.match(a[:href])
|
218
|
-
anchor = a[:href].sub(/^#/, "")
|
219
|
-
next if a["epub:type"] == "footnote"
|
220
|
-
next unless @anchors[anchor]
|
221
|
-
next unless @anchors[anchor][:type]
|
222
|
-
next if @anchors[anchor][:type] == "clause"
|
223
|
-
a.replace(a.children)
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
243
|
def table_th_center(docxml)
|
228
244
|
docxml.xpath("//thead//th | //thead//td").each do |th|
|
229
245
|
th["align"] = "center"
|
@@ -232,14 +248,14 @@ module IsoDoc
|
|
232
248
|
end
|
233
249
|
|
234
250
|
def hierarchical_formula_names(clause, num)
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
251
|
+
c = IsoDoc::Function::XrefGen::Counter.new
|
252
|
+
clause.xpath(ns(".//formula")).each do |t|
|
253
|
+
next if t["id"].nil? || t["id"].empty?
|
254
|
+
@anchors[t["id"]] =
|
255
|
+
anchor_struct("#{num}#{hiersep}#{c.increment(t).print}", t,
|
256
|
+
t["inequality"] ? @inequality_lbl : @formula_lbl,
|
257
|
+
"formula", t["unnumbered"])
|
258
|
+
end
|
243
259
|
end
|
244
260
|
end
|
245
261
|
end
|