metanorma-standoc 2.0.6 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/asciidoctor/standoc/base.rb +0 -1
- data/lib/asciidoctor/standoc/blocks.rb +0 -1
- data/lib/asciidoctor/standoc/blocks_notes.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_amend.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_block.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_footnotes.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_image.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_inline.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_maths.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_ref.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_ref_dl.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_reqt.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_section.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_section_names.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_symbols.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_table.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_terms.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_terms_designations.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_text.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_toc.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_xref.rb +0 -1
- data/lib/asciidoctor/standoc/converter.rb +0 -1
- data/lib/asciidoctor/standoc/deprecated.rb +4 -2
- data/lib/asciidoctor/standoc/front.rb +0 -1
- data/lib/asciidoctor/standoc/front_contributor.rb +0 -1
- data/lib/asciidoctor/standoc/inline.rb +0 -1
- data/lib/asciidoctor/standoc/lists.rb +0 -1
- data/lib/asciidoctor/standoc/macros.rb +0 -1
- data/lib/asciidoctor/standoc/macros_form.rb +0 -1
- data/lib/asciidoctor/standoc/macros_note.rb +0 -1
- data/lib/asciidoctor/standoc/macros_plantuml.rb +0 -1
- data/lib/asciidoctor/standoc/macros_terms.rb +0 -1
- data/lib/asciidoctor/standoc/render.rb +0 -1
- data/lib/asciidoctor/standoc/reqt.rb +0 -1
- data/lib/asciidoctor/standoc/section.rb +0 -1
- data/lib/asciidoctor/standoc/table.rb +0 -1
- data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +0 -1
- data/lib/asciidoctor/standoc/terms.rb +0 -1
- data/lib/asciidoctor/standoc/utils.rb +0 -1
- data/lib/asciidoctor/standoc/validate.rb +0 -1
- data/lib/asciidoctor/standoc/validate_section.rb +0 -1
- data/lib/isodoc/pdf_convert.rb +2 -3
- data/lib/metanorma/standoc/biblio.rng +62 -10
- data/lib/metanorma/standoc/blocks.rb +10 -0
- data/lib/metanorma/standoc/blocks_notes.rb +17 -11
- data/lib/metanorma/standoc/cleanup_block.rb +10 -0
- data/lib/metanorma/standoc/cleanup_boilerplate.rb +15 -7
- data/lib/metanorma/standoc/cleanup_maths.rb +5 -4
- data/lib/metanorma/standoc/cleanup_ref.rb +2 -4
- data/lib/metanorma/standoc/cleanup_reqt.rb +1 -1
- data/lib/metanorma/standoc/cleanup_section.rb +15 -13
- data/lib/metanorma/standoc/cleanup_xref.rb +3 -4
- data/lib/metanorma/standoc/inline.rb +13 -9
- data/lib/metanorma/standoc/isodoc.rng +56 -0
- data/lib/metanorma/standoc/macros.rb +3 -3
- data/lib/metanorma/standoc/macros_embed.rb +1 -3
- data/lib/metanorma/standoc/macros_form.rb +1 -1
- data/lib/metanorma/standoc/macros_terms.rb +1 -1
- data/lib/metanorma/standoc/processor.rb +2 -1
- data/lib/metanorma/standoc/ref.rb +4 -4
- data/lib/metanorma/standoc/render.rb +6 -1
- data/lib/metanorma/standoc/reqt.rb +5 -3
- data/lib/metanorma/standoc/term_lookup_cleanup.rb +1 -1
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +3 -1
- data/spec/assets/iso.adoc +10 -0
- data/spec/metanorma/blocks_spec.rb +138 -74
- data/spec/metanorma/cleanup_blocks_spec.rb +9 -0
- data/spec/metanorma/cleanup_sections_spec.rb +6 -6
- data/spec/metanorma/cleanup_spec.rb +5 -5
- data/spec/metanorma/cleanup_terms_spec.rb +93 -19
- data/spec/metanorma/inline_spec.rb +1 -1
- data/spec/metanorma/macros_spec.rb +216 -45
- data/spec/metanorma/refs_dl_spec.rb +28 -11
- data/spec/metanorma/refs_spec.rb +0 -6
- data/spec/metanorma/section_spec.rb +15 -15
- data/spec/metanorma/table_spec.rb +339 -342
- data/spec/spec_helper.rb +2 -5
- data/spec/vcr_cassettes/bsi16341.yml +496 -0
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +84 -84
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +13 -13
- data/spec/vcr_cassettes/hide_refs.yml +172 -172
- data/spec/vcr_cassettes/isobib_get_123.yml +13 -13
- data/spec/vcr_cassettes/isobib_get_123_1.yml +97 -97
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +109 -109
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +12 -12
- data/spec/vcr_cassettes/isobib_get_124.yml +11 -11
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +18 -22
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +48 -46
- data/spec/vcr_cassettes/std-link.yml +207 -0
- metadata +21 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2c3089664934dc34b5f41b7e03a7bc2d2b1060e17decafb29dfc1f36fb7bed0
|
4
|
+
data.tar.gz: 7ecc333b2847252e7965be128c701f4cb2241d148179cd43b66a9f5cd2a2e108
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5308c4354dc5fd14e1d5d18dc32e7b52d81ba492e53381771e7dfecea4c83af0bd73387af2bfb6c913687352eaad85c44ded592e1c95179d5d41b3974bc923ff
|
7
|
+
data.tar.gz: ba8122c376d231eb6f1f4f4ea235b608b4dd1769394a899fe9fcd6f5bee011f2384cf1455fae0d86d32648e37aee080c0db18755d4a761e793ad5164b500ce61
|
@@ -1,5 +1,7 @@
|
|
1
|
-
warn "Please replace your references to Asciidoctor::Standoc with
|
1
|
+
warn "Please replace your references to Asciidoctor::Standoc with "\
|
2
|
+
"Metanorma::Standoc and your instances of require 'asciidoctor/standoc' "\
|
3
|
+
"with require 'metanorma/standoc'"
|
2
4
|
|
3
|
-
exit 127 if ENV[
|
5
|
+
exit 127 if ENV["METANORMA_DEPRECATION_FAIL"]
|
4
6
|
|
5
7
|
Asciidoctor::Standoc = Metanorma::Standoc unless defined? Asciidoctor::Standoc
|
data/lib/isodoc/pdf_convert.rb
CHANGED
@@ -2,7 +2,6 @@ require "isodoc"
|
|
2
2
|
|
3
3
|
module IsoDoc
|
4
4
|
module Standoc
|
5
|
-
|
6
5
|
# A {Converter} implementation that generates HTML output, and a document
|
7
6
|
# schema encapsulation of the document for validation
|
8
7
|
#
|
@@ -12,8 +11,8 @@ module IsoDoc
|
|
12
11
|
super
|
13
12
|
end
|
14
13
|
|
15
|
-
def pdf_stylesheet(
|
16
|
-
|
14
|
+
def pdf_stylesheet(_docxml)
|
15
|
+
"base.standard.xsl"
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
@@ -527,7 +527,7 @@
|
|
527
527
|
</define>
|
528
528
|
<define name="LocalityType">
|
529
529
|
<data type="string">
|
530
|
-
<param name="pattern">section|clause|part|paragraph|chapter|page|whole|table|annex|figure|note|list|example|volume|issue|time|anchor|locality:[a-zA-Z0-9_]+</param>
|
530
|
+
<param name="pattern">section|clause|part|paragraph|chapter|page|title|line|whole|table|annex|figure|note|list|example|volume|issue|time|anchor|locality:[a-zA-Z0-9_]+</param>
|
531
531
|
</data>
|
532
532
|
</define>
|
533
533
|
<define name="referenceFrom">
|
@@ -677,6 +677,9 @@
|
|
677
677
|
<zeroOrMore>
|
678
678
|
<ref name="extent"/>
|
679
679
|
</zeroOrMore>
|
680
|
+
<optional>
|
681
|
+
<ref name="bibliographic_size"/>
|
682
|
+
</optional>
|
680
683
|
<zeroOrMore>
|
681
684
|
<ref name="accesslocation"/>
|
682
685
|
</zeroOrMore>
|
@@ -848,17 +851,46 @@
|
|
848
851
|
</define>
|
849
852
|
<define name="bplace">
|
850
853
|
<element name="place">
|
851
|
-
<
|
852
|
-
<
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
854
|
+
<choice>
|
855
|
+
<text/>
|
856
|
+
<group>
|
857
|
+
<ref name="bibliocity"/>
|
858
|
+
<zeroOrMore>
|
859
|
+
<ref name="biblioregion"/>
|
860
|
+
</zeroOrMore>
|
861
|
+
<zeroOrMore>
|
862
|
+
<ref name="bibliocountry"/>
|
863
|
+
</zeroOrMore>
|
864
|
+
</group>
|
865
|
+
</choice>
|
866
|
+
</element>
|
867
|
+
</define>
|
868
|
+
<define name="bibliocity">
|
869
|
+
<element name="city">
|
859
870
|
<text/>
|
860
871
|
</element>
|
861
872
|
</define>
|
873
|
+
<define name="biblioregion">
|
874
|
+
<element name="region">
|
875
|
+
<ref name="RegionType"/>
|
876
|
+
</element>
|
877
|
+
</define>
|
878
|
+
<define name="bibliocountry">
|
879
|
+
<element name="country">
|
880
|
+
<ref name="RegionType"/>
|
881
|
+
</element>
|
882
|
+
</define>
|
883
|
+
<define name="RegionType">
|
884
|
+
<optional>
|
885
|
+
<attribute name="iso"/>
|
886
|
+
</optional>
|
887
|
+
<optional>
|
888
|
+
<attribute name="recommended">
|
889
|
+
<data type="boolean"/>
|
890
|
+
</attribute>
|
891
|
+
</optional>
|
892
|
+
<text/>
|
893
|
+
</define>
|
862
894
|
<define name="bprice">
|
863
895
|
<element name="price">
|
864
896
|
<attribute name="currency"/>
|
@@ -922,9 +954,29 @@
|
|
922
954
|
<text/>
|
923
955
|
</element>
|
924
956
|
</define>
|
957
|
+
<define name="sizevalue">
|
958
|
+
<element name="value">
|
959
|
+
<attribute name="type"/>
|
960
|
+
<text/>
|
961
|
+
</element>
|
962
|
+
</define>
|
963
|
+
<define name="bibliographic_size">
|
964
|
+
<element name="size">
|
965
|
+
<oneOrMore>
|
966
|
+
<ref name="sizevalue"/>
|
967
|
+
</oneOrMore>
|
968
|
+
</element>
|
969
|
+
</define>
|
925
970
|
<define name="extent">
|
926
971
|
<element name="extent">
|
927
|
-
<
|
972
|
+
<choice>
|
973
|
+
<zeroOrMore>
|
974
|
+
<ref name="locality"/>
|
975
|
+
</zeroOrMore>
|
976
|
+
<zeroOrMore>
|
977
|
+
<ref name="localityStack"/>
|
978
|
+
</zeroOrMore>
|
979
|
+
</choice>
|
928
980
|
</element>
|
929
981
|
</define>
|
930
982
|
<define name="series">
|
@@ -96,6 +96,7 @@ module Metanorma
|
|
96
96
|
return svgmap_example(node) if role == "svgmap"
|
97
97
|
return form(node) if role == "form"
|
98
98
|
return termdefinition(node) if role == "definition"
|
99
|
+
return figure_example(node) if role == "figure"
|
99
100
|
|
100
101
|
reqt_subpart(role) and return requirement_subpart(node)
|
101
102
|
example_proper(node)
|
@@ -145,6 +146,15 @@ module Metanorma
|
|
145
146
|
end.join("\n")
|
146
147
|
end
|
147
148
|
|
149
|
+
def figure_example(node)
|
150
|
+
noko do |xml|
|
151
|
+
xml.figure **figure_attrs(node) do |ex|
|
152
|
+
node.title.nil? or ex.name { |name| name << node.title }
|
153
|
+
wrap_in_para(node, ex)
|
154
|
+
end
|
155
|
+
end.join("\n")
|
156
|
+
end
|
157
|
+
|
148
158
|
def figure_title(node, out)
|
149
159
|
return if node.title.nil?
|
150
160
|
|
@@ -12,12 +12,8 @@ module Metanorma
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def note_attrs(node)
|
15
|
-
attr_code(
|
16
|
-
|
17
|
-
type: node.attr("type"),
|
18
|
-
beforeclauses: node.attr("beforeclauses") == "true" ? "true" : nil,
|
19
|
-
),
|
20
|
-
)
|
15
|
+
attr_code(termnote_attrs(node).merge(admonition_core_attrs(node)
|
16
|
+
.merge(type: node.attr("type"))))
|
21
17
|
end
|
22
18
|
|
23
19
|
def sidebar_attrs(node)
|
@@ -73,15 +69,25 @@ module Metanorma
|
|
73
69
|
end
|
74
70
|
|
75
71
|
def admonition_attrs(node)
|
72
|
+
attr_code(keep_attrs(node).merge(id_attr(node)
|
73
|
+
.merge(admonition_core_attrs(node)
|
74
|
+
.merge(type: admonition_name(node)))))
|
75
|
+
end
|
76
|
+
|
77
|
+
def admonition_core_attrs(node)
|
78
|
+
{ notag: node.attr("notag") == "true" ? "true" : nil,
|
79
|
+
coverpage: node.attr("coverpage") == "true" ? "true" : nil,
|
80
|
+
beforeclauses: node.attr("beforeclauses") == "true" ? "true" : nil,
|
81
|
+
unnumbered: node.attr("unnumbered") ||
|
82
|
+
(node.attr("notag") == "true") || nil }
|
83
|
+
end
|
84
|
+
|
85
|
+
def admonition_name(node)
|
76
86
|
name = node.attr("name")
|
77
87
|
a = node.attr("type") and ["danger", "safety precautions"].each do |t|
|
78
88
|
name = t if a.casecmp(t).zero?
|
79
89
|
end
|
80
|
-
|
81
|
-
.merge(
|
82
|
-
type: name,
|
83
|
-
beforeclauses: node.attr("beforeclauses") == "true" ? "true" : nil,
|
84
|
-
)))
|
90
|
+
name
|
85
91
|
end
|
86
92
|
|
87
93
|
def admonition(node)
|
@@ -73,11 +73,21 @@ module Metanorma
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
+
def single_subfigure_cleanup(xmldoc)
|
77
|
+
xmldoc.xpath("//figure[figure]").each do |e|
|
78
|
+
s = e.xpath("./figure")
|
79
|
+
return unless s.size == 1
|
80
|
+
|
81
|
+
s[0].replace(s[0].children)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
76
85
|
def figure_cleanup(xmldoc)
|
77
86
|
figure_footnote_cleanup(xmldoc)
|
78
87
|
figure_dl_cleanup1(xmldoc)
|
79
88
|
figure_dl_cleanup2(xmldoc)
|
80
89
|
subfigure_cleanup(xmldoc)
|
90
|
+
single_subfigure_cleanup(xmldoc)
|
81
91
|
end
|
82
92
|
|
83
93
|
ELEMS_ALLOW_NOTES = %w[p formula ul ol dl figure].freeze
|
@@ -111,7 +111,7 @@ module Metanorma
|
|
111
111
|
return if xml.at("//boilerplate")
|
112
112
|
|
113
113
|
preface = xml.at("//preface") || xml.at("//sections") ||
|
114
|
-
xml.at("//annex") || xml.at("//references")
|
114
|
+
xml.at("//annex") || xml.at("//references") or return
|
115
115
|
b = boilerplate(xml, isodoc) or return
|
116
116
|
preface.previous = b
|
117
117
|
end
|
@@ -162,11 +162,11 @@ module Metanorma
|
|
162
162
|
end
|
163
163
|
|
164
164
|
def insert_indirect_biblio(xmldoc, refs, prefix)
|
165
|
-
|
166
|
-
xmldoc.root << "<bibliography/>" and
|
167
|
-
|
165
|
+
i = xmldoc.at("bibliography") or
|
166
|
+
xmldoc.root << "<bibliography/>" and i = xmldoc.at("bibliography")
|
167
|
+
i = i.add_child("<references hidden='true' normative='false'/>").first
|
168
168
|
refs.each do |x|
|
169
|
-
|
169
|
+
i << <<~BIB
|
170
170
|
<bibitem id="#{x}" type="internal">
|
171
171
|
<docidentifier type="repository">#{x.sub(/^#{prefix}_/, "#{prefix}/")}</docidentifier>
|
172
172
|
</bibitem>
|
@@ -213,12 +213,13 @@ module Metanorma
|
|
213
213
|
def bibdata_embed_hdr_cleanup(xmldoc)
|
214
214
|
return if @embed_hdr.nil? || @embed_hdr.empty?
|
215
215
|
|
216
|
-
|
216
|
+
xmldoc.at("//bibdata") << "<relation type='derivedFrom'>"\
|
217
|
+
"#{hdr2bibitem(@embed_hdr.first)}</relation>"
|
217
218
|
end
|
218
219
|
|
219
220
|
def hdr2bibitem(hdr)
|
220
221
|
xml = Asciidoctor
|
221
|
-
.convert(hdr[:text], backend:
|
222
|
+
.convert(hdr[:text], backend: hdr2bibitem_type(hdr),
|
222
223
|
header_footer: true)
|
223
224
|
b = Nokogiri::XML(xml).at("//xmlns:bibdata")
|
224
225
|
b.name = "bibitem"
|
@@ -227,6 +228,13 @@ module Metanorma
|
|
227
228
|
b.to_xml
|
228
229
|
end
|
229
230
|
|
231
|
+
def hdr2bibitem_type(hdr)
|
232
|
+
m = /:mn-document-class: (\S+)/.match(hdr[:text])
|
233
|
+
if m then m[1].to_sym
|
234
|
+
else Processor.new.asciidoctor_backend
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
230
238
|
def embed_recurse(bibitem, node)
|
231
239
|
node[:child].map { |x| hdr2bibitem(x) }.each do |x|
|
232
240
|
bibitem << "<relation type='derivedFrom'>#{x}</relation>"
|
@@ -20,8 +20,8 @@ module Metanorma
|
|
20
20
|
text = text.gsub(%r{<stem type="AsciiMath">(.+?)</stem>}m) do
|
21
21
|
"<amathstem>#{HTMLEntities.new.decode($1)}</amathstem>"
|
22
22
|
end
|
23
|
-
text = Html2Doc.
|
24
|
-
|
23
|
+
text = Html2Doc.new({})
|
24
|
+
.asciimath_to_mathml(text, ["<amathstem>", "</amathstem>"])
|
25
25
|
x = Nokogiri::XML(text)
|
26
26
|
x.xpath("//*[local-name() = 'math'][not(parent::stem)]").each do |y|
|
27
27
|
y.wrap("<stem type='MathML'></stem>")
|
@@ -68,10 +68,11 @@ module Metanorma
|
|
68
68
|
def mi_italicise?(char)
|
69
69
|
return false if char.length > 1
|
70
70
|
|
71
|
-
|
71
|
+
case char
|
72
|
+
when /\p{Greek}/
|
72
73
|
(/\p{Lower}/.match(char) && !mathml_mi_italics[:lowergreek]) ||
|
73
74
|
(/\p{Upper}/.match(char) && !mathml_mi_italics[:uppergreek])
|
74
|
-
|
75
|
+
when /\p{Latin}/
|
75
76
|
(/\p{Lower}/.match(char) && !mathml_mi_italics[:lowerroman]) ||
|
76
77
|
(/\p{Upper}/.match(char) && !mathml_mi_italics[:upperroman])
|
77
78
|
else false
|
@@ -50,10 +50,8 @@ module Metanorma
|
|
50
50
|
# only numeric references are renumbered
|
51
51
|
def biblio_renumber(xmldoc)
|
52
52
|
i = 0
|
53
|
-
xmldoc.xpath("//
|
54
|
-
"
|
55
|
-
next if r["normative"] == "true"
|
56
|
-
|
53
|
+
xmldoc.xpath("//references[not(@normative = 'true')]"\
|
54
|
+
"[not(@hidden = 'true')]").each do |r|
|
57
55
|
r.xpath("./bibitem[not(@hidden = 'true')]").each do |b|
|
58
56
|
i += 1
|
59
57
|
next unless docid = b.at("./docidentifier[@type = 'metanorma']")
|
@@ -53,7 +53,7 @@ module Metanorma
|
|
53
53
|
permission).include?(text.name))) ||
|
54
54
|
(text.text.strip.empty? && !text.at(".//xref | .//eref | .//link"))
|
55
55
|
|
56
|
-
t = Nokogiri::XML::Element.new("description", reqt)
|
56
|
+
t = Nokogiri::XML::Element.new("description", reqt.document)
|
57
57
|
text.before(t)
|
58
58
|
t.children = text.remove
|
59
59
|
end
|
@@ -125,11 +125,8 @@ module Metanorma
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def obligations_cleanup_info(xml)
|
128
|
-
|
129
|
-
|
130
|
-
s = xml.at("//acknowledgements") and s["obligation"] = "informative"
|
131
|
-
xml.xpath("//references").each { |r| r["obligation"] = "informative" }
|
132
|
-
xml.xpath("//preface//clause").each do |r|
|
128
|
+
xml.xpath("//foreword | //introduction | //acknowledgements | "\
|
129
|
+
"//references | //preface//clause").each do |r|
|
133
130
|
r["obligation"] = "informative"
|
134
131
|
end
|
135
132
|
end
|
@@ -158,29 +155,34 @@ module Metanorma
|
|
158
155
|
def preface_clausebefore_cleanup(xmldoc)
|
159
156
|
return unless xmldoc.at("//preface")
|
160
157
|
|
161
|
-
|
162
|
-
xmldoc.at("//preface") << " "
|
163
|
-
ins = xmldoc.at("//preface").children.first
|
164
|
-
end
|
158
|
+
ins = insert_before(xmldoc, "//preface")
|
165
159
|
xmldoc.xpath("//preface//*[@beforeclauses = 'true']").each do |x|
|
166
160
|
x.delete("beforeclauses")
|
167
161
|
ins.previous = x.remove
|
168
162
|
end
|
163
|
+
xmldoc.xpath("//*[@coverpage = 'true']").each do |x|
|
164
|
+
ins.previous = x.remove
|
165
|
+
end
|
169
166
|
end
|
170
167
|
|
171
168
|
def sections_clausebefore_cleanup(xmldoc)
|
172
169
|
return unless xmldoc.at("//sections")
|
173
170
|
|
174
|
-
|
175
|
-
xmldoc.at("//sections") << " "
|
176
|
-
ins = xmldoc.at("//sections").children.first
|
177
|
-
end
|
171
|
+
ins = insert_before(xmldoc, "//sections")
|
178
172
|
xmldoc.xpath("//sections//*[@beforeclauses = 'true']").each do |x|
|
179
173
|
x.delete("beforeclauses")
|
180
174
|
ins.previous = x.remove
|
181
175
|
end
|
182
176
|
end
|
183
177
|
|
178
|
+
def insert_before(xmldoc, xpath)
|
179
|
+
unless ins = xmldoc.at(xpath).children.first
|
180
|
+
xmldoc.at(xpath) << " "
|
181
|
+
ins = xmldoc.at(xpath).children.first
|
182
|
+
end
|
183
|
+
ins
|
184
|
+
end
|
185
|
+
|
184
186
|
def floatingtitle_cleanup(xmldoc)
|
185
187
|
pop_floating_title(xmldoc)
|
186
188
|
floating_title_preface2sections(xmldoc)
|