metanorma-standoc 1.4.4 → 1.6.0
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 +4 -9
- data/.github/workflows/ubuntu.yml +1 -5
- data/.github/workflows/windows.yml +2 -12
- data/.rubocop.yml +1 -1
- data/lib/asciidoctor/standoc/base.rb +11 -5
- data/lib/asciidoctor/standoc/base_structured_text_preprocessor.rb +123 -0
- data/lib/asciidoctor/standoc/basicdoc.rng +23 -0
- data/lib/asciidoctor/standoc/cleanup.rb +32 -12
- data/lib/asciidoctor/standoc/cleanup_amend.rb +54 -0
- data/lib/asciidoctor/standoc/cleanup_block.rb +0 -2
- data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +11 -24
- data/lib/asciidoctor/standoc/cleanup_footnotes.rb +0 -3
- data/lib/asciidoctor/standoc/cleanup_inline.rb +62 -1
- data/lib/asciidoctor/standoc/cleanup_ref.rb +10 -7
- data/lib/asciidoctor/standoc/cleanup_section.rb +91 -8
- data/lib/asciidoctor/standoc/cleanup_terms.rb +12 -2
- data/lib/asciidoctor/standoc/converter.rb +3 -3
- data/lib/asciidoctor/standoc/front.rb +0 -12
- data/lib/asciidoctor/standoc/front_contributor.rb +51 -10
- data/lib/asciidoctor/standoc/inline.rb +21 -31
- data/lib/asciidoctor/standoc/isodoc.rng +137 -21
- data/lib/asciidoctor/standoc/json2_text_preprocessor.rb +44 -0
- data/lib/asciidoctor/standoc/log.rb +10 -1
- data/lib/asciidoctor/standoc/macros.rb +45 -33
- data/lib/asciidoctor/standoc/ref.rb +45 -45
- data/lib/asciidoctor/standoc/section.rb +39 -30
- data/lib/asciidoctor/standoc/table.rb +3 -2
- data/lib/asciidoctor/standoc/utils.rb +18 -1
- data/lib/asciidoctor/standoc/validate.rb +30 -18
- data/lib/asciidoctor/standoc/validate_section.rb +1 -1
- data/lib/asciidoctor/standoc/views/datamodel/model_representation.adoc.erb +10 -10
- data/lib/asciidoctor/standoc/yaml2_text_preprocessor.rb +46 -0
- data/lib/liquid/custom_blocks/key_iterator.rb +21 -0
- data/lib/liquid/custom_filters/values.rb +7 -0
- data/lib/metanorma/standoc.rb +0 -5
- data/lib/metanorma/standoc/version.rb +20 -1
- data/metanorma-standoc.gemspec +4 -5
- data/spec/asciidoctor-standoc/base_spec.rb +140 -7
- data/spec/asciidoctor-standoc/blocks_spec.rb +275 -149
- data/spec/asciidoctor-standoc/cleanup_spec.rb +1372 -56
- data/spec/asciidoctor-standoc/inline_spec.rb +133 -6
- data/spec/asciidoctor-standoc/isobib_cache_spec.rb +9 -7
- data/spec/asciidoctor-standoc/macros_json2text_spec.rb +10 -0
- data/spec/asciidoctor-standoc/macros_spec.rb +43 -23
- data/spec/asciidoctor-standoc/macros_yaml2text_spec.rb +5 -560
- data/spec/asciidoctor-standoc/refs_dl_spec.rb +9 -7
- data/spec/asciidoctor-standoc/refs_spec.rb +43 -34
- data/spec/asciidoctor-standoc/section_spec.rb +42 -39
- data/spec/asciidoctor-standoc/table_spec.rb +119 -113
- data/spec/asciidoctor-standoc/validate_spec.rb +45 -1
- data/spec/assets/i18n.yaml +17 -2
- data/spec/examples/codes_table.html +1365 -1365
- data/spec/fixtures/macros_datamodel/address_class_profile.xml +46 -46
- data/spec/fixtures/macros_datamodel/address_component_profile.xml +21 -21
- data/spec/fixtures/macros_datamodel/blank_definition_profile.xml +21 -21
- data/spec/metanorma/processor_spec.rb +1 -2
- data/spec/spec_helper.rb +110 -109
- data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +629 -0
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +71 -71
- data/spec/vcr_cassettes/isobib_get_123.yml +16 -16
- data/spec/vcr_cassettes/isobib_get_123_1.yml +36 -36
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +16 -16
- data/spec/vcr_cassettes/isobib_get_124.yml +17 -17
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +8 -8
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +39 -37
- metadata +29 -14
- data/lib/asciidoctor-yaml/i18n-en.yaml +0 -20
- data/lib/asciidoctor-yaml/i18n-fr.yaml +0 -13
- data/lib/asciidoctor-yaml/i18n-zh-Hans.yaml +0 -15
- data/lib/asciidoctor/standoc/i18n.rb +0 -39
- data/lib/asciidoctor/standoc/macros_yaml2text.rb +0 -165
- 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: 0a619338025bf24d56d382fde0bfcd3d7c5f2e5ecf5520d995d8c7d4986cb67d
|
4
|
+
data.tar.gz: 1f8c10a80a5ada1b94c6216568eb11851fd081c9ae63bae2d8b9e3e080673b17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d9fea4687d265c36099b30faa69893c10ec011e7d1a8b7e32b4e0df4ef9d892e5efe90bb8bd0767f51f3ec74f91b05dc3613532eeff247f1a2039b6094f15dc
|
7
|
+
data.tar.gz: 2ccb181da62a4ca659c2f3915ffdbebbc88b501c97938244d65d780b241e05bd2f61870ac32cc8a3cef739ac7a36b8c714f2cc5027d9269e78c7e6f6bcabb12c
|
data/.github/workflows/macos.yml
CHANGED
@@ -29,18 +29,13 @@ jobs:
|
|
29
29
|
uses: actions/setup-ruby@v1
|
30
30
|
with:
|
31
31
|
ruby-version: ${{ matrix.ruby }}
|
32
|
-
- name: Install LaTeXML
|
33
|
-
run: |
|
34
|
-
brew install libxml2 cpanminus
|
35
|
-
env PATH=$(brew --prefix libxml2)/bin:$PATH \
|
36
|
-
cpanm --notest XML::LibXSLT@1.96 git://github.com/brucemiller/LaTeXML.git@9a0e7dc5
|
37
|
-
- name: Install PlantUML
|
38
|
-
run: |
|
39
|
-
brew install plantuml
|
40
32
|
- name: Update gems
|
41
33
|
run: |
|
42
34
|
sudo gem install bundler --force
|
43
35
|
bundle install --jobs 4 --retry 3
|
36
|
+
- name: Install PlantUML
|
37
|
+
run: |
|
38
|
+
brew install plantuml
|
44
39
|
- name: Run specs
|
45
40
|
run: |
|
46
|
-
|
41
|
+
bundle exec rake
|
@@ -33,17 +33,13 @@ jobs:
|
|
33
33
|
run: |
|
34
34
|
gem install bundler
|
35
35
|
bundle install --jobs 4 --retry 3
|
36
|
-
- name: Install LaTeXML
|
37
|
-
run: |
|
38
|
-
sudo snap install latexml --edge
|
39
|
-
echo "::add-path::/snap/bin"
|
40
36
|
- name: Install PlantUML
|
41
37
|
uses: nick-invision/retry@v1
|
42
38
|
with:
|
43
39
|
polling_interval_seconds: 5
|
44
40
|
timeout_minutes: 5
|
45
41
|
max_attempts: 3
|
46
|
-
command: sudo bash -c "curl -L https://github.com/metanorma/plantuml-install/raw/master/ubuntu.sh | bash"
|
42
|
+
command: sudo apt-get update -y && sudo bash -c "curl -L https://github.com/metanorma/plantuml-install/raw/master/ubuntu.sh | bash"
|
47
43
|
- name: Run specs
|
48
44
|
run: |
|
49
45
|
bundle exec rake
|
@@ -29,25 +29,15 @@ jobs:
|
|
29
29
|
uses: actions/setup-ruby@v1
|
30
30
|
with:
|
31
31
|
ruby-version: ${{ matrix.ruby }}
|
32
|
-
- name: Install MN Windows dependencies
|
33
|
-
shell: pwsh
|
34
|
-
run: |
|
35
|
-
choco install --no-progress plantuml make sed gnuwin32-coreutils.install grep
|
36
32
|
- name: Update gems
|
37
33
|
shell: pwsh
|
38
34
|
run: |
|
39
35
|
gem install bundler
|
40
36
|
bundle config --local path vendor/bundle
|
41
37
|
bundle install --jobs 4 --retry 3
|
42
|
-
- name: Install
|
43
|
-
shell: cmd
|
38
|
+
- name: Install PlantUML
|
44
39
|
run: |
|
45
|
-
cinst -y
|
46
|
-
refreshenv
|
47
|
-
set PATH=C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;%PATH%
|
48
|
-
where latexmlmath
|
40
|
+
cinst -y plantuml
|
49
41
|
- name: Run specs
|
50
|
-
shell: pwsh
|
51
42
|
run: |
|
52
|
-
$env:Path = "C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;$env:Path"
|
53
43
|
bundle exec rake
|
data/.rubocop.yml
CHANGED
@@ -111,9 +111,10 @@ module Asciidoctor
|
|
111
111
|
@log = Asciidoctor::Standoc::Log.new
|
112
112
|
init_bib_caches(node)
|
113
113
|
init_iev_caches(node)
|
114
|
-
lang = (node.attr("language") || "en")
|
115
|
-
script = (node.attr("script") || "
|
116
|
-
|
114
|
+
@lang = (node.attr("language") || "en")
|
115
|
+
@script = (node.attr("script") || "Latn")
|
116
|
+
@isodoc = isodoc(@lang, @script, node.attr("i18nyaml"))
|
117
|
+
@i18n = @isodoc.i18n
|
117
118
|
end
|
118
119
|
|
119
120
|
def default_fonts(node)
|
@@ -142,6 +143,11 @@ module Asciidoctor
|
|
142
143
|
ret
|
143
144
|
end
|
144
145
|
|
146
|
+
def version
|
147
|
+
flavour = self.class.name.sub(/::Converter$/, "").sub(/^.+::/, "")
|
148
|
+
Metanorma.versioned(Metanorma, flavour)[-1]::VERSION
|
149
|
+
end
|
150
|
+
|
145
151
|
def clean_exit
|
146
152
|
@log.write(@output_dir + @filename + ".err") unless @novalid
|
147
153
|
@files_to_delete.each { |f| FileUtils.rm f }
|
@@ -149,7 +155,7 @@ module Asciidoctor
|
|
149
155
|
|
150
156
|
def makexml1(node)
|
151
157
|
result = ["<?xml version='1.0' encoding='UTF-8'?>",
|
152
|
-
"<#{xml_root_tag}>"]
|
158
|
+
"<#{xml_root_tag} type='semantic' version='#{version}'>"]
|
153
159
|
result << noko { |ixml| front node, ixml }
|
154
160
|
result << noko { |ixml| middle node, ixml }
|
155
161
|
result << "</#{xml_root_tag}>"
|
@@ -169,7 +175,7 @@ module Asciidoctor
|
|
169
175
|
end
|
170
176
|
|
171
177
|
def doctype(node)
|
172
|
-
node.attr("doctype")
|
178
|
+
node.attr("doctype")&.gsub(/\s+/, "-")&.downcase
|
173
179
|
end
|
174
180
|
|
175
181
|
def front(node, xml)
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "liquid/custom_blocks/key_iterator"
|
4
|
+
require "liquid/custom_filters/values"
|
5
|
+
|
6
|
+
Liquid::Template.register_tag("keyiterator", Liquid::CustomBlocks::KeyIterator)
|
7
|
+
Liquid::Template.register_filter(Liquid::CustomFilters)
|
8
|
+
|
9
|
+
module Asciidoctor
|
10
|
+
module Standoc
|
11
|
+
# Base class for processing structured data blocks(yaml, json)
|
12
|
+
class BaseStructuredTextPreprocessor < Asciidoctor::Extensions::Preprocessor
|
13
|
+
BLOCK_START_REGEXP = /\{(.+?)\.\*,(.+),(.+)\}/
|
14
|
+
BLOCK_END_REGEXP = /\A\{[A-Z]+\}\z/
|
15
|
+
|
16
|
+
def process(document, reader)
|
17
|
+
input_lines = reader.readlines.to_enum
|
18
|
+
Reader.new(processed_lines(document, input_lines))
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
def content_from_file(_document, _file_path)
|
24
|
+
raise ArgumentError, "Implement `content_from_file` in your class"
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def processed_lines(document, input_lines)
|
30
|
+
result = []
|
31
|
+
loop do
|
32
|
+
result.push(*process_text_blocks(document, input_lines))
|
33
|
+
end
|
34
|
+
result
|
35
|
+
end
|
36
|
+
|
37
|
+
def relative_file_path(document, file_path)
|
38
|
+
docfile_directory = File.dirname(document.attributes["docfile"] || ".")
|
39
|
+
document
|
40
|
+
.path_resolver
|
41
|
+
.system_path(file_path, docfile_directory)
|
42
|
+
end
|
43
|
+
|
44
|
+
def process_text_blocks(document, input_lines)
|
45
|
+
line = input_lines.next
|
46
|
+
block_match = line.match(/^\[#{config[:block_name]},(.+?),(.+?)\]/)
|
47
|
+
return [line] if block_match.nil?
|
48
|
+
|
49
|
+
mark = input_lines.next
|
50
|
+
current_block = []
|
51
|
+
while (block_line = input_lines.next) != mark
|
52
|
+
current_block.push(block_line)
|
53
|
+
end
|
54
|
+
read_content_and_parse_template(document,
|
55
|
+
current_block,
|
56
|
+
block_match)
|
57
|
+
end
|
58
|
+
|
59
|
+
def read_content_and_parse_template(document, current_block, block_match)
|
60
|
+
transformed_liquid_lines = current_block
|
61
|
+
.map(&method(:transform_line_liquid))
|
62
|
+
context_items = content_from_file(document, block_match[1])
|
63
|
+
parse_context_block(document: document,
|
64
|
+
context_lines: transformed_liquid_lines,
|
65
|
+
context_items: context_items,
|
66
|
+
context_name: block_match[2])
|
67
|
+
rescue StandardError => exception
|
68
|
+
document.logger
|
69
|
+
.warn("Failed to parse #{config[:block_name]} \
|
70
|
+
block: #{exception.message}")
|
71
|
+
[]
|
72
|
+
end
|
73
|
+
|
74
|
+
def transform_line_liquid(line)
|
75
|
+
if line.match?(BLOCK_START_REGEXP)
|
76
|
+
line.gsub!(BLOCK_START_REGEXP,
|
77
|
+
'{% keyiterator \1, \2 %}')
|
78
|
+
end
|
79
|
+
|
80
|
+
if line.strip.match?(BLOCK_END_REGEXP)
|
81
|
+
line.gsub!(BLOCK_END_REGEXP, "{% endkeyiterator %}")
|
82
|
+
end
|
83
|
+
line
|
84
|
+
.gsub(/(?<!{){(?!%)([^{}]+)(?<!%)}(?!})/, '{{\1}}')
|
85
|
+
.gsub(/[a-z\.]+\#/, "index")
|
86
|
+
.gsub(/{{(.+)\s+\+\s+(\d+)\s*?}}/, '{{ \1 | plus: \2 }}')
|
87
|
+
.gsub(/{{(.+)\s+\-\s+(\d+)\s*?}}/, '{{ \1 | minus: \2 }}')
|
88
|
+
.gsub(/{{(.+).values(.*?)}}/,
|
89
|
+
'{% assign custom_value = \1 | values %}{{custom_value\2}}')
|
90
|
+
end
|
91
|
+
|
92
|
+
def parse_context_block(context_lines:,
|
93
|
+
context_items:,
|
94
|
+
context_name:,
|
95
|
+
document:)
|
96
|
+
render_result, errors = render_liquid_string(
|
97
|
+
template_string: context_lines.join("\n"),
|
98
|
+
context_items: context_items,
|
99
|
+
context_name: context_name
|
100
|
+
)
|
101
|
+
notify_render_errors(document, errors)
|
102
|
+
render_result.split("\n")
|
103
|
+
end
|
104
|
+
|
105
|
+
def render_liquid_string(template_string:, context_items:, context_name:)
|
106
|
+
liquid_template = Liquid::Template.parse(template_string)
|
107
|
+
rendered_string = liquid_template
|
108
|
+
.render(context_name => context_items,
|
109
|
+
strict_variables: true,
|
110
|
+
error_mode: :warn)
|
111
|
+
[rendered_string, liquid_template.errors]
|
112
|
+
end
|
113
|
+
|
114
|
+
def notify_render_errors(document, errors)
|
115
|
+
errors.each do |error_obj|
|
116
|
+
document
|
117
|
+
.logger
|
118
|
+
.warn("Liquid render error: #{error_obj.message}")
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -402,6 +402,16 @@
|
|
402
402
|
</choice>
|
403
403
|
</attribute>
|
404
404
|
</optional>
|
405
|
+
<optional>
|
406
|
+
<attribute name="valign">
|
407
|
+
<choice>
|
408
|
+
<value>top</value>
|
409
|
+
<value>middle</value>
|
410
|
+
<value>bottom</value>
|
411
|
+
<value>baseline</value>
|
412
|
+
</choice>
|
413
|
+
</attribute>
|
414
|
+
</optional>
|
405
415
|
<choice>
|
406
416
|
<zeroOrMore>
|
407
417
|
<ref name="TextElement"/>
|
@@ -429,6 +439,16 @@
|
|
429
439
|
</choice>
|
430
440
|
</attribute>
|
431
441
|
</optional>
|
442
|
+
<optional>
|
443
|
+
<attribute name="valign">
|
444
|
+
<choice>
|
445
|
+
<value>top</value>
|
446
|
+
<value>middle</value>
|
447
|
+
<value>bottom</value>
|
448
|
+
<value>baseline</value>
|
449
|
+
</choice>
|
450
|
+
</attribute>
|
451
|
+
</optional>
|
432
452
|
<choice>
|
433
453
|
<zeroOrMore>
|
434
454
|
<ref name="TextElement"/>
|
@@ -998,6 +1018,9 @@
|
|
998
1018
|
<value>alphabet_upper</value>
|
999
1019
|
</choice>
|
1000
1020
|
</attribute>
|
1021
|
+
<optional>
|
1022
|
+
<attribute name="start"/>
|
1023
|
+
</optional>
|
1001
1024
|
<oneOrMore>
|
1002
1025
|
<ref name="li"/>
|
1003
1026
|
</oneOrMore>
|
@@ -9,6 +9,7 @@ require_relative "./cleanup_boilerplate.rb"
|
|
9
9
|
require_relative "./cleanup_section.rb"
|
10
10
|
require_relative "./cleanup_terms.rb"
|
11
11
|
require_relative "./cleanup_inline.rb"
|
12
|
+
require_relative "./cleanup_amend.rb"
|
12
13
|
require "relaton_iev"
|
13
14
|
|
14
15
|
module Asciidoctor
|
@@ -71,6 +72,7 @@ module Asciidoctor
|
|
71
72
|
para_cleanup(xmldoc)
|
72
73
|
empty_element_cleanup(xmldoc)
|
73
74
|
img_cleanup(xmldoc)
|
75
|
+
anchor_cleanup(xmldoc)
|
74
76
|
xmldoc
|
75
77
|
end
|
76
78
|
|
@@ -79,12 +81,13 @@ module Asciidoctor
|
|
79
81
|
xmldoc.traverse do |n|
|
80
82
|
next unless n.text?
|
81
83
|
if @smartquotes
|
82
|
-
|
83
|
-
|
84
|
-
|
84
|
+
/[-'"(<>]|\.\.|\dx/.match(n) or next
|
85
|
+
n.ancestors("pre, tt, sourcecode, bibdata, on, "\
|
86
|
+
"stem, figure[@class = 'pseudocode']").empty? or next
|
85
87
|
n.replace(Utils::smartformat(n.text))
|
86
88
|
else
|
87
|
-
n.replace(n.text.gsub(/(?<=\p{Alnum})\u2019(?=\p{Alpha})/, "'"))
|
89
|
+
n.replace(n.text.gsub(/(?<=\p{Alnum})\u2019(?=\p{Alpha})/, "'"))#.
|
90
|
+
#gsub(/</, "<").gsub(/>/, ">"))
|
88
91
|
end
|
89
92
|
end
|
90
93
|
end
|
@@ -144,16 +147,33 @@ module Asciidoctor
|
|
144
147
|
align_callouts_to_annotations(xmldoc)
|
145
148
|
end
|
146
149
|
|
150
|
+
def xml_unescape_mathml(x)
|
151
|
+
return if x.children.any? { |y| y.element? }
|
152
|
+
math = x.text.gsub(/</, "<").gsub(/>/, ">").gsub(/"/, '"').
|
153
|
+
gsub(/'/, "'").gsub(/&/, "&").
|
154
|
+
gsub(/<[^: \r\n\t\/]+:/, "<").gsub(/<\/[^ \r\n\t:]+:/, "</")
|
155
|
+
x.children = math
|
156
|
+
end
|
157
|
+
|
158
|
+
def mathml_preserve_space(m)
|
159
|
+
m.xpath(".//m:mtext",
|
160
|
+
"m" => "http://www.w3.org/1998/Math/MathML").each do |x|
|
161
|
+
x.children = x.children.to_xml.gsub(/^\s/, " ").
|
162
|
+
gsub(/\s$/, " ")
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def mathml_namespace(stem)
|
167
|
+
stem.xpath("./math", ).each do |x|
|
168
|
+
x.default_namespace = "http://www.w3.org/1998/Math/MathML"
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
147
172
|
def mathml_cleanup(xmldoc)
|
148
173
|
xmldoc.xpath("//stem[@type = 'MathML']").each do |x|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
gsub(/<[^: \r\n\t\/]+:/, "<").gsub(/<\/[^ \r\n\t:]+:/, "</").
|
153
|
-
gsub(/ xmlns[^>"']+/, "").
|
154
|
-
gsub(/<math /, '<math xmlns="http://www.w3.org/1998/Math/MathML" ').
|
155
|
-
gsub(/<math>/, '<math xmlns="http://www.w3.org/1998/Math/MathML">')
|
156
|
-
x.children = math
|
174
|
+
xml_unescape_mathml(x)
|
175
|
+
mathml_namespace(x)
|
176
|
+
mathml_preserve_space(x)
|
157
177
|
end
|
158
178
|
end
|
159
179
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Asciidoctor
|
2
|
+
module Standoc
|
3
|
+
module Cleanup
|
4
|
+
def change_clauses(x)
|
5
|
+
x.xpath("//clause[@change]").each do |c|
|
6
|
+
a = create_amend(c)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_amend(c)
|
11
|
+
a = c.add_child("<amend id='_#{UUIDTools::UUID.random_create}'/>").first
|
12
|
+
c.elements.each do |e|
|
13
|
+
e.parent = a unless %w(amend title).include? e.name
|
14
|
+
end
|
15
|
+
create_amend1(c, a)
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_amend1(c, a)
|
19
|
+
create_amend2(c, a)
|
20
|
+
d = a.at("./description")
|
21
|
+
d.xpath(".//autonumber").each { |e| d.previous = e }
|
22
|
+
d.xpath(".//p[normalize-space(.)='']").each { |e| e.remove }
|
23
|
+
move_attrs_to_amend(c, a)
|
24
|
+
a
|
25
|
+
end
|
26
|
+
|
27
|
+
def create_amend2(c, a)
|
28
|
+
q = a.at("./quote") and q.name = "newcontent"
|
29
|
+
if q.nil?
|
30
|
+
a.children = "<description>#{a.children.to_xml}</description>"
|
31
|
+
else
|
32
|
+
pre = q&.xpath("./preceding-sibling::*")&.remove
|
33
|
+
post = q&.xpath("./following-sibling::*")&.remove
|
34
|
+
pre.empty? or a << "<description>#{pre.to_xml}</description>"
|
35
|
+
a << q.remove
|
36
|
+
post.empty? or a << "<description>#{post.to_xml}</description>"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def move_attrs_to_amend(c, a)
|
41
|
+
%w(change path path_end title).each do |e|
|
42
|
+
next unless c[e]
|
43
|
+
a[e] = c[e]
|
44
|
+
c.delete(e)
|
45
|
+
end
|
46
|
+
return unless a["locality"]
|
47
|
+
loc = a.children.add_previous_sibling("<location/>")
|
48
|
+
extract_localities1(loc, a["locality"])
|
49
|
+
loc1 = loc.at("./localityStack") and loc.replace(loc1.elements)
|
50
|
+
a.delete("locality")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -2,25 +2,25 @@ module Asciidoctor
|
|
2
2
|
module Standoc
|
3
3
|
module Cleanup
|
4
4
|
def external_terms_boilerplate(sources)
|
5
|
-
|
6
|
-
@external_terms_boilerplate.gsub(/%/, sources || "???"),
|
5
|
+
@i18n.l10n(
|
6
|
+
@i18n.external_terms_boilerplate.gsub(/%/, sources || "???"),
|
7
7
|
@lang, @script)
|
8
8
|
end
|
9
9
|
|
10
10
|
def internal_external_terms_boilerplate(sources)
|
11
|
-
|
12
|
-
@internal_external_terms_boilerplate.gsub(/%/, sources || "??"),
|
11
|
+
@i18n.l10n(
|
12
|
+
@i18n.internal_external_terms_boilerplate.gsub(/%/, sources || "??"),
|
13
13
|
@lang, @script)
|
14
14
|
end
|
15
15
|
|
16
16
|
def term_defs_boilerplate(div, source, term, preface, isodoc)
|
17
|
-
div.next =
|
17
|
+
a = @i18n.term_def_boilerplate and div.next = a
|
18
18
|
source.each do |s|
|
19
19
|
@anchors[s["bibitemid"]] or
|
20
20
|
@log.add("Crossreferences", nil, "term source #{s['bibitemid']} not referenced")
|
21
21
|
end
|
22
22
|
if source.empty? && term.nil?
|
23
|
-
div.next = @no_terms_boilerplate
|
23
|
+
div.next = @i18n.no_terms_boilerplate
|
24
24
|
else
|
25
25
|
div.next = term_defs_boilerplate_cont(source, term, isodoc)
|
26
26
|
end
|
@@ -30,7 +30,7 @@ module Asciidoctor
|
|
30
30
|
sources = isodoc.sentence_join(src.map do |s|
|
31
31
|
%{<eref bibitemid="#{s['bibitemid']}"/>}
|
32
32
|
end)
|
33
|
-
if src.empty? then @internal_terms_boilerplate
|
33
|
+
if src.empty? then @i18n.internal_terms_boilerplate
|
34
34
|
elsif term.nil? then external_terms_boilerplate(sources)
|
35
35
|
else
|
36
36
|
internal_external_terms_boilerplate(sources)
|
@@ -42,7 +42,7 @@ module Asciidoctor
|
|
42
42
|
["reference", "bibitem"].include? e.name
|
43
43
|
end
|
44
44
|
f.at("./title").next =
|
45
|
-
"<p>#{(refs.empty? ? @norm_empty_pref : @norm_with_refs_pref)}</p>"
|
45
|
+
"<p>#{(refs.empty? ? @i18n.norm_empty_pref : @i18n.norm_with_refs_pref)}</p>"
|
46
46
|
end
|
47
47
|
|
48
48
|
TERM_CLAUSE = "//sections/terms | "\
|
@@ -54,13 +54,9 @@ module Asciidoctor
|
|
54
54
|
x = xmldoc.dup
|
55
55
|
x.root.add_namespace(nil, self.class::XML_NAMESPACE)
|
56
56
|
xml = Nokogiri::XML(x.to_xml)
|
57
|
-
|
58
|
-
@
|
59
|
-
@
|
60
|
-
conv.i18n_init(@lang, @script)
|
61
|
-
conv.metadata_init(@lang, @script, conv.labels)
|
62
|
-
conv.info(xml, nil)
|
63
|
-
conv
|
57
|
+
@isodoc ||= isodoc(@lang, @script)
|
58
|
+
@isodoc.info(xml, nil)
|
59
|
+
@isodoc
|
64
60
|
end
|
65
61
|
|
66
62
|
def boilerplate_cleanup(xmldoc)
|
@@ -83,15 +79,6 @@ module Asciidoctor
|
|
83
79
|
preface.previous = b
|
84
80
|
end
|
85
81
|
|
86
|
-
class EmptyAttr
|
87
|
-
def attr(_x)
|
88
|
-
nil
|
89
|
-
end
|
90
|
-
def attributes
|
91
|
-
{}
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
82
|
def boilerplate_file(xmldoc)
|
96
83
|
File.join(@libdir, "boilerplate.xml")
|
97
84
|
end
|