metanorma-gb 1.3.22 → 1.3.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +8 -0
- data/.github/workflows/ubuntu.yml +10 -0
- data/.github/workflows/windows.yml +8 -0
- data/lib/asciidoctor/gb/biblio.rng +36 -6
- data/lib/asciidoctor/gb/converter.rb +7 -0
- data/lib/asciidoctor/gb/front.rb +2 -52
- data/lib/asciidoctor/gb/front_id.rb +57 -0
- data/lib/asciidoctor/gb/isodoc.rng +450 -4
- data/lib/asciidoctor/gb/isostandard.rng +12 -1
- data/lib/asciidoctor/gb/reqt.rng +23 -0
- data/lib/asciidoctor/gb/section_input.rb +2 -94
- data/lib/isodoc/gb/gb.recommendation.xsl +3252 -0
- data/lib/isodoc/gb/gbbaseconvert.rb +24 -28
- data/lib/isodoc/gb/html/scripts.html +17 -2
- data/lib/isodoc/gb/metadata.rb +4 -3
- data/lib/isodoc/gb/pdf_convert.rb +30 -0
- data/lib/metanorma-gb.rb +1 -0
- data/lib/metanorma/gb/processor.rb +13 -1
- data/lib/metanorma/gb/version.rb +1 -1
- metadata +5 -2
@@ -12,7 +12,8 @@ module IsoDoc
|
|
12
12
|
h = options[:headerfont] || "Arial"
|
13
13
|
m = options[:monospacefont] || "Courier"
|
14
14
|
t = options[:titlefont] || "Arial"
|
15
|
-
"$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n
|
15
|
+
"$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n"\
|
16
|
+
"$titlefont: #{t};\n"
|
16
17
|
end
|
17
18
|
|
18
19
|
def metadata_init(lang, script, labels)
|
@@ -45,7 +46,8 @@ module IsoDoc
|
|
45
46
|
YAML.load_file(File.join(File.dirname(__FILE__),
|
46
47
|
"i18n-zh-Hans.yaml"))
|
47
48
|
else
|
48
|
-
YAML.load_file(File.join(File.dirname(__FILE__),
|
49
|
+
YAML.load_file(File.join(File.dirname(__FILE__),
|
50
|
+
"i18n-zh-Hans.yaml"))
|
49
51
|
end
|
50
52
|
@labels = @labels.merge(y)
|
51
53
|
end
|
@@ -55,16 +57,18 @@ module IsoDoc
|
|
55
57
|
end
|
56
58
|
|
57
59
|
def formula_parse(node, out)
|
58
|
-
out.div **
|
60
|
+
out.div **formula_attrs(node) do |div1|
|
61
|
+
div1.div **attr_code(class: "formula") do |div|
|
59
62
|
insert_tab(div, 1)
|
60
|
-
parse(node.at(ns("./stem")),
|
63
|
+
parse(node.at(ns("./stem")), div)
|
61
64
|
lbl = anchor(node['id'], :label, false)
|
62
65
|
unless lbl.nil?
|
63
66
|
insert_tab(div, 1)
|
64
67
|
div << "(#{lbl})"
|
65
68
|
end
|
66
69
|
end
|
67
|
-
formula_where(node.at(ns("./dl")),
|
70
|
+
formula_where(node.at(ns("./dl")), div1)
|
71
|
+
end
|
68
72
|
end
|
69
73
|
|
70
74
|
def formula_where(dl, out)
|
@@ -100,12 +104,16 @@ module IsoDoc
|
|
100
104
|
end
|
101
105
|
|
102
106
|
def note_parse(node, out)
|
107
|
+
note_parse_table(node, out, note_label(node) + ":")
|
108
|
+
end
|
109
|
+
|
110
|
+
def note_parse_table(node, out, label)
|
103
111
|
@note = true
|
104
|
-
out.table **
|
112
|
+
out.table **note_attrs(node) do |t|
|
105
113
|
t.tr do |tr|
|
106
114
|
@libdir = File.dirname(__FILE__)
|
107
115
|
tr.td **EXAMPLE_TBL_ATTR do |td|
|
108
|
-
td << l10n(
|
116
|
+
td << l10n(label)
|
109
117
|
end
|
110
118
|
tr.td **{ style: "vertical-align:top;", class: "Note" } do |td|
|
111
119
|
node.children.each { |n| parse(n, td) }
|
@@ -116,18 +124,7 @@ module IsoDoc
|
|
116
124
|
end
|
117
125
|
|
118
126
|
def termnote_parse(node, out)
|
119
|
-
|
120
|
-
out.table **attr_code(id: node["id"], class: "Note") do |t|
|
121
|
-
t.tr do |tr|
|
122
|
-
tr.td **EXAMPLE_TBL_ATTR do |td|
|
123
|
-
td << l10n("#{anchor(node['id'], :label)}:")
|
124
|
-
end
|
125
|
-
tr.td **{ style: "vertical-align:top;", class: "Note" } do |td|
|
126
|
-
node.children.each { |n| parse(n, td) }
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
@note = false
|
127
|
+
note_parse_table(node, out, "#{anchor(node['id'], :label)}:")
|
131
128
|
end
|
132
129
|
|
133
130
|
def middle(isoxml, out)
|
@@ -168,15 +165,17 @@ module IsoDoc
|
|
168
165
|
def termref_render(x)
|
169
166
|
x.sub!(%r{\s*\[MODIFICATION\]\s*$}m, l10n(", #{@modified_lbl}"))
|
170
167
|
parts = x.split(%r{(\s*\[MODIFICATION\]|,)}m)
|
171
|
-
parts[1] = l10n(", #{@source_lbl}") if parts.size > 1 &&
|
172
|
-
!/^\s*#{@modified_lbl}/.match(parts[2])
|
168
|
+
parts[1] = l10n(", #{@source_lbl}") if parts.size > 1 &&
|
169
|
+
parts[1] == "," && !/^\s*#{@modified_lbl}/.match(parts[2])
|
173
170
|
parts.map do |p|
|
174
|
-
/\s*\[MODIFICATION\]/.match(p) ?
|
171
|
+
/\s*\[MODIFICATION\]/.match(p) ?
|
172
|
+
l10n(", #{@modified_lbl} — ") : p
|
175
173
|
end.join.sub(/\A\s*/m, l10n("[")).sub(/\s*\z/m, l10n("]"))
|
176
174
|
end
|
177
175
|
|
178
176
|
def termref_resolve(docxml)
|
179
|
-
docxml.
|
177
|
+
docxml.gsub(%r{\s*\[/TERMREF\]\s*</p>\s*<p>\s*\[TERMREF\]}, l10n("; ")).
|
178
|
+
split(%r{(\[TERMREF\]|\[/TERMREF\])}).each_slice(4).
|
180
179
|
map do |a|
|
181
180
|
a.size < 3 ? a[0] : a[0] + termref_render(a[2])
|
182
181
|
end.join
|
@@ -251,11 +250,8 @@ module IsoDoc
|
|
251
250
|
|
252
251
|
def example_parse(node, out)
|
253
252
|
out.div **{ id: node["id"], class: "example" } do |div|
|
254
|
-
|
255
|
-
example_p_parse(node, div)
|
256
|
-
else
|
257
|
-
example_parse1(node, div)
|
258
|
-
end
|
253
|
+
node_begins_with_para(node) ?
|
254
|
+
example_p_parse(node, div) : example_parse1(node, div)
|
259
255
|
end
|
260
256
|
end
|
261
257
|
|
@@ -53,5 +53,20 @@ $('#toggle').on('click', function(){
|
|
53
53
|
});
|
54
54
|
*/
|
55
55
|
</script>
|
56
|
-
|
57
|
-
|
56
|
+
<script>
|
57
|
+
// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat
|
58
|
+
//
|
59
|
+
// AnchorJS - v4.2.2 - 2020-04-20
|
60
|
+
// https://www.bryanbraun.com/anchorjs/
|
61
|
+
// Copyright (c) 2020 Bryan Braun; Licensed MIT
|
62
|
+
//
|
63
|
+
// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat
|
64
|
+
!function(A,e){"use strict";"function"==typeof define&&define.amd?define([],e):"object"==typeof module&&module.exports?module.exports=e():(A.AnchorJS=e(),A.anchors=new A.AnchorJS)}(this,function(){"use strict";return function(A){function f(A){A.icon=A.hasOwnProperty("icon")?A.icon:"",A.visible=A.hasOwnProperty("visible")?A.visible:"hover",A.placement=A.hasOwnProperty("placement")?A.placement:"right",A.ariaLabel=A.hasOwnProperty("ariaLabel")?A.ariaLabel:"Anchor",A.class=A.hasOwnProperty("class")?A.class:"",A.base=A.hasOwnProperty("base")?A.base:"",A.truncate=A.hasOwnProperty("truncate")?Math.floor(A.truncate):64,A.titleText=A.hasOwnProperty("titleText")?A.titleText:""}function p(A){var e;if("string"==typeof A||A instanceof String)e=[].slice.call(document.querySelectorAll(A));else{if(!(Array.isArray(A)||A instanceof NodeList))throw new Error("The selector provided to AnchorJS was invalid.");e=[].slice.call(A)}return e}this.options=A||{},this.elements=[],f(this.options),this.isTouchDevice=function(){return!!("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)},this.add=function(A){var e,t,i,n,o,s,a,r,c,h,l,u,d=[];if(f(this.options),"touch"===(l=this.options.visible)&&(l=this.isTouchDevice()?"always":"hover"),0===(e=p(A=A||"h2, h3, h4, h5, h6")).length)return this;for(!function(){if(null!==document.head.querySelector("style.anchorjs"))return;var A,e=document.createElement("style");e.className="anchorjs",e.appendChild(document.createTextNode("")),void 0===(A=document.head.querySelector('[rel="stylesheet"],style'))?document.head.appendChild(e):document.head.insertBefore(e,A);e.sheet.insertRule(".anchorjs-link{opacity:0;text-decoration:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}",e.sheet.cssRules.length),e.sheet.insertRule(":hover>.anchorjs-link,.anchorjs-link:focus{opacity:1}",e.sheet.cssRules.length),e.sheet.insertRule("[data-anchorjs-icon]::after{content:attr(data-anchorjs-icon)}",e.sheet.cssRules.length),e.sheet.insertRule('@font-face{font-family:anchorjs-icons;src:url(data:n/a;base64,AAEAAAALAIAAAwAwT1MvMg8yG2cAAAE4AAAAYGNtYXDp3gC3AAABpAAAAExnYXNwAAAAEAAAA9wAAAAIZ2x5ZlQCcfwAAAH4AAABCGhlYWQHFvHyAAAAvAAAADZoaGVhBnACFwAAAPQAAAAkaG10eASAADEAAAGYAAAADGxvY2EACACEAAAB8AAAAAhtYXhwAAYAVwAAARgAAAAgbmFtZQGOH9cAAAMAAAAAunBvc3QAAwAAAAADvAAAACAAAQAAAAEAAHzE2p9fDzz1AAkEAAAAAADRecUWAAAAANQA6R8AAAAAAoACwAAAAAgAAgAAAAAAAAABAAADwP/AAAACgAAA/9MCrQABAAAAAAAAAAAAAAAAAAAAAwABAAAAAwBVAAIAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAMCQAGQAAUAAAKZAswAAACPApkCzAAAAesAMwEJAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAQAAg//0DwP/AAEADwABAAAAAAQAAAAAAAAAAAAAAIAAAAAAAAAIAAAACgAAxAAAAAwAAAAMAAAAcAAEAAwAAABwAAwABAAAAHAAEADAAAAAIAAgAAgAAACDpy//9//8AAAAg6cv//f///+EWNwADAAEAAAAAAAAAAAAAAAAACACEAAEAAAAAAAAAAAAAAAAxAAACAAQARAKAAsAAKwBUAAABIiYnJjQ3NzY2MzIWFxYUBwcGIicmNDc3NjQnJiYjIgYHBwYUFxYUBwYGIwciJicmNDc3NjIXFhQHBwYUFxYWMzI2Nzc2NCcmNDc2MhcWFAcHBgYjARQGDAUtLXoWOR8fORYtLTgKGwoKCjgaGg0gEhIgDXoaGgkJBQwHdR85Fi0tOAobCgoKOBoaDSASEiANehoaCQkKGwotLXoWOR8BMwUFLYEuehYXFxYugC44CQkKGwo4GkoaDQ0NDXoaShoKGwoFBe8XFi6ALjgJCQobCjgaShoNDQ0NehpKGgobCgoKLYEuehYXAAAADACWAAEAAAAAAAEACAAAAAEAAAAAAAIAAwAIAAEAAAAAAAMACAAAAAEAAAAAAAQACAAAAAEAAAAAAAUAAQALAAEAAAAAAAYACAAAAAMAAQQJAAEAEAAMAAMAAQQJAAIABgAcAAMAAQQJAAMAEAAMAAMAAQQJAAQAEAAMAAMAAQQJAAUAAgAiAAMAAQQJAAYAEAAMYW5jaG9yanM0MDBAAGEAbgBjAGgAbwByAGoAcwA0ADAAMABAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAH//wAP) format("truetype")}',e.sheet.cssRules.length)}(),t=document.querySelectorAll("[id]"),i=[].map.call(t,function(A){return A.id}),o=0;o<e.length;o++)if(this.hasAnchorJSLink(e[o]))d.push(o);else{if(e[o].hasAttribute("id"))n=e[o].getAttribute("id");else if(e[o].hasAttribute("data-anchor-id"))n=e[o].getAttribute("data-anchor-id");else{for(c=r=this.urlify(e[o].textContent),a=0;void 0!==s&&(c=r+"-"+a),a+=1,-1!==(s=i.indexOf(c)););s=void 0,i.push(c),e[o].setAttribute("id",c),n=c}(h=document.createElement("a")).className="anchorjs-link "+this.options.class,h.setAttribute("aria-label",this.options.ariaLabel),h.setAttribute("data-anchorjs-icon",this.options.icon),this.options.titleText&&(h.title=this.options.titleText),u=document.querySelector("base")?window.location.pathname+window.location.search:"",u=this.options.base||u,h.href=u+"#"+n,"always"===l&&(h.style.opacity="1"),""===this.options.icon&&(h.style.font="1em/1 anchorjs-icons","left"===this.options.placement&&(h.style.lineHeight="inherit")),"left"===this.options.placement?(h.style.position="absolute",h.style.marginLeft="-1em",h.style.paddingRight="0.5em",e[o].insertBefore(h,e[o].firstChild)):(h.style.paddingLeft="0.375em",e[o].appendChild(h))}for(o=0;o<d.length;o++)e.splice(d[o]-o,1);return this.elements=this.elements.concat(e),this},this.remove=function(A){for(var e,t,i=p(A),n=0;n<i.length;n++)(t=i[n].querySelector(".anchorjs-link"))&&(-1!==(e=this.elements.indexOf(i[n]))&&this.elements.splice(e,1),i[n].removeChild(t));return this},this.removeAll=function(){this.remove(this.elements)},this.urlify=function(A){return this.options.truncate||f(this.options),A.trim().replace(/\'/gi,"").replace(/[& +$,:;=?@"#{}|^~[`%!'<>\]\.\/\(\)\*\\\n\t\b\v]/g,"-").replace(/-{2,}/g,"-").substring(0,this.options.truncate).replace(/^-+|-+$/gm,"").toLowerCase()},this.hasAnchorJSLink=function(A){var e=A.firstChild&&-1<(" "+A.firstChild.className+" ").indexOf(" anchorjs-link "),t=A.lastChild&&-1<(" "+A.lastChild.className+" ").indexOf(" anchorjs-link ");return e||t||!1}}});
|
65
|
+
// @license-end
|
66
|
+
</script>
|
67
|
+
<script>
|
68
|
+
anchors.options = {
|
69
|
+
placement: 'left'
|
70
|
+
};
|
71
|
+
anchors.add('h1, h2, h3, h4');
|
72
|
+
</script>
|
data/lib/isodoc/gb/metadata.rb
CHANGED
@@ -90,8 +90,8 @@ module IsoDoc
|
|
90
90
|
"95": "obsolete",
|
91
91
|
}
|
92
92
|
|
93
|
-
def status_abbrev_cn(stage, _substage, iter, draft)
|
94
|
-
return status_abbrev(stage, _substage, iter, draft) if @lang != "zh"
|
93
|
+
def status_abbrev_cn(stage, _substage, iter, draft, doctype)
|
94
|
+
return status_abbrev(stage, _substage, iter, draft, doctype) if @lang != "zh"
|
95
95
|
stage_num = stage == "PRF" ? "60" :
|
96
96
|
(Asciidoctor::Gb::Converter::STAGE_ABBRS&.invert[stage]&.to_s || "??")
|
97
97
|
stage = STAGE_ABBRS_CN[stage_num.to_sym] || "??"
|
@@ -109,7 +109,8 @@ module IsoDoc
|
|
109
109
|
set(:statusabbr, status_abbrev_cn(docstatus["abbreviation"],
|
110
110
|
isoxml&.at(ns("//bibdata/status/substage"))&.text,
|
111
111
|
isoxml&.at(ns("//bibdata/status/iteration"))&.text,
|
112
|
-
isoxml&.at(ns("//version/draft"))&.text
|
112
|
+
isoxml&.at(ns("//version/draft"))&.text,
|
113
|
+
isoxml&.at(ns("//bibdata/ext/doctype"))&.text))
|
113
114
|
set(:status, STATUS_CSS[docstatus.text.to_sym])
|
114
115
|
unpublished(docstatus.text) and
|
115
116
|
set(:stageabbr, docstatus["abbreviation"])
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "isodoc"
|
2
|
+
|
3
|
+
module IsoDoc
|
4
|
+
module Gb
|
5
|
+
|
6
|
+
# A {Converter} implementation that generates HTML output, and a document
|
7
|
+
# schema encapsulation of the document for validation
|
8
|
+
#
|
9
|
+
class PdfConvert < IsoDoc::XslfoPdfConvert
|
10
|
+
def initialize(options)
|
11
|
+
@libdir = File.dirname(__FILE__)
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def convert(filename, file = nil, debug = false)
|
16
|
+
file = File.read(filename, encoding: "utf-8") if file.nil?
|
17
|
+
docxml, outname_html, dir = convert_init(file, filename, debug)
|
18
|
+
/\.xml$/.match(filename) or
|
19
|
+
filename = Tempfile.open([outname_html, ".xml"], encoding: "utf-8") do |f|
|
20
|
+
f.write file
|
21
|
+
f.path
|
22
|
+
end
|
23
|
+
FileUtils.rm_rf dir
|
24
|
+
::Metanorma::Output::XslfoPdf.new.convert(
|
25
|
+
filename, outname_html + ".pdf", File.join(@libdir, "gb.recommendation.xsl"))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
data/lib/metanorma-gb.rb
CHANGED
@@ -2,6 +2,15 @@ require "metanorma/processor"
|
|
2
2
|
|
3
3
|
module Metanorma
|
4
4
|
module Gb
|
5
|
+
def self.fonts_used
|
6
|
+
{
|
7
|
+
compliant_html: ["SimSun", "Cambria", "SimHei", "Calibri", "Courier New"],
|
8
|
+
html: ["SimSun", "Cambria", "SimHei", "Calibri", "Courier New"],
|
9
|
+
doc: ["SimSun", "Cambria", "SimHei", "Calibri", "Courier New"],
|
10
|
+
pdf: ["SimSun", "Cambria", "SimHei", "Calibri", "Courier New"],
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
5
14
|
class Processor < Metanorma::Processor
|
6
15
|
|
7
16
|
def initialize
|
@@ -14,7 +23,8 @@ module Metanorma
|
|
14
23
|
super.merge(
|
15
24
|
html: "html",
|
16
25
|
compliant_html: "compliant.html",
|
17
|
-
doc: "doc"
|
26
|
+
doc: "doc",
|
27
|
+
pdf: "pdf",
|
18
28
|
)
|
19
29
|
end
|
20
30
|
|
@@ -49,6 +59,8 @@ module Metanorma
|
|
49
59
|
IsoDoc::Gb::HtmlConvert.new(options.merge(compliant: true)).convert(outname, isodoc_node)
|
50
60
|
when :doc
|
51
61
|
IsoDoc::Gb::WordConvert.new(options).convert(outname, isodoc_node)
|
62
|
+
when :doc
|
63
|
+
IsoDoc::Gb::PdfConvert.new(options).convert(outname, isodoc_node)
|
52
64
|
else
|
53
65
|
super
|
54
66
|
end
|
data/lib/metanorma/gb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-gb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.27
|
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-
|
11
|
+
date: 2020-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: metanorma-iso
|
@@ -255,12 +255,14 @@ files:
|
|
255
255
|
- lib/asciidoctor/gb/boilerplate.xml
|
256
256
|
- lib/asciidoctor/gb/converter.rb
|
257
257
|
- lib/asciidoctor/gb/front.rb
|
258
|
+
- lib/asciidoctor/gb/front_id.rb
|
258
259
|
- lib/asciidoctor/gb/gbstandard.rng
|
259
260
|
- lib/asciidoctor/gb/isodoc.rng
|
260
261
|
- lib/asciidoctor/gb/isostandard.rng
|
261
262
|
- lib/asciidoctor/gb/reqt.rng
|
262
263
|
- lib/asciidoctor/gb/section_input.rb
|
263
264
|
- lib/asciidoctor/gb/validate.rb
|
265
|
+
- lib/isodoc/gb/gb.recommendation.xsl
|
264
266
|
- lib/isodoc/gb/gbbaseconvert.rb
|
265
267
|
- lib/isodoc/gb/gbcleanup.rb
|
266
268
|
- lib/isodoc/gb/gbconvert.rb
|
@@ -305,6 +307,7 @@ files:
|
|
305
307
|
- lib/isodoc/gb/i18n-en.yaml
|
306
308
|
- lib/isodoc/gb/i18n-zh-Hans.yaml
|
307
309
|
- lib/isodoc/gb/metadata.rb
|
310
|
+
- lib/isodoc/gb/pdf_convert.rb
|
308
311
|
- lib/metanorma-gb.rb
|
309
312
|
- lib/metanorma/gb.rb
|
310
313
|
- lib/metanorma/gb/processor.rb
|