asciidoctor-gb 0.1.5 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.tb.yml +20 -10
- data/LICENSE +25 -0
- data/README.adoc +262 -34
- data/asciidoctor-gb.gemspec +2 -1
- data/bin/rspec +18 -0
- data/lib/asciidoctor/gb/biblio.rng +602 -0
- data/lib/asciidoctor/gb/converter.rb +104 -70
- data/lib/asciidoctor/gb/front.rb +109 -61
- data/lib/asciidoctor/gb/gbstandard.rng +135 -31
- data/lib/asciidoctor/gb/html/gb-logos/gb-issuer-default.gif +0 -0
- data/lib/asciidoctor/gb/html/gb-logos/gb-issuer-default.png +0 -0
- data/lib/asciidoctor/gb/html/gb-logos/gb-issuer-default.svg +980 -0
- data/lib/asciidoctor/gb/html/{gb.css → gb.scss} +133 -219
- data/lib/asciidoctor/gb/html/html_gb_intro.html +1 -37
- data/lib/asciidoctor/gb/html/html_gb_titlepage.html +6 -5
- data/lib/asciidoctor/gb/html/{htmlstyle.css → htmlstyle.scss} +85 -3
- data/lib/asciidoctor/gb/html/word_gb_intro.html +1 -1
- data/lib/asciidoctor/gb/html/word_gb_titlepage.html +320 -166
- data/lib/asciidoctor/gb/html/{wordstyle.css → wordstyle.scss} +605 -429
- data/lib/asciidoctor/gb/isodoc.rng +36 -564
- data/lib/asciidoctor/gb/isostandard.rng +198 -91
- data/lib/asciidoctor/gb/section_input.rb +21 -56
- data/lib/asciidoctor/gb/validate.rb +115 -0
- data/lib/asciidoctor/gb/version.rb +1 -1
- data/lib/asciidoctor-gb.rb +2 -1
- data/lib/isodoc/gb/agencies.rb +327 -0
- data/lib/isodoc/gb/block_output.rb +86 -0
- data/lib/isodoc/gb/gbcleanup.rb +87 -0
- data/lib/isodoc/gb/gbconvert.rb +153 -0
- data/lib/isodoc/gb/gbwordconvert.rb +89 -0
- data/lib/isodoc/gb/html/blank.png +0 -0
- data/lib/isodoc/gb/html/footer.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-issuer-default.gif +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-issuer-default.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-issuer-default.svg +980 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-db.gif +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-db.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-db.svg +1 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gb.gif +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gb.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gb.svg +1 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gjb.gif +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gjb.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gjb.svg +1 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gm.gif +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gm.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gm.svg +1 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-jjf.gif +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-jjf.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-jjf.svg +1 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-zb.gif +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-zb.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-zb.svg +13 -0
- data/lib/isodoc/gb/html/gb.scss +556 -0
- data/lib/isodoc/gb/html/header.html +216 -0
- data/lib/isodoc/gb/html/html_gb_intro.html +9 -0
- data/lib/isodoc/gb/html/html_gb_titlepage.html +99 -0
- data/lib/isodoc/gb/html/htmlstyle.scss +269 -0
- data/lib/isodoc/gb/html/logo.png +0 -0
- data/lib/isodoc/gb/html/scripts.html +71 -0
- data/lib/isodoc/gb/html/word_gb_intro.html +3 -0
- data/lib/isodoc/gb/html/word_gb_titlepage.html +388 -0
- data/lib/isodoc/gb/html/wordstyle.scss +2543 -0
- data/lib/isodoc/gb/i18n-en.yaml +12 -0
- data/lib/isodoc/gb/i18n-zh-Hans.yaml +12 -0
- data/lib/isodoc/gb/i18n.rb +20 -0
- data/lib/isodoc/gb/metadata.rb +216 -0
- data/lib/{asciidoctor → isodoc}/gb/section_output.rb +22 -4
- data/lib/isodoc/gb/xref_gen.rb +17 -0
- metadata +75 -15
- data/lib/asciidoctor/gb/agencies.rb +0 -186
- data/lib/asciidoctor/gb/gbconvert.rb +0 -86
- data/lib/asciidoctor/gb/metadata.rb +0 -186
- data/lib/asciidoctor/gb/xref_gen.rb +0 -25
@@ -1,9 +1,9 @@
|
|
1
1
|
require "asciidoctor"
|
2
|
-
require "asciidoctor/gb/version"
|
3
|
-
require "asciidoctor/gb/gbconvert"
|
4
2
|
require "asciidoctor/iso/converter"
|
3
|
+
require "asciidoctor/gb/version"
|
5
4
|
require_relative "./section_input.rb"
|
6
5
|
require_relative "./front.rb"
|
6
|
+
require_relative "./validate.rb"
|
7
7
|
require "pp"
|
8
8
|
|
9
9
|
module Asciidoctor
|
@@ -29,66 +29,89 @@ module Asciidoctor
|
|
29
29
|
ret1
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
33
|
-
|
34
|
-
schema_validate(formattedstr_strip(doc.dup),
|
35
|
-
File.join(File.dirname(__FILE__), "gbstandard.rng"))
|
36
|
-
end
|
37
|
-
|
38
|
-
def content_validate(doc)
|
39
|
-
super
|
40
|
-
bilingual_terms_validate(doc.root)
|
41
|
-
doc_converter(nil).gbtype_validate(doc.root)
|
32
|
+
def html_doc_path(file)
|
33
|
+
File.join(File.dirname(__FILE__), File.join("html", file))
|
42
34
|
end
|
43
35
|
|
44
|
-
def
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
36
|
+
def html_converter(node)
|
37
|
+
node.nil? ? IsoDoc::Gb::Convert.new({}) :
|
38
|
+
IsoDoc::Gb::Convert.new(
|
39
|
+
script: node.attr("script"),
|
40
|
+
bodyfont: node.attr("body-font"),
|
41
|
+
headerfont: node.attr("header-font"),
|
42
|
+
monospacefont: node.attr("monospace-font"),
|
43
|
+
titlefont: node.attr("title-font"),
|
44
|
+
i18nyaml: node.attr("i18nyaml"),
|
45
|
+
scope: node.attr("scope"),
|
46
|
+
)
|
51
47
|
end
|
52
48
|
|
53
|
-
def
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
49
|
+
def doc_converter(node)
|
50
|
+
node.nil? ? IsoDoc::Gb::WordConvert.new({}) :
|
51
|
+
IsoDoc::Gb::WordConvert.new(
|
52
|
+
script: node.attr("script"),
|
53
|
+
bodyfont: node.attr("body-font"),
|
54
|
+
headerfont: node.attr("header-font"),
|
55
|
+
monospacefont: node.attr("monospace-font"),
|
56
|
+
titlefont: node.attr("title-font"),
|
57
|
+
i18nyaml: node.attr("i18nyaml"),
|
58
|
+
scope: node.attr("scope"),
|
59
|
+
)
|
59
60
|
end
|
60
61
|
|
61
|
-
def
|
62
|
-
|
62
|
+
def default_fonts(node)
|
63
|
+
script = node.attr("script") || "Hans"
|
64
|
+
b = node.attr("body-font") ||
|
65
|
+
(script == "Hans" ? '"SimSun",serif' :
|
66
|
+
script == "Latn" ? '"Cambria",serif' : '"SimSun",serif' )
|
67
|
+
h = node.attr("header-font") ||
|
68
|
+
(script == "Hans" ? '"SimHei",sans-serif' :
|
69
|
+
script == "Latn" ? '"Calibri",sans-serif' : '"SimHei",sans-serif' )
|
70
|
+
m = node.attr("monospace-font") || '"Courier New",monospace'
|
71
|
+
scope = node.attr("scope") || "national"
|
72
|
+
t = node.attr("title-font") ||
|
73
|
+
(scope == "national" ? (script != "Hans" ? '"Cambria",serif' : '"SimSun",serif' ) :
|
74
|
+
(script == "Hans" ? '"SimHei",sans-serif' : '"Calibri",sans-serif' ))
|
75
|
+
"$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n$titlefont: #{t};\n"
|
63
76
|
end
|
64
77
|
|
65
|
-
def
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
78
|
+
def document(node)
|
79
|
+
init(node)
|
80
|
+
ret = makexml(node).to_xml(indent: 2)
|
81
|
+
filename = node.attr("docfile").gsub(/\.adoc$/, "").gsub(%r{^.*/}, "")
|
82
|
+
File.open(filename, "w") { |f| f.write(ret) }
|
83
|
+
unless node.attr("nodoc")
|
84
|
+
#html_converter_alt(node).convert(filename + ".xml")
|
85
|
+
#system "mv #{filename}.html #{filename}_alt.html"
|
86
|
+
html_converter(node).convert(filename + ".xml")
|
87
|
+
doc_converter(node).convert(filename + ".xml")
|
88
|
+
end
|
89
|
+
@files_to_delete.each { |f| system "rm #{f}" }
|
90
|
+
ret
|
77
91
|
end
|
78
92
|
|
79
93
|
def termdef_cleanup(xmldoc)
|
80
94
|
super
|
81
|
-
|
95
|
+
localisedstr(xmldoc)
|
82
96
|
end
|
83
97
|
|
84
98
|
ROMAN_TEXT = /\s*[a-z\u00c0-\u00d6\u00d8-\u00f0\u0100-\u0240]/i
|
85
99
|
HAN_TEXT = /\s*[\u4e00-\u9fff]+/
|
86
100
|
|
87
|
-
|
88
|
-
|
101
|
+
LOCALISED_ELEMS = "//admitted | //deprecates | //preferred | //prefix | "\
|
102
|
+
"//initial | //addition | //surname | //forename | //name | "\
|
103
|
+
"//abbreviation | //role/description | //affiliation/description | "\
|
104
|
+
"//bibdata/item | //bibitem/title | //bibdata/formattedref | "\
|
105
|
+
"//bibitem/formattedref | //bibdata/note | //bibitem/note | "\
|
106
|
+
"//bibdata/abstract | //bibitem/note ".freeze
|
107
|
+
|
108
|
+
MUST_LOCALISE_ELEMS = %w{admitted deprecates preferred}.freeze
|
109
|
+
|
110
|
+
def localisedstr(xmldoc)
|
111
|
+
xmldoc.xpath(LOCALISED_ELEMS).each do |zh|
|
89
112
|
if zh.at("./string")
|
90
113
|
extract_localisedstrings(zh)
|
91
|
-
|
114
|
+
elsif MUST_LOCALISE_ELEMS.include? zh.name
|
92
115
|
duplicate_localisedstrings(zh)
|
93
116
|
end
|
94
117
|
end
|
@@ -116,34 +139,20 @@ module Asciidoctor
|
|
116
139
|
end
|
117
140
|
|
118
141
|
def inline_quoted(node)
|
119
|
-
noko do |xml|
|
120
|
-
case node.
|
121
|
-
when
|
122
|
-
when
|
123
|
-
when
|
124
|
-
|
125
|
-
when
|
126
|
-
|
127
|
-
when :subscript then xml.sub node.text
|
128
|
-
when :asciimath then xml.stem node.text, **{ type: "AsciiMath" }
|
142
|
+
ret = noko do |xml|
|
143
|
+
case node.role
|
144
|
+
when "en" then xml.string node.text, **{ language: "en" }
|
145
|
+
when "zh" then xml.string node.text, **{ language: "zh" }
|
146
|
+
when "zh-Hans"
|
147
|
+
xml.string node.text, **{ language: "zh", script: "Hans" }
|
148
|
+
when "zh-Hant"
|
149
|
+
xml.string node.text, **{ language: "zh", script: "Hant" }
|
129
150
|
else
|
130
|
-
|
131
|
-
when "alt" then xml.admitted { |a| a << node.text }
|
132
|
-
when "deprecated" then xml.deprecates { |a| a << node.text }
|
133
|
-
when "domain" then xml.domain { |a| a << node.text }
|
134
|
-
when "strike" then xml.strike node.text
|
135
|
-
when "smallcap" then xml.smallcap node.text
|
136
|
-
when "en" then xml.string node.text, **{ language: "en" }
|
137
|
-
when "zh" then xml.string node.text, **{ language: "zh" }
|
138
|
-
when "zh-Hans"
|
139
|
-
xml.string node.text, **{ language: "zh", script: "Hans" }
|
140
|
-
when "zh-Hant"
|
141
|
-
xml.string node.text, **{ language: "zh", script: "Hant" }
|
142
|
-
else
|
143
|
-
xml << node.text
|
144
|
-
end
|
151
|
+
nil
|
145
152
|
end
|
146
153
|
end.join
|
154
|
+
return ret unless ret.nil? or ret.empty?
|
155
|
+
super
|
147
156
|
end
|
148
157
|
|
149
158
|
def termdef_boilerplate_cleanup(xmldoc)
|
@@ -153,7 +162,7 @@ module Asciidoctor
|
|
153
162
|
GBCODE = "((AQ|BB|CB|CH|CJ|CY|DA|DB|DL|DZ|EJ|FZ|GA|GH|GM|GY|HB|HG|"\
|
154
163
|
"HJ|HS|HY|JB|JC|JG|JR|JT|JY|LB|LD|LS|LY|MH|MT|MZ|NY|QB|QC|QJ|"\
|
155
164
|
"QZ|SB|SC|SH|SJ|SN|SY|TB|TD|TJ|TY|WB|WH|WJ|WM|WS|WW|XB|YB|YC|"\
|
156
|
-
"YD|YS|YY|YZ|ZY|GB|GBZ|GJB|GBn|GHZB|GWKB|GWPB|JJF|JJG)(/Z|/T)?)"
|
165
|
+
"YD|YS|YY|YZ|ZY|GB|GBZ|GJB|GBn|GHZB|GWKB|GWPB|JJF|JJG|Q|T)(/Z|/T)?)"
|
157
166
|
|
158
167
|
ISO_REF = %r{^<ref\sid="(?<anchor>[^"]+)">
|
159
168
|
\[(?<code>(ISO|IEC|#{GBCODE})[^0-9]*\s[0-9-]+)(:(?<year>[0-9]+))?\]</ref>,?\s
|
@@ -163,7 +172,6 @@ module Asciidoctor
|
|
163
172
|
\[(?<code>(ISO|IEC|#{GBCODE})[^0-9]*\s[0-9-]+):--\]</ref>,?\s?
|
164
173
|
<fn[^>]*>\s*<p>(?<fn>[^\]]+)</p>\s*</fn>,?\s?(?<text>.*)$}xm
|
165
174
|
|
166
|
-
# TODO: all parts in ZH
|
167
175
|
ISO_REF_ALL_PARTS = %r{^<ref\sid="(?<anchor>[^"]+)">
|
168
176
|
\[(?<code>(ISO|IEC|#{GBCODE})[^0-9]*\s[0-9]+)\s\(all\sparts\)\]</ref>(<p>)?,?\s?
|
169
177
|
(?<text>.*)(</p>)?$}xm
|
@@ -174,6 +182,32 @@ module Asciidoctor
|
|
174
182
|
matched3 = ISO_REF_ALL_PARTS.match item
|
175
183
|
[matched, matched2, matched3]
|
176
184
|
end
|
185
|
+
|
186
|
+
def cleanup(xmldoc)
|
187
|
+
super
|
188
|
+
contributor_cleanup(xmldoc)
|
189
|
+
xmldoc
|
190
|
+
end
|
191
|
+
|
192
|
+
def contributor_cleanup(xmldoc)
|
193
|
+
issuer = xmldoc.at("//bibdata/contributor[role/@type = 'issuer']/organization/name")
|
194
|
+
scope = xmldoc.at("//gbscope")&.text
|
195
|
+
prefix = xmldoc.at("//gbprefix")&.text
|
196
|
+
mandate = xmldoc.at("//gbmandate")&.text || "mandatory"
|
197
|
+
lang = xmldoc.at("//language")&.text
|
198
|
+
agency = issuer.content
|
199
|
+
agency = IsoDoc::Gb::Convert.new({}).standard_agency1(scope, prefix, mandate) if agency == "GB"
|
200
|
+
agency = "GB" unless agency
|
201
|
+
owner = xmldoc.at("//copyright/owner/organization/name")
|
202
|
+
owner.content = agency
|
203
|
+
owner = xmldoc.at("//contributor[role/@type = 'issuer']/organization/name")
|
204
|
+
owner.content = agency
|
205
|
+
xmldoc.xpath("//gbcommittee").each do |c|
|
206
|
+
xmldoc.at("//bibdata/contributor").next =
|
207
|
+
"<contributor><role type='technical-committee'/><organization>"\
|
208
|
+
"<name>#{c.text}</name></organization></contributor>"
|
209
|
+
end
|
210
|
+
end
|
177
211
|
end
|
178
212
|
end
|
179
213
|
end
|
data/lib/asciidoctor/gb/front.rb
CHANGED
@@ -1,20 +1,42 @@
|
|
1
1
|
module Asciidoctor
|
2
2
|
module Gb
|
3
3
|
class Converter < ISO::Converter
|
4
|
-
def
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
def standard_type(node)
|
5
|
+
type = node.attr("mandate") || "mandatory"
|
6
|
+
type = "standard" if type == "mandatory"
|
7
|
+
type = "recommendation" if type == "recommended"
|
8
|
+
type
|
9
|
+
end
|
10
|
+
|
11
|
+
def front(node, xml)
|
12
|
+
xml.bibdata **attr_code(type: standard_type(node)) do |b|
|
13
|
+
metadata node, b
|
14
|
+
end
|
15
|
+
metadata_version(node, xml)
|
16
|
+
end
|
17
|
+
|
18
|
+
def metadata_author(node, xml)
|
19
|
+
author = node.attr("author") || return
|
20
|
+
author.split(/, ?/).each do |author|
|
21
|
+
xml.contributor do |c|
|
22
|
+
c.role **{ type: "author" }
|
23
|
+
c.person do |p|
|
24
|
+
p.name do |n|
|
25
|
+
n.surname author
|
26
|
+
end
|
27
|
+
end
|
9
28
|
end
|
10
29
|
end
|
11
30
|
end
|
12
31
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
32
|
+
def metadata_contributor1(node, xml, type, role)
|
33
|
+
contrib = node.attr(type) || "GB"
|
34
|
+
contrib.split(/, ?/).each do |c|
|
35
|
+
xml.contributor do |x|
|
36
|
+
x.role **{ type: role }
|
37
|
+
x.organization do |a|
|
38
|
+
a.name { |n| n << c }
|
39
|
+
end
|
18
40
|
end
|
19
41
|
end
|
20
42
|
end
|
@@ -65,16 +87,24 @@ module Asciidoctor
|
|
65
87
|
end
|
66
88
|
|
67
89
|
def get_scope(node)
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
90
|
+
node.attr("scope") and return node.attr("scope")
|
91
|
+
scope = if %r{^[TQ]/}.match? node.attr("prefix")
|
92
|
+
m = node.attr("prefix").split(%{/})
|
93
|
+
mandate = m[0] == "T" ? "social" :
|
94
|
+
m[0] == "Q" ? "enterprise" : nil
|
95
|
+
end
|
96
|
+
return scope unless scope.nil?
|
97
|
+
warn "GB: no scope supplied, defaulting to National"
|
98
|
+
"national"
|
73
99
|
end
|
74
100
|
|
75
101
|
def get_prefix(node)
|
76
102
|
scope = get_scope(node)
|
77
|
-
|
103
|
+
if prefix = node.attr("prefix")
|
104
|
+
prefix.gsub!(%r{/[TZ]$}, "")
|
105
|
+
prefix.gsub!(%r{^[TQ]/([TZ]/)?}, "")
|
106
|
+
prefix.gsub!(/^DB/, "") if scope == "local"
|
107
|
+
else
|
78
108
|
prefix = "GB"
|
79
109
|
scope = "national"
|
80
110
|
warn "GB: no prefix supplied, defaulting to GB"
|
@@ -83,95 +113,113 @@ module Asciidoctor
|
|
83
113
|
end
|
84
114
|
|
85
115
|
def get_mandate(node)
|
86
|
-
|
116
|
+
node.attr("mandate") and return node.attr("mandate")
|
117
|
+
p = node.attr("prefix")
|
118
|
+
mandate = %r{/T}.match?(p) ? "recommended" :
|
119
|
+
%r{/Z}.match?(p) ? "guidelines" : nil
|
120
|
+
if mandate.nil?
|
87
121
|
mandate = "mandatory"
|
88
122
|
warn "GB: no mandate supplied, defaulting to mandatory"
|
89
123
|
end
|
90
124
|
mandate
|
91
125
|
end
|
92
126
|
|
127
|
+
def get_topic(node)
|
128
|
+
node.attr("topic") and return node.attr("topic")
|
129
|
+
warn "GB: no topic supplied, defaulting to basic"
|
130
|
+
"basic"
|
131
|
+
end
|
132
|
+
|
93
133
|
def metadata_gbtype(node, xml)
|
94
134
|
xml.gbtype do |t|
|
95
135
|
scope, prefix = get_prefix(node)
|
96
136
|
t.gbscope { |s| s << scope }
|
97
137
|
t.gbprefix { |p| p << prefix }
|
98
138
|
t.gbmandate { |m| m << get_mandate(node) }
|
139
|
+
t.gbtopic { |t| t << get_topic(node) }
|
99
140
|
end
|
100
141
|
end
|
101
142
|
|
143
|
+
def metadata_date1(node, xml, type)
|
144
|
+
date = node.attr("#{type}-date")
|
145
|
+
date and xml.date **{ type: type } do |d|
|
146
|
+
d.from date
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
DATETYPES = %w{ published accessed created implemented obsoleted
|
151
|
+
confirmed updated issued
|
152
|
+
}.freeze
|
153
|
+
|
102
154
|
def metadata_date(node, xml)
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
xml.date(activdate, **{ type: "activated" }) if activdate
|
155
|
+
DATETYPES.each do |t|
|
156
|
+
metadata_date1(node, xml, t)
|
157
|
+
end
|
107
158
|
end
|
108
159
|
|
109
160
|
def metadata_gblibraryids(node, xml)
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
xml.gblibraryids do |g|
|
114
|
-
xml.ics ics if ics
|
115
|
-
xml.l l if l
|
116
|
-
end
|
161
|
+
ccs = node.attr("library-ccs")
|
162
|
+
ccs and ccs.split(/, ?/).each do |l|
|
163
|
+
xml.ccs { |c| c << l }
|
117
164
|
end
|
165
|
+
l = node.attr("library-plan")
|
166
|
+
l && xml.plannumber { |plan| plan << l }
|
167
|
+
end
|
168
|
+
|
169
|
+
def metadata_contributors(node, xml)
|
170
|
+
metadata_author(node, xml)
|
171
|
+
metadata_contributor1(node, xml, "author-committee", "author")
|
172
|
+
metadata_contributor1(node, xml, "publisher", "publisher")
|
173
|
+
metadata_contributor1(node, xml, "authority", "authority")
|
174
|
+
metadata_contributor1(node, xml, "proposer", "proposer")
|
175
|
+
metadata_contributor1(node, xml, "issuer", "issuer")
|
118
176
|
end
|
119
177
|
|
120
178
|
def metadata(node, xml)
|
121
179
|
title node, xml
|
122
180
|
metadata_id(node, xml)
|
123
181
|
metadata_date(node, xml)
|
124
|
-
|
125
|
-
metadata_publisher(node, xml)
|
182
|
+
metadata_contributors(node, xml)
|
126
183
|
xml.language (node.attr("language") || "zh")
|
127
184
|
xml.script (node.attr("script") || "Hans")
|
128
185
|
metadata_status(node, xml)
|
129
186
|
metadata_copyright(node, xml)
|
130
187
|
metadata_equivalence(node, xml)
|
131
188
|
metadata_obsoletes(node, xml)
|
189
|
+
metadata_ics(node, xml)
|
132
190
|
metadata_committee(node, xml)
|
133
191
|
metadata_gbtype(node, xml)
|
134
192
|
metadata_gblibraryids(node, xml)
|
135
193
|
end
|
136
194
|
|
137
|
-
def
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
node.attr("title-intro-#{lang}") and
|
142
|
-
t.title_intro **attr_code(at) do |t1|
|
143
|
-
t1 << node.attr("title-intro-#{lang}")
|
144
|
-
end
|
145
|
-
t.title_main **attr_code(at) do |t1|
|
146
|
-
t1 << node.attr("title-main-#{lang}")
|
147
|
-
end
|
148
|
-
node.attr("title-part-#{lang}") and
|
149
|
-
t.title_part **attr_code(at) do |t1|
|
150
|
-
t1 << node.attr("title-part-#{lang}")
|
151
|
-
end
|
152
|
-
end
|
195
|
+
def title_intro(node, lang, t, at)
|
196
|
+
node.attr("title-intro-#{lang}") and
|
197
|
+
t.title_intro **attr_code(at) do |t1|
|
198
|
+
t1 << asciidoc_sub(node.attr("title-intro-#{lang}"))
|
153
199
|
end
|
154
200
|
end
|
155
201
|
|
156
|
-
def
|
157
|
-
|
158
|
-
|
159
|
-
if title_intro_en.nil? && !title_intro_zh.nil?
|
160
|
-
warn "No English Title Intro!"
|
161
|
-
end
|
162
|
-
if !title_intro_en.nil? && title_intro_zh.nil?
|
163
|
-
warn "No Chinese Title Intro!"
|
202
|
+
def title_main(node, lang, t, at)
|
203
|
+
t.title_main **attr_code(at) do |t1|
|
204
|
+
t1 << asciidoc_sub(node.attr("title-main-#{lang}"))
|
164
205
|
end
|
165
206
|
end
|
166
207
|
|
167
|
-
def
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
warn "No English Title Part!"
|
208
|
+
def title_part(node, lang, t, at)
|
209
|
+
node.attr("title-part-#{lang}") and
|
210
|
+
t.title_part **attr_code(at) do |t1|
|
211
|
+
t1 << asciidoc_sub(node.attr("title-part-#{lang}"))
|
172
212
|
end
|
173
|
-
|
174
|
-
|
213
|
+
end
|
214
|
+
|
215
|
+
def title(node, xml)
|
216
|
+
["en", "zh"].each do |lang|
|
217
|
+
xml.title do |t|
|
218
|
+
at = { language: lang, format: "plain" }
|
219
|
+
title_intro(node, lang, t, at)
|
220
|
+
title_main(node, lang, t, at)
|
221
|
+
title_part(node, lang, t, at)
|
222
|
+
end
|
175
223
|
end
|
176
224
|
end
|
177
225
|
end
|