metanorma-standoc 1.5.3 → 1.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +66 -0
- data/README.adoc +1 -3
- data/lib/asciidoctor/standoc/base.rb +6 -1
- data/lib/asciidoctor/standoc/basicdoc.rng +4 -11
- data/lib/asciidoctor/standoc/cleanup.rb +78 -12
- data/lib/asciidoctor/standoc/cleanup_block.rb +41 -4
- data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +14 -0
- data/lib/asciidoctor/standoc/cleanup_footnotes.rb +25 -0
- data/lib/asciidoctor/standoc/cleanup_inline.rb +6 -2
- data/lib/asciidoctor/standoc/cleanup_ref.rb +3 -4
- data/lib/asciidoctor/standoc/converter.rb +58 -3
- data/lib/asciidoctor/standoc/front.rb +9 -3
- data/lib/asciidoctor/standoc/front_contributor.rb +43 -11
- data/lib/asciidoctor/standoc/inline.rb +18 -40
- data/lib/asciidoctor/standoc/isodoc.rng +27 -50
- data/lib/asciidoctor/standoc/lists.rb +4 -2
- data/lib/asciidoctor/standoc/macros.rb +28 -2
- data/lib/asciidoctor/standoc/ref.rb +46 -48
- data/lib/asciidoctor/standoc/ref_sect.rb +16 -8
- data/lib/asciidoctor/standoc/section.rb +5 -9
- data/lib/liquid/custom_blocks/with_json_nested_context.rb +18 -0
- data/lib/liquid/custom_blocks/with_yaml_nested_context.rb +19 -0
- data/lib/metanorma/standoc.rb +0 -5
- data/lib/metanorma/standoc/version.rb +20 -1
- data/metanorma-standoc.gemspec +7 -3
- data/spec/asciidoctor-standoc/base_spec.rb +246 -9
- data/spec/asciidoctor-standoc/blocks_spec.rb +1 -1
- data/spec/asciidoctor-standoc/cleanup_sections_spec.rb +1514 -0
- data/spec/asciidoctor-standoc/cleanup_spec.rb +384 -1547
- data/spec/asciidoctor-standoc/inline_spec.rb +128 -4
- data/spec/asciidoctor-standoc/isobib_cache_spec.rb +15 -22
- data/spec/asciidoctor-standoc/lists_spec.rb +10 -1
- data/spec/asciidoctor-standoc/macros_json2text_spec.rb +1 -1
- data/spec/asciidoctor-standoc/macros_lutaml_spec.rb +80 -0
- data/spec/asciidoctor-standoc/macros_spec.rb +258 -0
- data/spec/asciidoctor-standoc/macros_yaml2text_spec.rb +1 -1
- data/spec/asciidoctor-standoc/refs_dl_spec.rb +8 -8
- data/spec/asciidoctor-standoc/refs_spec.rb +362 -104
- data/spec/asciidoctor-standoc/validate_spec.rb +26 -0
- data/spec/fixtures/diagram_definitions.lutaml +22 -0
- data/spec/fixtures/test.exp +121 -0
- data/spec/spec_helper.rb +34 -1
- data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +201 -3
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +47 -231
- data/spec/vcr_cassettes/isobib_get_123.yml +14 -60
- data/spec/vcr_cassettes/isobib_get_123_1.yml +24 -116
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +361 -0
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +14 -60
- data/spec/vcr_cassettes/isobib_get_124.yml +12 -58
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +8 -8
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +292 -162
- metadata +59 -17
- data/.github/workflows/macos.yml +0 -46
- data/.github/workflows/ubuntu.yml +0 -49
- data/.github/workflows/windows.yml +0 -53
- data/lib/asciidoctor/standoc/base_structured_text_preprocessor.rb +0 -123
- data/lib/asciidoctor/standoc/json2_text_preprocessor.rb +0 -43
- data/lib/asciidoctor/standoc/yaml2_text_preprocessor.rb +0 -43
- data/lib/metanorma/standoc/latexml_requirement.rb +0 -62
- data/lib/metanorma/standoc/requirement.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e30bd97d527914e60d6dfcd537620ba7d2d5ae82d9d9c07e24d5a535dd9ec8ee
|
4
|
+
data.tar.gz: b8774965fcb7e698288f1793460fd67b982085e8d0951b35cfa6c4f102157e9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74e250a48b25dd82c3174b78b515e57fe11bc3f4f8767d6942048bb3ef01ddf6937a6c2ff24ddb5e17d8f747eeb582b77248b28bdf50bc120a3fcfafd6f78221
|
7
|
+
data.tar.gz: a0fe35b39a730d18afe1cc7463b166377adb2137c4cfd9c650844e3a593e1a2312fa8242a8991a1508aaed44b7b7525a54cad7f747a177ea2848b27720cf644d
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
|
+
name: rake
|
4
|
+
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
branches: [ master, main ]
|
8
|
+
tags: [ v* ]
|
9
|
+
pull_request:
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
rake:
|
13
|
+
name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
|
14
|
+
runs-on: ${{ matrix.os }}
|
15
|
+
continue-on-error: ${{ matrix.experimental }}
|
16
|
+
strategy:
|
17
|
+
fail-fast: false
|
18
|
+
matrix:
|
19
|
+
ruby: [ '2.6', '2.5', '2.4' ]
|
20
|
+
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
21
|
+
experimental: [ false ]
|
22
|
+
include:
|
23
|
+
- ruby: '2.7'
|
24
|
+
os: 'ubuntu-latest'
|
25
|
+
experimental: true
|
26
|
+
- ruby: '2.7'
|
27
|
+
os: 'windows-latest'
|
28
|
+
experimental: true
|
29
|
+
- ruby: '2.7'
|
30
|
+
os: 'macos-latest'
|
31
|
+
experimental: true
|
32
|
+
steps:
|
33
|
+
- uses: actions/checkout@master
|
34
|
+
|
35
|
+
- uses: ruby/setup-ruby@v1
|
36
|
+
with:
|
37
|
+
ruby-version: ${{ matrix.ruby }}
|
38
|
+
|
39
|
+
- uses: actions/cache@v2
|
40
|
+
with:
|
41
|
+
path: vendor/bundle
|
42
|
+
key: bundle-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}
|
43
|
+
restore-keys: bundle-${{ matrix.os }}-${{ matrix.ruby }}
|
44
|
+
|
45
|
+
- run: bundle config set path 'vendor/bundle'
|
46
|
+
|
47
|
+
- run: bundle install --jobs 4 --retry 3
|
48
|
+
|
49
|
+
- name: install plantuml ubuntu
|
50
|
+
if: matrix.os == 'ubuntu-latest'
|
51
|
+
uses: nick-invision/retry@v1
|
52
|
+
with:
|
53
|
+
polling_interval_seconds: 5
|
54
|
+
timeout_minutes: 5
|
55
|
+
max_attempts: 3
|
56
|
+
command: >
|
57
|
+
sudo apt-get update -y && sudo bash -c
|
58
|
+
"curl -L https://github.com/metanorma/plantuml-install/raw/master/ubuntu.sh | bash"
|
59
|
+
|
60
|
+
- if: matrix.os == 'macos-latest'
|
61
|
+
run: brew install plantuml
|
62
|
+
|
63
|
+
- if: matrix.os == 'windows-latest'
|
64
|
+
run: cinst -y plantuml
|
65
|
+
|
66
|
+
- run: bundle exec rake
|
data/README.adoc
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
= Metanorma-standoc
|
2
2
|
|
3
3
|
image:https://img.shields.io/gem/v/metanorma-standoc.svg["Gem Version", link="https://rubygems.org/gems/metanorma-standoc"]
|
4
|
-
image:https://github.com/metanorma/metanorma-standoc/workflows/
|
5
|
-
image:https://github.com/metanorma/metanorma-standoc/workflows/ubuntu/badge.svg["Build Status (ubuntu)", link="https://github.com/metanorma/metanorma-standoc/actions?workflow=ubuntu"]
|
6
|
-
image:https://github.com/metanorma/metanorma-standoc/workflows/windows/badge.svg["Build Status (Windows)", link="https://github.com/metanorma/metanorma-standoc/actions?workflow=windows"]
|
4
|
+
image:https://github.com/metanorma/metanorma-standoc/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/metanorma-standoc/actions?workflow=rake"]
|
7
5
|
image:https://codeclimate.com/github/metanorma/metanorma-standoc/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/metanorma-standoc"]
|
8
6
|
image:https://img.shields.io/github/issues-pr-raw/metanorma/metanorma-standoc.svg["Pull Requests", link="https://github.com/metanorma/metanorma-standoc/pulls"]
|
9
7
|
image:https://img.shields.io/github/commits-since/metanorma/metanorma-standoc/latest.svg["Commits since latest",link="https://github.com/metanorma/metanorma-standoc/releases"]
|
@@ -143,6 +143,11 @@ module Asciidoctor
|
|
143
143
|
ret
|
144
144
|
end
|
145
145
|
|
146
|
+
def version
|
147
|
+
flavour = self.class.name.sub(/::Converter$/, "").sub(/^.+::/, "")
|
148
|
+
Metanorma.versioned(Metanorma, flavour)[-1]::VERSION
|
149
|
+
end
|
150
|
+
|
146
151
|
def clean_exit
|
147
152
|
@log.write(@output_dir + @filename + ".err") unless @novalid
|
148
153
|
@files_to_delete.each { |f| FileUtils.rm f }
|
@@ -150,7 +155,7 @@ module Asciidoctor
|
|
150
155
|
|
151
156
|
def makexml1(node)
|
152
157
|
result = ["<?xml version='1.0' encoding='UTF-8'?>",
|
153
|
-
"<#{xml_root_tag}>"]
|
158
|
+
"<#{xml_root_tag} type='semantic' version='#{version}'>"]
|
154
159
|
result << noko { |ixml| front node, ixml }
|
155
160
|
result << noko { |ixml| middle node, ixml }
|
156
161
|
result << "</#{xml_root_tag}>"
|
@@ -158,17 +158,7 @@
|
|
158
158
|
<data type="ID"/>
|
159
159
|
</attribute>
|
160
160
|
<oneOrMore>
|
161
|
-
<
|
162
|
-
<ref name="formula"/>
|
163
|
-
<ref name="ul"/>
|
164
|
-
<ref name="ol"/>
|
165
|
-
<ref name="dl"/>
|
166
|
-
<ref name="quote"/>
|
167
|
-
<ref name="sourcecode"/>
|
168
|
-
<ref name="paragraph"/>
|
169
|
-
<ref name="table"/>
|
170
|
-
<ref name="figure"/>
|
171
|
-
</choice>
|
161
|
+
<ref name="paragraph"/>
|
172
162
|
</oneOrMore>
|
173
163
|
</element>
|
174
164
|
</define>
|
@@ -1028,6 +1018,9 @@
|
|
1028
1018
|
<value>alphabet_upper</value>
|
1029
1019
|
</choice>
|
1030
1020
|
</attribute>
|
1021
|
+
<optional>
|
1022
|
+
<attribute name="start"/>
|
1023
|
+
</optional>
|
1031
1024
|
<oneOrMore>
|
1032
1025
|
<ref name="li"/>
|
1033
1026
|
</oneOrMore>
|
@@ -69,6 +69,7 @@ module Asciidoctor
|
|
69
69
|
bibdata_cleanup(xmldoc)
|
70
70
|
boilerplate_cleanup(xmldoc)
|
71
71
|
smartquotes_cleanup(xmldoc)
|
72
|
+
variant_cleanup(xmldoc)
|
72
73
|
para_cleanup(xmldoc)
|
73
74
|
empty_element_cleanup(xmldoc)
|
74
75
|
img_cleanup(xmldoc)
|
@@ -81,12 +82,13 @@ module Asciidoctor
|
|
81
82
|
xmldoc.traverse do |n|
|
82
83
|
next unless n.text?
|
83
84
|
if @smartquotes
|
84
|
-
|
85
|
-
|
86
|
-
|
85
|
+
/[-'"(<>]|\.\.|\dx/.match(n) or next
|
86
|
+
n.ancestors("pre, tt, sourcecode, bibdata, on, "\
|
87
|
+
"stem, figure[@class = 'pseudocode']").empty? or next
|
87
88
|
n.replace(Utils::smartformat(n.text))
|
88
89
|
else
|
89
|
-
n.replace(n.text.gsub(/(?<=\p{Alnum})\u2019(?=\p{Alpha})/, "'"))
|
90
|
+
n.replace(n.text.gsub(/(?<=\p{Alnum})\u2019(?=\p{Alpha})/, "'"))#.
|
91
|
+
#gsub(/</, "<").gsub(/>/, ">"))
|
90
92
|
end
|
91
93
|
end
|
92
94
|
end
|
@@ -146,16 +148,59 @@ module Asciidoctor
|
|
146
148
|
align_callouts_to_annotations(xmldoc)
|
147
149
|
end
|
148
150
|
|
151
|
+
def xml_unescape_mathml(x)
|
152
|
+
return if x.children.any? { |y| y.element? }
|
153
|
+
math = x.text.gsub(/</, "<").gsub(/>/, ">").gsub(/"/, '"').
|
154
|
+
gsub(/'/, "'").gsub(/&/, "&").
|
155
|
+
gsub(/<[^: \r\n\t\/]+:/, "<").gsub(/<\/[^ \r\n\t:]+:/, "</")
|
156
|
+
x.children = math
|
157
|
+
end
|
158
|
+
|
159
|
+
MATHML_NS = "http://www.w3.org/1998/Math/MathML".freeze
|
160
|
+
|
161
|
+
def mathml_preserve_space(m)
|
162
|
+
m.xpath(".//m:mtext", "m" => MATHML_NS).each do |x|
|
163
|
+
x.children = x.children.to_xml.gsub(/^\s/, " ").
|
164
|
+
gsub(/\s$/, " ")
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def mathml_namespace(stem)
|
169
|
+
stem.xpath("./math", ).each { |x| x.default_namespace = MATHML_NS }
|
170
|
+
end
|
171
|
+
|
172
|
+
def mathml_mi_italics
|
173
|
+
{ uppergreek: true, upperroman: true,
|
174
|
+
lowergreek: true, lowerroman: true }
|
175
|
+
end
|
176
|
+
|
177
|
+
# presuppose multichar mi upright, singlechar mi MathML default italic
|
178
|
+
def mathml_italicise(x)
|
179
|
+
x.xpath(".//m:mi", "m" => MATHML_NS).each do |i|
|
180
|
+
char = HTMLEntities.new.decode(i.text)
|
181
|
+
i["mathvariant"] = "normal" if mi_italicise?(char)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
def mi_italicise?(c)
|
186
|
+
return false if c.length > 1
|
187
|
+
if /\p{Greek}/.match(c)
|
188
|
+
/\p{Lower}/.match(c) && !mathml_mi_italics[:lowergreek] ||
|
189
|
+
/\p{Upper}/.match(c) && !mathml_mi_italics[:uppergreek]
|
190
|
+
elsif /\p{Latin}/.match(c)
|
191
|
+
/\p{Lower}/.match(c) && !mathml_mi_italics[:lowerroman] ||
|
192
|
+
/\p{Upper}/.match(c) && !mathml_mi_italics[:upperroman]
|
193
|
+
else
|
194
|
+
false
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
149
198
|
def mathml_cleanup(xmldoc)
|
150
199
|
xmldoc.xpath("//stem[@type = 'MathML']").each do |x|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
gsub(/ xmlns[^>"']+/, "").
|
156
|
-
gsub(/<math /, '<math xmlns="http://www.w3.org/1998/Math/MathML" ').
|
157
|
-
gsub(/<math>/, '<math xmlns="http://www.w3.org/1998/Math/MathML">')
|
158
|
-
x.children = math
|
200
|
+
xml_unescape_mathml(x)
|
201
|
+
mathml_namespace(x)
|
202
|
+
mathml_preserve_space(x)
|
203
|
+
mathml_italicise(x)
|
159
204
|
end
|
160
205
|
end
|
161
206
|
|
@@ -174,6 +219,27 @@ module Asciidoctor
|
|
174
219
|
i["src"] = datauri(i["src"])
|
175
220
|
end
|
176
221
|
end
|
222
|
+
|
223
|
+
def variant_cleanup(xmldoc)
|
224
|
+
xmldoc.xpath("//*[variant]").each do |c|
|
225
|
+
c&.next&.text? && c&.next&.next&.name == "variant" &&
|
226
|
+
c.next.text.gsub(/\s/, "").empty? and c.next.remove
|
227
|
+
end
|
228
|
+
xmldoc.xpath("//*[variant]").each do |c|
|
229
|
+
next unless c.children.any? do |n|
|
230
|
+
n.name != "variant" && (!n.text? || !n.text.gsub(/\s/, "").empty?)
|
231
|
+
end
|
232
|
+
c.xpath("./variant").each do |n|
|
233
|
+
if n.at_xpath('preceding-sibling::node()[not(self::text()'\
|
234
|
+
'[not(normalize-space())])][1][self::variantwrap]')
|
235
|
+
n.previous_element << n
|
236
|
+
else
|
237
|
+
n.replace('<variantwrap/>').first << n
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
xmldoc.xpath("//variantwrap").each { |n| n.name = "variant" }
|
242
|
+
end
|
177
243
|
end
|
178
244
|
end
|
179
245
|
end
|
@@ -19,12 +19,22 @@ module Asciidoctor
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
def dl1_table_cleanup(xmldoc)
|
23
|
+
q = "//table/following-sibling::*[1][self::dl]"
|
24
|
+
xmldoc.xpath(q).each do |s|
|
25
|
+
if s["key"] == "true"
|
26
|
+
s.previous_element << s.remove
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
22
31
|
# move Key dl after table footer
|
23
|
-
def
|
32
|
+
def dl2_table_cleanup(xmldoc)
|
24
33
|
q = "//table/following-sibling::*[1][self::p]"
|
25
34
|
xmldoc.xpath(q).each do |s|
|
26
35
|
if s.text =~ /^\s*key[^a-z]*$/i && !s.next_element.nil? &&
|
27
36
|
s.next_element.name == "dl"
|
37
|
+
s.next_element["key"] = "true"
|
28
38
|
s.previous_element << s.next_element.remove
|
29
39
|
s.remove
|
30
40
|
end
|
@@ -54,7 +64,8 @@ module Asciidoctor
|
|
54
64
|
end
|
55
65
|
|
56
66
|
def table_cleanup(xmldoc)
|
57
|
-
|
67
|
+
dl1_table_cleanup(xmldoc)
|
68
|
+
dl2_table_cleanup(xmldoc)
|
58
69
|
notes_table_cleanup(xmldoc)
|
59
70
|
header_rows_cleanup(xmldoc)
|
60
71
|
end
|
@@ -74,22 +85,47 @@ module Asciidoctor
|
|
74
85
|
|
75
86
|
# include where definition list inside stem block
|
76
87
|
def formula_cleanup(x)
|
88
|
+
formula_cleanup_where1(x)
|
89
|
+
formula_cleanup_where2(x)
|
90
|
+
end
|
91
|
+
|
92
|
+
def formula_cleanup_where1(x)
|
93
|
+
q = "//formula/following-sibling::*[1][self::dl]"
|
94
|
+
x.xpath(q).each do |s|
|
95
|
+
if s["key"] == "true"
|
96
|
+
s.previous_element << s.remove
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def formula_cleanup_where2(x)
|
77
102
|
q = "//formula/following-sibling::*[1][self::p]"
|
78
103
|
x.xpath(q).each do |s|
|
79
104
|
if s.text =~ /^\s*where[^a-z]*$/i && !s.next_element.nil? &&
|
80
105
|
s.next_element.name == "dl"
|
106
|
+
s.next_element["key"] = "true"
|
81
107
|
s.previous_element << s.next_element.remove
|
82
108
|
s.remove
|
83
109
|
end
|
84
110
|
end
|
85
111
|
end
|
86
112
|
|
113
|
+
def figure_dl_cleanup1(xmldoc)
|
114
|
+
q = "//figure/following-sibling::*[self::dl]"
|
115
|
+
xmldoc.xpath(q).each do |s|
|
116
|
+
if s["key"] == "true"
|
117
|
+
s.previous_element << s.remove
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
87
122
|
# include key definition list inside figure
|
88
|
-
def
|
123
|
+
def figure_dl_cleanup2(xmldoc)
|
89
124
|
q = "//figure/following-sibling::*[self::p]"
|
90
125
|
xmldoc.xpath(q).each do |s|
|
91
126
|
if s.text =~ /^\s*key[^a-z]*$/i && !s.next_element.nil? &&
|
92
127
|
s.next_element.name == "dl"
|
128
|
+
s.next_element["key"] = "true"
|
93
129
|
s.previous_element << s.next_element.remove
|
94
130
|
s.remove
|
95
131
|
end
|
@@ -115,7 +151,8 @@ module Asciidoctor
|
|
115
151
|
|
116
152
|
def figure_cleanup(xmldoc)
|
117
153
|
figure_footnote_cleanup(xmldoc)
|
118
|
-
|
154
|
+
figure_dl_cleanup1(xmldoc)
|
155
|
+
figure_dl_cleanup2(xmldoc)
|
119
156
|
subfigure_cleanup(xmldoc)
|
120
157
|
end
|
121
158
|
|
@@ -91,10 +91,24 @@ module Asciidoctor
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def bibdata_cleanup(xmldoc)
|
94
|
+
bibdata_anchor_cleanup(xmldoc)
|
95
|
+
bibdata_docidentifier_cleanup(xmldoc)
|
96
|
+
end
|
97
|
+
|
98
|
+
def bibdata_anchor_cleanup(xmldoc)
|
94
99
|
xmldoc.xpath("//bibdata//bibitem | //bibdata//note").each do |b|
|
95
100
|
b.delete("id")
|
96
101
|
end
|
97
102
|
end
|
103
|
+
|
104
|
+
def bibdata_docidentifier_cleanup(xmldoc)
|
105
|
+
ins = xmldoc.at("//bibdata/docidentifier")
|
106
|
+
xmldoc.xpath("//bibdata/docidentifier").each_with_index do |b, i|
|
107
|
+
next if i == 0
|
108
|
+
ins.next = b.remove
|
109
|
+
ins = ins.next
|
110
|
+
end
|
111
|
+
end
|
98
112
|
end
|
99
113
|
end
|
100
114
|
end
|
@@ -72,7 +72,32 @@ module Asciidoctor
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
+
def title_footnote_move(xmldoc)
|
76
|
+
ins = xmldoc.at("//bibdata/language")
|
77
|
+
xmldoc.xpath("//bibdata/title//fn").each do |f|
|
78
|
+
f.name = "note"
|
79
|
+
f["type"] = "title-footnote"
|
80
|
+
f.delete("reference")
|
81
|
+
ins.previous = f.remove
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def footnote_block_cleanup(xmldoc)
|
86
|
+
xmldoc.xpath("//footnoteblock").each do |f|
|
87
|
+
f.name = 'fn'
|
88
|
+
if id = xmldoc.at("//*[@id = '#{f.text}']")
|
89
|
+
f.children = id.remove.children
|
90
|
+
else
|
91
|
+
@log.add("Crossreferences", f,
|
92
|
+
"Could not resolve footnoteblock:[#{f.text}]")
|
93
|
+
f.children = "[ERROR]"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
75
98
|
def footnote_cleanup(xmldoc)
|
99
|
+
footnote_block_cleanup(xmldoc)
|
100
|
+
title_footnote_move(xmldoc)
|
76
101
|
table_footnote_renumber(xmldoc)
|
77
102
|
other_footnote_renumber(xmldoc)
|
78
103
|
xmldoc.xpath("//fn").each do |fn|
|
@@ -49,8 +49,12 @@ module Asciidoctor
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def extract_localities(x)
|
52
|
-
|
53
|
-
|
52
|
+
f = x&.children&.first or return
|
53
|
+
f.text? or return
|
54
|
+
head = f.remove.text
|
55
|
+
tail = x&.children&.remove
|
56
|
+
extract_localities1(x, head)
|
57
|
+
tail and x << tail
|
54
58
|
end
|
55
59
|
|
56
60
|
def extract_localities1(x, text)
|
@@ -49,9 +49,8 @@ module Asciidoctor
|
|
49
49
|
# consecutively, but that standards codes are preserved as is:
|
50
50
|
# only numeric references are renumbered
|
51
51
|
def biblio_renumber(xmldoc)
|
52
|
-
r = xmldoc.at("//references
|
53
|
-
"//
|
54
|
-
"//annex[.//references[@normative = 'false']]") or return
|
52
|
+
r = xmldoc.at("//references | //clause[.//references] | "\
|
53
|
+
"//annex[.//references]") or return
|
55
54
|
r.xpath(".//bibitem[not(ancestor::bibitem)]").each_with_index do |b, i|
|
56
55
|
next unless docid = b.at("./docidentifier[@type = 'metanorma']")
|
57
56
|
next unless /^\[\d+\]$/.match(docid.text)
|
@@ -127,7 +126,7 @@ module Asciidoctor
|
|
127
126
|
bibitemxml = RelatonBib::BibliographicItem.new(
|
128
127
|
RelatonBib::HashConverter::hash_to_bib(bib)).to_xml or next
|
129
128
|
bibitem = Nokogiri::XML(bibitemxml)
|
130
|
-
bibitem["id"] = c["id"] if c["id"]
|
129
|
+
bibitem.root["id"] = c["id"] if c["id"] && !/^_/.match(c["id"])
|
131
130
|
c.replace(bibitem.root)
|
132
131
|
end
|
133
132
|
end
|