metanorma-ieee 0.0.1 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +1 -1
  3. data/lib/html2doc/ieee/lists.rb +44 -0
  4. data/lib/html2doc/ieee/notes.rb +57 -0
  5. data/lib/html2doc/ieee.rb +4 -86
  6. data/lib/isodoc/ieee/base_convert.rb +56 -0
  7. data/lib/isodoc/ieee/html/header.html +1 -2
  8. data/lib/isodoc/ieee/html/header_amd.html +105 -0
  9. data/lib/isodoc/ieee/html/html_ieee_titlepage.html +14 -12
  10. data/lib/isodoc/ieee/html/htmlstyle.css +2 -1
  11. data/lib/isodoc/ieee/html/htmlstyle.scss +1 -0
  12. data/lib/isodoc/ieee/html/ieee.css +46 -273
  13. data/lib/isodoc/ieee/html/ieee.scss +46 -257
  14. data/lib/isodoc/ieee/html/word_ieee_intro.html +1 -1
  15. data/lib/isodoc/ieee/html/word_ieee_titlepage.html +12 -1
  16. data/lib/isodoc/ieee/html/wordstyle.css +20 -23
  17. data/lib/isodoc/ieee/html/wordstyle.scss +20 -17
  18. data/lib/isodoc/ieee/html_convert.rb +37 -1
  19. data/lib/isodoc/ieee/i18n-en.yaml +5 -0
  20. data/lib/isodoc/ieee/ieee.amendment.xsl +5488 -3540
  21. data/lib/isodoc/ieee/ieee.standard.xsl +5488 -3540
  22. data/lib/isodoc/ieee/metadata.rb +35 -51
  23. data/lib/isodoc/ieee/pdf_convert.rb +2 -2
  24. data/lib/isodoc/ieee/presentation_ref.rb +70 -0
  25. data/lib/isodoc/ieee/presentation_terms.rb +105 -32
  26. data/lib/isodoc/ieee/presentation_xml_convert.rb +136 -0
  27. data/lib/isodoc/ieee/word_authority.rb +73 -3
  28. data/lib/isodoc/ieee/word_cleanup.rb +55 -65
  29. data/lib/isodoc/ieee/word_cleanup_blocks.rb +151 -0
  30. data/lib/isodoc/ieee/word_convert.rb +98 -2
  31. data/lib/isodoc/ieee/xref.rb +31 -0
  32. data/lib/metanorma/ieee/boilerplate.xml +72 -23
  33. data/lib/metanorma/ieee/cleanup.rb +142 -77
  34. data/lib/metanorma/ieee/cleanup_ref.rb +126 -0
  35. data/lib/metanorma/ieee/converter.rb +8 -0
  36. data/lib/metanorma/ieee/front.rb +44 -53
  37. data/lib/metanorma/ieee/ieee.rng +44 -6
  38. data/lib/metanorma/ieee/isodoc.rng +32 -1
  39. data/lib/metanorma/ieee/reqt.rng +1 -1
  40. data/lib/metanorma/ieee/term_lookup_cleanup.rb +11 -0
  41. data/lib/metanorma/ieee/validate.rb +105 -57
  42. data/lib/metanorma/ieee/validate_section.rb +14 -7
  43. data/lib/metanorma/ieee/validate_style.rb +58 -1
  44. data/lib/metanorma/ieee/version.rb +1 -1
  45. data/lib/relaton/render/config.yml +44 -0
  46. data/lib/relaton/render/general.rb +13 -0
  47. data/metanorma-itu.gemspec +1 -1
  48. metadata +13 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4bbf250e70bbe6d7c3ce624147d503935bf9005694965377bee47b61d3260c67
4
- data.tar.gz: cd6e4e3f393d870c38f0d31ae11254123b7301659ed519e9a39988b472de9dcc
3
+ metadata.gz: 62bafd0727fc5b10d3a146196f4317b9d158802d918c7c3a7e407d689348bac9
4
+ data.tar.gz: ffd4fbc73ea2b2af25abf3b4b21863e07e79706fc2f2bf8403a75b804e8eb7cf
5
5
  SHA512:
6
- metadata.gz: 7c10105ed014eb7919a245ee2b1ca5bb9165768aa9cd3390cf7782abcaac24e1ff35fd0fbf9c14bcedfb39f7b4090ef17b43c7ba1bc36dbd6f7ad96abef9a04a
7
- data.tar.gz: 41d392c1240e1ad3f31660d22b3d46ff2471e4e4001fc990eea12ff388877aa39b6eb49fd119b19d707a26096f55955e8d31ea76827bdfdc3715e597896089fd
6
+ metadata.gz: 52bc01c58e681f92ed46c3241db36244fbb805d6ec81678e90ad07b5ad9b7c89c1a528fbfbe411af74a9b7d58c01f032b2bdebaaaa7996dc313fe052ba73e7f0
7
+ data.tar.gz: 6fb175826c51f3b48ceb6a7b330560f166d358a24412109b09b77f04f84a66bcdc2e75bff43d2d277767257cd619e33265218dd399c47eee842b85799b274ab0
data/README.adoc CHANGED
@@ -8,7 +8,7 @@ image:https://img.shields.io/github/commits-since/metanorma/metanorma-ieee/lates
8
8
 
9
9
  == Functionality
10
10
 
11
- This gem processes https://www.metanorma.com[Metanorma documents] following a template for generating ITU
11
+ This gem processes https://www.metanorma.com[Metanorma documents] following a template for generating IEEE
12
12
  standards and documents.
13
13
 
14
14
  The implementation inherits from https://github.com/metanorma/metanorma-standoc.
@@ -0,0 +1,44 @@
1
+ class Html2Doc
2
+ class IEEE < ::Html2Doc
3
+ def style_list(elem, level, liststyle, listnumber)
4
+ super
5
+ elem.parent["level"] = level
6
+ end
7
+
8
+ def list2para(list)
9
+ return if list.xpath("./li").empty?
10
+
11
+ level = list["level"] || "1"
12
+ list.delete("level")
13
+ list2para1(list, level, list.name)
14
+ end
15
+
16
+ def list2para1(list, level, type)
17
+ list.xpath("./li").first["class"] ||= list_style(type, level, "First")
18
+ list.xpath("./li").last["class"] ||= list_style(type, level, "Last")
19
+ list.xpath("./li/p").each do |p|
20
+ p["class"] ||= list_style(type, level, "Middle")
21
+ end
22
+ list.xpath("./li").each do |l|
23
+ l.name = "p"
24
+ l["class"] ||= list_style(type, level, "Middle")
25
+ next unless l&.first_element_child&.name == "p"
26
+
27
+ l["style"] += (l.first_element_child["style"]&.sub(/mso-list[^;]+;/, "") || "")
28
+ l.first_element_child.replace(l.first_element_child.children)
29
+ end
30
+ list.replace(list.children)
31
+ end
32
+
33
+ def list_style(listtype, level, position)
34
+ case listtype
35
+ when "ol" then "IEEEStdsNumberedListLevel#{level}CxSp#{position}"
36
+ when "ul"
37
+ case level
38
+ when "1" then "IEEEStdsUnorderedListCxSp#{position}"
39
+ else "IEEEStdsUnorderedListLevel2"
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,57 @@
1
+ class Html2Doc
2
+ class IEEE < ::Html2Doc
3
+ def process_footnote_texts(docxml, footnotes)
4
+ body = docxml.at("//body")
5
+ list = body.add_child("<div style='mso-element:footnote-list'/>")
6
+ footnotes.each_with_index do |f, i|
7
+ if i.zero?
8
+ fn = list.first.add_child(footnote_container_nofn(docxml, i + 1))
9
+ f.parent = fn.first
10
+ footnote_div_to_p_unstyled(f)
11
+ else
12
+ fn = list.first.add_child(footnote_container(docxml, i + 1))
13
+ f.parent = fn.first
14
+ footnote_div_to_p(f)
15
+ end
16
+ end
17
+ footnote_cleanup(docxml)
18
+ end
19
+
20
+ def footnote_container_nofn(_docxml, idx)
21
+ <<~DIV
22
+ <div style='mso-element:footnote' id='ftn#{idx}'>
23
+ <a style='mso-footnote-id:ftn#{idx}' href='#_ftn#{idx}'
24
+ name='_ftnref#{idx}' title='' id='_ftnref#{idx}'></a></div>
25
+ DIV
26
+ end
27
+
28
+ def footnote_div_to_p_unstyled(elem)
29
+ if %w{div aside}.include? elem.name
30
+ if elem.at(".//p")
31
+ elem.replace(elem.children)
32
+ else
33
+ elem.name = "p"
34
+ end
35
+ end
36
+ end
37
+
38
+ def transform_footnote_text(note)
39
+ note["id"] = ""
40
+ note.xpath(".//div").each { |div| div.replace(div.children) }
41
+ note.xpath(".//aside | .//p").each do |p|
42
+ p.name = "p"
43
+ %w(IEEEStdsCRTextReg IEEEStdsCRTextItal).include?(p["class"]) or
44
+ p["class"] = "IEEEStdsFootnote"
45
+ end
46
+ note.remove
47
+ end
48
+
49
+ def cleanup(docxml)
50
+ super
51
+ docxml.xpath("//div[@class = 'Note']").each do |d|
52
+ d.delete("class")
53
+ end
54
+ docxml
55
+ end
56
+ end
57
+ end
data/lib/html2doc/ieee.rb CHANGED
@@ -1,89 +1,7 @@
1
- class Html2Doc
2
- class IEEE < ::Html2Doc
3
- def process_footnote_texts(docxml, footnotes)
4
- body = docxml.at("//body")
5
- list = body.add_child("<div style='mso-element:footnote-list'/>")
6
- footnotes.each_with_index do |f, i|
7
- if i.zero?
8
- fn = list.first.add_child(footnote_container_nofn(docxml, i + 1))
9
- f.parent = fn.first
10
- footnote_div_to_p_unstyled(f)
11
- else
12
- fn = list.first.add_child(footnote_container(docxml, i + 1))
13
- f.parent = fn.first
14
- footnote_div_to_p(f)
15
- end
16
- end
17
- footnote_cleanup(docxml)
18
- end
19
-
20
- def footnote_container_nofn(_docxml, idx)
21
- <<~DIV
22
- <div style='mso-element:footnote' id='ftn#{idx}'>
23
- <a style='mso-footnote-id:ftn#{idx}' href='#_ftn#{idx}'
24
- name='_ftnref#{idx}' title='' id='_ftnref#{idx}'></a></div>
25
- DIV
26
- end
27
-
28
- def footnote_div_to_p_unstyled(elem)
29
- if %w{div aside}.include? elem.name
30
- if elem.at(".//p")
31
- elem.replace(elem.children)
32
- else
33
- elem.name = "p"
34
- end
35
- end
36
- end
37
-
38
- def transform_footnote_text(note)
39
- note["id"] = ""
40
- note.xpath(".//div").each { |div| div.replace(div.children) }
41
- note.xpath(".//aside | .//p").each do |p|
42
- p.name = "p"
43
- %w(IEEEStdsCRTextReg IEEEStdsCRTextItal).include?(p["class"]) or
44
- p["class"] = "IEEEStdsFootnote"
45
- end
46
- note.remove
47
- end
1
+ require "html2doc/ieee/notes"
2
+ require "html2doc/ieee/lists"
48
3
 
49
- def list2para(list)
50
- return if list.xpath("./li").empty?
51
-
52
- if list.name == "ol"
53
- list2para_ol(list)
54
- else
55
- list2para_ul(list)
56
- end
57
- end
58
-
59
- def list2para_ul(list)
60
- list.xpath("./li").first["class"] ||= "IEEEStdsUnorderedListCxSpFirst"
61
- list.xpath("./li").last["class"] ||= "IEEEStdsUnorderedListCxSpLast"
62
- list.xpath("./li/p").each do |p|
63
- p["class"] ||= "IEEEStdsUnorderedListCxSpMiddle"
64
- end
65
- list.xpath("./li").each do |l|
66
- l.name = "p"
67
- l["class"] ||= "IEEEStdsUnorderedListCxSpMiddle"
68
- l&.first_element_child&.name == "p" and
69
- l.first_element_child.replace(l.first_element_child.children)
70
- end
71
- list.replace(list.children)
72
- end
73
-
74
- def list2para_ol(list)
75
- list.xpath("./li").first["class"] ||= "IEEEStdsNumberedListLevel1CxSpFirst"
76
- list.xpath("./li").last["class"] ||= "IEEEStdsNumberedListLevel1CxSpLast"
77
- list.xpath("./li/p").each do |p|
78
- p["class"] ||= "IEEEStdsNumberedListLevel1CxSpMiddle"
79
- end
80
- list.xpath("./li").each do |l|
81
- l.name = "p"
82
- l["class"] ||= "IEEEStdsNumberedListLevel1CxSpMiddle"
83
- l&.first_element_child&.name == "p" and
84
- l.first_element_child.replace(l.first_element_child.children)
85
- end
86
- list.replace(list.children)
87
- end
4
+ class Html2Doc
5
+ class IEEE
88
6
  end
89
7
  end
@@ -28,6 +28,62 @@ module IsoDoc
28
28
  def para_attrs(node)
29
29
  super.merge(type: node["type"])
30
30
  end
31
+
32
+ def note_delim
33
+ "&#x2014;"
34
+ end
35
+
36
+ def note_p_parse(node, div)
37
+ name = node&.at(ns("./name"))&.remove
38
+ div.p do |p|
39
+ name and p.span **{ class: "note_label" } do |s|
40
+ name.children.each { |n| parse(n, s) }
41
+ s << note_delim
42
+ end
43
+ node.first_element_child.children.each { |n| parse(n, p) }
44
+ end
45
+ node.element_children[1..-1].each { |n| parse(n, div) }
46
+ end
47
+
48
+ def note_parse1(node, div)
49
+ name = node&.at(ns("./name"))&.remove
50
+ name and div.p do |p|
51
+ p.span **{ class: "note_label" } do |s|
52
+ name.children.each { |n| parse(n, s) }
53
+ s << note_delim
54
+ end
55
+ end
56
+ node.children.each { |n| parse(n, div) }
57
+ end
58
+
59
+ def termnote_delim
60
+ "&#x2014;"
61
+ end
62
+
63
+ def formula_where(dlist, out)
64
+ return unless dlist
65
+
66
+ parse(dlist, out)
67
+ out.parent.at("./dl")["class"] = "formula_dl"
68
+ end
69
+
70
+ def bracket_if_num(num)
71
+ return nil if num.nil?
72
+
73
+ num = num.text.sub(/^\[/, "").sub(/\]$/, "")
74
+ return "[#{num}]" if /^B?\d+$/.match?(num)
75
+
76
+ num
77
+ end
78
+
79
+ def example_label(_node, div, name)
80
+ return if name.nil?
81
+
82
+ name << ":"
83
+ div.p **{ class: "example-title" } do |p|
84
+ name.children.each { |n| parse(n, p) }
85
+ end
86
+ end
31
87
  end
32
88
  end
33
89
  end
@@ -62,8 +62,7 @@ xmlns="http://www.w3.org/TR/REC-html40">
62
62
  <p class=MsoHeader><span lang=EN-US>P{{ docnumeric }}{% if draft %}/D{{ draft }},
63
63
  {{ draft_month }} {{ draft_year }}{% endif %}</span></p>
64
64
 
65
- <p class=MsoHeader><span lang=EN-US>{% if draft %}Draft{% endif %} {{ doctype_abbrev }} for
66
- {{ doctitle }}</span></p>
65
+ <p class=MsoHeader><span lang=EN-US>{{ full_doctitle }}</span></p>
67
66
 
68
67
  </div>
69
68
 
@@ -0,0 +1,105 @@
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="http://www.w3.org/TR/REC-html40">
6
+
7
+ <head>
8
+ <meta http-equiv=Content-Type content="text/html; charset=utf-8">
9
+ <meta name=ProgId content=Word.Document>
10
+ <meta name=Generator content="Microsoft Word 15">
11
+ <meta name=Originator content="Microsoft Word 15">
12
+ <link id=Main-File rel=Main-File
13
+ href="../IEEESTD-WORDTEMPLATE_Amendments-Corri-v7-2022.html">
14
+ <!--[if gte mso 9]><xml>
15
+ <o:shapedefaults v:ext="edit" spidmax="2050"/>
16
+ </xml><![endif]-->
17
+ </head>
18
+
19
+ <body lang=el-AU link=blue vlink=purple>
20
+
21
+ <div style='mso-element:footnote-separator' id=fs>
22
+
23
+ <p class=MsoNormal><span lang=EN-US><span style='mso-special-character:footnote-separator'><![if !supportFootnotes]>
24
+
25
+ <hr align=left size=1 width="33%">
26
+
27
+ <![endif]></span></span></p>
28
+
29
+ </div>
30
+
31
+ <div style='mso-element:footnote-continuation-separator' id=fcs>
32
+
33
+ <p class=MsoNormal><span lang=EN-US><span style='mso-special-character:footnote-continuation-separator'><![if !supportFootnotes]>
34
+
35
+ <hr align=left size=1>
36
+
37
+ <![endif]></span></span></p>
38
+
39
+ </div>
40
+
41
+ <div style='mso-element:endnote-separator' id=es>
42
+
43
+ <p class=MsoNormal><span lang=EN-US><span style='mso-special-character:footnote-separator'><![if !supportFootnotes]>
44
+
45
+ <hr align=left size=1 width="33%">
46
+
47
+ <![endif]></span></span></p>
48
+
49
+ </div>
50
+
51
+ <div style='mso-element:endnote-continuation-separator' id=ecs>
52
+
53
+ <p class=MsoNormal><span lang=EN-US><span style='mso-special-character:footnote-continuation-separator'><![if !supportFootnotes]>
54
+
55
+ <hr align=left size=1>
56
+
57
+ <![endif]></span></span></p>
58
+
59
+ </div>
60
+
61
+ <div style='mso-element:header' id=h1>
62
+
63
+ <p class=MsoHeader><span lang=EN-US>IEEE
64
+ P{{ docnumeric }}{% if draft %}/D{{ draft }}, {{ draft_month }} {{ draft_year }}{% endif %}</span></p>
65
+
66
+ </div>
67
+
68
+ <div style='mso-element:header' id=fh1>
69
+
70
+ <p class=MsoHeader><span lang=EN-US>IEEE P{{ docnumeric }}{% if draft %}/D{{ draft }}, {{ draft_month }} {{ draft_year }}{% endif %}</span></p>
71
+
72
+ </div>
73
+
74
+ <div style='mso-element:footer' id=f8>
75
+
76
+ <p class=MsoFooter style='tab-stops:right 432.0pt'><!--[if supportFields]><span
77
+ class=MsoPageNumber><span lang=EN-US style='font-size:10.0pt'><span
78
+ style='mso-element:field-begin'></span>PAGE<span style='mso-spacerun:yes'> 
79
+ </span><span style='mso-element:field-separator'></span></span></span><![endif]--><span
80
+ class=MsoPageNumber><span lang=EN-US style='font-size:10.0pt'>9</span></span><!--[if supportFields]><span
81
+ class=MsoPageNumber><span lang=EN-US style='font-size:10.0pt'><span
82
+ style='mso-element:field-end'></span></span></span><![endif]--><span
83
+ class=MsoPageNumber><span lang=EN-US style='font-size:10.0pt'><o:p></o:p></span></span></p>
84
+
85
+ <p class=MsoFooter style='tab-stops:right 432.0pt'><span lang=EN-US>Copyright ©
86
+ {{ draft_year }} IEEE. All rights reserved.</span></p>
87
+
88
+ <p class=MsoFooter style='tab-stops:right 432.0pt'><span lang=EN-US>This is an
89
+ unapproved IEEE Standards Draft, subject to change.</span></p>
90
+
91
+ </div>
92
+
93
+ <div style='mso-element:header' id=h9>
94
+
95
+ <p class=MsoHeader align=center style='text-align:center;tab-stops:right 432.0pt'><span
96
+ lang=EN-US style='mso-bidi-font-size:8.0pt'>IEEE
97
+ P&lt;designation&gt;/D&lt;draft_number&gt;, &lt;draft_month&gt;
98
+ &lt;draft_year&gt;<o:p></o:p></span></p>
99
+
100
+ </div>
101
+
102
+ </body>
103
+
104
+ </html>
105
+
@@ -2,30 +2,32 @@
2
2
 
3
3
  <div class="doctitle-en"><span>P{{ docnumeric }}™{% if draft %}/D{{ draft }}{% endif %}</span><br/>
4
4
  <span lang="EN-US">{{ full_doctitle }}</span></div>
5
- {% if doctitleamdlabel %}
6
- <div class="doctitle-part">{{ doctitleamdlabel }}{% if doctitleamd %}: {{ doctitleamd }}{% endif %}</div>
5
+ {% if amd %}
6
+ <div class="doctitle-part">Amendment {{ amd }}</div>
7
7
  {% endif %}
8
- {% if doctitlecorrlabel %}
9
- <div class="doctitle-part">{{ doctitlecorrlabel }}</div>
8
+ {% if corr %}
9
+ <div class="doctitle-part">Corrigenda {{ corr }}</div>
10
10
  {% endif %}
11
+ {%if provenance_doctitle %}
12
+ <div class="doctitle-part">({{ provenance_doctitle }})</div>
13
+ {%endif%}
11
14
  </div>
12
15
 
13
16
  <div><p>Developed by the</p>
14
17
  <p><b>{{ technical_committee }}</b></p>
15
18
  <p>of the</p>
16
19
  <p><b>IEEE {{ society }}</b></p>
17
- <p>Approved {{ confirmeddate }}</p>
20
+ <p>Approved {{ issueddate }}</p>
18
21
  <p>IEEE SA Standards Board</p>
19
22
  </div>
20
23
 
21
-
22
-
23
-
24
- <div class="coverpage_docstage">
25
- {% if unpublished %}
26
- <p>{{ stageabbr }} stage</p>
27
- {% endif %}
24
+ {% if trial_use %}
25
+ <div>
26
+ {% if feedback_endeddate %}<p>Comments due: {{ feedback_endeddate }}</p>{% endif %}
27
+ {% if obsoleteddate %}<p>Expires: {{ obsoleteddate }}</p>{% endif %}
28
28
  </div>
29
+ {% endif %}
30
+
29
31
 
30
32
  {% if unpublished %}
31
33
  <div class="coverpage_warning">
@@ -865,7 +865,8 @@ pre {
865
865
  text-transform: uppercase;
866
866
  margin-left: -1.5em; }
867
867
  .example .example-title {
868
- margin-left: -1.5em; }
868
+ margin-left: -1.5em;
869
+ font-style: italic; }
869
870
  .example pre,
870
871
  .example .pseudocode {
871
872
  background: none; }
@@ -560,6 +560,7 @@ pre {
560
560
 
561
561
  .example-title {
562
562
  margin-left: -1.5em;
563
+ font-style: italic;
563
564
  }
564
565
 
565
566
  pre,