metanorma-standoc 2.1.1 → 2.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/metanorma/standoc/base.rb +3 -1
- data/lib/metanorma/standoc/biblio.rng +134 -39
- data/lib/metanorma/standoc/blocks.rb +8 -6
- data/lib/metanorma/standoc/blocks_notes.rb +4 -1
- data/lib/metanorma/standoc/cleanup.rb +1 -0
- data/lib/metanorma/standoc/cleanup_footnotes.rb +32 -25
- data/lib/metanorma/standoc/cleanup_inline.rb +17 -0
- data/lib/metanorma/standoc/cleanup_ref.rb +16 -0
- data/lib/metanorma/standoc/cleanup_section.rb +6 -0
- data/lib/metanorma/standoc/cleanup_terms.rb +3 -1
- data/lib/metanorma/standoc/cleanup_text.rb +9 -4
- data/lib/metanorma/standoc/cleanup_xref.rb +2 -1
- data/lib/metanorma/standoc/converter.rb +4 -0
- data/lib/metanorma/standoc/isodoc.rng +32 -0
- data/lib/metanorma/standoc/lists.rb +8 -3
- data/lib/metanorma/standoc/macros.rb +28 -1
- data/lib/metanorma/standoc/macros_note.rb +27 -6
- data/lib/metanorma/standoc/ref.rb +3 -1
- data/lib/metanorma/standoc/ref_sect.rb +5 -2
- data/lib/metanorma/standoc/ref_utility.rb +20 -5
- data/lib/metanorma/standoc/section.rb +1 -1
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +2 -2
- data/spec/examples/datamodel/address_class_profile.presentation.xml +14 -0
- data/spec/metanorma/base_spec.rb +41 -5
- data/spec/metanorma/blocks_spec.rb +58 -1
- data/spec/metanorma/cleanup_sections_spec.rb +60 -9
- data/spec/metanorma/cleanup_spec.rb +6 -6
- data/spec/metanorma/cleanup_terms_spec.rb +1 -1
- data/spec/metanorma/inline_spec.rb +3 -3
- data/spec/metanorma/lists_spec.rb +10 -4
- data/spec/metanorma/macros_spec.rb +50 -15
- data/spec/metanorma/refs_dl_spec.rb +18 -7
- data/spec/metanorma/refs_spec.rb +390 -450
- data/spec/metanorma/table_spec.rb +24 -6
- data/spec/spec_helper.rb +2 -2
- data/spec/vcr_cassettes/bsi16341.yml +57 -71
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +67 -67
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +14 -14
- data/spec/vcr_cassettes/hide_refs.yml +62 -62
- data/spec/vcr_cassettes/isobib_get_123.yml +14 -14
- data/spec/vcr_cassettes/isobib_get_123_1.yml +26 -26
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +37 -37
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +14 -14
- data/spec/vcr_cassettes/isobib_get_124.yml +12 -12
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +228 -52
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +47 -49
- data/spec/vcr_cassettes/std-link.yml +15 -15
- metadata +10 -10
- data/docs/quickstart.adoc +0 -375
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d55c699cf84e05288a133b4e0b9305cfb14809780ec379b8d617a928338f1fca
|
4
|
+
data.tar.gz: 772eaa9e0e09e9ad7c40b70ade1825d437ba079673767b31c3c5b493cf29af4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fba5328a1ebbc7d236174893d3e98ece5768c3d8935c326506692023d1254c1a2bda95f842956b4830d18c949ba817d4ca4f00548c569999ae38381c1406f02f
|
7
|
+
data.tar.gz: d3aed7321347c856c5f8ff600118773094ffc948a5f7b3be6655dff48749c4780a5a4048baf1a04d4aad94e22b650648c91c7ca9bc159680beb48ec4275a8904
|
@@ -171,7 +171,9 @@ module Metanorma
|
|
171
171
|
end
|
172
172
|
|
173
173
|
def doctype(node)
|
174
|
-
node.attr("doctype")&.gsub(/\s+/, "-")&.downcase
|
174
|
+
ret = node.attr("doctype")&.gsub(/\s+/, "-")&.downcase || "standard"
|
175
|
+
ret = "standard" if ret == "article"
|
176
|
+
ret
|
175
177
|
end
|
176
178
|
|
177
179
|
def front(node, xml)
|
@@ -614,12 +614,103 @@
|
|
614
614
|
<optional>
|
615
615
|
<ref name="fetched"/>
|
616
616
|
</optional>
|
617
|
-
<
|
618
|
-
<oneOrMore>
|
619
|
-
<ref name="btitle"/>
|
620
|
-
</oneOrMore>
|
617
|
+
<optional>
|
621
618
|
<ref name="formattedref"/>
|
622
|
-
</
|
619
|
+
</optional>
|
620
|
+
<oneOrMore>
|
621
|
+
<ref name="btitle"/>
|
622
|
+
</oneOrMore>
|
623
|
+
<zeroOrMore>
|
624
|
+
<ref name="bsource"/>
|
625
|
+
</zeroOrMore>
|
626
|
+
<oneOrMore>
|
627
|
+
<ref name="docidentifier"/>
|
628
|
+
</oneOrMore>
|
629
|
+
<optional>
|
630
|
+
<ref name="docnumber"/>
|
631
|
+
</optional>
|
632
|
+
<zeroOrMore>
|
633
|
+
<ref name="bdate"/>
|
634
|
+
</zeroOrMore>
|
635
|
+
<zeroOrMore>
|
636
|
+
<ref name="contributor"/>
|
637
|
+
</zeroOrMore>
|
638
|
+
<optional>
|
639
|
+
<ref name="edition"/>
|
640
|
+
</optional>
|
641
|
+
<zeroOrMore>
|
642
|
+
<ref name="version"/>
|
643
|
+
</zeroOrMore>
|
644
|
+
<zeroOrMore>
|
645
|
+
<ref name="biblionote"/>
|
646
|
+
</zeroOrMore>
|
647
|
+
<zeroOrMore>
|
648
|
+
<ref name="language"/>
|
649
|
+
</zeroOrMore>
|
650
|
+
<zeroOrMore>
|
651
|
+
<ref name="script"/>
|
652
|
+
</zeroOrMore>
|
653
|
+
<zeroOrMore>
|
654
|
+
<ref name="bibabstract"/>
|
655
|
+
</zeroOrMore>
|
656
|
+
<optional>
|
657
|
+
<ref name="status"/>
|
658
|
+
</optional>
|
659
|
+
<zeroOrMore>
|
660
|
+
<ref name="copyright"/>
|
661
|
+
</zeroOrMore>
|
662
|
+
<zeroOrMore>
|
663
|
+
<ref name="docrelation"/>
|
664
|
+
</zeroOrMore>
|
665
|
+
<zeroOrMore>
|
666
|
+
<ref name="series"/>
|
667
|
+
</zeroOrMore>
|
668
|
+
<optional>
|
669
|
+
<ref name="medium"/>
|
670
|
+
</optional>
|
671
|
+
<zeroOrMore>
|
672
|
+
<ref name="bplace"/>
|
673
|
+
</zeroOrMore>
|
674
|
+
<zeroOrMore>
|
675
|
+
<ref name="bprice"/>
|
676
|
+
</zeroOrMore>
|
677
|
+
<zeroOrMore>
|
678
|
+
<ref name="extent"/>
|
679
|
+
</zeroOrMore>
|
680
|
+
<optional>
|
681
|
+
<ref name="bibliographic_size"/>
|
682
|
+
</optional>
|
683
|
+
<zeroOrMore>
|
684
|
+
<ref name="accesslocation"/>
|
685
|
+
</zeroOrMore>
|
686
|
+
<zeroOrMore>
|
687
|
+
<ref name="license"/>
|
688
|
+
</zeroOrMore>
|
689
|
+
<zeroOrMore>
|
690
|
+
<ref name="bclassification"/>
|
691
|
+
</zeroOrMore>
|
692
|
+
<zeroOrMore>
|
693
|
+
<ref name="bkeyword"/>
|
694
|
+
</zeroOrMore>
|
695
|
+
<optional>
|
696
|
+
<ref name="validity"/>
|
697
|
+
</optional>
|
698
|
+
</define>
|
699
|
+
<define name="ReducedBibliographicItem">
|
700
|
+
<optional>
|
701
|
+
<attribute name="type">
|
702
|
+
<ref name="BibItemType"/>
|
703
|
+
</attribute>
|
704
|
+
</optional>
|
705
|
+
<optional>
|
706
|
+
<ref name="fetched"/>
|
707
|
+
</optional>
|
708
|
+
<optional>
|
709
|
+
<ref name="formattedref"/>
|
710
|
+
</optional>
|
711
|
+
<zeroOrMore>
|
712
|
+
<ref name="btitle"/>
|
713
|
+
</zeroOrMore>
|
623
714
|
<zeroOrMore>
|
624
715
|
<ref name="bsource"/>
|
625
716
|
</zeroOrMore>
|
@@ -638,9 +729,9 @@
|
|
638
729
|
<optional>
|
639
730
|
<ref name="edition"/>
|
640
731
|
</optional>
|
641
|
-
<
|
732
|
+
<zeroOrMore>
|
642
733
|
<ref name="version"/>
|
643
|
-
</
|
734
|
+
</zeroOrMore>
|
644
735
|
<zeroOrMore>
|
645
736
|
<ref name="biblionote"/>
|
646
737
|
</zeroOrMore>
|
@@ -833,6 +924,12 @@
|
|
833
924
|
<data type="boolean"/>
|
834
925
|
</attribute>
|
835
926
|
</optional>
|
927
|
+
<optional>
|
928
|
+
<attribute name="language"/>
|
929
|
+
</optional>
|
930
|
+
<optional>
|
931
|
+
<attribute name="script"/>
|
932
|
+
</optional>
|
836
933
|
<text/>
|
837
934
|
</element>
|
838
935
|
</define>
|
@@ -986,36 +1083,34 @@
|
|
986
1083
|
<ref name="SeriesType"/>
|
987
1084
|
</attribute>
|
988
1085
|
</optional>
|
989
|
-
<
|
1086
|
+
<optional>
|
990
1087
|
<ref name="formattedref"/>
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
</group>
|
1018
|
-
</choice>
|
1088
|
+
</optional>
|
1089
|
+
<ref name="btitle"/>
|
1090
|
+
<optional>
|
1091
|
+
<ref name="bplace"/>
|
1092
|
+
</optional>
|
1093
|
+
<optional>
|
1094
|
+
<ref name="seriesorganization"/>
|
1095
|
+
</optional>
|
1096
|
+
<optional>
|
1097
|
+
<ref name="abbreviation"/>
|
1098
|
+
</optional>
|
1099
|
+
<optional>
|
1100
|
+
<ref name="seriesfrom"/>
|
1101
|
+
</optional>
|
1102
|
+
<optional>
|
1103
|
+
<ref name="seriesto"/>
|
1104
|
+
</optional>
|
1105
|
+
<optional>
|
1106
|
+
<ref name="seriesnumber"/>
|
1107
|
+
</optional>
|
1108
|
+
<optional>
|
1109
|
+
<ref name="seriespartnumber"/>
|
1110
|
+
</optional>
|
1111
|
+
<optional>
|
1112
|
+
<ref name="seriesrun"/>
|
1113
|
+
</optional>
|
1019
1114
|
</element>
|
1020
1115
|
</define>
|
1021
1116
|
<define name="SeriesType">
|
@@ -1174,7 +1269,7 @@
|
|
1174
1269
|
</element>
|
1175
1270
|
</optional>
|
1176
1271
|
<element name="bibitem">
|
1177
|
-
<ref name="
|
1272
|
+
<ref name="ReducedBibliographicItem"/>
|
1178
1273
|
</element>
|
1179
1274
|
<choice>
|
1180
1275
|
<zeroOrMore>
|
@@ -1199,9 +1294,9 @@
|
|
1199
1294
|
<optional>
|
1200
1295
|
<ref name="revision-date"/>
|
1201
1296
|
</optional>
|
1202
|
-
<
|
1297
|
+
<optional>
|
1203
1298
|
<ref name="draft"/>
|
1204
|
-
</
|
1299
|
+
</optional>
|
1205
1300
|
</element>
|
1206
1301
|
</define>
|
1207
1302
|
<define name="vedition">
|
@@ -38,9 +38,7 @@ module Metanorma
|
|
38
38
|
role == "form" and return form(node)
|
39
39
|
role == "definition" and return termdefinition(node)
|
40
40
|
result = []
|
41
|
-
node.blocks.each
|
42
|
-
result << send(b.context, b)
|
43
|
-
end
|
41
|
+
node.blocks.each { |b| result << send(b.context, b) }
|
44
42
|
result
|
45
43
|
end
|
46
44
|
|
@@ -80,14 +78,17 @@ module Metanorma
|
|
80
78
|
|
81
79
|
def term_example(node)
|
82
80
|
noko do |xml|
|
83
|
-
xml.termexample **attr_code(id_attr(node)
|
81
|
+
xml.termexample **attr_code(id_attr(node)
|
82
|
+
.merge(
|
83
|
+
keepasterm: node.option?("termexample") || nil,
|
84
|
+
)) do |ex|
|
84
85
|
wrap_in_para(node, ex)
|
85
86
|
end
|
86
87
|
end.join("\n")
|
87
88
|
end
|
88
89
|
|
89
90
|
def example(node)
|
90
|
-
return term_example(node) if in_terms?
|
91
|
+
return term_example(node) if in_terms? || node.option?("termexample")
|
91
92
|
|
92
93
|
role = node.role || node.attr("style")
|
93
94
|
%w(recommendation requirement permission).include?(role) and
|
@@ -237,10 +238,11 @@ module Metanorma
|
|
237
238
|
end
|
238
239
|
|
239
240
|
def pass(node)
|
241
|
+
c = HTMLEntities.new
|
240
242
|
noko do |xml|
|
241
243
|
xml.passthrough **attr_code(formats:
|
242
244
|
node.attr("format") || "metanorma") do |p|
|
243
|
-
p <<
|
245
|
+
p << c.encode(c.decode(node.content), :basic, :hexadecimal)
|
244
246
|
end
|
245
247
|
end
|
246
248
|
end
|
@@ -8,6 +8,7 @@ module Metanorma
|
|
8
8
|
number: node.attr("number"),
|
9
9
|
subsequence: node.attr("subsequence"),
|
10
10
|
"keep-separate": node.attr("keep-separate"),
|
11
|
+
keepasterm: node.option?("termnote") ? "true" : nil,
|
11
12
|
)))
|
12
13
|
end
|
13
14
|
|
@@ -61,6 +62,8 @@ module Metanorma
|
|
61
62
|
end
|
62
63
|
|
63
64
|
def note(node)
|
65
|
+
return termnote(node) if node.option?("termnote")
|
66
|
+
|
64
67
|
noko do |xml|
|
65
68
|
xml.note **note_attrs(node) do |c|
|
66
69
|
wrap_in_para(node, c)
|
@@ -91,7 +94,7 @@ module Metanorma
|
|
91
94
|
end
|
92
95
|
|
93
96
|
def admonition(node)
|
94
|
-
return termnote(node) if in_terms?
|
97
|
+
return termnote(node) if in_terms? && node.attr("name") == "note"
|
95
98
|
return note(node) if node.attr("name") == "note"
|
96
99
|
return todo(node) if node.attr("name") == "todo"
|
97
100
|
|
@@ -5,20 +5,27 @@ require "json"
|
|
5
5
|
module Metanorma
|
6
6
|
module Standoc
|
7
7
|
module Cleanup
|
8
|
-
def footnote_content(
|
9
|
-
c =
|
8
|
+
def footnote_content(fnote)
|
9
|
+
c = if fnote.children.respond_to?(:to_xml)
|
10
|
+
fnote.children.to_xml
|
11
|
+
else fn.children
|
12
|
+
end
|
10
13
|
c.gsub(/ id="[^"]+"/, "")
|
11
14
|
end
|
12
15
|
|
13
|
-
|
16
|
+
FIGURE_FN_XPATH =
|
17
|
+
"//figure/following-sibling::*[1][self::p and *[1][self::fn]]".freeze
|
18
|
+
|
19
|
+
# include footnotes inside figure if they are the only content
|
14
20
|
# of the paras following
|
15
21
|
def figure_footnote_cleanup(xmldoc)
|
16
22
|
nomatches = false
|
17
23
|
until nomatches
|
18
|
-
q = "//figure/following-sibling::*[1][self::p and *[1][self::fn]]"
|
19
24
|
nomatches = true
|
20
|
-
xmldoc.xpath(
|
21
|
-
next if s.children.map
|
25
|
+
xmldoc.xpath(FIGURE_FN_XPATH).each do |s|
|
26
|
+
next if s.children.map do |c|
|
27
|
+
c.text? && /[[:alpha:]]/.match(c.text)
|
28
|
+
end.any?
|
22
29
|
|
23
30
|
s.previous_element << s.first_element_child.remove
|
24
31
|
s.remove
|
@@ -27,17 +34,17 @@ module Metanorma
|
|
27
34
|
end
|
28
35
|
end
|
29
36
|
|
30
|
-
def table_footnote_renumber1(
|
31
|
-
content = footnote_content(
|
37
|
+
def table_footnote_renumber1(fnote, idx, seen)
|
38
|
+
content = footnote_content(fnote)
|
32
39
|
if seen[content] then outnum = seen[content]
|
33
40
|
else
|
34
|
-
|
35
|
-
outnum =
|
41
|
+
idx += 1
|
42
|
+
outnum = idx
|
36
43
|
seen[content] = outnum
|
37
44
|
end
|
38
|
-
|
39
|
-
|
40
|
-
[
|
45
|
+
fnote["reference"] = (outnum - 1 + "a".ord).chr
|
46
|
+
fnote["table"] = true
|
47
|
+
[idx, seen]
|
41
48
|
end
|
42
49
|
|
43
50
|
def table_footnote_renumber(xmldoc)
|
@@ -50,18 +57,18 @@ module Metanorma
|
|
50
57
|
end
|
51
58
|
end
|
52
59
|
|
53
|
-
def other_footnote_renumber1(
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
fn["reference"] = outnum.to_s
|
60
|
+
def other_footnote_renumber1(fnote, idx, seen)
|
61
|
+
return [idx, seen] if fnote["table"]
|
62
|
+
|
63
|
+
content = footnote_content(fnote)
|
64
|
+
if seen[content] then outnum = seen[content]
|
65
|
+
else
|
66
|
+
idx += 1
|
67
|
+
outnum = idx
|
68
|
+
seen[content] = outnum
|
63
69
|
end
|
64
|
-
[
|
70
|
+
fnote["reference"] = outnum.to_s
|
71
|
+
[idx, seen]
|
65
72
|
end
|
66
73
|
|
67
74
|
def other_footnote_renumber(xmldoc)
|
@@ -84,7 +91,7 @@ module Metanorma
|
|
84
91
|
|
85
92
|
def footnote_block_cleanup(xmldoc)
|
86
93
|
xmldoc.xpath("//footnoteblock").each do |f|
|
87
|
-
f.name =
|
94
|
+
f.name = "fn"
|
88
95
|
if id = xmldoc.at("//*[@id = '#{f.text}']")
|
89
96
|
f.children = id.remove.children
|
90
97
|
else
|
@@ -185,6 +185,23 @@ module Metanorma
|
|
185
185
|
Digest::MD5.hexdigest("#{elem.path}////#{elem.text}")
|
186
186
|
.sub(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, "_\\1-\\2-\\3-\\4-\\5")
|
187
187
|
end
|
188
|
+
|
189
|
+
def passthrough_cleanup(doc)
|
190
|
+
doc.xpath("//passthrough-inline").each do |p|
|
191
|
+
p.name = "passthrough"
|
192
|
+
p.children = select_odd_chars(p.children.to_xml)
|
193
|
+
end
|
194
|
+
doc.xpath("//identifier").each do |p|
|
195
|
+
p.children = select_odd_chars(p.children.to_xml)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
private
|
200
|
+
|
201
|
+
# skip ZWNJ inserted to prevent regexes operating in asciidoctor
|
202
|
+
def select_odd_chars(text)
|
203
|
+
text.gsub(/(?!&)([[:punct:]])\u200c/, "\\1")
|
204
|
+
end
|
188
205
|
end
|
189
206
|
end
|
190
207
|
end
|
@@ -80,6 +80,7 @@ module Metanorma
|
|
80
80
|
|
81
81
|
def biblio_cleanup(xmldoc)
|
82
82
|
biblio_reorder(xmldoc)
|
83
|
+
biblio_annex(xmldoc)
|
83
84
|
biblio_nested(xmldoc)
|
84
85
|
biblio_renumber(xmldoc)
|
85
86
|
biblio_linkonly(xmldoc)
|
@@ -119,6 +120,16 @@ module Metanorma
|
|
119
120
|
xmldoc.xpath("//bibitem/ext").each(&:remove)
|
120
121
|
end
|
121
122
|
|
123
|
+
def biblio_annex(xmldoc)
|
124
|
+
xmldoc.xpath("//annex[references/references]").each do |t|
|
125
|
+
next unless t.xpath("./clause | ./references | ./terms").size == 1
|
126
|
+
|
127
|
+
r = t.at("./references")
|
128
|
+
r.xpath("./references").each { |b| b["normative"] = r["normative"] }
|
129
|
+
r.replace(r.elements)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
122
133
|
def biblio_nested(xmldoc)
|
123
134
|
xmldoc.xpath("//references[references]").each do |t|
|
124
135
|
t.name = "clause"
|
@@ -143,6 +154,11 @@ module Metanorma
|
|
143
154
|
def reference_names(xmldoc)
|
144
155
|
xmldoc.xpath("//bibitem[not(ancestor::bibitem)]").each do |ref|
|
145
156
|
docid = ref.at("./docidentifier[@type = 'metanorma']") ||
|
157
|
+
ref.at("./docidentifier[@primary = 'true'][@language = '#{@lang}']") ||
|
158
|
+
ref.at("./docidentifier[@primary = 'true'][not(@language)]") ||
|
159
|
+
ref.at("./docidentifier[@primary = 'true']") ||
|
160
|
+
ref.at("./docidentifier[not(@type = 'DOI')][@language = '#{@lang}']") ||
|
161
|
+
ref.at("./docidentifier[not(@type = 'DOI')][not(@language)]") ||
|
146
162
|
ref.at("./docidentifier[not(@type = 'DOI')]") or next
|
147
163
|
reference = format_ref(docid.children.to_xml, docid["type"])
|
148
164
|
@anchors[ref["id"]] = { xref: reference }
|
@@ -118,6 +118,12 @@ module Metanorma
|
|
118
118
|
change_clauses(xml)
|
119
119
|
end
|
120
120
|
|
121
|
+
def single_clause_annex(xml)
|
122
|
+
xml.xpath("//annex").each do |a|
|
123
|
+
single_clause_annex1(a)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
121
127
|
def obligations_cleanup(xml)
|
122
128
|
obligations_cleanup_info(xml)
|
123
129
|
obligations_cleanup_norm(xml)
|
@@ -93,7 +93,9 @@ module Metanorma
|
|
93
93
|
def termnote_example_cleanup(xmldoc)
|
94
94
|
%w(note example).each do |w|
|
95
95
|
xmldoc.xpath("//term#{w}[not(ancestor::term)]").each do |x|
|
96
|
-
x
|
96
|
+
if x["keepasterm"] then x.delete("keepasterm")
|
97
|
+
else x.name = w
|
98
|
+
end
|
97
99
|
end
|
98
100
|
end
|
99
101
|
end
|
@@ -5,8 +5,11 @@ module Metanorma
|
|
5
5
|
text = result.flatten.map { |l| l.sub(/\s*\Z/, "") } * "\n"
|
6
6
|
!@keepasciimath and text = asciimath2mathml(text)
|
7
7
|
text = text.gsub(/\s+<fn /, "<fn ")
|
8
|
-
|
9
|
-
|
8
|
+
%w(passthrough passthrough-inline).each do |v|
|
9
|
+
text.gsub!(%r{<#{v}\s+formats="metanorma">([^<]*)
|
10
|
+
</#{v}>}mx) { HTMLEntities.new.decode($1) }
|
11
|
+
end
|
12
|
+
text
|
10
13
|
end
|
11
14
|
|
12
15
|
def smartquotes_cleanup(xmldoc)
|
@@ -33,7 +36,8 @@ module Metanorma
|
|
33
36
|
|
34
37
|
def uninterrupt_quotes_around_xml_skip(elem)
|
35
38
|
!(/\A['"]/.match?(elem.text) &&
|
36
|
-
elem.previous.ancestors("pre, tt, sourcecode, stem, figure, bibdata
|
39
|
+
elem.previous.ancestors("pre, tt, sourcecode, stem, figure, bibdata,
|
40
|
+
passthrough, identifer")
|
37
41
|
.empty? &&
|
38
42
|
((elem.previous.text.strip.empty? &&
|
39
43
|
!empty_tag_with_text_content?(elem.previous)) ||
|
@@ -70,7 +74,8 @@ module Metanorma
|
|
70
74
|
empty_tag_with_text_content?(x) and prev = "dummy"
|
71
75
|
next unless x.text?
|
72
76
|
|
73
|
-
x.ancestors("pre, tt, sourcecode, stem, figure, bibdata
|
77
|
+
x.ancestors("pre, tt, sourcecode, stem, figure, bibdata, passthrough,
|
78
|
+
identifier").empty? and
|
74
79
|
dumb2smart_quotes1(x, prev)
|
75
80
|
prev = x.text if x.ancestors("index").empty?
|
76
81
|
end
|
@@ -68,9 +68,10 @@ module Metanorma
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def xref_to_eref(elem)
|
71
|
+
c = HTMLEntities.new
|
71
72
|
elem["bibitemid"] = elem["target"]
|
72
73
|
if ref = @anchors&.dig(elem["target"], :xref)
|
73
|
-
elem["citeas"] =
|
74
|
+
elem["citeas"] = c.decode(ref)
|
74
75
|
else
|
75
76
|
elem["citeas"] = ""
|
76
77
|
xref_to_eref1(elem)
|
@@ -36,6 +36,7 @@ module Metanorma
|
|
36
36
|
inline_macro Metanorma::Standoc::DomainTermInlineMacro
|
37
37
|
inline_macro Metanorma::Standoc::InheritInlineMacro
|
38
38
|
inline_macro Metanorma::Standoc::HTML5RubyMacro
|
39
|
+
inline_macro Metanorma::Standoc::IdentifierInlineMacro
|
39
40
|
inline_macro Metanorma::Standoc::ConceptInlineMacro
|
40
41
|
inline_macro Metanorma::Standoc::AutonumberInlineMacro
|
41
42
|
inline_macro Metanorma::Standoc::VariantInlineMacro
|
@@ -58,11 +59,14 @@ module Metanorma
|
|
58
59
|
inline_macro Metanorma::Plugin::Lutaml::LutamlTableInlineMacro
|
59
60
|
block_macro Metanorma::Plugin::Lutaml::LutamlDiagramBlockMacro
|
60
61
|
block Metanorma::Standoc::ToDoAdmonitionBlock
|
62
|
+
block Metanorma::Standoc::EditorAdmonitionBlock
|
63
|
+
treeprocessor Metanorma::Standoc::EditorInlineAdmonitionBlock
|
61
64
|
treeprocessor Metanorma::Standoc::ToDoInlineAdmonitionBlock
|
62
65
|
block Metanorma::Standoc::PlantUMLBlockMacro
|
63
66
|
block Metanorma::Plugin::Lutaml::LutamlDiagramBlock
|
64
67
|
block Metanorma::Standoc::PseudocodeBlockMacro
|
65
68
|
preprocessor Metanorma::Standoc::EmbedIncludeProcessor
|
69
|
+
preprocessor Metanorma::Standoc::NamedEscapePreprocessor
|
66
70
|
end
|
67
71
|
|
68
72
|
include ::Asciidoctor::Converter
|
@@ -69,6 +69,17 @@
|
|
69
69
|
</zeroOrMore>
|
70
70
|
</element>
|
71
71
|
</define>
|
72
|
+
<define name="AdmonitionType">
|
73
|
+
<choice>
|
74
|
+
<value>warning</value>
|
75
|
+
<value>note</value>
|
76
|
+
<value>tip</value>
|
77
|
+
<value>important</value>
|
78
|
+
<value>caution</value>
|
79
|
+
<value>statement</value>
|
80
|
+
<value>editorial</value>
|
81
|
+
</choice>
|
82
|
+
</define>
|
72
83
|
<define name="index">
|
73
84
|
<element name="index">
|
74
85
|
<optional>
|
@@ -116,6 +127,11 @@
|
|
116
127
|
<data type="boolean"/>
|
117
128
|
</attribute>
|
118
129
|
</optional>
|
130
|
+
<optional>
|
131
|
+
<attribute name="suppress_identifier">
|
132
|
+
<data type="boolean"/>
|
133
|
+
</attribute>
|
134
|
+
</optional>
|
119
135
|
<ref name="BibliographicItem"/>
|
120
136
|
</element>
|
121
137
|
</define>
|
@@ -282,6 +298,9 @@
|
|
282
298
|
<ref name="MultilingualRenderingType"/>
|
283
299
|
</attribute>
|
284
300
|
</optional>
|
301
|
+
<optional>
|
302
|
+
<ref name="tname"/>
|
303
|
+
</optional>
|
285
304
|
<oneOrMore>
|
286
305
|
<ref name="ul_li"/>
|
287
306
|
</oneOrMore>
|
@@ -324,6 +343,9 @@
|
|
324
343
|
</choice>
|
325
344
|
</attribute>
|
326
345
|
</optional>
|
346
|
+
<optional>
|
347
|
+
<ref name="tname"/>
|
348
|
+
</optional>
|
327
349
|
<oneOrMore>
|
328
350
|
<ref name="li"/>
|
329
351
|
</oneOrMore>
|
@@ -360,6 +382,9 @@
|
|
360
382
|
<ref name="MultilingualRenderingType"/>
|
361
383
|
</attribute>
|
362
384
|
</optional>
|
385
|
+
<optional>
|
386
|
+
<ref name="tname"/>
|
387
|
+
</optional>
|
363
388
|
<oneOrMore>
|
364
389
|
<ref name="dt"/>
|
365
390
|
<ref name="dd"/>
|
@@ -694,6 +719,9 @@
|
|
694
719
|
<optional>
|
695
720
|
<attribute name="tag"/>
|
696
721
|
</optional>
|
722
|
+
<optional>
|
723
|
+
<attribute name="type"/>
|
724
|
+
</optional>
|
697
725
|
<optional>
|
698
726
|
<attribute name="multilingual-rendering">
|
699
727
|
<ref name="MultilingualRenderingType"/>
|
@@ -729,6 +757,9 @@
|
|
729
757
|
<optional>
|
730
758
|
<attribute name="tag"/>
|
731
759
|
</optional>
|
760
|
+
<optional>
|
761
|
+
<attribute name="type"/>
|
762
|
+
</optional>
|
732
763
|
<optional>
|
733
764
|
<attribute name="multilingual-rendering">
|
734
765
|
<ref name="MultilingualRenderingType"/>
|
@@ -2050,6 +2081,7 @@
|
|
2050
2081
|
<value>compare</value>
|
2051
2082
|
<value>contrast</value>
|
2052
2083
|
<value>see</value>
|
2084
|
+
<value>seealso</value>
|
2053
2085
|
</choice>
|
2054
2086
|
</define>
|
2055
2087
|
<define name="deprecates">
|