metanorma-un 0.4.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -340,6 +340,13 @@
340
340
  </define>
341
341
  <define name="un-standard">
342
342
  <element name="un-standard">
343
+ <attribute name="version"/>
344
+ <attribute name="type">
345
+ <choice>
346
+ <value>semantic</value>
347
+ <value>presentation</value>
348
+ </choice>
349
+ </attribute>
343
350
  <ref name="bibdata"/>
344
351
  <optional>
345
352
  <ref name="boilerplate"/>
@@ -14,7 +14,8 @@ module Asciidoctor
14
14
  stage = xmldoc&.at("//bibdata/status/stage")&.text
15
15
  %w(proposal working-draft committee-draft draft-standard final-draft
16
16
  published withdrawn).include? stage or
17
- @log.add("Document Attributes", nil, "#{stage} is not a recognised status")
17
+ @log.add("Document Attributes", nil,
18
+ "#{stage} is not a recognised status")
18
19
  end
19
20
  end
20
21
  end
@@ -1,52 +1,12 @@
1
- require_relative "metadata"
2
- require_relative "xref"
3
1
  require "fileutils"
4
2
 
5
3
  module IsoDoc
6
4
  module UN
7
5
  module BaseConvert
8
- def metadata_init(lang, script, labels)
9
- @meta = Metadata.new(lang, script, labels)
10
- @meta.set(:toc, @toc)
11
- end
12
-
13
- def xref_init(lang, script, klass, labels, options)
14
- @xrefs = Xref.new(lang, script, klass, labels, options)
15
- end
16
-
17
- def annex_name(annex, name, div)
18
- div.h1 **{ class: "Annex" } do |t|
19
- t << "#{@xrefs.anchor(annex['id'], :label)}"
20
- t.br
21
- t.b do |b|
22
- name&.children&.each { |c2| parse(c2, b) }
23
- end
24
- end
25
- end
26
-
27
- def i18n_init(lang, script)
28
- super
29
- @admonition_lbl = "Box"
30
- @abstract_lbl = "Summary"
31
- end
32
-
33
- def fileloc(loc)
34
- File.join(File.dirname(__FILE__), loc)
35
- end
36
-
37
6
  def middle_clause
38
7
  "//clause[parent::sections]"
39
8
  end
40
9
 
41
- def admonition_name_parse(node, div, name)
42
- div.p **{ class: "AdmonitionTitle", style: "text-align:center;" } do |p|
43
- lbl = @xrefs.anchor(node['id'], :label)
44
- lbl.nil? or p << l10n("#{@admonition_lbl} #{lbl}")
45
- name and !lbl.nil? and p << "&nbsp;&mdash; "
46
- name and name.children.each { |n| parse(n, div) }
47
- end
48
- end
49
-
50
10
  def admonition_parse(node, out)
51
11
  name = node.at(ns("./name"))
52
12
  out.div **admonition_attrs(node) do |t|
@@ -57,13 +17,10 @@ def xref_init(lang, script, klass, labels, options)
57
17
  end
58
18
  end
59
19
 
60
- def inline_header_title(out, node, c1)
20
+ def inline_header_title(out, node, title)
61
21
  out.span **{ class: "zzMoveToFollowing" } do |s|
62
- if lbl = @xrefs.anchor(node['id'], :label)
63
- s << "#{lbl}. " unless @suppressheadingnumbers
64
- insert_tab(s, 1)
65
- end
66
- c1&.children&.each { |c2| parse(c2, s) }
22
+ title&.children&.each { |c2| parse(c2, s) }
23
+ clausedelimspace(out) if /\S/.match(title&.text)
67
24
  end
68
25
  end
69
26
 
@@ -73,18 +30,6 @@ def xref_init(lang, script, klass, labels, options)
73
30
  return true if docxml&.at(ns("//bibdata/ext/session/*"))
74
31
  false
75
32
  end
76
-
77
- def note_label(node)
78
- n = @xrefs.get[node["id"]]
79
- lbl = case node["type"]
80
- when "source" then "Source"
81
- when "abbreviation" then "Abbreviations"
82
- else
83
- @note_lbl
84
- end
85
- return "#{lbl}:" # if n.nil? || n[:label].nil? || n[:label].empty?
86
- #l10n("#{lbl} #{n[:label]}:")
87
- end
88
33
  end
89
34
  end
90
35
  end
@@ -679,7 +679,7 @@ div.WordSection2 {
679
679
  div.WordSection3 {
680
680
  page: WordSection3; }
681
681
 
682
- table.MsoISOTable {
682
+ table.MsoISOTable, table.MsoISOTableBig {
683
683
  mso-style-name: "Table ISO";
684
684
  mso-tstyle-rowband-size: 0;
685
685
  mso-tstyle-colband-size: 0;
@@ -701,15 +701,15 @@ table.MsoISOTable {
701
701
  font-size: 10.0pt;
702
702
  font-family: {{bodyfont}}; }
703
703
 
704
- table.MsoISOTable th {
704
+ table.MsoISOTable th, table.MsoISOTableBig th {
705
705
  border: solid windowtext 1pt;
706
706
  mso-border-alt: solid windowtext 1pt;
707
707
  padding: 0cm 2.85pt 0cm 2.85pt; }
708
708
 
709
- table.MsoISOTable p {
709
+ table.MsoISOTable p, table.MsoISOTableBig p {
710
710
  font-size: 10.0pt; }
711
711
 
712
- table.MsoISOTable td {
712
+ table.MsoISOTable td, table.MsoISOTableBig td {
713
713
  border: solid windowtext 1pt;
714
714
  mso-border-alt: solid windowtext 1pt;
715
715
  padding: 0cm 2.85pt 0cm 2.85pt; }
@@ -799,8 +799,20 @@ div.example p.MsoListParagraph {
799
799
  font-size: 10.0pt; }
800
800
 
801
801
  div.Note p.MsoListParagraph {
802
+ font-size: 10.0pt;
803
+ margin-left: 1.0cm; }
804
+
805
+ div.Note span.stem {
802
806
  font-size: 10.0pt; }
803
807
 
808
+ div.Note p.Sourcecode, div.Note pre.Sourcecode {
809
+ font-size: 8.0pt;
810
+ margin-left: 1.0cm; }
811
+
812
+ div.Note table.dl {
813
+ font-size: 10.0pt;
814
+ margin-left: 1.0cm; }
815
+
804
816
  span.note_label, span.example_label, td.example_label, td.note_label {
805
817
  font-size: 10.0pt;
806
818
  font-family: {{bodyfont}}; }
@@ -662,7 +662,7 @@ div.WordSection2
662
662
  }
663
663
  div.WordSection3
664
664
  {page:WordSection3;}
665
- table.MsoISOTable
665
+ table.MsoISOTable, table.MsoISOTableBig
666
666
  {mso-style-name:"Table ISO";
667
667
  mso-tstyle-rowband-size:0;
668
668
  mso-tstyle-colband-size:0;
@@ -683,13 +683,13 @@ table.MsoISOTable
683
683
  margin-bottom:12pt;
684
684
  font-size:10.0pt;
685
685
  font-family:$bodyfont;}
686
- table.MsoISOTable th
686
+ table.MsoISOTable th, table.MsoISOTableBig th
687
687
  {border:solid windowtext 1pt;
688
688
  mso-border-alt:solid windowtext 1pt;
689
689
  padding:0cm 2.85pt 0cm 2.85pt;}
690
- table.MsoISOTable p
690
+ table.MsoISOTable p, table.MsoISOTableBig p
691
691
  {font-size:10.0pt; }
692
- table.MsoISOTable td
692
+ table.MsoISOTable td, table.MsoISOTableBig td
693
693
  {border:solid windowtext 1pt;
694
694
  mso-border-alt:solid windowtext 1pt;
695
695
  padding:0cm 2.85pt 0cm 2.85pt;}
@@ -778,6 +778,20 @@ div.example p.MsoListParagraph {
778
778
 
779
779
  div.Note p.MsoListParagraph {
780
780
  font-size: 10.0pt;
781
+ margin-left: 1.0cm;
782
+ }
783
+
784
+ div.Note span.stem {
785
+ font-size: 10.0pt; }
786
+
787
+ div.Note p.Sourcecode, div.Note pre.Sourcecode {
788
+ font-size: 8.0pt;
789
+ margin-left: 1.0cm;
790
+ }
791
+
792
+ div.Note table.dl {
793
+ font-size: 10.0pt;
794
+ margin-left: 1.0cm;
781
795
  }
782
796
 
783
797
  span.note_label, span.example_label, td.example_label, td.note_label
@@ -1,4 +1,5 @@
1
1
  require_relative "base_convert"
2
+ require_relative "init"
2
3
  require "isodoc"
3
4
 
4
5
  module IsoDoc
@@ -48,8 +49,10 @@ module IsoDoc
48
49
 
49
50
  def make_body(xml, docxml)
50
51
  plenary = is_plenary?(docxml)
51
- body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72", "xml:lang": "EN-US", class: "container" }
52
- if plenary && @htmlcoverpage == html_doc_path("html_unece_titlepage.html")
52
+ body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72",
53
+ "xml:lang": "EN-US", class: "container" }
54
+ if plenary &&
55
+ @htmlcoverpage == html_doc_path("html_unece_titlepage.html")
53
56
  @htmlcoverpage = html_doc_path("html_unece_plenary_titlepage.html")
54
57
  end
55
58
  xml.body **body_attr do |body|
@@ -62,6 +65,7 @@ module IsoDoc
62
65
  def make_body3(body, docxml)
63
66
  body.div **{ class: "main-section" } do |div3|
64
67
  boilerplate docxml, div3
68
+ preface_block docxml, div3
65
69
  abstract docxml, div3
66
70
  foreword docxml, div3
67
71
  introduction docxml, div3
@@ -80,26 +84,11 @@ module IsoDoc
80
84
  bibliography isoxml, out
81
85
  end
82
86
 
83
- def clause_parse_title(node, div, c1, out)
84
- if node["inline-header"] == "true"
85
- inline_header_title(out, node, c1)
86
- else
87
- div.send "h#{@xrefs.anchor(node['id'], :level, false) || '1'}" do |h|
88
- lbl = @xrefs.anchor(node['id'], :label, false)
89
- h << "#{lbl}. " if lbl && !@suppressheadingnumbers
90
- insert_tab(h, 1) if lbl && !@suppressheadingnumbers
91
- c1&.children&.each { |c2| parse(c2, h) }
92
- end
93
- end
94
- end
95
-
96
87
  def introduction(isoxml, out)
97
88
  f = isoxml.at(ns("//introduction")) || return
98
89
  page_break(out)
99
90
  out.div **{ class: "Section3", id: f["id"] } do |div|
100
- div.h1(**{ class: "IntroTitle" }) do |h1|
101
- h1 << @introduction_lbl
102
- end
91
+ clause_name(nil, f.at(ns("./title")), div, { class: "IntroTitle" })
103
92
  f.elements.each do |e|
104
93
  parse(e, div) unless e.name == "title"
105
94
  end
@@ -110,14 +99,14 @@ module IsoDoc
110
99
  f = isoxml.at(ns("//foreword")) || return
111
100
  page_break(out)
112
101
  out.div **attr_code(id: f["id"]) do |s|
113
- s.h1(**{ class: "ForewordTitle" }) do |h1|
114
- h1 << @foreword_lbl
115
- end
102
+ clause_name(nil, f.at(ns("./title")) || @i18n.foreword, s,
103
+ class: "ForewordTitle")
116
104
  f.elements.each { |e| parse(e, s) unless e.name == "title" }
117
105
  end
118
106
  end
119
107
 
120
108
  include BaseConvert
109
+ include Init
121
110
  end
122
111
  end
123
112
  end
@@ -0,0 +1,2 @@
1
+ admonition: Box
2
+ abstract: Summary
@@ -0,0 +1,11 @@
1
+ module IsoDoc
2
+ module UN
3
+ class I18n < IsoDoc::I18n
4
+ def load_yaml1(lang, script)
5
+ y = YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
6
+ super.merge(y)
7
+ end
8
+ end
9
+ end
10
+ end
11
+
@@ -0,0 +1,29 @@
1
+ require "isodoc"
2
+ require_relative "metadata"
3
+ require_relative "xref"
4
+ require_relative "i18n"
5
+
6
+ module IsoDoc
7
+ module UN
8
+ module Init
9
+ def metadata_init(lang, script, labels)
10
+ @meta = Metadata.new(lang, script, labels)
11
+ @meta.set(:toc, @toc)
12
+ end
13
+
14
+ def xref_init(lang, script, klass, labels, options)
15
+ html = HtmlConvert.new(language: lang, script: script)
16
+ @xrefs = Xref.new(lang, script, html, labels, options)
17
+ end
18
+
19
+ def i18n_init(lang, script, i18nyaml = nil)
20
+ @i18n = I18n.new(lang, script, i18nyaml || @i18nyaml)
21
+ end
22
+
23
+ def fileloc(loc)
24
+ File.join(File.dirname(__FILE__), loc)
25
+ end
26
+ end
27
+ end
28
+ end
29
+
@@ -13,12 +13,14 @@ module IsoDoc
13
13
  end
14
14
 
15
15
  def title(isoxml, _out)
16
- main = isoxml&.at(ns("//bibdata/title[@language='en' and @type='main']"))&.text
16
+ main = isoxml&.at(ns("//bibdata/title"\
17
+ "[@language='en' and @type='main']"))&.text
17
18
  set(:doctitle, main)
18
19
  end
19
20
 
20
21
  def subtitle(isoxml, _out)
21
- main = isoxml&.at(ns("//bibdata/title[@language='en' and @type='subtitle']"))&.text
22
+ main = isoxml&.at(ns("//bibdata/title"\
23
+ "[@language='en' and @type='subtitle']"))&.text
22
24
  set(:docsubtitle, main)
23
25
  end
24
26
 
@@ -36,8 +38,10 @@ module IsoDoc
36
38
  set(:tc, tc.text) if tc
37
39
  set(:distribution, isoxml&.at(ns("//bibdata/ext/distribution"))&.text)
38
40
  lgs = extract_languages(isoxml.xpath(ns("//bibdata/language")))
39
- lgs = [] if lgs.sort == %w(English French Arabic Chinese Russian Spanish).sort
40
- slgs = extract_languages(isoxml.xpath(ns("//bibdata/ext/submissionlanguage")))
41
+ lgs.sort == %w(English French Arabic Chinese Russian Spanish).sort and
42
+ lgs = []
43
+ slgs = extract_languages(isoxml.xpath(ns("//bibdata/ext/"\
44
+ "submissionlanguage")))
41
45
  lgs = [] if slgs.size == 1
42
46
  set(:doclanguage, lgs) unless lgs.empty?
43
47
  set(:submissionlanguage, slgs) unless slgs.empty?
@@ -52,25 +56,32 @@ module IsoDoc
52
56
  end
53
57
 
54
58
  def session(isoxml, _out)
55
- set(:session_number, isoxml&.at(ns("//bibdata/ext/session/number"))&.text&.to_i&.
56
- localize&.to_rbnf_s("SpelloutRules", "spellout-ordinal")&.capitalize)
59
+ set(:session_number, isoxml&.at(ns("//bibdata/ext/session/number"))&.
60
+ text&.to_i&.localize&.
61
+ to_rbnf_s("SpelloutRules", "spellout-ordinal")&.capitalize)
57
62
  set(:session_date, isoxml&.at(ns("//bibdata/ext/session/date"))&.text)
58
- set(:session_collaborator, isoxml&.at(ns("//bibdata/ext/session/collaborator"))&.text)
63
+ set(:session_collaborator,
64
+ isoxml&.at(ns("//bibdata/ext/session/collaborator"))&.text)
59
65
  sid = isoxml&.at(ns("//bibdata/ext/session/id"))&.text
60
66
  set(:session_id, sid)
61
67
  set(:session_id_head, sid&.sub(%r{/.*$}, ""))
62
68
  set(:session_id_tail, sid&.sub(%r{^[^/]+}, ""))
63
- set(:item_footnote, isoxml&.at(ns("//bibdata/ext/session/item-footnote"))&.text)
64
- set(:session_itemnumber, multival(isoxml, "//bibdata/ext/session/item-number"))
65
- set(:session_itemname, multival(isoxml, "//bibdata/ext/session/item-name"))
66
- set(:session_subitemname, multival(isoxml, "//bibdata/ext/session/subitem-name"))
69
+ set(:item_footnote,
70
+ isoxml&.at(ns("//bibdata/ext/session/item-footnote"))&.text)
71
+ set(:session_itemnumber,
72
+ multival(isoxml, "//bibdata/ext/session/item-number"))
73
+ set(:session_itemname,
74
+ multival(isoxml, "//bibdata/ext/session/item-name"))
75
+ set(:session_subitemname,
76
+ multival(isoxml, "//bibdata/ext/session/subitem-name"))
67
77
  end
68
78
 
69
79
  def docid(isoxml, _out)
70
80
  dn = isoxml.at(ns("//bibdata/docidentifier"))&.text
71
81
  set(:docnumber, dn)
72
82
  type = isoxml&.at(ns("//bibdata/ext/doctype"))&.text
73
- set(:formatted_docnumber, type == "recommendation" ? "UN/CEFACT Recommendation #{dn}" : dn)
83
+ set(:formatted_docnumber, type == "recommendation" ?
84
+ "UN/CEFACT Recommendation #{dn}" : dn)
74
85
  end
75
86
 
76
87
  def stage_abbr(status)
@@ -1,9 +1,52 @@
1
- require_relative "base_convert"
1
+ require_relative "init"
2
2
  require "isodoc"
3
3
 
4
4
  module IsoDoc
5
5
  module UN
6
6
  class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
7
+ def initialize(options)
8
+ super
9
+ @toc = options[:toc]
10
+ end
11
+
12
+ def note1(f)
13
+ return if f.parent.name == "bibitem"
14
+ n = @xrefs.get[f["id"]]
15
+ lbl = case f["type"]
16
+ when "source" then "Source"
17
+ when "abbreviation" then "Abbreviations"
18
+ else
19
+ @i18n.note
20
+ end
21
+ prefix_name(f, "", lbl, "name")
22
+ end
23
+
24
+ def conversions(docxml)
25
+ super
26
+ admonition docxml
27
+ end
28
+
29
+ def admonition(docxml)
30
+ docxml.xpath(ns("//admonition")).each do |f|
31
+ admonition1(f)
32
+ end
33
+ end
34
+
35
+ def admonition1(f)
36
+ n = @xrefs.anchor(f['id'], :label) or return
37
+ lbl = l10n("#{@i18n.admonition} #{n}")
38
+ prefix_name(f, "&nbsp;&mdash; ", lbl, "name")
39
+ end
40
+
41
+ def annex1(f)
42
+ lbl = @xrefs.anchor(f['id'], :label)
43
+ if t = f.at(ns("./title"))
44
+ t.children = "<strong>#{t.children.to_xml}</strong>"
45
+ end
46
+ prefix_name(f, "<br/>", lbl, "title")
47
+ end
48
+
49
+ include Init
7
50
  end
8
51
  end
9
52
  end