metanorma-standoc 1.5.1 → 1.6.2
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 +62 -0
- data/lib/asciidoctor/standoc/base.rb +7 -2
- 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 +14 -0
- data/lib/asciidoctor/standoc/cleanup_footnotes.rb +11 -3
- data/lib/asciidoctor/standoc/cleanup_inline.rb +62 -1
- data/lib/asciidoctor/standoc/cleanup_ref.rb +6 -5
- data/lib/asciidoctor/standoc/cleanup_section.rb +19 -3
- data/lib/asciidoctor/standoc/cleanup_terms.rb +2 -2
- data/lib/asciidoctor/standoc/converter.rb +4 -2
- data/lib/asciidoctor/standoc/front.rb +9 -3
- data/lib/asciidoctor/standoc/front_contributor.rb +58 -18
- data/lib/asciidoctor/standoc/inline.rb +21 -31
- data/lib/asciidoctor/standoc/isodoc.rng +125 -58
- data/lib/asciidoctor/standoc/log.rb +10 -1
- data/lib/asciidoctor/standoc/macros.rb +44 -33
- data/lib/asciidoctor/standoc/ref.rb +39 -44
- data/lib/asciidoctor/standoc/ref_sect.rb +12 -5
- data/lib/asciidoctor/standoc/section.rb +11 -10
- data/lib/asciidoctor/standoc/table.rb +3 -2
- data/lib/asciidoctor/standoc/utils.rb +2 -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/liquid/custom_blocks/key_iterator.rb +21 -0
- 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/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 -4
- data/spec/asciidoctor-standoc/base_spec.rb +248 -10
- data/spec/asciidoctor-standoc/blocks_spec.rb +263 -144
- data/spec/asciidoctor-standoc/cleanup_spec.rb +199 -50
- data/spec/asciidoctor-standoc/inline_spec.rb +132 -5
- data/spec/asciidoctor-standoc/isobib_cache_spec.rb +13 -27
- 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 +6 -561
- data/spec/asciidoctor-standoc/refs_dl_spec.rb +5 -3
- data/spec/asciidoctor-standoc/refs_spec.rb +268 -57
- data/spec/asciidoctor-standoc/section_spec.rb +0 -1
- data/spec/asciidoctor-standoc/table_spec.rb +119 -113
- data/spec/asciidoctor-standoc/validate_spec.rb +27 -1
- 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/spec_helper.rb +115 -109
- data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +781 -0
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +54 -238
- 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 +11 -57
- 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 +42 -11
- 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/macros_yaml2text.rb +0 -165
- data/lib/metanorma/standoc/latexml_requirement.rb +0 -62
- data/lib/metanorma/standoc/requirement.rb +0 -13
@@ -8,7 +8,8 @@ module Asciidoctor
|
|
8
8
|
module Standoc
|
9
9
|
module Validate
|
10
10
|
|
11
|
-
SOURCELOCALITY = "./termsource/origin//locality[@type = 'clause']/
|
11
|
+
SOURCELOCALITY = "./termsource/origin//locality[@type = 'clause']/"\
|
12
|
+
"referenceFrom".freeze
|
12
13
|
|
13
14
|
def init_iev
|
14
15
|
return nil if @no_isobib
|
@@ -19,13 +20,16 @@ module Asciidoctor
|
|
19
20
|
|
20
21
|
def iev_validate(xmldoc)
|
21
22
|
xmldoc.xpath("//term").each do |t|
|
22
|
-
/^IEC 60050-/.match(t&.at("./termsource/origin/@citeas")&.text)
|
23
|
-
|
24
|
-
locality = t.xpath(SOURCELOCALITY)&.text or next
|
23
|
+
/^IEC 60050-/.match(t&.at("./termsource/origin/@citeas")&.text) &&
|
24
|
+
loc = t.xpath(SOURCELOCALITY)&.text or next
|
25
25
|
@iev = init_iev or return
|
26
|
-
iev = @iev.fetch(
|
26
|
+
iev = @iev.fetch(loc, xmldoc&.at("//language")&.text || "en") or next
|
27
|
+
pref = t.xpath("./preferred").inject([]) do |m, x|
|
28
|
+
m << x&.text&.downcase
|
29
|
+
end
|
27
30
|
pref.include?(iev.downcase) or
|
28
|
-
|
31
|
+
@log.add("Bibliography", t, %(Term "#{pref[0]}" does not match ) +
|
32
|
+
%(IEV #{loc} "#{iev}"))
|
29
33
|
end
|
30
34
|
end
|
31
35
|
|
@@ -35,20 +39,26 @@ module Asciidoctor
|
|
35
39
|
iev_validate(doc.root)
|
36
40
|
end
|
37
41
|
|
42
|
+
def repeat_id_validate1(ids, x)
|
43
|
+
if ids[x["id"]]
|
44
|
+
@log.add("Anchors", x, "Anchor #{x['id']} has already been used "\
|
45
|
+
"at line #{ids[x['id']]}")
|
46
|
+
raise StandardError.new "Error: multiple instances of same ID"
|
47
|
+
else
|
48
|
+
ids[x["id"]] = x.line
|
49
|
+
end
|
50
|
+
ids
|
51
|
+
end
|
52
|
+
|
38
53
|
def repeat_id_validate(doc)
|
39
54
|
ids = {}
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
@log.add("Anchors", x, "Anchor #{x['id']} has already been used at line #{ids[x['id']]}")
|
44
|
-
crash = true
|
45
|
-
else
|
46
|
-
ids[x["id"]] = x.line
|
55
|
+
begin
|
56
|
+
doc.xpath("//*[@id]").each do |x|
|
57
|
+
ids = repeat_id_validate1(ids, x)
|
47
58
|
end
|
48
|
-
|
49
|
-
if crash
|
59
|
+
rescue StandardError => e
|
50
60
|
clean_exit
|
51
|
-
abort(
|
61
|
+
abort(e.message)
|
52
62
|
end
|
53
63
|
end
|
54
64
|
|
@@ -59,8 +69,10 @@ module Asciidoctor
|
|
59
69
|
f.close
|
60
70
|
errors = Jing.new(schema).validate(f.path)
|
61
71
|
warn "Syntax Valid!" if errors.none?
|
62
|
-
errors.each do |
|
63
|
-
@log.add("
|
72
|
+
errors.each do |e|
|
73
|
+
@log.add("Metanorma XML Syntax",
|
74
|
+
"XML Line #{"%06d" % e[:line]}:#{e[:column]}",
|
75
|
+
e[:message])
|
64
76
|
end
|
65
77
|
rescue Jing::Error => e
|
66
78
|
clean_exit
|
@@ -2,29 +2,29 @@
|
|
2
2
|
[yaml2text,<%= model_path %>,definition]
|
3
3
|
----
|
4
4
|
|
5
|
-
=== {definition.name
|
5
|
+
=== {definition.name | default: "<%= file_name %>"}
|
6
6
|
{definition.definition}
|
7
7
|
|
8
|
-
{if definition.attributes}
|
9
|
-
.{definition.name
|
8
|
+
{% if definition.attributes %}
|
9
|
+
.{definition.name | default: "<%= file_name %>"} attributes
|
10
10
|
|===
|
11
11
|
|Name |Definition |Mandatory/ Optional/ Conditional |Max Occur |Data Type
|
12
12
|
|
13
|
-
{definition.attributes
|
14
|
-
|{key} |{definition.attributes[key].definition
|
13
|
+
{definition.attributes.*,key,EOK}
|
14
|
+
|{key} |{% if definition.attributes[key].definition %}{{ definition.attributes[key].definition }}{% else %}TODO: enum {{ key }}'s definition{% endif %} |{% if definition.attributes[key].cardinality.min == 0 %}O{% else %}M{% endif %} |{% if definition.attributes[key].cardinality.max == "*" %}N{% else %}1{% endif %} |{% if definition.attributes[key].origin %}<<{{ definition.attributes[key].origin }}>>{% endif %} `{definition.attributes[key].type}`
|
15
15
|
{EOK}
|
16
16
|
|===
|
17
|
-
{
|
17
|
+
{% endif %}
|
18
18
|
|
19
|
-
{if definition['values']}
|
20
|
-
.{definition.name
|
19
|
+
{% if definition['values'] %}
|
20
|
+
.{definition.name | default: "<%= file_name %>"} values
|
21
21
|
|===
|
22
22
|
|Name |Definition
|
23
23
|
|
24
|
-
{definition['values']
|
24
|
+
{definition['values'].*,key,EOK}
|
25
25
|
|{key} |{definition['values'][key].definition}
|
26
26
|
{EOK}
|
27
27
|
|===
|
28
|
-
{
|
28
|
+
{% endif %}
|
29
29
|
|
30
30
|
----
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Liquid
|
2
|
+
module CustomBlocks
|
3
|
+
class KeyIterator < Block
|
4
|
+
def initialize(tag_name, markup, tokens)
|
5
|
+
super
|
6
|
+
@context_name, @var_name = markup.split(',').map(&:strip)
|
7
|
+
end
|
8
|
+
|
9
|
+
def render(context)
|
10
|
+
res = ''
|
11
|
+
iterator = context[@context_name].is_a?(Hash) ? context[@context_name].keys : context[@context_name]
|
12
|
+
iterator.each.with_index do |key, index|
|
13
|
+
context['index'] = index
|
14
|
+
context[@var_name] = key
|
15
|
+
res += super
|
16
|
+
end
|
17
|
+
res
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Liquid
|
2
|
+
module CustomBlocks
|
3
|
+
class WithJsonNestedContext < Block
|
4
|
+
def initialize(tag_name, markup, tokens)
|
5
|
+
super
|
6
|
+
@context_file_variable, @context_name = markup.split(",").map(&:strip)
|
7
|
+
end
|
8
|
+
|
9
|
+
def render(context)
|
10
|
+
context_file = context[@context_file_variable].to_s.strip
|
11
|
+
context[@context_name] = JSON.parse(
|
12
|
+
File.read(context_file, encoding: "utf-8")
|
13
|
+
)
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Liquid
|
2
|
+
module CustomBlocks
|
3
|
+
class WithYamlNestedContext < Block
|
4
|
+
def initialize(tag_name, markup, tokens)
|
5
|
+
super
|
6
|
+
@context_file_variable, @context_name = markup.split(",").map(&:strip)
|
7
|
+
end
|
8
|
+
|
9
|
+
def render(context)
|
10
|
+
context_file = context[@context_file_variable].to_s.strip
|
11
|
+
context[@context_name] = YAML.safe_load(
|
12
|
+
File.read(context_file, encoding: "utf-8"),
|
13
|
+
[Date, Time]
|
14
|
+
)
|
15
|
+
super
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/metanorma/standoc.rb
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
module Metanorma
|
2
|
+
class << self
|
3
|
+
# https://stackoverflow.com/a/53399471
|
4
|
+
def parent_of(mod)
|
5
|
+
parent_name = mod.name =~ /::[^:]+\Z/ ? $`.freeze : nil
|
6
|
+
Object.const_get(parent_name) if parent_name
|
7
|
+
end
|
8
|
+
|
9
|
+
def all_modules(mod)
|
10
|
+
[mod] + mod.constants.map { |c| mod.const_get(c) }
|
11
|
+
.select {|c| c.is_a?(Module) && parent_of(c) == mod }
|
12
|
+
.flat_map {|m| all_modules(m) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def versioned(mod, flavour)
|
16
|
+
all_modules(mod).select {|c| defined? c::VERSION}.
|
17
|
+
select {|c| c.name =~ /::#{flavour}$/ }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
2
21
|
module Standoc
|
3
|
-
|
22
|
+
VERSION = "1.6.2".freeze
|
4
23
|
end
|
5
24
|
end
|
data/metanorma-standoc.gemspec
CHANGED
@@ -30,13 +30,16 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_dependency "ruby-jing"
|
31
31
|
spec.add_dependency "isodoc", "~> 1.2.0"
|
32
32
|
spec.add_dependency "iev", "~> 0.2.1"
|
33
|
-
spec.add_dependency "
|
33
|
+
spec.add_dependency "metanorma-plugin-datastruct"
|
34
|
+
# relaton-cli not just relaton, to avoid circular reference in metanorma
|
35
|
+
spec.add_dependency "relaton-cli", "~> 1.5.0"
|
34
36
|
spec.add_dependency "relaton-iev", "~> 1.0.0"
|
35
37
|
spec.add_dependency "sterile", "~> 1.0.14"
|
36
38
|
spec.add_dependency "concurrent-ruby"
|
37
39
|
spec.add_dependency "unicode2latex", "~> 0.0.1"
|
38
40
|
spec.add_dependency "mimemagic"
|
39
41
|
spec.add_dependency "mathml2asciimath"
|
42
|
+
spec.add_dependency "latexmath"
|
40
43
|
|
41
44
|
spec.add_development_dependency "byebug"
|
42
45
|
spec.add_development_dependency "sassc", "2.4.0"
|
@@ -50,7 +53,4 @@ Gem::Specification.new do |spec|
|
|
50
53
|
spec.add_development_dependency "timecop", "~> 0.9"
|
51
54
|
spec.add_development_dependency "vcr", "~> 5.0.0"
|
52
55
|
spec.add_development_dependency "webmock"
|
53
|
-
#spec.add_development_dependency "relaton-iec"
|
54
|
-
#spec.add_development_dependency "relaton-iso"
|
55
|
-
#spec.add_development_dependency "relaton-ietf"
|
56
56
|
end
|
@@ -32,8 +32,101 @@ RSpec.describe Asciidoctor::Standoc do
|
|
32
32
|
expect(File.exist?("htmlstyle.css")).to be false
|
33
33
|
end
|
34
34
|
|
35
|
+
it "processes publisher abbreviations" do
|
36
|
+
mock_org_abbrevs
|
37
|
+
expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
38
|
+
= Document title
|
39
|
+
Author
|
40
|
+
:docfile: test.adoc
|
41
|
+
:nodoc:
|
42
|
+
:novalid:
|
43
|
+
:publisher: International Electrotechnical Commission,IETF,ISO
|
44
|
+
INPUT
|
45
|
+
<standard-document xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Standoc::VERSION}'>
|
46
|
+
<bibdata type='standard'>
|
47
|
+
<title language='en' format='text/plain'>Document title</title>
|
48
|
+
<contributor>
|
49
|
+
<role type='author'/>
|
50
|
+
<organization>
|
51
|
+
<name>International Electrotechnical Commission</name>
|
52
|
+
<abbreviation>IEC</abbreviation>
|
53
|
+
</organization>
|
54
|
+
</contributor>
|
55
|
+
<contributor>
|
56
|
+
<role type='author'/>
|
57
|
+
<organization>
|
58
|
+
<name>IETF</name>
|
59
|
+
</organization>
|
60
|
+
</contributor>
|
61
|
+
<contributor>
|
62
|
+
<role type='author'/>
|
63
|
+
<organization>
|
64
|
+
<name>International Standards Organization</name>
|
65
|
+
<abbreviation>ISO</abbreviation>
|
66
|
+
</organization>
|
67
|
+
</contributor>
|
68
|
+
<contributor>
|
69
|
+
<role type='publisher'/>
|
70
|
+
<organization>
|
71
|
+
<name>International Electrotechnical Commission</name>
|
72
|
+
<abbreviation>IEC</abbreviation>
|
73
|
+
</organization>
|
74
|
+
</contributor>
|
75
|
+
<contributor>
|
76
|
+
<role type='publisher'/>
|
77
|
+
<organization>
|
78
|
+
<name>IETF</name>
|
79
|
+
</organization>
|
80
|
+
</contributor>
|
81
|
+
<contributor>
|
82
|
+
<role type='publisher'/>
|
83
|
+
<organization>
|
84
|
+
<name>International Standards Organization</name>
|
85
|
+
<abbreviation>ISO</abbreviation>
|
86
|
+
</organization>
|
87
|
+
</contributor>
|
88
|
+
<language>en</language>
|
89
|
+
<script>Latn</script>
|
90
|
+
<status>
|
91
|
+
<stage>published</stage>
|
92
|
+
</status>
|
93
|
+
<copyright>
|
94
|
+
<from>2020</from>
|
95
|
+
<owner>
|
96
|
+
<organization>
|
97
|
+
<name>International Electrotechnical Commission</name>
|
98
|
+
<abbreviation>IEC</abbreviation>
|
99
|
+
</organization>
|
100
|
+
</owner>
|
101
|
+
</copyright>
|
102
|
+
<copyright>
|
103
|
+
<from>2020</from>
|
104
|
+
<owner>
|
105
|
+
<organization>
|
106
|
+
<name>IETF</name>
|
107
|
+
</organization>
|
108
|
+
</owner>
|
109
|
+
</copyright>
|
110
|
+
<copyright>
|
111
|
+
<from>2020</from>
|
112
|
+
<owner>
|
113
|
+
<organization>
|
114
|
+
<name>International Standards Organization</name>
|
115
|
+
<abbreviation>ISO</abbreviation>
|
116
|
+
</organization>
|
117
|
+
</owner>
|
118
|
+
</copyright>
|
119
|
+
<ext>
|
120
|
+
<doctype>article</doctype>
|
121
|
+
</ext>
|
122
|
+
</bibdata>
|
123
|
+
<sections> </sections>
|
124
|
+
</standard-document>
|
125
|
+
OUTPUT
|
126
|
+
end
|
127
|
+
|
35
128
|
it "processes default metadata" do
|
36
|
-
expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to xmlpp(<<~
|
129
|
+
expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
37
130
|
= Document title
|
38
131
|
Author
|
39
132
|
:docfile: test.adoc
|
@@ -98,7 +191,8 @@ RSpec.describe Asciidoctor::Standoc do
|
|
98
191
|
:role_2: editor
|
99
192
|
:affiliation_2: Rockhead and Quarry Cave Construction Company
|
100
193
|
:affiliation_abbrev_2: RQCCC
|
101
|
-
:address_2: 6A Rubble Way,
|
194
|
+
:address_2: 6A Rubble Way, + \\
|
195
|
+
Bedrock
|
102
196
|
:email_2: barney@rockhead.example.com
|
103
197
|
:phone_2: 789
|
104
198
|
:fax_2: 012
|
@@ -107,12 +201,22 @@ RSpec.describe Asciidoctor::Standoc do
|
|
107
201
|
:part-of: ABC
|
108
202
|
:translated-from: DEF,GHI;JKL MNO,PQR
|
109
203
|
:keywords: a, b, c
|
204
|
+
:pub-address: 1 Infinity Loop + \\
|
205
|
+
California
|
206
|
+
:pub-phone: 3333333
|
207
|
+
:pub-fax: 4444444
|
208
|
+
:pub-email: x@example.com
|
209
|
+
:pub-uri: http://www.example.com
|
210
|
+
:isbn: ISBN-13
|
211
|
+
:isbn10: ISBN-10
|
110
212
|
INPUT
|
111
213
|
<?xml version="1.0" encoding="UTF-8"?>
|
112
|
-
<standard-document xmlns="https://www.metanorma.org/ns/standoc">
|
214
|
+
<standard-document xmlns="https://www.metanorma.org/ns/standoc" type="semantic" version="#{Metanorma::Standoc::VERSION}">
|
113
215
|
<bibdata type="standard">
|
114
216
|
<title language="en" format="text/plain">Main Title — Title</title>
|
115
217
|
<docidentifier>1000-1</docidentifier>
|
218
|
+
<docidentifier type='ISBN'>ISBN-13</docidentifier>
|
219
|
+
<docidentifier type='ISBN10'>ISBN-10</docidentifier>
|
116
220
|
<docnumber>1000</docnumber>
|
117
221
|
<date type="published">
|
118
222
|
<on>1000-01-01</on>
|
@@ -159,19 +263,19 @@ RSpec.describe Asciidoctor::Standoc do
|
|
159
263
|
<contributor>
|
160
264
|
<role type="author"/>
|
161
265
|
<organization>
|
162
|
-
<name>
|
266
|
+
<name>Hanna Barbera</name>
|
163
267
|
</organization>
|
164
268
|
</contributor>
|
165
269
|
<contributor>
|
166
270
|
<role type="author"/>
|
167
271
|
<organization>
|
168
|
-
<name>
|
272
|
+
<name>Cartoon Network</name>
|
169
273
|
</organization>
|
170
274
|
</contributor>
|
171
275
|
<contributor>
|
172
276
|
<role type="author"/>
|
173
277
|
<organization>
|
174
|
-
<name>
|
278
|
+
<name>Ribose, Inc.</name>
|
175
279
|
</organization>
|
176
280
|
</contributor>
|
177
281
|
<contributor>
|
@@ -185,7 +289,9 @@ RSpec.describe Asciidoctor::Standoc do
|
|
185
289
|
<name>Slate Rock and Gravel Company</name>
|
186
290
|
<abbreviation>SRG</abbreviation>
|
187
291
|
<address>
|
188
|
-
|
292
|
+
<formattedAddress>
|
293
|
+
6 Rubble Way, Bedrock
|
294
|
+
</formattedAddress>
|
189
295
|
</address>
|
190
296
|
</organization>
|
191
297
|
</affiliation>
|
@@ -207,7 +313,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
207
313
|
<name>Rockhead and Quarry Cave Construction Company</name>
|
208
314
|
<abbreviation>RQCCC</abbreviation>
|
209
315
|
<address>
|
210
|
-
<formattedAddress>6A Rubble Way, Bedrock</formattedAddress>
|
316
|
+
<formattedAddress>6A Rubble Way, <br/>Bedrock</formattedAddress>
|
211
317
|
</address>
|
212
318
|
</organization>
|
213
319
|
</affiliation>
|
@@ -327,6 +433,9 @@ RSpec.describe Asciidoctor::Standoc do
|
|
327
433
|
:doc-uri: E
|
328
434
|
:relaton-uri: F
|
329
435
|
:title-eo: Dokumenttitolo
|
436
|
+
:doctype: This is a DocType
|
437
|
+
:subdivision: Subdivision
|
438
|
+
:subdivision-abbr: SD
|
330
439
|
|
331
440
|
[abstract]
|
332
441
|
== Abstract
|
@@ -338,7 +447,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
338
447
|
== Clause 1
|
339
448
|
INPUT
|
340
449
|
<?xml version="1.0" encoding="UTF-8"?>
|
341
|
-
<standard-document xmlns="https://www.metanorma.org/ns/standoc">
|
450
|
+
<standard-document xmlns="https://www.metanorma.org/ns/standoc" type="semantic" version="#{Metanorma::Standoc::VERSION}">
|
342
451
|
<bibdata type="standard">
|
343
452
|
<title language="en" format="text/plain">Document title</title>
|
344
453
|
<title language="eo" format="text/plain">Dokumenttitolo</title>
|
@@ -422,7 +531,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
422
531
|
</owner>
|
423
532
|
</copyright>
|
424
533
|
<ext>
|
425
|
-
<doctype>
|
534
|
+
<doctype>this-is-a-doctype</doctype>
|
426
535
|
</ext>
|
427
536
|
</bibdata>
|
428
537
|
<preface>
|
@@ -441,6 +550,105 @@ RSpec.describe Asciidoctor::Standoc do
|
|
441
550
|
OUTPUT
|
442
551
|
end
|
443
552
|
|
553
|
+
it "processes subdivisions" do
|
554
|
+
mock_default_publisher
|
555
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
556
|
+
= Document title
|
557
|
+
Author
|
558
|
+
:docfile: test.adoc
|
559
|
+
:nodoc:
|
560
|
+
:novalid:
|
561
|
+
:revdate: 2000-01
|
562
|
+
:published-date: 1000-01
|
563
|
+
:docnumber: 1000
|
564
|
+
:partnumber: 1-1
|
565
|
+
:tc-docnumber: 2000
|
566
|
+
:language: el
|
567
|
+
:script: Grek
|
568
|
+
:subdivision: Subdivision
|
569
|
+
:subdivision-abbr: SD
|
570
|
+
:doctype: This is a DocType
|
571
|
+
:pub-address: 1 Infinity Loop + \\
|
572
|
+
California
|
573
|
+
:pub-phone: 3333333
|
574
|
+
:pub-fax: 4444444
|
575
|
+
:pub-email: x@example.com
|
576
|
+
:pub-uri: http://www.example.com
|
577
|
+
|
578
|
+
INPUT
|
579
|
+
<standard-document xmlns="https://www.metanorma.org/ns/standoc" type="semantic" version="#{Metanorma::Standoc::VERSION}">
|
580
|
+
<bibdata type='standard'>
|
581
|
+
<title language='en' format='text/plain'>Document title</title>
|
582
|
+
<docidentifier>1000-1-1</docidentifier>
|
583
|
+
<docnumber>1000</docnumber>
|
584
|
+
<date type='published'>
|
585
|
+
<on>1000-01</on>
|
586
|
+
</date>
|
587
|
+
<contributor>
|
588
|
+
<role type='author'/>
|
589
|
+
<organization>
|
590
|
+
<name>International Standards Organization</name>
|
591
|
+
<subdivision>Subdivision</subdivision>
|
592
|
+
<abbreviation>SD</abbreviation>
|
593
|
+
<address>
|
594
|
+
<formattedAddress>1 Infinity Loop <br/>California</formattedAddress>
|
595
|
+
</address>
|
596
|
+
<phone>3333333</phone>
|
597
|
+
<phone type='fax'>4444444</phone>
|
598
|
+
<email>x@example.com</email>
|
599
|
+
<uri>http://www.example.com</uri>
|
600
|
+
</organization>
|
601
|
+
</contributor>
|
602
|
+
<contributor>
|
603
|
+
<role type='publisher'/>
|
604
|
+
<organization>
|
605
|
+
<name>International Standards Organization</name>
|
606
|
+
<subdivision>Subdivision</subdivision>
|
607
|
+
<abbreviation>SD</abbreviation>
|
608
|
+
<address>
|
609
|
+
<formattedAddress>1 Infinity Loop <br/>California</formattedAddress>
|
610
|
+
</address>
|
611
|
+
<phone>3333333</phone>
|
612
|
+
<phone type='fax'>4444444</phone>
|
613
|
+
<email>x@example.com</email>
|
614
|
+
<uri>http://www.example.com</uri>
|
615
|
+
</organization>
|
616
|
+
</contributor>
|
617
|
+
<version>
|
618
|
+
<revision-date>2000-01</revision-date>
|
619
|
+
</version>
|
620
|
+
<language>el</language>
|
621
|
+
<script>Grek</script>
|
622
|
+
<status>
|
623
|
+
<stage>published</stage>
|
624
|
+
</status>
|
625
|
+
<copyright>
|
626
|
+
<from>2020</from>
|
627
|
+
<owner>
|
628
|
+
<organization>
|
629
|
+
<name>International Standards Organization</name>
|
630
|
+
<subdivision>Subdivision</subdivision>
|
631
|
+
<abbreviation>SD</abbreviation>
|
632
|
+
<address>
|
633
|
+
<formattedAddress>1 Infinity Loop <br/>California</formattedAddress>
|
634
|
+
</address>
|
635
|
+
<phone>3333333</phone>
|
636
|
+
<phone type='fax'>4444444</phone>
|
637
|
+
<email>x@example.com</email>
|
638
|
+
<uri>http://www.example.com</uri>
|
639
|
+
</organization>
|
640
|
+
</owner>
|
641
|
+
</copyright>
|
642
|
+
<ext>
|
643
|
+
<doctype>this-is-a-doctype</doctype>
|
644
|
+
</ext>
|
645
|
+
</bibdata>
|
646
|
+
<sections> </sections>
|
647
|
+
</standard-document>
|
648
|
+
|
649
|
+
OUTPUT
|
650
|
+
end
|
651
|
+
|
444
652
|
it "reads scripts into blank HTML document" do
|
445
653
|
FileUtils.rm_f "test.html"
|
446
654
|
Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
|
@@ -525,6 +733,36 @@ QU1FOiB0ZXN0Cgo=
|
|
525
733
|
])
|
526
734
|
end
|
527
735
|
|
736
|
+
it "test submitting-organizations with delimiter in end" do
|
737
|
+
FileUtils.rm_f "test.doc"
|
738
|
+
Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
|
739
|
+
= Document title
|
740
|
+
Author
|
741
|
+
:docfile: test.adoc
|
742
|
+
:doctype: standard
|
743
|
+
:encoding: utf-8
|
744
|
+
:lang: en
|
745
|
+
:submitting-organizations: Organization One; Organization Two;
|
746
|
+
:publisher: "Hanna Barbera", "Cartoon Network", "Ribose, Inc.",
|
747
|
+
INPUT
|
748
|
+
expect(File.exist?("test.doc")).to be true
|
749
|
+
end
|
750
|
+
|
751
|
+
private
|
752
|
+
|
753
|
+
def mock_org_abbrevs
|
754
|
+
allow_any_instance_of(::Asciidoctor::Standoc::Front).to receive(:org_abbrev).and_return(
|
755
|
+
{ "International Standards Organization" => "ISO",
|
756
|
+
"International Electrotechnical Commission" => "IEC" }
|
757
|
+
)
|
758
|
+
end
|
759
|
+
|
760
|
+
def mock_default_publisher
|
761
|
+
allow_any_instance_of(::Asciidoctor::Standoc::Front).to receive(:default_publisher).and_return(
|
762
|
+
"International Standards Organization"
|
763
|
+
)
|
764
|
+
end
|
765
|
+
|
528
766
|
|
529
767
|
end
|
530
768
|
|