metanorma-itu 1.2.3 → 1.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +62 -0
  3. data/README.adoc +3 -4
  4. data/lib/asciidoctor/itu/basicdoc.rng +4 -11
  5. data/lib/asciidoctor/itu/converter.rb +3 -2
  6. data/lib/asciidoctor/itu/front.rb +55 -12
  7. data/lib/asciidoctor/itu/isodoc.rng +27 -50
  8. data/lib/asciidoctor/itu/itu.rng +68 -0
  9. data/lib/asciidoctor/itu/validate.rb +1 -8
  10. data/lib/isodoc/itu/base_convert.rb +1 -6
  11. data/lib/isodoc/itu/html/_coverpage.css +8 -1
  12. data/lib/isodoc/itu/html/_coverpage.scss +4 -0
  13. data/lib/isodoc/itu/html/header.html +8 -8
  14. data/lib/isodoc/itu/html/html_itu_titlepage.html +27 -13
  15. data/lib/isodoc/itu/html/htmlstyle.css +787 -776
  16. data/lib/isodoc/itu/html/htmlstyle.scss +6 -8
  17. data/lib/isodoc/itu/html/itu.css +43 -43
  18. data/lib/isodoc/itu/html/itu.scss +44 -43
  19. data/lib/isodoc/itu/html/word_itu_intro.html +18 -0
  20. data/lib/isodoc/itu/html/word_itu_titlepage.html +139 -4
  21. data/lib/isodoc/itu/html/wordstyle.css +37 -37
  22. data/lib/isodoc/itu/html/wordstyle.scss +37 -37
  23. data/lib/isodoc/itu/html_convert.rb +7 -2
  24. data/lib/isodoc/itu/i18n-en.yaml +14 -0
  25. data/lib/isodoc/itu/itu.recommendation-annex.xsl +1020 -179
  26. data/lib/isodoc/itu/itu.recommendation.xsl +1020 -179
  27. data/lib/isodoc/itu/itu.resolution.xsl +1020 -179
  28. data/lib/isodoc/itu/itu.technical-paper.xsl +5147 -0
  29. data/lib/isodoc/itu/itu.technical-report.xsl +5147 -0
  30. data/lib/isodoc/itu/metadata.rb +64 -3
  31. data/lib/isodoc/itu/pdf_convert.rb +2 -0
  32. data/lib/isodoc/itu/presentation_xml_convert.rb +16 -0
  33. data/lib/isodoc/itu/ref.rb +0 -13
  34. data/lib/isodoc/itu/terms.rb +7 -30
  35. data/lib/isodoc/itu/word_cleanup.rb +4 -1
  36. data/lib/isodoc/itu/word_convert.rb +6 -1
  37. data/lib/isodoc/itu/xref.rb +3 -2
  38. data/lib/metanorma/itu/fonts_manifest.yaml +4 -0
  39. data/lib/metanorma/itu/processor.rb +0 -8
  40. data/lib/metanorma/itu/version.rb +1 -1
  41. data/metanorma-itu.gemspec +4 -2
  42. metadata +38 -9
  43. data/.github/workflows/macos.yml +0 -38
  44. data/.github/workflows/ubuntu.yml +0 -56
  45. data/.github/workflows/windows.yml +0 -40
@@ -1,4 +1,5 @@
1
1
  require "isodoc"
2
+ require "twitter_cldr"
2
3
 
3
4
  module IsoDoc
4
5
  module ITU
@@ -23,6 +24,12 @@ module IsoDoc
23
24
  main = isoxml&.at(ns("//bibdata/title[@language='#{@lang}']"\
24
25
  "[@type = 'subtitle']"))&.text
25
26
  set(:docsubtitle, main)
27
+ main = isoxml&.at(ns("//bibdata/title[@language='#{@lang}']"\
28
+ "[@type = 'amendment']"))&.text
29
+ set(:amendmenttitle, main)
30
+ main = isoxml&.at(ns("//bibdata/title[@language='#{@lang}']"\
31
+ "[@type = 'corrigendum']"))&.text
32
+ set(:corrigendumtitle, main)
26
33
  series = isoxml&.at(ns("//bibdata/series[@type='main']/title"))&.text
27
34
  set(:series, series)
28
35
  series1 =
@@ -39,21 +46,54 @@ module IsoDoc
39
46
  nil
40
47
  end
41
48
 
42
- def author(isoxml, _out)
43
- bureau = isoxml.at(ns("//bibdata/ext/editorialgroup/bureau"))
49
+ def author(xml, _out)
50
+ bureau = xml.at(ns("//bibdata/ext/editorialgroup/bureau"))
44
51
  set(:bureau, bureau.text) if bureau
45
- tc = isoxml.at(ns("//bibdata/ext/editorialgroup/committee"))
52
+ tc = xml.at(ns("//bibdata/ext/editorialgroup/committee"))
46
53
  set(:tc, tc.text) if tc
54
+ tc = xml.at(ns("//bibdata/ext/editorialgroup/group/name"))
55
+ set(:group, tc.text) if tc
56
+ tc = xml.at(ns("//bibdata/ext/editorialgroup/subgroup/name"))
57
+ set(:subgroup, tc.text) if tc
58
+ tc = xml.at(ns("//bibdata/ext/editorialgroup/workgroup/name"))
59
+ set(:workgroup, tc.text) if tc
47
60
  super
61
+ authors = xml.xpath(ns("//bibdata/contributor[role/@type = 'author' "\
62
+ "or xmlns:role/@type = 'editor']/person"))
63
+ person_attributes(authors) unless authors.empty?
64
+ end
65
+
66
+ def append(key, value)
67
+ @metadata[key] << value
68
+ end
69
+
70
+ def person_attributes(authors)
71
+ %i(affiliations addresses emails faxes phones).each { |i| set(i, []) }
72
+ authors.each do |a|
73
+ append(:affiliations,
74
+ a&.at(ns("./affiliation/organization/name"))&.text)
75
+ append(:addresses, a&.at(ns("./affiliation/organization/address/"\
76
+ "formattedAddress"))&.text)
77
+ append(:emails, a&.at(ns("./email"))&.text)
78
+ append(:faxes, a&.at(ns("./phone[@type = 'fax']"))&.text)
79
+ append(:phones, a&.at(ns("./phone[not(@type = 'fax')]"))&.text)
80
+ end
48
81
  end
49
82
 
50
83
  def docid(isoxml, _out)
51
84
  dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'ITU']"))
52
85
  set(:docnumber, dn&.text)
86
+ dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'ITU-Recommendation']"))
87
+ dn and set(:recommendationnumber, dn&.text)
53
88
  dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/annexid"))
54
89
  oblig = isoxml&.at(ns("//annex/@obligation"))&.text
55
90
  lbl = oblig == "informative" ? @labels["appendix"] : @labels["annex"]
56
91
  dn and set(:annexid, @i18n.l10n("#{lbl} #{dn&.text}"))
92
+ dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/amendment")) and
93
+ set(:amendmentid, @i18n.l10n("#{@labels["amendment"]} #{dn&.text}"))
94
+ dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/corrigendum")) and
95
+ set(:corrigendumid,
96
+ @i18n.l10n("#{@labels["corrigendum"]} #{dn&.text}"))
57
97
  end
58
98
 
59
99
  def unpublished(status)
@@ -91,6 +131,27 @@ module IsoDoc
91
131
  "false"
92
132
  set(:ip_notice_received, received)
93
133
  end
134
+
135
+ def ddMMMYYYY(isodate)
136
+ m = /(?<yr>\d\d\d\d)-(?<mo>\d\d)-(?<dd>\d\d)/.match isodate
137
+ return isodate unless m && m[:yr] && m[:mo] && m[:dd]
138
+ mmm = DateTime.parse(isodate).localize(@lang.to_sym).#with_timezone("UCT").
139
+ to_additional_s("MMM")
140
+ @i18n.l10n("#{m[:dd]} #{mmm} #{m[:yr]}")
141
+ end
142
+
143
+ def techreport(isoxml, _out)
144
+ a = isoxml&.at(ns("//bibdata/ext/meeting"))&.text and set(:meeting, a)
145
+ a = isoxml&.at(ns("//bibdata/ext/intended-type"))&.text and
146
+ set(:intended_type, a)
147
+ a = isoxml&.at(ns("//bibdata/ext/source"))&.text and set(:source, a)
148
+ if o = isoxml&.at(ns("//bibdata/ext/meeting-date/on"))&.text
149
+ set(:meeting_date, ddMMMYYYY(o))
150
+ elsif f = isoxml&.at(ns("//bibdata/ext/meeting-date/from"))&.text
151
+ t = isoxml&.at(ns("//bibdata/ext/meeting-date/to"))&.text
152
+ set(:meeting_date, "#{ddMMMYYYY(f)}/#{ddMMMYYYY(t)}")
153
+ end
154
+ end
94
155
  end
95
156
  end
96
157
  end
@@ -16,6 +16,8 @@ module IsoDoc
16
16
  case doctype = docxml&.at(ns("//bibdata/ext/doctype"))&.text
17
17
  when "resolution" then "itu.resolution.xsl"
18
18
  when "recommendation-annex" then "itu.recommendation-annex.xsl"
19
+ when "technical-report" then "itu.technical-report.xsl"
20
+ when "technical-paper" then "itu.technical-paper.xsl"
19
21
  else
20
22
  "itu.recommendation.xsl"
21
23
  end
@@ -48,6 +48,22 @@ module IsoDoc
48
48
  node.add_child(link)
49
49
  end
50
50
 
51
+ def bibdata_i18n(b)
52
+ super
53
+ %w(amendment corrigendum).each do |w|
54
+ if dn = b.at(ns("./ext/structuredidentifier/#{w}"))
55
+ dn["language"] = ""
56
+ dn.next = dn.dup
57
+ dn.next["language"] = @lang
58
+ dn.next.children = @i18n.l10n("#{@i18n.get[w]} #{dn&.text}")
59
+ end
60
+ end
61
+ end
62
+
63
+ def twitter_cldr_localiser_symbols
64
+ {group: "'"}
65
+ end
66
+
51
67
  include Init
52
68
  end
53
69
  end
@@ -5,19 +5,6 @@ require "fileutils"
5
5
  module IsoDoc
6
6
  module ITU
7
7
  module BaseConvert
8
- =begin
9
- def norm_ref(isoxml, out, num)
10
- q = "//bibliography/references[@normative = 'true']"
11
- f = isoxml.at(ns(q)) or return num
12
- out.div do |div|
13
- num = num + 1
14
- clause_name(num, f.at(ns("./title")), div, nil)
15
- biblio_list(f, div, false)
16
- end
17
- num
18
- end
19
- =end
20
-
21
8
  def nonstd_bibitem(list, b, ordinal, biblio)
22
9
  list.tr **attr_code(iso_bibitem_entry_attrs(b, biblio)) do |ref|
23
10
  id = render_identifier(bibitem_ref_code(b))
@@ -1,35 +1,6 @@
1
1
  module IsoDoc
2
2
  module ITU
3
3
  module BaseConvert
4
- =begin
5
- def terms_defs(node, out, num)
6
- f = node.at(ns(IsoDoc::Convert::TERM_CLAUSE)) or return num
7
- out.div **attr_code(id: f["id"]) do |div|
8
- num = num + 1
9
- clause_name(num, f.at(ns("./title")), div, nil)
10
- if f.at(ns("./clause | ./terms | ./term")).nil? then out.p "None."
11
- else
12
- f.children.reject { |c1| c1.name == "title" }.each do |c1|
13
- parse(c1, div)
14
- end
15
- end
16
- end
17
- num
18
- end
19
-
20
- def terms_parse(node, out)
21
- out.div **attr_code(id: node["id"]) do |div|
22
- clause_parse_title(node, div, node.at(ns("./title")), out)
23
- if node.at(ns("./clause | ./term")).nil? then out.p "None."
24
- else
25
- node.children.reject { |c1| c1.name == "title" }.each do |c1|
26
- parse(c1, div)
27
- end
28
- end
29
- end
30
- end
31
- =end
32
-
33
4
  def termdef_parse1(node, div, defn, source)
34
5
  div.p **{ class: "TermNum", id: node["id"] } do |p|
35
6
  p.b do |b|
@@ -37,8 +8,8 @@ module IsoDoc
37
8
  insert_tab(b, 1)
38
9
  node&.at(ns("./preferred"))&.children&.each { |n| parse(n, b) }
39
10
  end
40
- source and p << " #{bracket_opt(source.value)}"
41
11
  p << ": "
12
+ source and p << "#{bracket_opt(source.value)} "
42
13
  end
43
14
  defn and defn.children.each { |n| parse(n, div) }
44
15
  end
@@ -56,6 +27,12 @@ module IsoDoc
56
27
  end
57
28
  end
58
29
 
30
+ def bracket_opt(b)
31
+ return b if b.nil?
32
+ return b if /^\[.+\]$/.match(b)
33
+ "[#{b}]"
34
+ end
35
+
59
36
  def termnote_delim
60
37
  " &ndash; "
61
38
  end
@@ -55,14 +55,17 @@ module IsoDoc
55
55
  historybox = docxml.at("//div[@id='historybox']")
56
56
  sourcebox = docxml.at("//div[@id='sourcebox']")
57
57
  keywordsbox = docxml.at("//div[@id='keywordsbox']")
58
+ changelogbox = docxml.at("//div[@id='change_logbox']")
58
59
  abstract = docxml.at("//div[@class = 'Abstract']")
59
60
  history = docxml.at("//div[@class = 'history']")
60
61
  source = docxml.at("//div[@class = 'source']")
61
- keywords = docxml.at("//div[@class = 'Keywords']")
62
+ keywords = docxml.at("//div[@class = 'Keyword']")
63
+ changelog = docxml.at("//div[@id = 'change_log']")
62
64
  abstract.parent = abstractbox if abstract && abstractbox
63
65
  history.parent = historybox if history && historybox
64
66
  source.parent = sourcebox if source && sourcebox
65
67
  keywords.parent = keywordsbox if keywords && keywordsbox
68
+ changelog.parent = changelogbox if changelog && changelogbox
66
69
  end
67
70
 
68
71
  def toWord(result, filename, dir, header)
@@ -69,7 +69,12 @@ module IsoDoc
69
69
  '"Times New Roman",serif'),
70
70
  headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' :
71
71
  '"Times New Roman",serif'),
72
- monospacefont: '"Courier New",monospace' }
72
+ monospacefont: '"Courier New",monospace',
73
+ normalfontsize: "12.0pt",
74
+ footnotefontsize: "11.0pt",
75
+ smallerfontsize: "11.0pt",
76
+ monospacefontsize: "10.0pt",
77
+ }
73
78
  end
74
79
 
75
80
  def default_file_locations(options)
@@ -20,7 +20,7 @@ module IsoDoc
20
20
  @labels["appendix"] : @labels["annex"]
21
21
  @anchors[clause["id"]] =
22
22
  { label: annex_name_lbl(clause, num), type: "clause",
23
- xref: "#{lbl} #{num}", level: 1 }
23
+ xref: l10n("#{lbl} #{num}"), level: 1, value: num }
24
24
  if a = single_annex_special_section(clause)
25
25
  annex_names1(a, "#{num}", 1)
26
26
  else
@@ -51,7 +51,7 @@ module IsoDoc
51
51
 
52
52
  def annex_names1(clause, num, level)
53
53
  @anchors[clause["id"]] =
54
- { label: num, xref: "#{@labels["annex_subclause"]} #{num}",
54
+ { label: num, xref: l10n("#{@labels["annex_subclause"]} #{num}"),
55
55
  level: level, type: "clause" }
56
56
  clause.xpath(ns("./clause | ./references | ./terms | ./definitions"))
57
57
  .each_with_index do |c, i|
@@ -164,6 +164,7 @@ module IsoDoc
164
164
  idx = notes.size == 1 ? "" : " #{c.increment(n).print}"
165
165
  @anchors[n["id"]] =
166
166
  { label: termnote_label(idx).strip, type: "termnote",
167
+ value: idx,
167
168
  xref: l10n("#{anchor(t['id'], :xref)}, "\
168
169
  "#{@labels["note_xref"]} #{c.print}") }
169
170
 
@@ -0,0 +1,4 @@
1
+ ---
2
+ Arial:
3
+ Courier New:
4
+ Times New Roman:
@@ -2,14 +2,6 @@ require "metanorma/processor"
2
2
 
3
3
  module Metanorma
4
4
  module ITU
5
- def self.fonts_used
6
- {
7
- html: ["Arial", "Courier New", "Times New Roman"],
8
- doc: ["Arial", "Courier New", "Times New Roman"],
9
- pdf: ["Arial", "Courier New", "Times New Roman"]
10
- }
11
- end
12
-
13
5
  class Processor < Metanorma::Processor
14
6
 
15
7
  def initialize
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ITU
3
- VERSION = "1.2.3"
3
+ VERSION = "1.2.8"
4
4
  end
5
5
  end
@@ -26,8 +26,10 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_dependency "htmlentities", "~> 4.3.4"
28
28
  spec.add_dependency "ruby-jing"
29
- spec.add_dependency "metanorma-standoc", "~> 1.5.0"
30
- spec.add_dependency "isodoc", "~> 1.2.0"
29
+ spec.add_dependency "metanorma-standoc", "~> 1.6.0"
30
+ spec.add_dependency "isodoc", "~> 1.3.0"
31
+ spec.add_dependency "twitter_cldr"
32
+ spec.add_dependency "tzinfo-data" # we need this for windows only
31
33
 
32
34
  spec.add_development_dependency "byebug", "~> 9.1"
33
35
  spec.add_development_dependency "sassc", "2.4.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-itu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-11 00:00:00.000000000 Z
11
+ date: 2020-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -44,28 +44,56 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.5.0
47
+ version: 1.6.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.5.0
54
+ version: 1.6.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: isodoc
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.2.0
61
+ version: 1.3.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.2.0
68
+ version: 1.3.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: twitter_cldr
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: tzinfo-data
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: byebug
71
99
  requirement: !ruby/object:Gem::Requirement
@@ -243,9 +271,7 @@ executables: []
243
271
  extensions: []
244
272
  extra_rdoc_files: []
245
273
  files:
246
- - ".github/workflows/macos.yml"
247
- - ".github/workflows/ubuntu.yml"
248
- - ".github/workflows/windows.yml"
274
+ - ".github/workflows/rake.yml"
249
275
  - ".gitignore"
250
276
  - ".hound.yml"
251
277
  - ".rubocop.yml"
@@ -296,6 +322,8 @@ files:
296
322
  - lib/isodoc/itu/itu.recommendation-annex.xsl
297
323
  - lib/isodoc/itu/itu.recommendation.xsl
298
324
  - lib/isodoc/itu/itu.resolution.xsl
325
+ - lib/isodoc/itu/itu.technical-paper.xsl
326
+ - lib/isodoc/itu/itu.technical-report.xsl
299
327
  - lib/isodoc/itu/metadata.rb
300
328
  - lib/isodoc/itu/pdf_convert.rb
301
329
  - lib/isodoc/itu/presentation_xml_convert.rb
@@ -306,6 +334,7 @@ files:
306
334
  - lib/isodoc/itu/xref.rb
307
335
  - lib/metanorma-itu.rb
308
336
  - lib/metanorma/itu.rb
337
+ - lib/metanorma/itu/fonts_manifest.yaml
309
338
  - lib/metanorma/itu/processor.rb
310
339
  - lib/metanorma/itu/version.rb
311
340
  - metanorma-itu.gemspec
@@ -1,38 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: macos
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- pull_request:
9
- paths-ignore:
10
- - .github/workflows/ubuntu.yml
11
- - .github/workflows/windows.yml
12
-
13
- jobs:
14
- test-macos:
15
- name: Test on Ruby ${{ matrix.ruby }} macOS
16
- runs-on: macos-latest
17
- continue-on-error: ${{ matrix.experimental }}
18
- strategy:
19
- fail-fast: false
20
- matrix:
21
- ruby: [ '2.6', '2.5', '2.4' ]
22
- experimental: [false]
23
- include:
24
- - ruby: '2.7'
25
- experimental: true
26
- steps:
27
- - uses: actions/checkout@master
28
- - name: Use Ruby
29
- uses: actions/setup-ruby@v1
30
- with:
31
- ruby-version: ${{ matrix.ruby }}
32
- - name: Update gems
33
- run: |
34
- sudo gem install bundler --force
35
- bundle install --jobs 4 --retry 3
36
- - name: Run specs
37
- run: |
38
- bundle exec rake