metanorma-iso 1.3.22 → 1.3.27
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 +8 -7
- data/.github/workflows/ubuntu.yml +8 -7
- data/.github/workflows/windows.yml +8 -8
- data/Gemfile +2 -0
- data/lib/asciidoctor/iso/base.rb +22 -0
- data/lib/asciidoctor/iso/biblio.rng +89 -32
- data/lib/asciidoctor/iso/cleanup.rb +20 -3
- data/lib/asciidoctor/iso/front.rb +16 -107
- data/lib/asciidoctor/iso/front_id.rb +196 -0
- data/lib/asciidoctor/iso/isodoc.rng +475 -2
- data/lib/asciidoctor/iso/isostandard-amd.rng +98 -0
- data/lib/asciidoctor/iso/isostandard.rng +12 -1
- data/lib/asciidoctor/iso/macros.rb +21 -0
- data/lib/asciidoctor/iso/reqt.rng +23 -0
- data/lib/asciidoctor/iso/section.rb +18 -32
- data/lib/asciidoctor/iso/term_lookup_cleanup.rb +87 -0
- data/lib/asciidoctor/iso/validate.rb +41 -25
- data/lib/asciidoctor/iso/validate_requirements.rb +1 -1
- data/lib/asciidoctor/iso/validate_section.rb +2 -2
- data/lib/asciidoctor/iso/validate_style.rb +6 -5
- data/lib/asciidoctor/iso/validate_title.rb +1 -1
- data/lib/isodoc/iso/base_convert.rb +77 -107
- data/lib/isodoc/iso/html/header.html +10 -6
- data/lib/isodoc/iso/html/html_iso_titlepage.html +27 -18
- data/lib/isodoc/iso/html/isodoc.scss +53 -28
- data/lib/isodoc/iso/html/scripts.html +23 -21
- data/lib/isodoc/iso/html/style-human.scss +23 -0
- data/lib/isodoc/iso/html/style-iso.scss +18 -0
- data/lib/isodoc/iso/html/word_iso_intro.html +4 -0
- data/lib/isodoc/iso/html/word_iso_titlepage.html +23 -2
- data/lib/isodoc/iso/html/wordstyle.scss +80 -39
- data/lib/isodoc/iso/html_convert.rb +7 -9
- data/lib/isodoc/iso/iso.amendment.xsl +4597 -0
- data/lib/isodoc/iso/iso.international-standard.xsl +4597 -0
- data/lib/isodoc/iso/metadata.rb +71 -23
- data/lib/isodoc/iso/pdf_convert.rb +39 -0
- data/lib/isodoc/iso/sections.rb +66 -0
- data/lib/isodoc/iso/sts_convert.rb +29 -0
- data/lib/isodoc/iso/xref.rb +105 -0
- data/lib/metanorma-iso.rb +2 -0
- data/lib/metanorma/iso/processor.rb +16 -1
- data/lib/metanorma/iso/version.rb +1 -1
- data/metanorma-iso.gemspec +4 -1
- data/spec/asciidoctor-iso/amd_spec.rb +726 -0
- data/spec/asciidoctor-iso/base_spec.rb +38 -21
- data/spec/asciidoctor-iso/blocks_spec.rb +6 -6
- data/spec/asciidoctor-iso/cleanup_spec.rb +195 -174
- data/spec/asciidoctor-iso/inline_spec.rb +2 -1
- data/spec/asciidoctor-iso/macros_spec.rb +289 -0
- data/spec/asciidoctor-iso/refs_spec.rb +8 -5
- data/spec/asciidoctor-iso/section_spec.rb +8 -8
- data/spec/assets/iso.xml +64 -1
- data/spec/isodoc/amd_spec.rb +652 -0
- data/spec/isodoc/blocks_spec.rb +112 -27
- data/spec/isodoc/i18n_spec.rb +12 -20
- data/spec/isodoc/inline_spec.rb +4 -4
- data/spec/isodoc/iso_spec.rb +1 -1
- data/spec/isodoc/metadata_spec.rb +92 -4
- data/spec/isodoc/postproc_spec.rb +21 -120
- data/spec/isodoc/ref_spec.rb +9 -9
- data/spec/isodoc/section_spec.rb +36 -13
- data/spec/isodoc/table_spec.rb +30 -30
- data/spec/isodoc/terms_spec.rb +6 -6
- data/spec/isodoc/xref_spec.rb +43 -37
- data/spec/metanorma/processor_spec.rb +2 -2
- data/spec/spec_helper.rb +11 -0
- metadata +58 -5
- data/asciidoctor-iso.gemspec.old +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f2bd4b15c4295ebf947cb014b8bbc6f53b7c539860613320a00e65f44e918fc
|
4
|
+
data.tar.gz: 2e3741a0bf4f87e702571463f70460d8ba94e54d71a3f1ed910c54735df60b1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dab537420c96a7c56e6eaf99d20462e7bf8284ed2e919761df70e1e8b2c3331376001abdf81d14e769f938492ecbe5a4439dc547c050a01e6bb4529ed2f0bab
|
7
|
+
data.tar.gz: 9acb9ac16c1fb230c842d43596af7fd01ee8f08504ab62119ce03379fab9c56e7aa1e878a5114b74c0cf5214656cef47d9b0846eac9e94ca6e282181445bc948
|
data/.github/workflows/macos.yml
CHANGED
@@ -6,15 +6,23 @@ on:
|
|
6
6
|
push:
|
7
7
|
branches: [ master ]
|
8
8
|
pull_request:
|
9
|
+
paths-ignore:
|
10
|
+
- .github/workflows/ubuntu.yml
|
11
|
+
- .github/workflows/windows.yml
|
9
12
|
|
10
13
|
jobs:
|
11
14
|
test-macos:
|
12
15
|
name: Test on Ruby ${{ matrix.ruby }} macOS
|
13
16
|
runs-on: macos-latest
|
17
|
+
continue-on-error: ${{ matrix.experimental }}
|
14
18
|
strategy:
|
15
19
|
fail-fast: false
|
16
20
|
matrix:
|
17
21
|
ruby: [ '2.6', '2.5', '2.4' ]
|
22
|
+
experimental: [false]
|
23
|
+
include:
|
24
|
+
- ruby: '2.7'
|
25
|
+
experimental: true
|
18
26
|
steps:
|
19
27
|
- uses: actions/checkout@master
|
20
28
|
- name: Use Ruby
|
@@ -26,13 +34,6 @@ jobs:
|
|
26
34
|
run: |
|
27
35
|
sudo gem install bundler --force
|
28
36
|
bundle install --jobs 4 --retry 3
|
29
|
-
- name: Use Node
|
30
|
-
uses: actions/setup-node@v1
|
31
|
-
with:
|
32
|
-
node-version: '8'
|
33
|
-
- name: Install Puppeteer
|
34
|
-
run: |
|
35
|
-
npm install -g puppeteer
|
36
37
|
- name: Install PlantUML
|
37
38
|
run: |
|
38
39
|
brew install plantuml
|
@@ -6,15 +6,23 @@ on:
|
|
6
6
|
push:
|
7
7
|
branches: [ master ]
|
8
8
|
pull_request:
|
9
|
+
paths-ignore:
|
10
|
+
- .github/workflows/macos.yml
|
11
|
+
- .github/workflows/windows.yml
|
9
12
|
|
10
13
|
jobs:
|
11
14
|
test-linux:
|
12
15
|
name: Test on Ruby ${{ matrix.ruby }} Ubuntu
|
13
16
|
runs-on: ubuntu-latest
|
17
|
+
continue-on-error: ${{ matrix.experimental }}
|
14
18
|
strategy:
|
15
19
|
fail-fast: false
|
16
20
|
matrix:
|
17
21
|
ruby: [ '2.6', '2.5', '2.4' ]
|
22
|
+
experimental: [false]
|
23
|
+
include:
|
24
|
+
- ruby: '2.7'
|
25
|
+
experimental: true
|
18
26
|
steps:
|
19
27
|
- uses: actions/checkout@master
|
20
28
|
- name: Use Ruby
|
@@ -26,13 +34,6 @@ jobs:
|
|
26
34
|
run: |
|
27
35
|
gem install bundler
|
28
36
|
bundle install --jobs 4 --retry 3
|
29
|
-
- name: Use Node
|
30
|
-
uses: actions/setup-node@v1
|
31
|
-
with:
|
32
|
-
node-version: '8'
|
33
|
-
- name: Install Puppeteer
|
34
|
-
run: |
|
35
|
-
npm install -g puppeteer
|
36
37
|
- name: Install PlantUML
|
37
38
|
run: |
|
38
39
|
sudo bash -c "curl -L https://github.com/riboseinc/plantuml-install/raw/master/ubuntu.sh | bash"
|
@@ -6,15 +6,23 @@ on:
|
|
6
6
|
push:
|
7
7
|
branches: [ master ]
|
8
8
|
pull_request:
|
9
|
+
paths-ignore:
|
10
|
+
- .github/workflows/macos.yml
|
11
|
+
- .github/workflows/ubuntu.yml
|
9
12
|
|
10
13
|
jobs:
|
11
14
|
test-windows:
|
12
15
|
name: Test on Ruby ${{ matrix.ruby }} Windows
|
13
16
|
runs-on: windows-latest
|
17
|
+
continue-on-error: ${{ matrix.experimental }}
|
14
18
|
strategy:
|
15
19
|
fail-fast: false
|
16
20
|
matrix:
|
17
21
|
ruby: [ '2.6', '2.5', '2.4' ]
|
22
|
+
experimental: [false]
|
23
|
+
include:
|
24
|
+
- ruby: '2.7'
|
25
|
+
experimental: true
|
18
26
|
steps:
|
19
27
|
- uses: actions/checkout@master
|
20
28
|
- name: Use Ruby
|
@@ -27,15 +35,7 @@ jobs:
|
|
27
35
|
run: |
|
28
36
|
gem install bundler
|
29
37
|
bundle config --local path vendor/bundle
|
30
|
-
bundle update
|
31
38
|
bundle install --jobs 4 --retry 3
|
32
|
-
- name: Use Node
|
33
|
-
uses: actions/setup-node@v1
|
34
|
-
with:
|
35
|
-
node-version: '8'
|
36
|
-
- name: Install Puppeteer
|
37
|
-
run: |
|
38
|
-
npm install -g puppeteer
|
39
39
|
- name: Install PlantUML
|
40
40
|
run: |
|
41
41
|
cinst -y plantuml
|
data/Gemfile
CHANGED
@@ -4,8 +4,10 @@ Encoding.default_internal = Encoding::UTF_8
|
|
4
4
|
source "https://rubygems.org"
|
5
5
|
git_source(:github) { |repo| "https://github.com/#{repo}" }
|
6
6
|
|
7
|
+
#gem "asciimath", git: "https://github.com/asciidoctor/asciimath"
|
7
8
|
gemspec
|
8
9
|
|
9
10
|
if File.exist? 'Gemfile.devel'
|
10
11
|
eval File.read('Gemfile.devel'), nil, 'Gemfile.devel' # rubocop:disable Security/Eval
|
11
12
|
end
|
13
|
+
|
data/lib/asciidoctor/iso/base.rb
CHANGED
@@ -6,6 +6,7 @@ require "open-uri"
|
|
6
6
|
require "pp"
|
7
7
|
require "isodoc"
|
8
8
|
require "fileutils"
|
9
|
+
require 'asciidoctor/iso/macros'
|
9
10
|
|
10
11
|
module Asciidoctor
|
11
12
|
module ISO
|
@@ -13,6 +14,10 @@ module Asciidoctor
|
|
13
14
|
XML_ROOT_TAG = "iso-standard".freeze
|
14
15
|
XML_NAMESPACE = "https://www.metanorma.org/ns/iso".freeze
|
15
16
|
|
17
|
+
Asciidoctor::Extensions.register do
|
18
|
+
inline_macro Asciidoctor::Iso::TermRefInlineMacro
|
19
|
+
end
|
20
|
+
|
16
21
|
def html_converter(node)
|
17
22
|
IsoDoc::Iso::HtmlConvert.new(html_extract_attributes(node))
|
18
23
|
end
|
@@ -26,6 +31,21 @@ module Asciidoctor
|
|
26
31
|
IsoDoc::Iso::WordConvert.new(doc_extract_attributes(node))
|
27
32
|
end
|
28
33
|
|
34
|
+
def pdf_converter(node)
|
35
|
+
return nil if node.attr("no-pdf")
|
36
|
+
IsoDoc::Iso::PdfConvert.new(doc_extract_attributes(node))
|
37
|
+
end
|
38
|
+
|
39
|
+
def sts_converter(node)
|
40
|
+
return nil if node.attr("no-pdf")
|
41
|
+
IsoDoc::Iso::StsConvert.new(html_extract_attributes(node))
|
42
|
+
end
|
43
|
+
|
44
|
+
def init(node)
|
45
|
+
super
|
46
|
+
@amd = %w(amendment technical-corrigendum).include? node.attr("doctype")
|
47
|
+
end
|
48
|
+
|
29
49
|
def document(node)
|
30
50
|
init(node)
|
31
51
|
ret = makexml(node).to_xml(indent: 2)
|
@@ -35,6 +55,8 @@ module Asciidoctor
|
|
35
55
|
FileUtils.mv "#{@filename}.html", "#{@filename}_alt.html"
|
36
56
|
html_converter(node).convert(@filename + ".xml")
|
37
57
|
doc_converter(node).convert(@filename + ".xml")
|
58
|
+
pdf_converter(node)&.convert(@filename + ".xml")
|
59
|
+
sts_converter(node)&.convert(@filename + ".xml")
|
38
60
|
end
|
39
61
|
@log.write(@localdir + @filename + ".err") unless @novalid
|
40
62
|
@files_to_delete.each { |f| FileUtils.rm f }
|
@@ -88,7 +88,7 @@
|
|
88
88
|
<text/>
|
89
89
|
</element>
|
90
90
|
</define>
|
91
|
-
<define name="
|
91
|
+
<define name="LocalizedString1">
|
92
92
|
<optional>
|
93
93
|
<!-- multiple languages and scripts possible: comma delimit them if so -->
|
94
94
|
<attribute name="language"/>
|
@@ -98,6 +98,16 @@
|
|
98
98
|
</optional>
|
99
99
|
<text/>
|
100
100
|
</define>
|
101
|
+
<define name="LocalizedString">
|
102
|
+
<choice>
|
103
|
+
<ref name="LocalizedString1"/>
|
104
|
+
<oneOrMore>
|
105
|
+
<element name="variant">
|
106
|
+
<ref name="LocalizedString1"/>
|
107
|
+
</element>
|
108
|
+
</oneOrMore>
|
109
|
+
</choice>
|
110
|
+
</define>
|
101
111
|
<!--
|
102
112
|
Unlike UML, change type to format: type is overloaded
|
103
113
|
Would be need if plain were default value and could omit the attribute
|
@@ -121,7 +131,7 @@
|
|
121
131
|
</optional>
|
122
132
|
<ref name="LocalizedStringOrXsAny"/>
|
123
133
|
</define>
|
124
|
-
<define name="
|
134
|
+
<define name="LocalizedStringOrXsAny1">
|
125
135
|
<optional>
|
126
136
|
<!-- multiple languages and scripts possible: comma delimit them if so -->
|
127
137
|
<attribute name="language"/>
|
@@ -136,6 +146,16 @@
|
|
136
146
|
</choice>
|
137
147
|
</oneOrMore>
|
138
148
|
</define>
|
149
|
+
<define name="LocalizedStringOrXsAny">
|
150
|
+
<choice>
|
151
|
+
<ref name="LocalizedStringOrXsAny1"/>
|
152
|
+
<oneOrMore>
|
153
|
+
<element name="variant">
|
154
|
+
<ref name="LocalizedStringOrXsAny1"/>
|
155
|
+
</element>
|
156
|
+
</oneOrMore>
|
157
|
+
</choice>
|
158
|
+
</define>
|
139
159
|
<define name="contributor">
|
140
160
|
<element name="contributor">
|
141
161
|
<zeroOrMore>
|
@@ -512,7 +532,7 @@
|
|
512
532
|
</define>
|
513
533
|
<define name="LocalityType">
|
514
534
|
<data type="string">
|
515
|
-
<param name="pattern">section|clause|part|paragraph|chapter|page|whole|table|annex|figure|note|list|example|volume|issue|time|locality:[a-zA-Z0-9_]+</param>
|
535
|
+
<param name="pattern">section|clause|part|paragraph|chapter|page|whole|table|annex|figure|note|list|example|volume|issue|time|anchor|locality:[a-zA-Z0-9_]+</param>
|
516
536
|
</data>
|
517
537
|
</define>
|
518
538
|
<define name="referenceFrom">
|
@@ -641,9 +661,9 @@
|
|
641
661
|
<optional>
|
642
662
|
<ref name="status"/>
|
643
663
|
</optional>
|
644
|
-
<
|
664
|
+
<zeroOrMore>
|
645
665
|
<ref name="copyright"/>
|
646
|
-
</
|
666
|
+
</zeroOrMore>
|
647
667
|
<zeroOrMore>
|
648
668
|
<ref name="docrelation"/>
|
649
669
|
</zeroOrMore>
|
@@ -767,6 +787,8 @@
|
|
767
787
|
<value>unchanged</value>
|
768
788
|
<value>circulated</value>
|
769
789
|
<value>adapted</value>
|
790
|
+
<value>vote-started</value>
|
791
|
+
<value>vote-ended</value>
|
770
792
|
</choice>
|
771
793
|
</define>
|
772
794
|
<define name="bdate">
|
@@ -999,7 +1021,17 @@
|
|
999
1021
|
<optional>
|
1000
1022
|
<ref name="to"/>
|
1001
1023
|
</optional>
|
1002
|
-
<
|
1024
|
+
<oneOrMore>
|
1025
|
+
<ref name="owner"/>
|
1026
|
+
</oneOrMore>
|
1027
|
+
<optional>
|
1028
|
+
<ref name="copyright_scope"/>
|
1029
|
+
</optional>
|
1030
|
+
</element>
|
1031
|
+
</define>
|
1032
|
+
<define name="copyright_scope">
|
1033
|
+
<element name="scope">
|
1034
|
+
<text/>
|
1003
1035
|
</element>
|
1004
1036
|
</define>
|
1005
1037
|
<define name="from">
|
@@ -1019,38 +1051,63 @@
|
|
1019
1051
|
</define>
|
1020
1052
|
<define name="DocRelationType">
|
1021
1053
|
<choice>
|
1022
|
-
<value>obsoletes</value>
|
1023
|
-
<value>obsoletedBy</value>
|
1024
|
-
<value>supersedes</value>
|
1025
|
-
<value>supersededBy</value>
|
1026
|
-
<value>updates</value>
|
1027
|
-
<value>updatedBy</value>
|
1028
|
-
<value>complements</value>
|
1029
|
-
<value>derivedFrom</value>
|
1030
|
-
<value>translatedFrom</value>
|
1031
|
-
<value>hasTranslation</value>
|
1032
|
-
<value>adoptedFrom</value>
|
1033
|
-
<value>equivalent</value>
|
1034
|
-
<value>identical</value>
|
1035
|
-
<value>nonequivalent</value>
|
1036
|
-
<value>includedIn</value>
|
1037
1054
|
<value>includes</value>
|
1038
|
-
<value>
|
1039
|
-
<value>instanceOf</value>
|
1040
|
-
<value>partOf</value>
|
1055
|
+
<value>includedIn</value>
|
1041
1056
|
<value>hasPart</value>
|
1042
|
-
<value>
|
1043
|
-
<value>draftOf</value>
|
1057
|
+
<value>partOf</value>
|
1044
1058
|
<value>merges</value>
|
1059
|
+
<value>mergedInto</value>
|
1045
1060
|
<value>splits</value>
|
1046
|
-
<value>
|
1047
|
-
<value>
|
1048
|
-
<value>
|
1049
|
-
<value>
|
1050
|
-
<value>
|
1051
|
-
<value>
|
1061
|
+
<value>splitInto</value>
|
1062
|
+
<value>instance</value>
|
1063
|
+
<value>hasInstance</value>
|
1064
|
+
<value>exemplarOf</value>
|
1065
|
+
<value>hasExemplar</value>
|
1066
|
+
<value>manifestationOf</value>
|
1067
|
+
<value>hasManifestation</value>
|
1068
|
+
<value>reproductionOf</value>
|
1069
|
+
<value>hasReproduction</value>
|
1070
|
+
<value>reprintOf</value>
|
1071
|
+
<value>hasReprint</value>
|
1072
|
+
<value>expressionOf</value>
|
1073
|
+
<value>hasExpression</value>
|
1074
|
+
<value>translatedFrom</value>
|
1075
|
+
<value>hasTranslation</value>
|
1076
|
+
<value>arrangementOf</value>
|
1077
|
+
<value>hasArrangement</value>
|
1078
|
+
<value>abridgementOf</value>
|
1079
|
+
<value>hasAbridgement</value>
|
1080
|
+
<value>annotationOf</value>
|
1081
|
+
<value>hasAnnotation</value>
|
1082
|
+
<value>draftOf</value>
|
1083
|
+
<value>hasDraft</value>
|
1084
|
+
<value>editionOf</value>
|
1085
|
+
<value>hasEdition</value>
|
1086
|
+
<value>updates</value>
|
1087
|
+
<value>updatedBy</value>
|
1088
|
+
<value>derivedFrom</value>
|
1089
|
+
<value>derives</value>
|
1052
1090
|
<value>describes</value>
|
1053
1091
|
<value>describedBy</value>
|
1092
|
+
<value>catalogues</value>
|
1093
|
+
<value>cataloguedBy</value>
|
1094
|
+
<value>hasSuccessor</value>
|
1095
|
+
<value>successorOf</value>
|
1096
|
+
<value>adaptedFrom</value>
|
1097
|
+
<value>hasAdaptation</value>
|
1098
|
+
<value>adoptedFrom</value>
|
1099
|
+
<value>adoptedAs</value>
|
1100
|
+
<value>reviewOf</value>
|
1101
|
+
<value>hasReview</value>
|
1102
|
+
<value>commentaryOf</value>
|
1103
|
+
<value>hasCommentary</value>
|
1104
|
+
<value>related</value>
|
1105
|
+
<value>complements</value>
|
1106
|
+
<value>complementOf</value>
|
1107
|
+
<value>obsoletes</value>
|
1108
|
+
<value>obsoletedBy</value>
|
1109
|
+
<value>cited</value>
|
1110
|
+
<value>isCitedIn</value>
|
1054
1111
|
</choice>
|
1055
1112
|
</define>
|
1056
1113
|
<define name="docrelation">
|
@@ -5,6 +5,7 @@ require "json"
|
|
5
5
|
require "pathname"
|
6
6
|
require "open-uri"
|
7
7
|
require "pp"
|
8
|
+
require "asciidoctor/iso/term_lookup_cleanup"
|
8
9
|
|
9
10
|
module Asciidoctor
|
10
11
|
module ISO
|
@@ -13,12 +14,12 @@ module Asciidoctor
|
|
13
14
|
"//clause[title = 'Scope']//fn".freeze
|
14
15
|
|
15
16
|
NORMREF_FOOTNOTES =
|
16
|
-
"//references[
|
17
|
+
"//references[@normative = 'true']//fn".freeze
|
17
18
|
|
18
19
|
POST_NORMREF_FOOTNOTES =
|
19
20
|
"//sections//clause[not(title = 'Scope')]//fn | "\
|
20
21
|
"//annex//fn | "\
|
21
|
-
"//references[
|
22
|
+
"//references[@normative = 'false']//fn".freeze
|
22
23
|
|
23
24
|
def other_footnote_renumber(xmldoc)
|
24
25
|
seen = {}
|
@@ -35,6 +36,7 @@ module Asciidoctor
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def id_prefix(prefix, id)
|
39
|
+
return id.text if @amd # we're just inheriting the prefixes from parent doc
|
38
40
|
prefix.join("/") + ( id.text.match(%{^/}) ? "" : " " ) + id.text
|
39
41
|
end
|
40
42
|
|
@@ -51,12 +53,14 @@ module Asciidoctor
|
|
51
53
|
# ISO as a prefix goes first
|
52
54
|
def docidentifier_cleanup(xmldoc)
|
53
55
|
prefix = get_id_prefix(xmldoc)
|
54
|
-
id = xmldoc.at("//bibdata/docidentifier[@type = '
|
56
|
+
id = xmldoc.at("//bibdata/docidentifier[@type = 'ISO']") or return
|
55
57
|
id.content = id_prefix(prefix, id)
|
56
58
|
id = xmldoc.at("//bibdata/ext/structuredidentifier/project-number") and
|
57
59
|
id.content = id_prefix(prefix, id)
|
58
60
|
id = xmldoc.at("//bibdata/docidentifier[@type = 'iso-with-lang']") and
|
59
61
|
id.content = id_prefix(prefix, id)
|
62
|
+
id = xmldoc.at("//bibdata/docidentifier[@type = 'iso-reference']") and
|
63
|
+
id.content = id_prefix(prefix, id)
|
60
64
|
end
|
61
65
|
|
62
66
|
def format_ref(ref, type, isopub)
|
@@ -86,6 +90,11 @@ module Asciidoctor
|
|
86
90
|
end
|
87
91
|
end
|
88
92
|
|
93
|
+
def termdef_cleanup(xmldoc)
|
94
|
+
Asciidoctor::ISO::TermLookupCleanup.new(xmldoc, @log).call
|
95
|
+
super
|
96
|
+
end
|
97
|
+
|
89
98
|
# TODO sort by authors
|
90
99
|
# sort by: doc class (ISO, IEC, other standard (not DOI &c), other
|
91
100
|
# then standard class (docid class other than DOI &c)
|
@@ -108,6 +117,14 @@ module Asciidoctor
|
|
108
117
|
"#{num.nil? ? abbrid : sprintf("%09d", num.to_i)} :: "\
|
109
118
|
"#{partid} :: #{id&.text} :: #{title}"
|
110
119
|
end
|
120
|
+
|
121
|
+
def sections_cleanup(x)
|
122
|
+
super
|
123
|
+
return unless @amd
|
124
|
+
x.xpath("//*[@inline-header]").each do |h|
|
125
|
+
h.delete('inline-header')
|
126
|
+
end
|
127
|
+
end
|
111
128
|
end
|
112
129
|
end
|
113
130
|
end
|
@@ -5,110 +5,18 @@ require "json"
|
|
5
5
|
require "pathname"
|
6
6
|
require "open-uri"
|
7
7
|
require "pp"
|
8
|
+
require_relative "front_id"
|
8
9
|
|
9
10
|
module Asciidoctor
|
10
11
|
module ISO
|
11
12
|
class Converter < Standoc::Converter
|
12
|
-
STAGE_ABBRS = {
|
13
|
-
"00": "PWI",
|
14
|
-
"10": "NWIP",
|
15
|
-
"20": "WD",
|
16
|
-
"30": "CD",
|
17
|
-
"40": "DIS",
|
18
|
-
"50": "FDIS",
|
19
|
-
"60": "IS",
|
20
|
-
"90": "(Review)",
|
21
|
-
"95": "(Withdrawal)",
|
22
|
-
}.freeze
|
23
|
-
|
24
|
-
STAGE_NAMES = {
|
25
|
-
"00": "Preliminary work item",
|
26
|
-
"10": "New work item proposal",
|
27
|
-
"20": "Working draft",
|
28
|
-
"30": "Committee draft",
|
29
|
-
"40": "Draft international standard",
|
30
|
-
"50": "Final draft international standard",
|
31
|
-
"60": "International standard",
|
32
|
-
"90": "Review",
|
33
|
-
"95": "Withdrawal",
|
34
|
-
}.freeze
|
35
|
-
|
36
|
-
def stage_abbr(stage, substage)
|
37
|
-
return nil if stage.to_i > 60
|
38
|
-
return "PRF" if stage == "60" && substage == "00"
|
39
|
-
STAGE_ABBRS[stage.to_sym]
|
40
|
-
end
|
41
|
-
|
42
|
-
def stage_name(stage, substage)
|
43
|
-
return "Proof" if stage == "60" && substage == "00"
|
44
|
-
STAGE_NAMES[stage.to_sym]
|
45
|
-
end
|
46
|
-
|
47
|
-
def metadata_id(node, xml)
|
48
|
-
iso_id(node, xml)
|
49
|
-
node&.attr("tc-docnumber")&.split(/,\s*/)&.each do |n|
|
50
|
-
xml.docidentifier(n, **attr_code(type: "iso-tc"))
|
51
|
-
end
|
52
|
-
xml.docnumber node&.attr("docnumber")
|
53
|
-
end
|
54
|
-
|
55
|
-
def iso_id(node, xml)
|
56
|
-
return unless node.attr("docnumber")
|
57
|
-
part, subpart = node&.attr("partnumber")&.split(/-/)
|
58
|
-
dn = add_id_parts(node.attr("docnumber"), part, subpart)
|
59
|
-
dn = id_stage_prefix(dn, node)
|
60
|
-
xml.docidentifier dn, **attr_code(type: "iso")
|
61
|
-
xml.docidentifier id_langsuffix(dn, node), **attr_code(type: "iso-with-lang")
|
62
|
-
end
|
63
|
-
|
64
|
-
def id_langsuffix(dn, node)
|
65
|
-
lang = node.attr("language") || "en"
|
66
|
-
suffix = case lang
|
67
|
-
when "en" then "(E)"
|
68
|
-
when "fr" then "(F)"
|
69
|
-
else
|
70
|
-
"(X)"
|
71
|
-
end
|
72
|
-
"#{dn} #{suffix}"
|
73
|
-
end
|
74
|
-
|
75
13
|
def metadata_ext(node, xml)
|
76
14
|
super
|
77
15
|
structured_id(node, xml)
|
78
|
-
xml.stagename stage_name(get_stage(node), get_substage(node)
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
return unless node.attr("docnumber")
|
83
|
-
part, subpart = node&.attr("partnumber")&.split(/-/)
|
84
|
-
xml.structuredidentifier do |i|
|
85
|
-
i.project_number node.attr("docnumber"),
|
86
|
-
**attr_code(part: part, subpart: subpart)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def add_id_parts(dn, part, subpart)
|
91
|
-
dn += "-#{part}" if part
|
92
|
-
dn += "-#{subpart}" if subpart
|
93
|
-
dn
|
94
|
-
end
|
95
|
-
|
96
|
-
def id_stage_abbr(stage, substage, node)
|
97
|
-
IsoDoc::Iso::Metadata.new("en", "Latn", {}).
|
98
|
-
status_abbrev(stage_abbr(stage, substage), substage, node.attr("iteration"),
|
99
|
-
node.attr("draft"))
|
100
|
-
end
|
101
|
-
|
102
|
-
def id_stage_prefix(dn, node)
|
103
|
-
stage = get_stage(node)
|
104
|
-
substage = get_substage(node)
|
105
|
-
if stage && (stage.to_i < 60)
|
106
|
-
abbr = id_stage_abbr(stage, substage, node)
|
107
|
-
dn = "/#{abbr} #{dn}" unless abbr.nil? || abbr.empty? # prefixes added in cleanup
|
108
|
-
else
|
109
|
-
dn += ":#{node.attr("copyright-year")}" if node.attr("copyright-year")
|
110
|
-
end
|
111
|
-
dn
|
16
|
+
xml.stagename stage_name(get_stage(node), get_substage(node),
|
17
|
+
node.attr("doctype"), node.attr("iteration"))
|
18
|
+
@amd && a = node.attr("updates-document-type") and
|
19
|
+
xml.updates_document_type a
|
112
20
|
end
|
113
21
|
|
114
22
|
def organization(org, orgname)
|
@@ -157,20 +65,11 @@ module Asciidoctor
|
|
157
65
|
end
|
158
66
|
end
|
159
67
|
|
160
|
-
def get_stage(node)
|
161
|
-
stage = node.attr("status") || node.attr("docstage") || "60"
|
162
|
-
end
|
163
|
-
|
164
|
-
def get_substage(node)
|
165
|
-
stage = get_stage(node)
|
166
|
-
node.attr("docsubstage") || ( stage == "60" ? "60" : "00" )
|
167
|
-
end
|
168
|
-
|
169
68
|
def metadata_status(node, xml)
|
170
69
|
stage = get_stage(node)
|
171
70
|
substage = get_substage(node)
|
172
71
|
xml.status do |s|
|
173
|
-
s.stage stage, **attr_code(abbreviation: stage_abbr(stage, substage))
|
72
|
+
s.stage stage, **attr_code(abbreviation: stage_abbr(stage, substage, node.attr("doctype")))
|
174
73
|
s.substage substage
|
175
74
|
node.attr("iteration") && (s.iteration node.attr("iteration"))
|
176
75
|
end
|
@@ -205,12 +104,21 @@ module Asciidoctor
|
|
205
104
|
end
|
206
105
|
end
|
207
106
|
|
107
|
+
def title_amd(node, t, lang, at)
|
108
|
+
return unless node.attr("title-amendment-#{lang}")
|
109
|
+
t.title(**attr_code(at.merge(type: "title-amd"))) do |t1|
|
110
|
+
t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-amendment-#{lang}"))
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
208
114
|
def title_full(node, t, lang, at)
|
209
115
|
title = node.attr("title-main-#{lang}")
|
210
116
|
intro = node.attr("title-intro-#{lang}")
|
211
117
|
part = node.attr("title-part-#{lang}")
|
118
|
+
amd = node.attr("title-amendment-#{lang}")
|
212
119
|
title = "#{intro} -- #{title}" if intro
|
213
120
|
title = "#{title} -- #{part}" if part
|
121
|
+
title = "#{title} -- #{amd}" if amd && @amd
|
214
122
|
t.title **attr_code(at.merge(type: "main")) do |t1|
|
215
123
|
t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(title)
|
216
124
|
end
|
@@ -223,6 +131,7 @@ module Asciidoctor
|
|
223
131
|
title_intro(node, xml, lang, at)
|
224
132
|
title_main(node, xml, lang, at)
|
225
133
|
title_part(node, xml, lang, at)
|
134
|
+
title_amd(node, xml, lang, at) if @amd
|
226
135
|
end
|
227
136
|
end
|
228
137
|
end
|