metanorma-iec 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/bin/rspec +18 -0
  4. data/lib/asciidoctor/iec/biblio.rng +949 -0
  5. data/lib/asciidoctor/iec/converter.rb +68 -0
  6. data/lib/asciidoctor/iec/iec_intro_en.xml +15 -0
  7. data/lib/asciidoctor/iec/iec_intro_fr.xml +15 -0
  8. data/lib/asciidoctor/iec/isodoc.rng +1132 -0
  9. data/lib/asciidoctor/iec/isostandard.rng +789 -0
  10. data/lib/asciidoctor/iec/reqt.rng +162 -0
  11. data/lib/isodoc/iec/base_convert.rb +69 -0
  12. data/lib/isodoc/iec/html/header.html +160 -0
  13. data/lib/isodoc/iec/html/html_iec_intro.html +34 -0
  14. data/lib/isodoc/iec/html/html_iec_titlepage.html +62 -0
  15. data/lib/isodoc/iec/html/htmlstyle.scss +840 -0
  16. data/lib/isodoc/iec/html/isodoc.scss +785 -0
  17. data/lib/isodoc/iec/html/scripts.html +176 -0
  18. data/lib/isodoc/iec/html/word_iec_intro.html +72 -0
  19. data/lib/isodoc/iec/html/word_iec_titlepage.html +92 -0
  20. data/lib/isodoc/iec/html/wordstyle.scss +1849 -0
  21. data/lib/isodoc/iec/html_convert.rb +33 -0
  22. data/lib/isodoc/iec/i18n-en.yaml +3 -0
  23. data/lib/isodoc/iec/i18n-fr.yaml +3 -0
  24. data/lib/isodoc/iec/i18n-zh-Hans.yaml +3 -0
  25. data/lib/isodoc/iec/metadata.rb +20 -0
  26. data/lib/isodoc/iec/word_convert.rb +165 -0
  27. data/lib/metanorma-iec.rb +12 -0
  28. data/lib/metanorma/iec.rb +8 -0
  29. data/lib/metanorma/iec/processor.rb +40 -0
  30. data/lib/metanorma/iec/version.rb +6 -0
  31. data/metanorma-iec.gemspec +47 -0
  32. data/spec/asciidoctor-iec/base_spec.rb +609 -0
  33. data/spec/asciidoctor-iec/blocks_spec.rb +467 -0
  34. data/spec/asciidoctor-iec/cleanup_spec.rb +766 -0
  35. data/spec/asciidoctor-iec/inline_spec.rb +162 -0
  36. data/spec/asciidoctor-iec/lists_spec.rb +190 -0
  37. data/spec/asciidoctor-iec/macros_spec.rb +21 -0
  38. data/spec/asciidoctor-iec/refs_spec.rb +268 -0
  39. data/spec/asciidoctor-iec/section_spec.rb +341 -0
  40. data/spec/asciidoctor-iec/table_spec.rb +307 -0
  41. data/spec/asciidoctor-iec/validate_spec.rb +132 -0
  42. data/spec/examples/rice.adoc +723 -0
  43. data/spec/examples/rice.doc +19162 -0
  44. data/spec/examples/rice.html +1787 -0
  45. data/spec/examples/rice.xml +1951 -0
  46. data/spec/isodoc/i18n_spec.rb +642 -0
  47. data/spec/isodoc/inline_spec.rb +265 -0
  48. data/spec/isodoc/iso_spec.rb +319 -0
  49. data/spec/isodoc/metadata_spec.rb +153 -0
  50. data/spec/isodoc/postproc_spec.rb +569 -0
  51. data/spec/isodoc/section_spec.rb +686 -0
  52. data/spec/isodoc/terms_spec.rb +206 -0
  53. data/spec/isodoc/xref_spec.rb +1323 -0
  54. data/spec/metanorma/processor_spec.rb +88 -0
  55. data/spec/spec_helper.rb +253 -0
  56. metadata +325 -0
@@ -0,0 +1,162 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
+ <!--
4
+ Presupposes isodoc.rnc, is included in it
5
+ include "isodoc.rnc" { }
6
+ -->
7
+ <define name="requirement">
8
+ <element name="requirement">
9
+ <ref name="RequirementType"/>
10
+ </element>
11
+ </define>
12
+ <define name="recommendation">
13
+ <element name="recommendation">
14
+ <ref name="RequirementType"/>
15
+ </element>
16
+ </define>
17
+ <define name="permission">
18
+ <element name="permission">
19
+ <ref name="RequirementType"/>
20
+ </element>
21
+ </define>
22
+ <define name="RequirementType">
23
+ <optional>
24
+ <attribute name="obligation">
25
+ <ref name="ObligationType"/>
26
+ </attribute>
27
+ </optional>
28
+ <optional>
29
+ <attribute name="unnumbered">
30
+ <data type="boolean"/>
31
+ </attribute>
32
+ </optional>
33
+ <attribute name="id">
34
+ <data type="ID"/>
35
+ </attribute>
36
+ <optional>
37
+ <attribute name="filename"/>
38
+ </optional>
39
+ <optional>
40
+ <ref name="reqtitle"/>
41
+ </optional>
42
+ <optional>
43
+ <ref name="label"/>
44
+ </optional>
45
+ <optional>
46
+ <ref name="subject"/>
47
+ </optional>
48
+ <optional>
49
+ <ref name="reqinherit"/>
50
+ </optional>
51
+ <zeroOrMore>
52
+ <ref name="classification"/>
53
+ </zeroOrMore>
54
+ <zeroOrMore>
55
+ <choice>
56
+ <ref name="measurementtarget"/>
57
+ <ref name="specification"/>
58
+ <ref name="verification"/>
59
+ <ref name="import"/>
60
+ <ref name="description"/>
61
+ </choice>
62
+ </zeroOrMore>
63
+ <optional>
64
+ <ref name="reqt_references"/>
65
+ </optional>
66
+ <zeroOrMore>
67
+ <choice>
68
+ <ref name="requirement"/>
69
+ <ref name="recommendation"/>
70
+ <ref name="permission"/>
71
+ </choice>
72
+ </zeroOrMore>
73
+ </define>
74
+ <define name="reqtitle">
75
+ <element name="title">
76
+ <ref name="FormattedString"/>
77
+ </element>
78
+ </define>
79
+ <define name="label">
80
+ <element name="label">
81
+ <text/>
82
+ </element>
83
+ </define>
84
+ <define name="subject">
85
+ <element name="subject">
86
+ <text/>
87
+ </element>
88
+ </define>
89
+ <define name="reqinherit">
90
+ <element name="subject">
91
+ <text/>
92
+ </element>
93
+ </define>
94
+ <define name="measurementtarget">
95
+ <element name="measurement-target">
96
+ <ref name="RequirementSubpart"/>
97
+ </element>
98
+ </define>
99
+ <define name="specification">
100
+ <element name="specification">
101
+ <ref name="RequirementSubpart"/>
102
+ </element>
103
+ </define>
104
+ <define name="verification">
105
+ <element name="verification">
106
+ <ref name="RequirementSubpart"/>
107
+ </element>
108
+ </define>
109
+ <define name="import">
110
+ <element name="import">
111
+ <ref name="RequirementSubpart"/>
112
+ </element>
113
+ </define>
114
+ <define name="description">
115
+ <element name="description">
116
+ <ref name="RequirementSubpart"/>
117
+ </element>
118
+ </define>
119
+ <define name="reqt_references">
120
+ <element name="references">
121
+ <oneOrMore>
122
+ <ref name="bibitem"/>
123
+ </oneOrMore>
124
+ </element>
125
+ </define>
126
+ <define name="RequirementSubpart">
127
+ <optional>
128
+ <attribute name="type"/>
129
+ </optional>
130
+ <optional>
131
+ <attribute name="exclude">
132
+ <data type="boolean"/>
133
+ </attribute>
134
+ </optional>
135
+ <oneOrMore>
136
+ <ref name="BasicBlock"/>
137
+ </oneOrMore>
138
+ </define>
139
+ <define name="ObligationType">
140
+ <choice>
141
+ <value>requirement</value>
142
+ <value>recommendation</value>
143
+ <value>permission</value>
144
+ </choice>
145
+ </define>
146
+ <define name="classification">
147
+ <element name="classification">
148
+ <ref name="classification_tag"/>
149
+ <ref name="classification_value"/>
150
+ </element>
151
+ </define>
152
+ <define name="classification_tag">
153
+ <element name="tag">
154
+ <text/>
155
+ </element>
156
+ </define>
157
+ <define name="classification_value">
158
+ <element name="value">
159
+ <text/>
160
+ </element>
161
+ </define>
162
+ </grammar>
@@ -0,0 +1,69 @@
1
+ require "isodoc"
2
+ require "metanorma-iso"
3
+
4
+ module IsoDoc
5
+ module Iec
6
+ module BaseConvert
7
+ def foreword(isoxml, out)
8
+ f = isoxml.at(ns("//foreword"))
9
+ b = isoxml.at(ns("//boilerplate/legal-statement"))
10
+ page_break(out)
11
+ middle_title(out)
12
+ out.div **attr_code(id: f ? f["id"] : "") do |s|
13
+ s.h1(**{ class: "ForewordTitle" }) { |h1| h1 << @foreword_lbl }
14
+ @meta.get[:doctype] == "Amendment" or
15
+ s.div **attr_code(class: "boilerplate_legal") do |s1|
16
+ b&.elements&.each { |e| parse(e, s1) }
17
+ end
18
+ f&.elements&.each { |e| parse(e, s) unless e.name == "title" }
19
+ end
20
+ end
21
+
22
+ def middle_title(out)
23
+ out.p(**{ class: "zzSTDTitle1" }) { |p| p << @labels["IEC"] }
24
+ out.p(**{ class: "zzSTDTitle1" }) { |p| p << "____________" }
25
+ out.p(**{ class: "zzSTDTitle1" }) { |p| p << "&nbsp;" }
26
+ title1 = @meta.get[:doctitlemain]&.sub(/\s+$/, "")
27
+ @meta.get[:doctitleintro] and
28
+ title1 = "#{@meta.get[:doctitleintro]} &mdash; #{title1}"
29
+ if @meta.get[:doctitlepart]
30
+ title1 += " &mdash;"
31
+ title2 = @meta.get[:doctitlepart]&.sub(/\s+$/, "")
32
+ @meta.get[:doctitlepartlabel] and
33
+ title2 = "#{@meta.get[:doctitlepartlabel]}: #{title2}"
34
+ end
35
+ out.p(**{ class: "zzSTDTitle1" }) do |p|
36
+ p.b { |b| b << title1 }
37
+ end
38
+ if @meta.get[:doctitlepart]
39
+ out.p(**{ class: "zzSTDTitle1" }) { |p| p << "&nbsp;" }
40
+ out.p(**{ class: "zzSTDTitle2" }) do |p|
41
+ p.b { |b| b << title2 }
42
+ end
43
+ end
44
+ out.p(**{ class: "zzSTDTitle1" }) { |p| p << "&nbsp;" }
45
+ end
46
+
47
+ def load_yaml(lang, script)
48
+ y = if @i18nyaml then YAML.load_file(@i18nyaml)
49
+ elsif lang == "en"
50
+ YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
51
+ elsif lang == "fr"
52
+ YAML.load_file(File.join(File.dirname(__FILE__), "i18n-fr.yaml"))
53
+ elsif lang == "zh" && script == "Hans"
54
+ YAML.load_file(File.join(File.dirname(__FILE__),
55
+ "i18n-zh-Hans.yaml"))
56
+ else
57
+ YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
58
+ end
59
+ super.merge(y)
60
+ end
61
+
62
+ def annex_name_lbl(clause, num)
63
+ obl = l10n("(#{@inform_annex_lbl})")
64
+ obl = l10n("(#{@norm_annex_lbl})") if clause["obligation"] == "normative"
65
+ l10n("<b>#{@annex_lbl} #{num}</b><br/><br/>#{obl}")
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,160 @@
1
+ <html xmlns:v="urn:schemas-microsoft-com:vml"
2
+ xmlns:o="urn:schemas-microsoft-com:office:office"
3
+ xmlns:w="urn:schemas-microsoft-com:office:word"
4
+ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
5
+ xmlns:mv="http://macVmlSchemaUri" xmlns="http://www.w3.org/TR/REC-html40">
6
+
7
+ <head>
8
+ <meta name=Title content="">
9
+ <meta name=Keywords content="">
10
+ <meta http-equiv=Content-Type content="text/html; charset=utf-8">
11
+ <meta name=ProgId content=Word.Document>
12
+ <meta name=Generator content="Microsoft Word 15">
13
+ <meta name=Originator content="Microsoft Word 15">
14
+ <link id=Main-File rel=Main-File href="../{{ filename }}.html">
15
+ <!--[if gte mso 9]><xml>
16
+ <o:shapedefaults v:ext="edit" spidmax="2049"/>
17
+ </xml><![endif]-->
18
+ </head>
19
+
20
+ <body lang=EL link="#000000" vlink="#000000">
21
+
22
+ <div style='mso-element:footnote-separator' id=fs>
23
+
24
+ <p class=Note style='margin-bottom:0cm;margin-bottom:.0001pt'><span lang=EN-GB>—————————</span><span
25
+ lang=EN-GB style='letter-spacing:0pt'><o:p></o:p></span></p>
26
+
27
+ </div>
28
+
29
+ <div style='mso-element:footnote-continuation-separator' id=fcs>
30
+
31
+ <p class=MsoNormal><span lang=EN-GB><span style='mso-special-character:footnote-continuation-separator'><![if !supportFootnotes]>
32
+
33
+ <hr align=left size=1>
34
+
35
+ <![endif]></span></span></p>
36
+
37
+ </div>
38
+
39
+ <div style='mso-element:footnote-continuation-notice' id=fcn>
40
+
41
+ <p class=MsoNormal><span lang=EN-GB><o:p>&nbsp;</o:p></span></p>
42
+
43
+ </div>
44
+
45
+
46
+ <div style='mso-element:endnote-separator' id=es>
47
+
48
+ <p class=MsoNormal><span lang=EN-GB><span style='mso-special-character:footnote-separator'><![if !supportFootnotes]>
49
+
50
+ <hr align=left size=1 width="33%">
51
+
52
+ <![endif]></span></span></p>
53
+
54
+ </div>
55
+
56
+ <div style='mso-element:endnote-continuation-separator' id=ecs>
57
+
58
+ <p class=MsoNormal><span lang=EN-GB><span style='mso-special-character:footnote-continuation-separator'><![if !supportFootnotes]>
59
+
60
+ <hr align=left size=1>
61
+
62
+ <![endif]></span></span></p>
63
+
64
+ </div>
65
+
66
+ <div style='mso-element:header' id=eha>
67
+
68
+ <p class=MsoHeader><span lang=EN-GB><span style='mso-tab-count:1'>                                                                        </span>–
69
+ </span><!--[if supportFields]><span class=MsoPageNumber><span lang=EN-GB><span
70
+ style='mso-element:field-begin'></span><span
71
+ style='mso-spacerun:yes'> </span>PAGE <span style='mso-element:field-separator'></span></span></span><![endif]--><span
72
+ class=MsoPageNumber><span lang=EN-GB><span style='mso-no-proof:yes'>2</span></span></span><!--[if supportFields]><span
73
+ class=MsoPageNumber><span lang=EN-GB><span style='mso-element:field-end'></span></span></span><![endif]--><span
74
+ lang=EN-GB> –<span style='mso-tab-count:1'>     </span> {{ docnumber }} </span> © <span
75
+ lang=EN-GB> {{ agency }}:{{docyear}}</span></p>
76
+
77
+
78
+ </div>
79
+
80
+ <div style='mso-element:header' id=ha>
81
+
82
+ <p class=MsoHeader><span lang=EN-GB>{{ docnumber }}
83
+ </span> © <span
84
+ lang=EN-GB> {{ agency }}:{{docyear}}<span style='mso-tab-count:
85
+ 1'>      </span>– </span><!--[if supportFields]><span class=MsoPageNumber><span
86
+ lang=EN-GB><span style='mso-element:field-begin'></span><span
87
+ style='mso-spacerun:yes'> </span>PAGE <span style='mso-element:field-separator'></span></span></span><![endif]--><span
88
+ class=MsoPageNumber><span lang=EN-GB><span style='mso-no-proof:yes'>1</span></span></span><!--[if supportFields]><span
89
+ class=MsoPageNumber><span lang=EN-GB><span style='mso-element:field-end'></span></span></span><![endif]--><span
90
+ lang=EN-GB> –<span style='mso-tab-count:1'>                                                                        </span></span></p>
91
+
92
+ </div>
93
+
94
+ <div style='mso-element:footer' id=efa>
95
+
96
+
97
+ </div>
98
+
99
+ <div style='mso-element:header' id=eh2>
100
+
101
+ <p class=MsoHeader><span lang=EN-GB><span style='mso-tab-count:1'>                                                                        </span>–
102
+ </span><!--[if supportFields]><span class=MsoPageNumber><span lang=EN-GB><span
103
+ style='mso-element:field-begin'></span><span
104
+ style='mso-spacerun:yes'> </span>PAGE <span style='mso-element:field-separator'></span></span></span><![endif]--><span
105
+ class=MsoPageNumber><span lang=EN-GB><span style='mso-no-proof:yes'>2</span></span></span><!--[if supportFields]><span
106
+ class=MsoPageNumber><span lang=EN-GB><span style='mso-element:field-end'></span></span></span><![endif]--><span
107
+ lang=EN-GB> –<span style='mso-tab-count:1'>     </span> {{ docnumber }} </span> © <span
108
+ lang=EN-GB> {{ agency }}:{{docyear}}</span></p>
109
+
110
+ </div>
111
+
112
+ <div style='mso-element:header' id=h2>
113
+
114
+ <p class=MsoHeader><span lang=EN-GB>{{ docnumber }}
115
+ </span> © <span
116
+ lang=EN-GB> {{ agency }}:{{docyear}}<span style='mso-tab-count:
117
+ 1'>      </span>– </span><!--[if supportFields]><span class=MsoPageNumber><span
118
+ lang=EN-GB><span style='mso-element:field-begin'></span><span
119
+ style='mso-spacerun:yes'> </span>PAGE <span style='mso-element:field-separator'></span></span></span><![endif]--><span
120
+ class=MsoPageNumber><span lang=EN-GB><span style='mso-no-proof:yes'>1</span></span></span><!--[if supportFields]><span
121
+ class=MsoPageNumber><span lang=EN-GB><span style='mso-element:field-end'></span></span></span><![endif]--><span
122
+ lang=EN-GB> –<span style='mso-tab-count:1'>                                                                        </span></span></p>
123
+
124
+ </div>
125
+
126
+ <div style='mso-element:footer' id=ef2>
127
+
128
+ <p class=MsoFooter><span lang=EN-GB><o:p>&nbsp;</o:p></span></p>
129
+
130
+ </div>
131
+
132
+ <div style='mso-element:footer' id=f2>
133
+
134
+ <p class=MsoFooter><span lang=EN-GB><o:p>&nbsp;</o:p></span></p>
135
+
136
+ </div>
137
+
138
+ <div style='mso-element:footer' id=ef3>
139
+
140
+ <p class=MsoFooter><span lang=EN-GB><o:p>&nbsp;</o:p></span></p>
141
+
142
+ </div>
143
+
144
+ <div style='mso-element:footer' id=f3>
145
+
146
+ <p class=MsoFooter><span lang=EN-GB><o:p>&nbsp;</o:p></span></p>
147
+
148
+ </div>
149
+
150
+ <div style='mso-element:footer' id=f4>
151
+
152
+ <p class=MsoFooter><span lang=EN-GB><o:p>&nbsp;</o:p></span></p>
153
+
154
+ </div>
155
+
156
+
157
+
158
+ </body>
159
+
160
+ </html>
@@ -0,0 +1,34 @@
1
+ <div class="copyright">
2
+ <p class="year">
3
+ &copy; {{ agency }} {{ docyear }}, Published in Switzerland
4
+ </p>
5
+
6
+ <p class="message">
7
+ All rights
8
+ reserved. Unless otherwise specified, no part of this publication may be
9
+ reproduced or utilized otherwise in any form or by any means, electronic or
10
+ mechanical, including photocopying, or posting on the internet or an intranet,
11
+ without prior written permission. Permission can be requested from either IEC
12
+ at the address below or IEC’s member body in the country of the requester.
13
+ </p>
14
+
15
+ <p class="name">IEC Central Office</p>
16
+ <p class="address">
17
+ 3, rue de Varemb&eacute;<br/>
18
+ CH-1211 Geneva 20, Switzerland<br/>
19
+ Tel.&nbsp;&nbsp;+ 41 22 919 02 11<br/>
20
+ Fax&nbsp;&nbsp;+ 41 22 919 03 00<br/>
21
+ info@iec.ch<br/>
22
+ www.iec.ch
23
+ </p>
24
+ </div>
25
+
26
+
27
+ </div>
28
+
29
+ <nav>
30
+
31
+ <h1 id="content">Contents</h1>
32
+ <div id="toc"></div>
33
+
34
+ </nav>
@@ -0,0 +1,62 @@
1
+ <div id='toggle'> <span>•</span> </div>
2
+ {% if tc_docnumber %}
3
+ <p class="coverpage_docnumber">{{ tc_docnumber }}</p>
4
+ {% else %}
5
+ <p class="coverpage_docnumber">{{ docnumber }}(E) {{ draftinfo }}</p>
6
+ {% endif %}
7
+
8
+ {% if revdate %}
9
+ <p class="coverpage_docnumber">Date: {{ revdate }}</p>
10
+ {% endif %}
11
+
12
+ {% if tc_docnumber %}
13
+ <p class="coverpage_docnumber">{{ docnumber }}(E) {{ draftinfo }}</p>
14
+ {% endif %}
15
+
16
+ <p class="coverpage_techcommittee">{{ agency }}/{{ editorialgroup | join: "/" }}</p>
17
+
18
+ <p class="coverpage_techcommittee"><a
19
+ name="CVP_Secretariat_Loca">Secretariat</a>: {{ secretariat }}</p>
20
+
21
+ <div class="doctitle-en"><div><span class="title">{{ doctitleintro }}{% if doctitleintro and doctitlemain %} &mdash; {% endif %}</span><span class="subtitle">{{ doctitlemain }}{% if doctitlemain and doctitlepart %} &mdash;{% endif %}</span>
22
+ {% if doctitlepart %}
23
+ </div><div class="doctitle-part">
24
+ {% if doctitlepartlabel %}<span class="partlabel">{{ doctitlepartlabel }}: </span>{% endif %}
25
+ <span class="part">{{ doctitlepart }}</span>
26
+ {% endif %}
27
+ </div></div>
28
+
29
+ <div class="doctitle-fr"><div><span class="title">{{ docsubtitleintro }}{% if docsubtitleintro and docsubtitlemain %} &mdash; {% endif %}</span><span class="subtitle">{{ docsubtitlemain }}{% if docsubtitlemain and docsubtitlepart %} &mdash;{% endif %}</span>
30
+ {% if docsubtitlepart %}
31
+ </div><div>
32
+ {% if docsubtitlepartlabel %}<span class="partlabel">{{ docsubtitlepartlabel }}: </span>{% endif %}
33
+ <span class="part">{{ docsubtitlepart }}</span>
34
+ {% endif %}
35
+ </div></div>
36
+
37
+ <div class="coverpage_docstage">
38
+ {% if unpublished %}
39
+ <p>{{ stageabbr }} stage</p>
40
+ {% endif %}
41
+ </div>
42
+
43
+ {% if unpublished %}
44
+ <div class="coverpage_warning">
45
+
46
+ <p>Warning for WDs
47
+ and CDs<o:p></o:p></span></b></p>
48
+
49
+ <p>This
50
+ document is not an ISO International Standard. It is distributed for review and
51
+ comment. It is subject to change without notice and may not be referred to as
52
+ an International Standard.</p>
53
+
54
+ <p>Recipients
55
+ of this draft are invited to submit, with their comments, notification of any
56
+ relevant patent rights of which they are aware and to provide supporting
57
+ documentation.</p>
58
+ {% endif %}
59
+
60
+ </div>
61
+
62
+