isodoc 1.2.2 → 1.2.7
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 +64 -0
- data/isodoc.gemspec +3 -1
- data/lib/isodoc-yaml/i18n-fr.yaml +1 -1
- data/lib/isodoc/base_style/all.css +5 -1
- data/lib/isodoc/base_style/metanorma_word.css +6 -0
- data/lib/isodoc/base_style/metanorma_word.scss +6 -0
- data/lib/isodoc/base_style/reset.css +5 -1
- data/lib/isodoc/base_style/reset.scss +6 -1
- data/lib/isodoc/convert.rb +1 -14
- data/lib/isodoc/function/blocks.rb +1 -0
- data/lib/isodoc/function/cleanup.rb +1 -1
- data/lib/isodoc/function/references.rb +4 -2
- data/lib/isodoc/function/section.rb +13 -1
- data/lib/isodoc/function/table.rb +1 -0
- data/lib/isodoc/function/to_word_html.rb +4 -0
- data/lib/isodoc/function/utils.rb +1 -1
- data/lib/isodoc/html_function/html.rb +1 -0
- data/lib/isodoc/i18n.rb +8 -50
- data/lib/isodoc/metadata.rb +44 -111
- data/lib/isodoc/metadata_contributor.rb +90 -0
- data/lib/isodoc/metadata_date.rb +11 -0
- data/lib/isodoc/presentation_function/bibdata.rb +96 -0
- data/lib/isodoc/presentation_function/block.rb +14 -0
- data/lib/isodoc/presentation_function/inline.rb +27 -14
- data/lib/isodoc/presentation_xml_convert.rb +4 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +1 -0
- data/lib/isodoc/word_function/postprocess.rb +2 -2
- data/lib/isodoc/word_function/table.rb +3 -2
- data/lib/isodoc/xref.rb +1 -0
- data/lib/isodoc/xref/xref_anchor.rb +8 -3
- data/lib/isodoc/xref/xref_counter.rb +21 -7
- data/lib/isodoc/xref/xref_gen.rb +29 -6
- data/lib/isodoc/xref/xref_sect_gen.rb +1 -1
- data/lib/isodoc/xslfo_convert.rb +6 -1
- data/spec/assets/i18n.yaml +16 -0
- data/spec/isodoc/blocks_spec.rb +330 -215
- data/spec/isodoc/cleanup_spec.rb +3 -1
- data/spec/isodoc/i18n_spec.rb +68 -16
- data/spec/isodoc/inline_spec.rb +47 -5
- data/spec/isodoc/metadata_spec.rb +69 -19
- data/spec/isodoc/postproc_spec.rb +39 -3
- data/spec/isodoc/ref_spec.rb +3 -3
- data/spec/isodoc/section_spec.rb +134 -10
- data/spec/isodoc/table_spec.rb +306 -207
- data/spec/isodoc/terms_spec.rb +1 -1
- data/spec/isodoc/xref_spec.rb +46 -18
- data/spec/spec_helper.rb +6 -0
- metadata +35 -7
- data/.github/workflows/macos.yml +0 -42
- data/.github/workflows/ubuntu.yml +0 -62
- data/.github/workflows/windows.yml +0 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1a16a6af5cb8621eb1dd8e14a2680e7858476d5ffc1007e45566928e9ebaef7
|
4
|
+
data.tar.gz: ef5696d693f602b825457939bfab6f1ccfd827a9f24cbfa975ee6120c603b264
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3f8718e404915ce3d9d7ad8de1b4f6c0eb6442c930ced3e05c6f1db25ee23324de1783c3fe96e41e86d765a705b7b41df78bd159ff1333f3809ed2682188cc6
|
7
|
+
data.tar.gz: 0ba52d047fb5b1119d1cf485eea60511066f5fec0152222123cedea05f346a7f2276a9ac90aede713d6ae14b3a2be4c5e41267ffdb4ccdff285b5d13350cd26c
|
@@ -0,0 +1,64 @@
|
|
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 ]
|
8
|
+
pull_request:
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
rake:
|
12
|
+
name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
|
13
|
+
runs-on: ${{ matrix.os }}
|
14
|
+
continue-on-error: ${{ matrix.experimental }}
|
15
|
+
strategy:
|
16
|
+
fail-fast: false
|
17
|
+
matrix:
|
18
|
+
ruby: [ '2.6', '2.5', '2.4' ]
|
19
|
+
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
20
|
+
experimental: [ false ]
|
21
|
+
include:
|
22
|
+
- ruby: '2.7'
|
23
|
+
os: 'ubuntu-latest'
|
24
|
+
experimental: true
|
25
|
+
- ruby: '2.7'
|
26
|
+
os: 'windows-latest'
|
27
|
+
experimental: true
|
28
|
+
- ruby: '2.7'
|
29
|
+
os: 'macos-latest'
|
30
|
+
experimental: true
|
31
|
+
steps:
|
32
|
+
- uses: actions/checkout@master
|
33
|
+
|
34
|
+
- name: Use Ruby
|
35
|
+
uses: ruby/setup-ruby@v1
|
36
|
+
with:
|
37
|
+
ruby-version: ${{ matrix.ruby }}
|
38
|
+
bundler-cache: true
|
39
|
+
|
40
|
+
- name: Install Inkscape macOS
|
41
|
+
if: matrix.os == 'macos-latest'
|
42
|
+
run: |
|
43
|
+
brew cask install inkscape
|
44
|
+
inkscape --version
|
45
|
+
|
46
|
+
- name: Install Inkscape Ubuntu
|
47
|
+
if: matrix.os == 'ubuntu-latest'
|
48
|
+
run: |
|
49
|
+
sudo add-apt-repository ppa:inkscape.dev/stable
|
50
|
+
sudo apt update
|
51
|
+
sudo apt install inkscape
|
52
|
+
inkscape --version
|
53
|
+
|
54
|
+
- name: Install Inkscape Windows
|
55
|
+
if: matrix.os == 'windows-latest'
|
56
|
+
run: |
|
57
|
+
choco install --no-progress -y inkscape
|
58
|
+
inkscape --version
|
59
|
+
|
60
|
+
- name: Update gems
|
61
|
+
run: bundle install --jobs 4 --retry 3
|
62
|
+
|
63
|
+
- name: Run specs
|
64
|
+
run: bundle exec rake
|
data/isodoc.gemspec
CHANGED
@@ -36,7 +36,9 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_dependency "html2doc", "~> 1.0.0"
|
37
37
|
spec.add_dependency "liquid"
|
38
38
|
spec.add_dependency "roman-numerals"
|
39
|
-
spec.add_dependency "metanorma", "~> 1.
|
39
|
+
spec.add_dependency "metanorma", "~> 1.2.0"
|
40
|
+
spec.add_dependency "relaton-cli"
|
41
|
+
spec.add_dependency "gyoku", "~> 1.3"
|
40
42
|
|
41
43
|
spec.add_development_dependency "rake", "~> 13.0"
|
42
44
|
spec.add_development_dependency "byebug", "~> 9.1"
|
@@ -9,7 +9,7 @@ fieldset, form, label, legend,
|
|
9
9
|
table, caption, tbody, tfoot, thead, tr, th, td,
|
10
10
|
article, aside, canvas, details, embed,
|
11
11
|
figure, figcaption, footer, header, hgroup,
|
12
|
-
menu,
|
12
|
+
menu, output, ruby, section, summary,
|
13
13
|
time, mark, audio, video {
|
14
14
|
margin: 0;
|
15
15
|
padding: 0; }
|
@@ -104,6 +104,10 @@ b, strong {
|
|
104
104
|
div.document-stage-band, div.document-type-band {
|
105
105
|
background-color: #333333; }
|
106
106
|
|
107
|
+
a.FootnoteRef + a.FootnoteRef:before {
|
108
|
+
content: ", ";
|
109
|
+
vertical-align: super; }
|
110
|
+
|
107
111
|
#standard-band {
|
108
112
|
background-color: #0AC442; }
|
109
113
|
|
@@ -16,6 +16,12 @@ td {
|
|
16
16
|
tr {
|
17
17
|
page-break-after: avoid; }
|
18
18
|
|
19
|
+
table.MsoISOTableBig tr {
|
20
|
+
page-break-inside: auto; }
|
21
|
+
|
22
|
+
table.MsoISOTableBig td {
|
23
|
+
page-break-inside: auto; }
|
24
|
+
|
19
25
|
span.stem {
|
20
26
|
font-family: "Cambria Math",serif;
|
21
27
|
mso-ascii-font-family: "Cambria Math";
|
@@ -13,6 +13,12 @@ table.MsoISOTable tr
|
|
13
13
|
td { page-break-inside:avoid; }
|
14
14
|
tr { page-break-after:avoid; }
|
15
15
|
|
16
|
+
table.MsoISOTableBig tr
|
17
|
+
{page-break-inside:auto;}
|
18
|
+
|
19
|
+
table.MsoISOTableBig td
|
20
|
+
{page-break-inside:auto;}
|
21
|
+
|
16
22
|
span.stem
|
17
23
|
{font-family:"Cambria Math",serif;
|
18
24
|
mso-ascii-font-family:"Cambria Math";
|
@@ -9,7 +9,7 @@ fieldset, form, label, legend,
|
|
9
9
|
table, caption, tbody, tfoot, thead, tr, th, td,
|
10
10
|
article, aside, canvas, details, embed,
|
11
11
|
figure, figcaption, footer, header, hgroup,
|
12
|
-
menu,
|
12
|
+
menu, output, ruby, section, summary,
|
13
13
|
time, mark, audio, video {
|
14
14
|
margin: 0;
|
15
15
|
padding: 0; }
|
@@ -103,3 +103,7 @@ b, strong {
|
|
103
103
|
|
104
104
|
div.document-stage-band, div.document-type-band {
|
105
105
|
background-color: #333333; }
|
106
|
+
|
107
|
+
a.FootnoteRef + a.FootnoteRef:before {
|
108
|
+
content: ", ";
|
109
|
+
vertical-align: super; }
|
@@ -9,7 +9,7 @@ fieldset, form, label, legend,
|
|
9
9
|
table, caption, tbody, tfoot, thead, tr, th, td,
|
10
10
|
article, aside, canvas, details, embed,
|
11
11
|
figure, figcaption, footer, header, hgroup,
|
12
|
-
menu,
|
12
|
+
menu, output, ruby, section, summary,
|
13
13
|
time, mark, audio, video {
|
14
14
|
margin: 0;
|
15
15
|
padding: 0;
|
@@ -127,3 +127,8 @@ b, strong {
|
|
127
127
|
div.document-stage-band, div.document-type-band {
|
128
128
|
background-color: #333333;
|
129
129
|
}
|
130
|
+
|
131
|
+
a.FootnoteRef + a.FootnoteRef:before {
|
132
|
+
content: ", ";
|
133
|
+
vertical-align: super;
|
134
|
+
}
|
data/lib/isodoc/convert.rb
CHANGED
@@ -116,20 +116,7 @@ module IsoDoc
|
|
116
116
|
end
|
117
117
|
|
118
118
|
# none for this parent gem, but will be populated in child gems
|
119
|
-
# which have access to stylesheets &c
|
120
|
-
# {
|
121
|
-
# htmlstylesheet: html_doc_path("htmlstyle.scss"),
|
122
|
-
# htmlcoverpage: html_doc_path("html_rsd_titlepage.html"),
|
123
|
-
# htmlintropage: html_doc_path("html_rsd_intro.html"),
|
124
|
-
# scripts: html_doc_path("scripts.html"),
|
125
|
-
# wordstylesheet: html_doc_path("wordstyle.scss"),
|
126
|
-
# standardstylesheet: html_doc_path("rsd.scss"),
|
127
|
-
# header: html_doc_path("header.html"),
|
128
|
-
# wordcoverpage: html_doc_path("word_rsd_titlepage.html"),
|
129
|
-
# wordintropage: html_doc_path("word_rsd_intro.html"),
|
130
|
-
# ulstyle: l3
|
131
|
-
# olstyle: l2
|
132
|
-
# }
|
119
|
+
# which have access to stylesheets &c
|
133
120
|
def default_file_locations(_options)
|
134
121
|
{}
|
135
122
|
end
|
@@ -181,6 +181,7 @@ module IsoDoc::Function
|
|
181
181
|
def quote_attribution(node, out)
|
182
182
|
author = node.at(ns("./author"))
|
183
183
|
source = node.at(ns("./source"))
|
184
|
+
return if author.nil? && source.nil?
|
184
185
|
out.p **{ class: "QuoteAttribution" } do |p|
|
185
186
|
p << "— #{author.text}" if author
|
186
187
|
p << ", " if author && source
|
@@ -6,9 +6,9 @@ module IsoDoc::Function
|
|
6
6
|
|
7
7
|
def termref_cleanup(docxml)
|
8
8
|
docxml.
|
9
|
+
gsub(/\s*\[MODIFICATION\]\s*\[\/TERMREF\]/, l10n(", #{@i18n.modified} [/TERMREF]")).
|
9
10
|
gsub(%r{\s*\[/TERMREF\]\s*</p>\s*<p>\s*\[TERMREF\]}, "; ").
|
10
11
|
gsub(/\[TERMREF\]\s*/, l10n("[#{@i18n.source}: ")).
|
11
|
-
gsub(/\s*\[MODIFICATION\]\s*\[\/TERMREF\]/, l10n(", #{@i18n.modified} [/TERMREF]")).
|
12
12
|
gsub(%r{\s*\[\/TERMREF\]\s*}, l10n("]")).
|
13
13
|
gsub(/\s*\[MODIFICATION\]/, l10n(", #{@i18n.modified} — "))
|
14
14
|
end
|
@@ -54,7 +54,8 @@ module IsoDoc::Function
|
|
54
54
|
def bibitem_ref_code(b)
|
55
55
|
id = b.at(ns("./docidentifier[@type = 'metanorma']"))
|
56
56
|
id1 = pref_ref_code(b)
|
57
|
-
id2 = b.at(ns("./docidentifier[@type = 'DOI' or @type = 'ISSN' or
|
57
|
+
id2 = b.at(ns("./docidentifier[@type = 'DOI' or @type = 'ISSN' or "\
|
58
|
+
"@type = 'ISBN']"))
|
58
59
|
return [id, id1, id2] if id || id1 || id2
|
59
60
|
id = Nokogiri::XML::Node.new("docidentifier", b.document)
|
60
61
|
id << "(NO ID)"
|
@@ -193,7 +194,8 @@ module IsoDoc::Function
|
|
193
194
|
def bibliography_parse(node, out)
|
194
195
|
title = node&.at(ns("./title"))&.text || ""
|
195
196
|
out.div do |div|
|
196
|
-
clause_parse_title(node, div, node.at(ns("./title")), out,
|
197
|
+
clause_parse_title(node, div, node.at(ns("./title")), out,
|
198
|
+
{ class: "Section3" })
|
197
199
|
biblio_list(node, div, true)
|
198
200
|
end
|
199
201
|
end
|
@@ -182,7 +182,6 @@ module IsoDoc::Function
|
|
182
182
|
page_break(out)
|
183
183
|
out.div **attr_code(id: f["id"]) do |s|
|
184
184
|
clause_name(nil, f.at(ns("./title")), s, { class: "AbstractTitle" })
|
185
|
-
#s.h1(**{ class: "AbstractTitle" }) { |h1| h1 << @i18n.abstract }
|
186
185
|
f.elements.each { |e| parse(e, s) unless e.name == "title" }
|
187
186
|
end
|
188
187
|
end
|
@@ -201,6 +200,19 @@ module IsoDoc::Function
|
|
201
200
|
end
|
202
201
|
end
|
203
202
|
|
203
|
+
def is_clause?(name)
|
204
|
+
%w(clause references definitions terms foreword introduction abstract
|
205
|
+
acknowledgements).include? name
|
206
|
+
end
|
207
|
+
|
208
|
+
def preface_block(isoxml, out)
|
209
|
+
p = isoxml.at(ns("//preface")) or return
|
210
|
+
p.elements.each do |e|
|
211
|
+
next if is_clause?(e.name)
|
212
|
+
parse(e, out)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
204
216
|
def copyright_parse(node, out)
|
205
217
|
out.div **{class: "boilerplate-copyright"} do |div|
|
206
218
|
node.children.each { |n| parse(n, div) }
|
@@ -82,6 +82,7 @@ module IsoDoc::Function
|
|
82
82
|
def make_tr_attr(td, row, totalrows, header)
|
83
83
|
style = td.name == "th" ? "font-weight:bold;" : ""
|
84
84
|
td["align"] and style += "text-align:#{td['align']};"
|
85
|
+
td["valign"] and style += "vertical-align:#{td['valign']};"
|
85
86
|
rowmax = td["rowspan"] ? row + td["rowspan"].to_i - 1 : row
|
86
87
|
style += <<~STYLE
|
87
88
|
border-top:#{row.zero? ? "#{SW} 1.5pt;" : 'none;'}
|
@@ -80,6 +80,7 @@ module IsoDoc::Function
|
|
80
80
|
def make_body3(body, docxml)
|
81
81
|
body.div **{ class: "main-section" } do |div3|
|
82
82
|
boilerplate docxml, div3
|
83
|
+
preface_block docxml, div3
|
83
84
|
abstract docxml, div3
|
84
85
|
foreword docxml, div3
|
85
86
|
introduction docxml, div3
|
@@ -95,6 +96,7 @@ module IsoDoc::Function
|
|
95
96
|
@meta.subtitle isoxml, out
|
96
97
|
@meta.docstatus isoxml, out
|
97
98
|
@meta.docid isoxml, out
|
99
|
+
@meta.otherid isoxml, out
|
98
100
|
@meta.docnumeric isoxml, out
|
99
101
|
@meta.doctype isoxml, out
|
100
102
|
@meta.author isoxml, out
|
@@ -103,6 +105,7 @@ module IsoDoc::Function
|
|
103
105
|
@meta.version isoxml, out
|
104
106
|
@meta.url isoxml, out
|
105
107
|
@meta.keywords isoxml, out
|
108
|
+
@meta.note isoxml, out
|
106
109
|
@meta.get
|
107
110
|
end
|
108
111
|
|
@@ -220,6 +223,7 @@ module IsoDoc::Function
|
|
220
223
|
when "feedback-statement" then feedback_parse(node, out)
|
221
224
|
when "passthrough" then passthrough_parse(node, out)
|
222
225
|
when "variant" then variant_parse(node, out)
|
226
|
+
when "amend" then amend_parse(node, out)
|
223
227
|
when "tab" then clausedelimspace(out) # in Presentation XML only
|
224
228
|
else
|
225
229
|
error_parse(node, out)
|
data/lib/isodoc/i18n.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require "yaml"
|
2
2
|
|
3
|
-
# TODO: Cleanup and generalize
|
4
3
|
module IsoDoc
|
5
4
|
class I18n
|
6
5
|
def load_yaml(lang, script, i18nyaml = nil)
|
@@ -43,55 +42,6 @@ module IsoDoc
|
|
43
42
|
@labels.each do |k, v|
|
44
43
|
self.class.send(:define_method, k.downcase) { v }
|
45
44
|
end
|
46
|
-
=begin
|
47
|
-
@term_def_boilerplate = y["term_def_boilerplate"]
|
48
|
-
@scope_lbl = y["scope"]
|
49
|
-
@symbols_lbl = y["symbols"]
|
50
|
-
@table_of_contents_lbl = y["table_of_contents"]
|
51
|
-
@introduction_lbl = y["introduction"]
|
52
|
-
@foreword_lbl = y["foreword"]
|
53
|
-
@abstract_lbl = y["abstract"]
|
54
|
-
@termsdef_lbl = y["termsdef"]
|
55
|
-
@termsdefsymbols_lbl = y["termsdefsymbols"]
|
56
|
-
@normref_lbl = y["normref"]
|
57
|
-
@bibliography_lbl = y["bibliography"]
|
58
|
-
@clause_lbl = y["clause"]
|
59
|
-
@annex_lbl = y["annex"]
|
60
|
-
@appendix_lbl = y["appendix"]
|
61
|
-
@no_terms_boilerplate = y["no_terms_boilerplate"]
|
62
|
-
@internal_terms_boilerplate = y["internal_terms_boilerplate"]
|
63
|
-
@norm_with_refs_pref = y["norm_with_refs_pref"]
|
64
|
-
@norm_empty_pref = y["norm_empty_pref"]
|
65
|
-
@external_terms_boilerplate = y["external_terms_boilerplate"]
|
66
|
-
@internal_external_terms_boilerplate =
|
67
|
-
y["internal_external_terms_boilerplate"]
|
68
|
-
@note_lbl = y["note"]
|
69
|
-
@note_xref_lbl = y["note_xref"]
|
70
|
-
@termnote_lbl = y["termnote"]
|
71
|
-
@figure_lbl = y["figure"]
|
72
|
-
@list_lbl = y["list"]
|
73
|
-
@formula_lbl = y["formula"]
|
74
|
-
@inequality_lbl = y["inequality"]
|
75
|
-
@table_lbl = y["table"]
|
76
|
-
@key_lbl = y["key"]
|
77
|
-
@example_lbl = y["example"]
|
78
|
-
@example_xref_lbl = y["example_xref"]
|
79
|
-
@where_lbl = y["where"]
|
80
|
-
@wholeoftext_lbl = y["wholeoftext"]
|
81
|
-
@draft_lbl = y["draft_label"]
|
82
|
-
@inform_annex_lbl = y["inform_annex"]
|
83
|
-
@norm_annex_lbl = y["norm_annex"]
|
84
|
-
@modified_lbl = y["modified"]
|
85
|
-
@deprecated_lbl = y["deprecated"]
|
86
|
-
@source_lbl = y["source"]
|
87
|
-
@and_lbl = y["and"]
|
88
|
-
@all_parts_lbl = y["all_parts"]
|
89
|
-
@permission_lbl = y["permission"]
|
90
|
-
@recommendation_lbl = y["recommendation"]
|
91
|
-
@requirement_lbl = y["requirement"]
|
92
|
-
@locality = y["locality"]
|
93
|
-
@admonition = y["admonition"]
|
94
|
-
=end
|
95
45
|
end
|
96
46
|
|
97
47
|
def self.l10n(x, lang = @lang, script = @script)
|
@@ -116,6 +66,14 @@ module IsoDoc
|
|
116
66
|
end
|
117
67
|
end
|
118
68
|
|
69
|
+
def multiple_and(names, andword)
|
70
|
+
return '' if names.empty?
|
71
|
+
return names[0] if names.length == 1
|
72
|
+
(names.length == 2) &&
|
73
|
+
(return l10n("#{names[0]} #{andword} #{names[1]}", @lang, @script))
|
74
|
+
l10n(names[0..-2].join(', ') + " #{andword} #{names[-1]}", @lang, @script)
|
75
|
+
end
|
76
|
+
|
119
77
|
#module_function :l10n
|
120
78
|
|
121
79
|
end
|
data/lib/isodoc/metadata.rb
CHANGED
@@ -1,14 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative './metadata_date'
|
4
|
+
require_relative './metadata_contributor'
|
4
5
|
|
5
6
|
module IsoDoc
|
6
7
|
class Metadata
|
7
|
-
DATETYPES = %w{published accessed created implemented obsoleted confirmed
|
8
|
-
updated issued received transmitted copied unchanged
|
9
|
-
circulated vote-started
|
10
|
-
vote-ended}.freeze
|
11
|
-
|
12
8
|
attr_accessor :fonts_options
|
13
9
|
|
14
10
|
def ns(xpath)
|
@@ -20,7 +16,7 @@ module IsoDoc
|
|
20
16
|
end
|
21
17
|
|
22
18
|
def initialize(lang, script, i18n, fonts_options = {})
|
23
|
-
@metadata = {}
|
19
|
+
@metadata = { lang: lang, script: script }
|
24
20
|
DATETYPES.each { |w| @metadata["#{w.gsub(/-/, '_')}date".to_sym] = 'XXX' }
|
25
21
|
@lang = lang
|
26
22
|
@script = script
|
@@ -42,113 +38,37 @@ module IsoDoc
|
|
42
38
|
@metadata[key] = value
|
43
39
|
end
|
44
40
|
|
45
|
-
|
46
|
-
authors.reduce([]) do |ret, a|
|
47
|
-
if a.at(ns('./name/completename'))
|
48
|
-
ret << a.at(ns('./name/completename')).text
|
49
|
-
else
|
50
|
-
fn = []
|
51
|
-
forenames = a.xpath(ns('./name/forename'))
|
52
|
-
forenames.each { |f| fn << f.text }
|
53
|
-
surname = a&.at(ns('./name/surname'))&.text
|
54
|
-
ret << fn.join(' ') + ' ' + surname
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
41
|
+
NOLANG = "[not(@language) or @language = '']".freeze
|
58
42
|
|
59
|
-
def
|
60
|
-
|
61
|
-
name = a&.at(ns('./affiliation/organization/name'))&.text
|
62
|
-
location = a&.at(ns('./affiliation/organization/address/'\
|
63
|
-
'formattedAddress'))&.text
|
64
|
-
m << (!name.nil? && !location.nil? ? "#{name}, #{location}" :
|
65
|
-
(name || location || ''))
|
66
|
-
m
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def extract_person_names_affiliations(authors)
|
71
|
-
names = extract_person_names(authors)
|
72
|
-
affils = extract_person_affiliations(authors)
|
73
|
-
ret = {}
|
74
|
-
affils.each_with_index do |a, i|
|
75
|
-
ret[a] ||= []
|
76
|
-
ret[a] << names[i]
|
77
|
-
end
|
78
|
-
ret
|
79
|
-
end
|
80
|
-
|
81
|
-
def personal_authors(isoxml)
|
82
|
-
authors = isoxml.xpath(ns("//bibdata/contributor[role/@type = 'author' "\
|
83
|
-
"or xmlns:role/@type = 'editor']/person"))
|
84
|
-
set(:authors, extract_person_names(authors))
|
85
|
-
set(:authors_affiliations, extract_person_names_affiliations(authors))
|
86
|
-
end
|
87
|
-
|
88
|
-
def author(xml, _out)
|
89
|
-
personal_authors(xml)
|
90
|
-
agency(xml)
|
91
|
-
end
|
92
|
-
|
93
|
-
def bibdate(isoxml, _out)
|
94
|
-
isoxml.xpath(ns('//bibdata/date')).each do |d|
|
95
|
-
set("#{d['type'].gsub(/-/, '_')}date".to_sym, Common::date_range(d))
|
96
|
-
end
|
43
|
+
def currlang
|
44
|
+
"[@language = '#{@lang}']"
|
97
45
|
end
|
98
46
|
|
99
47
|
def doctype(isoxml, _out)
|
100
|
-
b = isoxml&.at(ns(
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
def iso?(org)
|
106
|
-
name = org&.at(ns('./name'))&.text
|
107
|
-
abbrev = org&.at(ns('./abbreviation'))&.text
|
108
|
-
(abbrev == 'ISO' ||
|
109
|
-
name == 'International Organization for Standardization')
|
110
|
-
end
|
111
|
-
|
112
|
-
def agency(xml)
|
113
|
-
agency = ''
|
114
|
-
publisher = []
|
115
|
-
xml.xpath(ns("//bibdata/contributor[xmlns:role/@type = 'publisher']/"\
|
116
|
-
'organization')).each do |org|
|
117
|
-
name = org&.at(ns('./name'))&.text
|
118
|
-
agency1 = org&.at(ns('./abbreviation'))&.text || name
|
119
|
-
publisher << name if name
|
120
|
-
agency = iso?(org) ? "ISO/#{agency}" : "#{agency}#{agency1}/"
|
121
|
-
end
|
122
|
-
set(:agency, agency.sub(%r{/$}, ''))
|
123
|
-
set(:publisher, multiple_and(publisher, @labels['and']))
|
124
|
-
end
|
125
|
-
|
126
|
-
def multiple_and(names, andword)
|
127
|
-
return '' if names.empty?
|
128
|
-
return names[0] if names.length == 1
|
129
|
-
(names.length == 2) &&
|
130
|
-
(return l10n("#{names[0]} #{andword} #{names[1]}", @lang, @script))
|
131
|
-
l10n(names[0..-2].join(', ') + " #{andword} #{names[-1]}", @lang, @script)
|
48
|
+
b = isoxml&.at(ns("//bibdata/ext/doctype#{NOLANG}"))&.text || return
|
49
|
+
set(:doctype, status_print(b))
|
50
|
+
b1 = isoxml&.at(ns("//bibdata/ext/doctype#{currlang}"))&.text || b
|
51
|
+
set(:doctype_display, status_print(b1))
|
132
52
|
end
|
133
53
|
|
134
|
-
def docstatus(
|
135
|
-
docstatus = isoxml.at(ns('//bibdata/status/stage'))
|
54
|
+
def docstatus(xml, _out)
|
136
55
|
set(:unpublished, true)
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
56
|
+
return unless s = xml.at(ns("//bibdata/status/stage#{NOLANG}"))
|
57
|
+
s1 = xml.at(ns("//bibdata/status/stage#{currlang}")) || s
|
58
|
+
set(:stage, status_print(s.text))
|
59
|
+
s1 and set(:stage_display, status_print(s1.text))
|
60
|
+
(i = xml&.at(ns("//bibdata/status/substage#{NOLANG}"))&.text) and
|
61
|
+
set(:substage, i)
|
62
|
+
(i1 = xml&.at(ns("//bibdata/status/substage#{currlang}"))&.text || i) and
|
63
|
+
set(:substage_display, i1)
|
64
|
+
(i2 = xml&.at(ns('//bibdata/status/iteration'))&.text) and
|
65
|
+
set(:iteration, i2)
|
66
|
+
set(:unpublished, unpublished(s.text))
|
67
|
+
unpublished(s.text) && set(:stageabbr, stage_abbr(s.text))
|
147
68
|
end
|
148
69
|
|
149
70
|
def stage_abbr(docstatus)
|
150
|
-
status_print(docstatus).split(/ /)
|
151
|
-
.map { |s| s[0].upcase }.join('')
|
71
|
+
status_print(docstatus).split(/ /).map { |s| s[0].upcase }.join('')
|
152
72
|
end
|
153
73
|
|
154
74
|
def unpublished(status)
|
@@ -156,7 +76,7 @@ module IsoDoc
|
|
156
76
|
end
|
157
77
|
|
158
78
|
def status_print(status)
|
159
|
-
status.split(
|
79
|
+
status.split(/[- ]/).map(&:capitalize).join(' ')
|
160
80
|
end
|
161
81
|
|
162
82
|
def docid(isoxml, _out)
|
@@ -164,18 +84,23 @@ module IsoDoc
|
|
164
84
|
set(:docnumber, dn&.text)
|
165
85
|
end
|
166
86
|
|
87
|
+
def otherid(isoxml, _out)
|
88
|
+
dn = isoxml.at(ns('//bibdata/docidentifier[@type = "ISBN"]'))
|
89
|
+
set(:isbn, dn&.text)
|
90
|
+
dn = isoxml.at(ns('//bibdata/docidentifier[@type = "ISBN10"]'))
|
91
|
+
set(:isbn10, dn&.text)
|
92
|
+
end
|
93
|
+
|
167
94
|
def docnumeric(isoxml, _out)
|
168
95
|
dn = isoxml.at(ns('//bibdata/docnumber'))
|
169
96
|
set(:docnumeric, dn&.text)
|
170
97
|
end
|
171
98
|
|
172
99
|
def draftinfo(draft, revdate)
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
draftinfo += ')'
|
178
|
-
end
|
100
|
+
return "" unless draft
|
101
|
+
draftinfo = " (#{@labels['draft_label']} #{draft}"
|
102
|
+
draftinfo += ", #{revdate}" if revdate
|
103
|
+
draftinfo += ')'
|
179
104
|
l10n(draftinfo, @lang, @script)
|
180
105
|
end
|
181
106
|
|
@@ -191,7 +116,7 @@ module IsoDoc
|
|
191
116
|
end
|
192
117
|
|
193
118
|
def title(isoxml, _out)
|
194
|
-
main = isoxml&.at(ns("//bibdata/title[@language='
|
119
|
+
main = isoxml&.at(ns("//bibdata/title[@language='#{@lang}']"))&.text
|
195
120
|
set(:doctitle, main)
|
196
121
|
end
|
197
122
|
|
@@ -231,5 +156,13 @@ module IsoDoc
|
|
231
156
|
isoxml.xpath(ns('//bibdata/keyword')).each { |kw| ret << kw.text }
|
232
157
|
set(:keywords, ret)
|
233
158
|
end
|
159
|
+
|
160
|
+
def note(isoxml, _out)
|
161
|
+
ret = []
|
162
|
+
isoxml.xpath(ns("//bibdata/note[@type = 'title-footnote']")).each do |n|
|
163
|
+
ret << n.text
|
164
|
+
end
|
165
|
+
set(:title_footnote, ret)
|
166
|
+
end
|
234
167
|
end
|
235
168
|
end
|