metanorma-standoc 1.10.8 → 1.11.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/lib/asciidoctor/standoc/base.rb +5 -4
- data/lib/asciidoctor/standoc/blocks.rb +1 -1
- data/lib/asciidoctor/standoc/cleanup.rb +20 -11
- data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +28 -20
- data/lib/asciidoctor/standoc/cleanup_inline.rb +20 -7
- data/lib/asciidoctor/standoc/cleanup_maths.rb +5 -6
- data/lib/asciidoctor/standoc/cleanup_ref_dl.rb +25 -15
- data/lib/asciidoctor/standoc/cleanup_reqt.rb +2 -21
- data/lib/asciidoctor/standoc/cleanup_section_names.rb +2 -2
- data/lib/asciidoctor/standoc/cleanup_symbols.rb +48 -0
- data/lib/asciidoctor/standoc/cleanup_terms.rb +54 -79
- data/lib/asciidoctor/standoc/cleanup_terms_designations.rb +179 -0
- data/lib/asciidoctor/standoc/cleanup_text.rb +23 -0
- data/lib/asciidoctor/standoc/converter.rb +2 -0
- data/lib/asciidoctor/standoc/datamodel/attributes_table_preprocessor.rb +6 -6
- data/lib/asciidoctor/standoc/inline.rb +20 -16
- data/lib/asciidoctor/standoc/isodoc.rng +254 -27
- data/lib/asciidoctor/standoc/lists.rb +1 -3
- data/lib/asciidoctor/standoc/macros_plantuml.rb +29 -14
- data/lib/asciidoctor/standoc/macros_terms.rb +49 -5
- data/lib/asciidoctor/standoc/ref.rb +101 -75
- data/lib/asciidoctor/standoc/ref_date_id.rb +30 -1
- data/lib/asciidoctor/standoc/ref_sect.rb +42 -24
- data/lib/asciidoctor/standoc/reqt.rb +1 -1
- data/lib/asciidoctor/standoc/section.rb +14 -13
- data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +50 -11
- data/lib/asciidoctor/standoc/terms.rb +12 -2
- data/lib/asciidoctor/standoc/utils.rb +36 -23
- data/lib/asciidoctor/standoc/validate.rb +25 -16
- data/lib/isodoc/html/htmlstyle.css +1 -1
- data/lib/isodoc/html/htmlstyle.scss +1 -1
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +3 -3
- data/spec/asciidoctor/base_spec.rb +4 -3
- data/spec/asciidoctor/blocks_spec.rb +202 -21
- data/spec/asciidoctor/cleanup_sections_spec.rb +7 -7
- data/spec/asciidoctor/cleanup_spec.rb +23 -197
- data/spec/asciidoctor/cleanup_terms_spec.rb +1205 -0
- data/spec/asciidoctor/datamodel/attributes_table_preprocessor_spec.rb +21 -21
- data/spec/asciidoctor/datamodel/diagram_preprocessor_spec.rb +16 -16
- data/spec/asciidoctor/inline_spec.rb +7 -7
- data/spec/asciidoctor/isobib_cache_spec.rb +4 -8
- data/spec/asciidoctor/macros_plantuml_spec.rb +36 -1
- data/spec/asciidoctor/macros_spec.rb +189 -112
- data/spec/asciidoctor/refs_dl_spec.rb +4 -4
- data/spec/asciidoctor/refs_spec.rb +860 -522
- data/spec/asciidoctor/section_spec.rb +18 -18
- data/spec/asciidoctor/validate_spec.rb +59 -2
- data/spec/spec_helper.rb +3 -2
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +180 -180
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +12 -12
- data/spec/vcr_cassettes/isobib_get_123.yml +12 -12
- data/spec/vcr_cassettes/isobib_get_123_1.yml +27 -27
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +35 -35
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +13 -13
- data/spec/vcr_cassettes/isobib_get_124.yml +12 -12
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +45 -65
- metadata +11 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a5cc91caf1f8d674aeff3b46209557d7be11087bf59728df07a73b26cec880a
|
4
|
+
data.tar.gz: 7b674d7c013a3e5aee09394c085ee40dbbed6e241ffb14a14b363ca5956636f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dab0eafeeb100111eecdd7ae0eeb3a23dd1b60acdbf1fc884a7fba6084db22bc816c8255c230a16eb4ab0fc68555378586106145545672a5b39d444e8a3f97c8
|
7
|
+
data.tar.gz: 1f6ffc49435ffebec0441fafbf4a6eb629216270d0d8fd38d68ad15a5d99e4e3162f3d685229827e0eb1df2a2c6d43aaf475795cbcdb143b772d5589787248ff
|
data/Rakefile
CHANGED
@@ -14,6 +14,7 @@ module Asciidoctor
|
|
14
14
|
module Base
|
15
15
|
XML_ROOT_TAG = "standard-document".freeze
|
16
16
|
XML_NAMESPACE = "https://www.metanorma.org/ns/standoc".freeze
|
17
|
+
FONTS_MANIFEST = "fonts-manifest".freeze
|
17
18
|
|
18
19
|
def xml_root_tag
|
19
20
|
self.class::XML_ROOT_TAG
|
@@ -38,7 +39,7 @@ module Asciidoctor
|
|
38
39
|
scripts: node.attr("scripts"),
|
39
40
|
scripts_override: node.attr("scripts-override"),
|
40
41
|
scripts_pdf: node.attr("scripts-pdf"),
|
41
|
-
datauriimage: node.attr("data-uri-image"),
|
42
|
+
datauriimage: node.attr("data-uri-image") != "false",
|
42
43
|
htmltoclevels: node.attr("htmltoclevels") || node.attr("toclevels"),
|
43
44
|
doctoclevels: node.attr("doctoclevels") || node.attr("toclevels"),
|
44
45
|
break_up_urls_in_tables: node.attr("break-up-urls-in-tables"),
|
@@ -85,9 +86,9 @@ module Asciidoctor
|
|
85
86
|
aligncrosselements: node.attr("align-cross-elements"),
|
86
87
|
}
|
87
88
|
|
88
|
-
if
|
89
|
+
if fonts_manifest = node.attr(FONTS_MANIFEST)
|
89
90
|
attrs[IsoDoc::XslfoPdfConvert::MN2PDF_OPTIONS] = {
|
90
|
-
IsoDoc::XslfoPdfConvert::MN2PDF_FONT_MANIFEST =>
|
91
|
+
IsoDoc::XslfoPdfConvert::MN2PDF_FONT_MANIFEST => fonts_manifest,
|
91
92
|
}
|
92
93
|
end
|
93
94
|
|
@@ -127,7 +128,7 @@ module Asciidoctor
|
|
127
128
|
@sourcecode_markup_end = node.attr("sourcecode-markup-end") || "}}}"
|
128
129
|
@bibdb = nil
|
129
130
|
@seen_headers = []
|
130
|
-
@datauriimage = node.attr("data-uri-image")
|
131
|
+
@datauriimage = node.attr("data-uri-image") != "false"
|
131
132
|
@boilerplateauthority = node.attr("boilerplate-authority")
|
132
133
|
@sourcecode_markup_start = node.attr("sourcecode-markup-start") || "{{{"
|
133
134
|
@sourcecode_markup_end = node.attr("sourcecode-markup-end") || "}}}"
|
@@ -9,6 +9,7 @@ require_relative "./cleanup_ref_dl"
|
|
9
9
|
require_relative "./cleanup_boilerplate"
|
10
10
|
require_relative "./cleanup_section"
|
11
11
|
require_relative "./cleanup_terms"
|
12
|
+
require_relative "./cleanup_symbols"
|
12
13
|
require_relative "./cleanup_xref"
|
13
14
|
require_relative "./cleanup_inline"
|
14
15
|
require_relative "./cleanup_amend"
|
@@ -41,6 +42,7 @@ module Asciidoctor
|
|
41
42
|
symbols_cleanup(xmldoc)
|
42
43
|
xref_cleanup(xmldoc)
|
43
44
|
concept_cleanup(xmldoc)
|
45
|
+
related_cleanup(xmldoc)
|
44
46
|
origin_cleanup(xmldoc)
|
45
47
|
bookmark_cleanup(xmldoc)
|
46
48
|
termdef_cleanup(xmldoc)
|
@@ -73,7 +75,8 @@ module Asciidoctor
|
|
73
75
|
%w{status language script version author name callout phone email
|
74
76
|
street city state country postcode identifier referenceFrom surname
|
75
77
|
referenceTo docidentifier docnumber prefix initial addition forename
|
76
|
-
title draft secretariat title-main title-intro title-part
|
78
|
+
title draft secretariat title-main title-intro title-part
|
79
|
+
verbal-definition non-verbal-representation}.freeze
|
77
80
|
|
78
81
|
# it seems Nokogiri::XML is treating the content of <script> as cdata,
|
79
82
|
# because of its use in HTML. Bad nokogiri. Undoing that, since we use
|
@@ -83,7 +86,9 @@ module Asciidoctor
|
|
83
86
|
end
|
84
87
|
|
85
88
|
def empty_element_cleanup(xmldoc)
|
86
|
-
xmldoc.xpath("
|
89
|
+
xmldoc.xpath("//#{TEXT_ELEMS.join(' | //')}").each do |x|
|
90
|
+
next if x.name == "name" && x.parent.name == "expression"
|
91
|
+
|
87
92
|
x.remove if x.children.empty?
|
88
93
|
end
|
89
94
|
end
|
@@ -108,19 +113,23 @@ module Asciidoctor
|
|
108
113
|
n.name != "variant" && (!n.text? || !n.text.gsub(/\s/, "").empty?)
|
109
114
|
end
|
110
115
|
|
111
|
-
c
|
112
|
-
if n.at_xpath("preceding-sibling::node()"\
|
113
|
-
"[not(self::text()[not(normalize-space())])][1]"\
|
114
|
-
"[self::variantwrap]")
|
115
|
-
n.previous_element << n
|
116
|
-
else
|
117
|
-
n.replace("<variantwrap/>").first << n
|
118
|
-
end
|
119
|
-
end
|
116
|
+
variant_cleanup1(c)
|
120
117
|
end
|
121
118
|
xmldoc.xpath("//variantwrap").each { |n| n.name = "variant" }
|
122
119
|
end
|
123
120
|
|
121
|
+
def variant_cleanup1(elem)
|
122
|
+
elem.xpath("./variant").each do |n|
|
123
|
+
if n.at_xpath("preceding-sibling::node()"\
|
124
|
+
"[not(self::text()[not(normalize-space())])][1]"\
|
125
|
+
"[self::variantwrap]")
|
126
|
+
n.previous_element << n
|
127
|
+
else
|
128
|
+
n.replace("<variantwrap/>").first << n
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
124
133
|
def variant_space_cleanup(xmldoc)
|
125
134
|
xmldoc.xpath("//*[variant]").each do |c|
|
126
135
|
if c&.next&.text? && c&.next&.next&.name == "variant"
|
@@ -15,15 +15,18 @@ module Asciidoctor
|
|
15
15
|
)
|
16
16
|
end
|
17
17
|
|
18
|
-
def term_defs_boilerplate(div, source, term,
|
18
|
+
def term_defs_boilerplate(div, source, term, _preface, isodoc)
|
19
19
|
a = @i18n.term_def_boilerplate and div.next = a
|
20
20
|
source.each do |s|
|
21
21
|
@anchors[s["bibitemid"]] or
|
22
22
|
@log.add("Crossreferences", nil,
|
23
23
|
"term source #{s['bibitemid']} not referenced")
|
24
24
|
end
|
25
|
-
a = source.empty? && term.nil?
|
26
|
-
|
25
|
+
a = if source.empty? && term.nil?
|
26
|
+
@i18n.no_terms_boilerplate
|
27
|
+
else
|
28
|
+
term_defs_boilerplate_cont(source, term, isodoc)
|
29
|
+
end
|
27
30
|
a and div.next = a
|
28
31
|
end
|
29
32
|
|
@@ -51,10 +54,11 @@ module Asciidoctor
|
|
51
54
|
end
|
52
55
|
|
53
56
|
TERM_CLAUSE = "//sections/terms | "\
|
54
|
-
|
57
|
+
"//sections/clause[descendant::terms]".freeze
|
55
58
|
|
56
59
|
NORM_REF = "//bibliography/references[@normative = 'true'] | "\
|
57
|
-
|
60
|
+
"//bibliography/clause[.//references[@normative = 'true']]"
|
61
|
+
.freeze
|
58
62
|
|
59
63
|
def boilerplate_isodoc(xmldoc)
|
60
64
|
x = xmldoc.dup
|
@@ -118,8 +122,11 @@ module Asciidoctor
|
|
118
122
|
|
119
123
|
def boilerplate(xml, conv)
|
120
124
|
file = boilerplate_file(xml)
|
121
|
-
|
122
|
-
|
125
|
+
if @boilerplateauthority
|
126
|
+
file = File.join(@localdir,
|
127
|
+
@boilerplateauthority)
|
128
|
+
end
|
129
|
+
(!file.nil? and File.exists?(file)) or return
|
123
130
|
conv.populate_template(File.read(file, encoding: "UTF-8"), nil)
|
124
131
|
end
|
125
132
|
|
@@ -166,28 +173,29 @@ module Asciidoctor
|
|
166
173
|
end
|
167
174
|
end
|
168
175
|
|
169
|
-
def indirect_eref_to_xref(
|
170
|
-
loc =
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
176
|
+
def indirect_eref_to_xref(eref, ident)
|
177
|
+
loc = eref&.at("./localityStack[locality[@type = 'anchor']]")
|
178
|
+
&.remove&.text ||
|
179
|
+
eref&.at("./locality[@type = 'anchor']")&.remove&.text || ident
|
180
|
+
eref.name = "xref"
|
181
|
+
eref.delete("bibitemid")
|
182
|
+
eref.delete("citeas")
|
183
|
+
eref["target"] = loc
|
184
|
+
unless eref.document.at("//*[@id = '#{loc}']")
|
185
|
+
eref.children = %(** Missing target #{loc})
|
186
|
+
eref["target"] = ident
|
179
187
|
end
|
180
188
|
end
|
181
189
|
|
182
190
|
def resolve_local_indirect_erefs(xmldoc, refs, prefix)
|
183
191
|
refs.each_with_object([]) do |r, m|
|
184
192
|
id = r.sub(/^#{prefix}_/, "")
|
185
|
-
if n = xmldoc.at("//*[@id = '#{id}']") and
|
193
|
+
if n = xmldoc.at("//*[@id = '#{id}']") and
|
194
|
+
n.at("./ancestor-or-self::*[@type = '#{prefix}']")
|
186
195
|
xmldoc.xpath("//eref[@bibitemid = '#{r}']").each do |e|
|
187
196
|
indirect_eref_to_xref(e, id)
|
188
197
|
end
|
189
|
-
else
|
190
|
-
m << r
|
198
|
+
else m << r
|
191
199
|
end
|
192
200
|
end
|
193
201
|
end
|
@@ -60,13 +60,26 @@ module Asciidoctor
|
|
60
60
|
xmldoc.xpath("//concept[not(termxref)]").each do |x|
|
61
61
|
term = x.at("./refterm")
|
62
62
|
term&.remove if term&.text&.empty?
|
63
|
-
x
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
63
|
+
concept_cleanup1(x)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def concept_cleanup1(elem)
|
68
|
+
elem.children.remove if elem&.children&.text&.strip&.empty?
|
69
|
+
key_extract_locality(elem)
|
70
|
+
if /:/.match?(elem["key"]) then concept_termbase_cleanup(elem)
|
71
|
+
elsif refid? elem["key"] then concept_eref_cleanup(elem)
|
72
|
+
else concept_xref_cleanup(elem)
|
73
|
+
end
|
74
|
+
elem.delete("key")
|
75
|
+
end
|
76
|
+
|
77
|
+
def related_cleanup(xmldoc)
|
78
|
+
xmldoc.xpath("//related[not(termxref)]").each do |x|
|
79
|
+
term = x.at("./refterm")
|
80
|
+
term.replace("<preferred>#{term_expr(term.children.to_xml)}"\
|
81
|
+
"</preferred>")
|
82
|
+
concept_cleanup1(x)
|
70
83
|
end
|
71
84
|
end
|
72
85
|
|
@@ -69,13 +69,12 @@ module Asciidoctor
|
|
69
69
|
return false if char.length > 1
|
70
70
|
|
71
71
|
if /\p{Greek}/.match?(char)
|
72
|
-
/\p{Lower}/.match(char) && !mathml_mi_italics[:lowergreek] ||
|
73
|
-
/\p{Upper}/.match(char) && !mathml_mi_italics[:uppergreek]
|
72
|
+
(/\p{Lower}/.match(char) && !mathml_mi_italics[:lowergreek]) ||
|
73
|
+
(/\p{Upper}/.match(char) && !mathml_mi_italics[:uppergreek])
|
74
74
|
elsif /\p{Latin}/.match?(char)
|
75
|
-
/\p{Lower}/.match(char) && !mathml_mi_italics[:lowerroman] ||
|
76
|
-
/\p{Upper}/.match(char) && !mathml_mi_italics[:upperroman]
|
77
|
-
else
|
78
|
-
false
|
75
|
+
(/\p{Lower}/.match(char) && !mathml_mi_italics[:lowerroman]) ||
|
76
|
+
(/\p{Upper}/.match(char) && !mathml_mi_italics[:upperroman])
|
77
|
+
else false
|
79
78
|
end
|
80
79
|
end
|
81
80
|
|
@@ -17,45 +17,53 @@ module Asciidoctor
|
|
17
17
|
|
18
18
|
def validate_ref_dl(bib, c)
|
19
19
|
id = bib["id"]
|
20
|
-
id ||= c["id"] unless /^_/.match(c["id"]) # do not accept implicit id
|
20
|
+
id ||= c["id"] unless /^_/.match?(c["id"]) # do not accept implicit id
|
21
21
|
unless id
|
22
|
-
@log.add("Anchors", c,
|
22
|
+
@log.add("Anchors", c,
|
23
|
+
"The following reference is missing an anchor:\n" + c.to_xml)
|
23
24
|
return
|
24
25
|
end
|
25
26
|
@refids << id
|
26
|
-
bib["title"] or
|
27
|
-
|
27
|
+
bib["title"] or
|
28
|
+
@log.add("Bibliography", c, "Reference #{id} is missing a title")
|
29
|
+
bib["docid"] or
|
30
|
+
@log.add("Bibliography", c,
|
31
|
+
"Reference #{id} is missing a document identifier (docid)")
|
28
32
|
end
|
29
33
|
|
30
34
|
def extract_from_p(tag, bib, key)
|
31
35
|
return unless bib[tag]
|
36
|
+
|
32
37
|
"<#{key}>#{bib[tag].at('p').children}</#{key}>"
|
33
38
|
end
|
34
39
|
|
35
40
|
# if the content is a single paragraph, replace it with its children
|
36
41
|
# single links replaced with uri
|
37
|
-
def p_unwrap(
|
38
|
-
elems =
|
42
|
+
def p_unwrap(para)
|
43
|
+
elems = para.elements
|
39
44
|
if elems.size == 1 && elems[0].name == "p"
|
40
45
|
link_unwrap(elems[0]).children.to_xml.strip
|
41
46
|
else
|
42
|
-
|
47
|
+
para.to_xml.strip
|
43
48
|
end
|
44
49
|
end
|
45
50
|
|
46
|
-
def link_unwrap(
|
47
|
-
elems =
|
51
|
+
def link_unwrap(para)
|
52
|
+
elems = para.elements
|
48
53
|
if elems.size == 1 && elems[0].name == "link"
|
49
|
-
|
54
|
+
para.at("./link").replace(elems[0]["target"].strip)
|
50
55
|
end
|
51
|
-
|
56
|
+
para
|
52
57
|
end
|
53
58
|
|
54
59
|
def dd_bib_extract(dtd)
|
55
60
|
return nil if dtd.children.empty?
|
61
|
+
|
56
62
|
dtd.at("./dl") and return dl_bib_extract(dtd)
|
57
63
|
elems = dtd.remove.elements
|
58
|
-
return p_unwrap(dtd) unless elems.size == 1 &&
|
64
|
+
return p_unwrap(dtd) unless elems.size == 1 &&
|
65
|
+
%w(ol ul).include?(elems[0].name)
|
66
|
+
|
59
67
|
ret = []
|
60
68
|
elems[0].xpath("./li").each do |li|
|
61
69
|
ret << p_unwrap(li)
|
@@ -64,7 +72,7 @@ module Asciidoctor
|
|
64
72
|
end
|
65
73
|
|
66
74
|
def add_to_hash(bib, key, val)
|
67
|
-
Metanorma::Utils::set_nested_value(bib, key.split(
|
75
|
+
Metanorma::Utils::set_nested_value(bib, key.split("."), val)
|
68
76
|
end
|
69
77
|
|
70
78
|
# definition list, with at most one level of unordered lists
|
@@ -73,14 +81,16 @@ module Asciidoctor
|
|
73
81
|
bib = {}
|
74
82
|
key = ""
|
75
83
|
dl.xpath("./dt | ./dd").each do |dtd|
|
76
|
-
dtd.name == "dt" and key = dtd.text.sub(/:+$/, "") or
|
84
|
+
(dtd.name == "dt" and key = dtd.text.sub(/:+$/, "")) or
|
85
|
+
add_to_hash(bib, key, dd_bib_extract(dtd))
|
77
86
|
end
|
78
87
|
c.xpath("./clause").each do |c1|
|
79
88
|
key = c1&.at("./title")&.text&.downcase&.strip
|
80
89
|
next unless %w(contributor relation series).include? key
|
90
|
+
|
81
91
|
add_to_hash(bib, key, dl_bib_extract(c1, true))
|
82
92
|
end
|
83
|
-
if !nested
|
93
|
+
if !nested && c.at("./title")
|
84
94
|
title = c.at("./title").remove.children.to_xml
|
85
95
|
bib["title"] = [bib["title"]] if bib["title"].is_a? Hash
|
86
96
|
bib["title"] = [bib["title"]] if bib["title"].is_a? String
|
@@ -86,33 +86,14 @@ module Asciidoctor
|
|
86
86
|
ins = reqt.children.first
|
87
87
|
end
|
88
88
|
%w(obligation model type).each do |a|
|
89
|
-
|
89
|
+
dl_to_attrs(reqt, dlist, a)
|
90
90
|
end
|
91
91
|
requirement_metadata1_tags.each do |a|
|
92
|
-
ins =
|
92
|
+
ins = dl_to_elems(ins, reqt, dlist, a)
|
93
93
|
end
|
94
94
|
reqt_dl_to_classif(ins, reqt, dlist)
|
95
95
|
end
|
96
96
|
|
97
|
-
def reqt_dl_to_attrs(reqt, dlist, name)
|
98
|
-
e = dlist.at("./dt[text()='#{name}']") or return
|
99
|
-
val = e.at("./following::dd/p") || e.at("./following::dd") or return
|
100
|
-
reqt[name] = val.text
|
101
|
-
end
|
102
|
-
|
103
|
-
def reqt_dl_to_elems(ins, reqt, dlist, name)
|
104
|
-
if a = reqt.at("./#{name}[last()]")
|
105
|
-
ins = a
|
106
|
-
end
|
107
|
-
dlist.xpath("./dt[text()='#{name}']").each do |e|
|
108
|
-
val = e.at("./following::dd/p") || e.at("./following::dd")
|
109
|
-
val.name = name
|
110
|
-
ins.next = val
|
111
|
-
ins = ins.next
|
112
|
-
end
|
113
|
-
ins
|
114
|
-
end
|
115
|
-
|
116
97
|
def reqt_dl_to_classif(ins, reqt, dlist)
|
117
98
|
if a = reqt.at("./classification[last()]") then ins = a end
|
118
99
|
dlist.xpath("./dt[text()='classification']").each do |e|
|
@@ -21,7 +21,7 @@ module Asciidoctor
|
|
21
21
|
title = get_or_make_title(node)
|
22
22
|
fn = title.xpath("./fn")
|
23
23
|
fn.each(&:remove)
|
24
|
-
title.
|
24
|
+
title.children = text
|
25
25
|
fn.each { |n| title << n }
|
26
26
|
end
|
27
27
|
end
|
@@ -82,7 +82,7 @@ module Asciidoctor
|
|
82
82
|
p.delete("id")
|
83
83
|
p.delete("variant_title")
|
84
84
|
p.xpath("(#{path})[last()]").each do |sect|
|
85
|
-
ins = sect.at("./title") and ins.next = p or
|
85
|
+
(ins = sect.at("./title") and ins.next = p) or
|
86
86
|
sect.children.first.previous = p
|
87
87
|
end
|
88
88
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Asciidoctor
|
2
|
+
module Standoc
|
3
|
+
module Cleanup
|
4
|
+
# Indices sort after letter but before any following
|
5
|
+
# letter (x, x_m, x_1, xa); we use colon to force that sort order.
|
6
|
+
# Numbers sort *after* letters; we use thorn to force that sort order.
|
7
|
+
def symbol_key(sym)
|
8
|
+
key = sym.dup
|
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
|
+
HTMLEntities.new.decode(ret.text.downcase)
|
15
|
+
.gsub(/[\[\]{}<>()]/, "").gsub(/\s/m, "")
|
16
|
+
.gsub(/[[:punct:]]|[_^]/, ":\\0").gsub(/`/, "")
|
17
|
+
.gsub(/[0-9]+/, "þ\\0")
|
18
|
+
end
|
19
|
+
|
20
|
+
def grkletters(text)
|
21
|
+
text.gsub(/\b(alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|
|
22
|
+
lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|
|
23
|
+
psi|omega)\b/xi, "&\\1;")
|
24
|
+
end
|
25
|
+
|
26
|
+
def extract_symbols_list(dlist)
|
27
|
+
dl_out = []
|
28
|
+
dlist.xpath("./dt | ./dd").each do |dtd|
|
29
|
+
if dtd.name == "dt"
|
30
|
+
dl_out << { dt: dtd.remove, key: symbol_key(dtd) }
|
31
|
+
else
|
32
|
+
dl_out.last[:dd] = dtd.remove
|
33
|
+
end
|
34
|
+
end
|
35
|
+
dl_out
|
36
|
+
end
|
37
|
+
|
38
|
+
def symbols_cleanup(docxml)
|
39
|
+
docxml.xpath("//definitions/dl").each do |dl|
|
40
|
+
dl_out = extract_symbols_list(dl)
|
41
|
+
dl_out.sort! { |a, b| a[:key] <=> b[:key] || a[:dt] <=> b[:dt] }
|
42
|
+
dl.children = dl_out.map { |d| d[:dt].to_s + d[:dd].to_s }.join("\n")
|
43
|
+
end
|
44
|
+
docxml
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|