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.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.tb.yml +20 -10
  3. data/LICENSE +25 -0
  4. data/README.adoc +262 -34
  5. data/asciidoctor-gb.gemspec +2 -1
  6. data/bin/rspec +18 -0
  7. data/lib/asciidoctor/gb/biblio.rng +602 -0
  8. data/lib/asciidoctor/gb/converter.rb +104 -70
  9. data/lib/asciidoctor/gb/front.rb +109 -61
  10. data/lib/asciidoctor/gb/gbstandard.rng +135 -31
  11. data/lib/asciidoctor/gb/html/gb-logos/gb-issuer-default.gif +0 -0
  12. data/lib/asciidoctor/gb/html/gb-logos/gb-issuer-default.png +0 -0
  13. data/lib/asciidoctor/gb/html/gb-logos/gb-issuer-default.svg +980 -0
  14. data/lib/asciidoctor/gb/html/{gb.css → gb.scss} +133 -219
  15. data/lib/asciidoctor/gb/html/html_gb_intro.html +1 -37
  16. data/lib/asciidoctor/gb/html/html_gb_titlepage.html +6 -5
  17. data/lib/asciidoctor/gb/html/{htmlstyle.css → htmlstyle.scss} +85 -3
  18. data/lib/asciidoctor/gb/html/word_gb_intro.html +1 -1
  19. data/lib/asciidoctor/gb/html/word_gb_titlepage.html +320 -166
  20. data/lib/asciidoctor/gb/html/{wordstyle.css → wordstyle.scss} +605 -429
  21. data/lib/asciidoctor/gb/isodoc.rng +36 -564
  22. data/lib/asciidoctor/gb/isostandard.rng +198 -91
  23. data/lib/asciidoctor/gb/section_input.rb +21 -56
  24. data/lib/asciidoctor/gb/validate.rb +115 -0
  25. data/lib/asciidoctor/gb/version.rb +1 -1
  26. data/lib/asciidoctor-gb.rb +2 -1
  27. data/lib/isodoc/gb/agencies.rb +327 -0
  28. data/lib/isodoc/gb/block_output.rb +86 -0
  29. data/lib/isodoc/gb/gbcleanup.rb +87 -0
  30. data/lib/isodoc/gb/gbconvert.rb +153 -0
  31. data/lib/isodoc/gb/gbwordconvert.rb +89 -0
  32. data/lib/isodoc/gb/html/blank.png +0 -0
  33. data/lib/isodoc/gb/html/footer.png +0 -0
  34. data/lib/isodoc/gb/html/gb-logos/gb-issuer-default.gif +0 -0
  35. data/lib/isodoc/gb/html/gb-logos/gb-issuer-default.png +0 -0
  36. data/lib/isodoc/gb/html/gb-logos/gb-issuer-default.svg +980 -0
  37. data/lib/isodoc/gb/html/gb-logos/gb-standard-db.gif +0 -0
  38. data/lib/isodoc/gb/html/gb-logos/gb-standard-db.png +0 -0
  39. data/lib/isodoc/gb/html/gb-logos/gb-standard-db.svg +1 -0
  40. data/lib/isodoc/gb/html/gb-logos/gb-standard-gb.gif +0 -0
  41. data/lib/isodoc/gb/html/gb-logos/gb-standard-gb.png +0 -0
  42. data/lib/isodoc/gb/html/gb-logos/gb-standard-gb.svg +1 -0
  43. data/lib/isodoc/gb/html/gb-logos/gb-standard-gjb.gif +0 -0
  44. data/lib/isodoc/gb/html/gb-logos/gb-standard-gjb.png +0 -0
  45. data/lib/isodoc/gb/html/gb-logos/gb-standard-gjb.svg +1 -0
  46. data/lib/isodoc/gb/html/gb-logos/gb-standard-gm.gif +0 -0
  47. data/lib/isodoc/gb/html/gb-logos/gb-standard-gm.png +0 -0
  48. data/lib/isodoc/gb/html/gb-logos/gb-standard-gm.svg +1 -0
  49. data/lib/isodoc/gb/html/gb-logos/gb-standard-jjf.gif +0 -0
  50. data/lib/isodoc/gb/html/gb-logos/gb-standard-jjf.png +0 -0
  51. data/lib/isodoc/gb/html/gb-logos/gb-standard-jjf.svg +1 -0
  52. data/lib/isodoc/gb/html/gb-logos/gb-standard-zb.gif +0 -0
  53. data/lib/isodoc/gb/html/gb-logos/gb-standard-zb.png +0 -0
  54. data/lib/isodoc/gb/html/gb-logos/gb-standard-zb.svg +13 -0
  55. data/lib/isodoc/gb/html/gb.scss +556 -0
  56. data/lib/isodoc/gb/html/header.html +216 -0
  57. data/lib/isodoc/gb/html/html_gb_intro.html +9 -0
  58. data/lib/isodoc/gb/html/html_gb_titlepage.html +99 -0
  59. data/lib/isodoc/gb/html/htmlstyle.scss +269 -0
  60. data/lib/isodoc/gb/html/logo.png +0 -0
  61. data/lib/isodoc/gb/html/scripts.html +71 -0
  62. data/lib/isodoc/gb/html/word_gb_intro.html +3 -0
  63. data/lib/isodoc/gb/html/word_gb_titlepage.html +388 -0
  64. data/lib/isodoc/gb/html/wordstyle.scss +2543 -0
  65. data/lib/isodoc/gb/i18n-en.yaml +12 -0
  66. data/lib/isodoc/gb/i18n-zh-Hans.yaml +12 -0
  67. data/lib/isodoc/gb/i18n.rb +20 -0
  68. data/lib/isodoc/gb/metadata.rb +216 -0
  69. data/lib/{asciidoctor → isodoc}/gb/section_output.rb +22 -4
  70. data/lib/isodoc/gb/xref_gen.rb +17 -0
  71. metadata +75 -15
  72. data/lib/asciidoctor/gb/agencies.rb +0 -186
  73. data/lib/asciidoctor/gb/gbconvert.rb +0 -86
  74. data/lib/asciidoctor/gb/metadata.rb +0 -186
  75. 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 validate(doc)
33
- content_validate(doc)
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 check_bilingual(t, element)
45
- zh = t.at(".//#{element}[@language = 'zh']")
46
- en = t.at(".//#{element}[@language = 'en']")
47
- (en.nil? || en.text.empty?) && !(zh.nil? || zh.text.empty?) &&
48
- warn("GB: #{element} term #{zh.text} has no English counterpart")
49
- !(en.nil? || en.text.empty?) && (zh.nil? || zh.text.empty?) &&
50
- warn("GB: #{element} term #{en.text} has no Chinese counterpart")
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 bilingual_terms_validate(root)
54
- root.xpath("//term").each do |t|
55
- check_bilingual(t, "preferred")
56
- check_bilingual(t, "admitted")
57
- check_bilingual(t, "deprecates")
58
- end
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 html_doc_path(file)
62
- File.join(File.dirname(__FILE__), File.join("html", file))
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 doc_converter(node)
66
- GbConvert.new(
67
- htmlstylesheet: html_doc_path("htmlstyle.css"),
68
- wordstylesheet: html_doc_path("wordstyle.css"),
69
- standardstylesheet: html_doc_path("gb.css"),
70
- header: html_doc_path("header.html"),
71
- htmlcoverpage: html_doc_path("html_gb_titlepage.html"),
72
- wordcoverpage: html_doc_path("word_gb_titlepage.html"),
73
- htmlintropage: html_doc_path("html_gb_intro.html"),
74
- wordintropage: html_doc_path("word_gb_intro.html"),
75
- i18nyaml: node&.attr("i18nyaml"),
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
- termdef_localisedstr(xmldoc)
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
- def termdef_localisedstr(xmldoc)
88
- xmldoc.xpath("//admitted | //deprecates | //preferred").each do |zh|
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
- else
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.type
121
- when :emphasis then xml.em node.text
122
- when :strong then xml.strong node.text
123
- when :monospaced then xml.tt node.text
124
- when :double then xml << "\"#{node.text}\""
125
- when :single then xml << "'#{node.text}'"
126
- when :superscript then xml.sup node.text
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
- case node.role
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
@@ -1,20 +1,42 @@
1
1
  module Asciidoctor
2
2
  module Gb
3
3
  class Converter < ISO::Converter
4
- def metadata_author(_node, xml)
5
- xml.contributor do |c|
6
- c.role **{ type: "author" }
7
- c.organization do |a|
8
- a.name "GB"
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 metadata_publisher(_node, xml)
14
- xml.contributor do |c|
15
- c.role **{ type: "publisher" }
16
- c.organization do |a|
17
- a.name "GB"
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
- unless scope = node.attr("scope")
69
- scope = "national"
70
- warn "GB: no scope supplied, defaulting to National"
71
- end
72
- scope
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
- unless prefix = node.attr("prefix")
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
- unless mandate = node.attr("mandate")
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
- pubdate = node.attr("published-date")
104
- activdate = node.attr("activated-date")
105
- xml.date(pubdate, **{ type: "published" }) if pubdate
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
- ics = node.attr("library-ics")
111
- l = node.attr("library-l")
112
- if ics || l
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
- metadata_author(node, xml)
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 title(node, xml)
138
- ["en", "zh"].each do |lang|
139
- xml.title do |t|
140
- at = { language: lang, format: "plain" }
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 title_intro_validate(root)
157
- title_intro_en = root.at("//title-intro[@language='en']")
158
- title_intro_zh = root.at("//title-intro[@language='zh']")
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 title_part_validate(root)
168
- title_part_en = root.at("//title-part[@language='en']")
169
- title_part_zh = root.at("//title-part[@language='zh']")
170
- if title_part_en.nil? && !title_part_zh.nil?
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
- if !title_part_en.nil? && title_part_zh.nil?
174
- warn "No Chinese Title Part!"
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