isodoc 1.2.3 → 1.2.8
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 +69 -0
- data/README.adoc +1 -3
- data/isodoc.gemspec +3 -1
- data/lib/isodoc-yaml/i18n-en.yaml +1 -0
- data/lib/isodoc-yaml/i18n-fr.yaml +9 -8
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
- 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/inline.rb +0 -33
- data/lib/isodoc/function/references.rb +5 -3
- data/lib/isodoc/function/table.rb +1 -0
- data/lib/isodoc/function/to_word_html.rb +3 -2
- data/lib/isodoc/function/utils.rb +1 -1
- data/lib/isodoc/html_function/postprocess.rb +1 -0
- data/lib/isodoc/i18n.rb +23 -52
- 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 +28 -9
- data/lib/isodoc/presentation_function/inline.rb +149 -34
- data/lib/isodoc/presentation_xml_convert.rb +7 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +12 -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 +22 -5
- data/spec/isodoc/blocks_spec.rb +331 -215
- data/spec/isodoc/footnotes_spec.rb +4 -5
- data/spec/isodoc/i18n_spec.rb +89 -16
- data/spec/isodoc/inline_spec.rb +185 -163
- data/spec/isodoc/metadata_spec.rb +69 -19
- data/spec/isodoc/postproc_spec.rb +40 -3
- data/spec/isodoc/presentation_xml_spec.rb +584 -1
- data/spec/isodoc/ref_spec.rb +5 -5
- data/spec/isodoc/section_spec.rb +9 -9
- 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: 491a322b0df2e6b1c8b4f12e520ca349657a009058b416067acdd5437a16085c
|
4
|
+
data.tar.gz: 1f52844ffdc37875d2b40f8d46f52263abcbe5101c99adaf88d839a28a18ed49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce472eadec9ab44d5739f0e506813cb89cf7de6def2909e8ffd0788cf4fe246bf3433b75c22490528b0287bbfad1e2cc5ca50eeaacdd4156fe9bb32a36e912df
|
7
|
+
data.tar.gz: efb30d195c6a15f97133b76d1d4cac762800fe7620d11a58a2655e7ccd3bc972827d419337cbff13fb7d1c4b96004da7b9d95323ae7d8f6c1eaa07d784f67834
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
|
+
name: rake
|
4
|
+
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
branches: [ master, main ]
|
8
|
+
tags: [ v* ]
|
9
|
+
pull_request:
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
rake:
|
13
|
+
name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
|
14
|
+
runs-on: ${{ matrix.os }}
|
15
|
+
continue-on-error: ${{ matrix.experimental }}
|
16
|
+
strategy:
|
17
|
+
fail-fast: false
|
18
|
+
matrix:
|
19
|
+
ruby: [ '2.6', '2.5', '2.4' ]
|
20
|
+
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
21
|
+
experimental: [ false ]
|
22
|
+
include:
|
23
|
+
- ruby: '2.7'
|
24
|
+
os: 'ubuntu-latest'
|
25
|
+
experimental: true
|
26
|
+
- ruby: '2.7'
|
27
|
+
os: 'windows-latest'
|
28
|
+
experimental: true
|
29
|
+
- ruby: '2.7'
|
30
|
+
os: 'macos-latest'
|
31
|
+
experimental: true
|
32
|
+
steps:
|
33
|
+
- uses: actions/checkout@master
|
34
|
+
|
35
|
+
- uses: ruby/setup-ruby@v1
|
36
|
+
with:
|
37
|
+
ruby-version: ${{ matrix.ruby }}
|
38
|
+
|
39
|
+
- uses: actions/cache@v1
|
40
|
+
with:
|
41
|
+
path: vendor/bundle
|
42
|
+
key: bundle-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}
|
43
|
+
restore-keys: bundle-${{ matrix.os }}-${{ matrix.ruby }}
|
44
|
+
|
45
|
+
- run: bundle config set path 'vendor/bundle'
|
46
|
+
|
47
|
+
- run: bundle install --jobs 4 --retry 3
|
48
|
+
|
49
|
+
- name: Install Inkscape macOS
|
50
|
+
if: matrix.os == 'macos-latest'
|
51
|
+
run: |
|
52
|
+
brew cask install inkscape
|
53
|
+
inkscape --version
|
54
|
+
|
55
|
+
- name: Install Inkscape Ubuntu
|
56
|
+
if: matrix.os == 'ubuntu-latest'
|
57
|
+
run: |
|
58
|
+
sudo add-apt-repository ppa:inkscape.dev/stable
|
59
|
+
sudo apt update
|
60
|
+
sudo apt install inkscape
|
61
|
+
inkscape --version
|
62
|
+
|
63
|
+
- name: Install Inkscape Windows
|
64
|
+
if: matrix.os == 'windows-latest'
|
65
|
+
run: |
|
66
|
+
choco install --no-progress -y inkscape
|
67
|
+
inkscape --version
|
68
|
+
|
69
|
+
- run: bundle exec rake
|
data/README.adoc
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
= isodoc: Processor to generate HTML/Word from Metanorma XML
|
2
2
|
|
3
3
|
image:https://img.shields.io/gem/v/isodoc.svg["Gem Version", link="https://rubygems.org/gems/isodoc"]
|
4
|
-
image:https://github.com/metanorma/isodoc/workflows/
|
5
|
-
image:https://github.com/metanorma/isodoc/workflows/macos/badge.svg["OSX Build Status", link="https://github.com/metanorma/isodoc/actions?query=workflow%3Amacos"]
|
6
|
-
image:https://github.com/metanorma/isodoc/workflows/windows/badge.svg["Windows Build Status", link="https://github.com/metanorma/isodoc/actions?query=workflow%3Awindows"]
|
4
|
+
image:https://github.com/metanorma/isodoc/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/isodoc/actions?query=workflow%3Arake"]
|
7
5
|
image:https://codeclimate.com/github/metanorma/isodoc/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/isodoc"]
|
8
6
|
image:https://img.shields.io/github/issues-pr-raw/metanorma/isodoc.svg["Pull Requests", link="https://github.com/metanorma/isodoc/pulls"]
|
9
7
|
image:https://img.shields.io/github/commits-since/metanorma/isodoc/latest.svg["Commits since latest",link="https://github.com/metanorma/isodoc/releases"]
|
data/isodoc.gemspec
CHANGED
@@ -35,8 +35,10 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_dependency "uuidtools"
|
36
36
|
spec.add_dependency "html2doc", "~> 1.0.0"
|
37
37
|
spec.add_dependency "liquid"
|
38
|
+
spec.add_dependency "twitter_cldr"
|
38
39
|
spec.add_dependency "roman-numerals"
|
39
|
-
spec.add_dependency "metanorma", "~> 1.
|
40
|
+
spec.add_dependency "metanorma", "~> 1.2.0"
|
41
|
+
spec.add_dependency "relaton-cli"
|
40
42
|
|
41
43
|
spec.add_development_dependency "rake", "~> 13.0"
|
42
44
|
spec.add_development_dependency "byebug", "~> 9.1"
|
@@ -36,6 +36,7 @@ external_terms_boilerplate: |
|
|
36
36
|
internal_external_terms_boilerplate: |
|
37
37
|
<p>For the purposes of this document, the terms and definitions
|
38
38
|
given in % and the following apply.</p>
|
39
|
+
term_defined_in: "[term defined in %]"
|
39
40
|
note: NOTE
|
40
41
|
note_xref: Note
|
41
42
|
termnote: Note % to entry
|
@@ -1,6 +1,6 @@
|
|
1
1
|
term_def_boilerplate:
|
2
|
-
scope: Domaine d
|
3
|
-
|
2
|
+
scope: Domaine d’application
|
3
|
+
symbolsabbrev: Symboles et termes abrégés
|
4
4
|
abbrev: Termes abrégés
|
5
5
|
symbols: Symboles
|
6
6
|
table_of_contents: Sommaire
|
@@ -18,20 +18,21 @@ clause: Article
|
|
18
18
|
annex: Annexe
|
19
19
|
appendix: Appendice
|
20
20
|
no_terms_boilerplate: |
|
21
|
-
<p>Aucun terme n
|
21
|
+
<p>Aucun terme n’est defini dans le présent document.</p>
|
22
22
|
internal_terms_boilerplate: |
|
23
|
-
<p>Pour les besoins du présent document, les termes et définitions suivants s
|
23
|
+
<p>Pour les besoins du présent document, les termes et définitions suivants s’appliquent.</p>
|
24
24
|
norm_with_refs_pref:
|
25
|
-
Les documents suivants
|
25
|
+
Les documents suivants cités dans le texte constituent, pour tout ou partie de leur contenu, des exigences du présent document. Pour les références datées, seule l’édition citée s’applique. Pour les références non datées, la dernière édition du document de référence s’applique (y compris les éventuels amendements).
|
26
26
|
norm_empty_pref:
|
27
27
|
Le présent document ne contient aucune référence normative.
|
28
28
|
external_terms_boilerplate: |
|
29
|
-
<p>Pour les besoins du présent document, les termes et définitions de % s
|
29
|
+
<p>Pour les besoins du présent document, les termes et définitions de % s’appliquent.</p>
|
30
30
|
internal_external_terms_boilerplate: |
|
31
|
-
<p>Pour les besoins du présent document, les termes et définitions de % ainsi que les suivants, s
|
31
|
+
<p>Pour les besoins du présent document, les termes et définitions de % ainsi que les suivants, s’appliquent.</p>
|
32
|
+
term_defined_in: "[terme défini dans %]"
|
32
33
|
note: NOTE
|
33
34
|
note_xref: Note
|
34
|
-
termnote: Note % à l
|
35
|
+
termnote: Note % à l’article
|
35
36
|
figure: Figure
|
36
37
|
formula: Formule
|
37
38
|
inequality: Formule
|
@@ -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
|
@@ -67,19 +67,6 @@ module IsoDoc::Function
|
|
67
67
|
out << "Termbase #{node['base']}, term ID #{node['target']}"
|
68
68
|
end
|
69
69
|
|
70
|
-
def concept_parse(node, out)
|
71
|
-
content = node.first_element_child.children.select do |c|
|
72
|
-
!%w{locality localityStack}.include? c.name
|
73
|
-
end.select { |c| !c.text? || /\S/.match(c) }
|
74
|
-
if content.empty?
|
75
|
-
out << "[Term defined in "
|
76
|
-
parse(node.first_element_child, out)
|
77
|
-
out << "]"
|
78
|
-
else
|
79
|
-
content.each { |n| parse(n, out) }
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
70
|
def stem_parse(node, out)
|
84
71
|
ooml = if node["type"] == "AsciiMath"
|
85
72
|
"#{@openmathdelim}#{HTMLEntities.new.encode(node.text)}"\
|
@@ -131,25 +118,5 @@ module IsoDoc::Function
|
|
131
118
|
p.b(**{ role: "strong" }) { |e| e << text }
|
132
119
|
end
|
133
120
|
end
|
134
|
-
|
135
|
-
def variant_parse(node, out)
|
136
|
-
if node["lang"] == @lang && node["script"] == @script
|
137
|
-
node.children.each { |n| parse(n, out) }
|
138
|
-
else
|
139
|
-
return if found_matching_variant_sibling(node)
|
140
|
-
return unless !node.at("./preceding-sibling::xmlns:variant")
|
141
|
-
node.children.each { |n| parse(n, out) }
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
def found_matching_variant_sibling(node)
|
146
|
-
prev = node.xpath("./preceding-sibling::xmlns:variant")
|
147
|
-
foll = node.xpath("./following-sibling::xmlns:variant")
|
148
|
-
found = false
|
149
|
-
(prev + foll).each do |n|
|
150
|
-
found = true if n["lang"] == @lang && n["script"] == @script
|
151
|
-
end
|
152
|
-
found
|
153
|
-
end
|
154
121
|
end
|
155
122
|
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)"
|
@@ -89,7 +90,7 @@ module IsoDoc::Function
|
|
89
90
|
end
|
90
91
|
|
91
92
|
def date_note_process(b, ref)
|
92
|
-
date_note = b.at(ns("./note[@type = '
|
93
|
+
date_note = b.at(ns("./note[@type = 'Unpublished-Status']"))
|
93
94
|
return if date_note.nil?
|
94
95
|
date_note.children.first.replace("<p>#{date_note.content}</p>")
|
95
96
|
footnote_parse(date_note, ref)
|
@@ -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
|
@@ -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;'}
|
@@ -96,6 +96,7 @@ module IsoDoc::Function
|
|
96
96
|
@meta.subtitle isoxml, out
|
97
97
|
@meta.docstatus isoxml, out
|
98
98
|
@meta.docid isoxml, out
|
99
|
+
@meta.otherid isoxml, out
|
99
100
|
@meta.docnumeric isoxml, out
|
100
101
|
@meta.doctype isoxml, out
|
101
102
|
@meta.author isoxml, out
|
@@ -104,6 +105,7 @@ module IsoDoc::Function
|
|
104
105
|
@meta.version isoxml, out
|
105
106
|
@meta.url isoxml, out
|
106
107
|
@meta.keywords isoxml, out
|
108
|
+
@meta.note isoxml, out
|
107
109
|
@meta.get
|
108
110
|
end
|
109
111
|
|
@@ -213,14 +215,13 @@ module IsoDoc::Function
|
|
213
215
|
when "verification" then requirement_component_parse(node, out)
|
214
216
|
when "import" then requirement_component_parse(node, out)
|
215
217
|
when "index" then index_parse(node, out)
|
216
|
-
when "concept" then concept_parse(node, out)
|
217
218
|
when "termref" then termrefelem_parse(node, out)
|
218
219
|
when "copyright-statement" then copyright_parse(node, out)
|
219
220
|
when "license-statement" then license_parse(node, out)
|
220
221
|
when "legal-statement" then legal_parse(node, out)
|
221
222
|
when "feedback-statement" then feedback_parse(node, out)
|
222
223
|
when "passthrough" then passthrough_parse(node, out)
|
223
|
-
when "
|
224
|
+
when "amend" then amend_parse(node, out)
|
224
225
|
when "tab" then clausedelimspace(out) # in Presentation XML only
|
225
226
|
else
|
226
227
|
error_parse(node, out)
|
data/lib/isodoc/i18n.rb
CHANGED
@@ -1,12 +1,24 @@
|
|
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)
|
7
6
|
ret = load_yaml1(lang, script)
|
8
|
-
return ret.merge(YAML.load_file(i18nyaml)) if i18nyaml
|
9
|
-
ret
|
7
|
+
return normalise_hash(ret.merge(YAML.load_file(i18nyaml))) if i18nyaml
|
8
|
+
normalise_hash(ret)
|
9
|
+
end
|
10
|
+
|
11
|
+
def normalise_hash(ret)
|
12
|
+
if ret.is_a? Hash
|
13
|
+
ret.each do |k, v|
|
14
|
+
ret[k] = normalise_hash(v)
|
15
|
+
end
|
16
|
+
ret
|
17
|
+
elsif ret.is_a? Array then ret.map { |n| normalise_hash(n) }
|
18
|
+
elsif ret.is_a? String then ret.unicode_normalize(:nfc)
|
19
|
+
else
|
20
|
+
ret
|
21
|
+
end
|
10
22
|
end
|
11
23
|
|
12
24
|
def load_yaml1(lang, script)
|
@@ -43,55 +55,6 @@ module IsoDoc
|
|
43
55
|
@labels.each do |k, v|
|
44
56
|
self.class.send(:define_method, k.downcase) { v }
|
45
57
|
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
58
|
end
|
96
59
|
|
97
60
|
def self.l10n(x, lang = @lang, script = @script)
|
@@ -116,6 +79,14 @@ module IsoDoc
|
|
116
79
|
end
|
117
80
|
end
|
118
81
|
|
82
|
+
def multiple_and(names, andword)
|
83
|
+
return '' if names.empty?
|
84
|
+
return names[0] if names.length == 1
|
85
|
+
(names.length == 2) &&
|
86
|
+
(return l10n("#{names[0]} #{andword} #{names[1]}", @lang, @script))
|
87
|
+
l10n(names[0..-2].join(', ') + " #{andword} #{names[-1]}", @lang, @script)
|
88
|
+
end
|
89
|
+
|
119
90
|
#module_function :l10n
|
120
91
|
|
121
92
|
end
|