asciidoctor-gb 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05fd934d04e964153dbc4a60fc64478b96b286c42ba80c0b154ab821db11e5de
4
- data.tar.gz: f05e4828dfe59146657900740535bcd98807536be0fd69c158672d40450af2f9
3
+ metadata.gz: a3e9ad8796eb1e2a3ffe4403f9d6b4b936b06bd831796ab37d8286b7e2f94607
4
+ data.tar.gz: 5dd921064ac73351c6650ad15b4ff5e49c716935e2e14d8243f10c05dbdc7169
5
5
  SHA512:
6
- metadata.gz: d2550d7415566a3068d99b8bc2116d6ce36b67917e5656d5b6492e9ffccc55d1b72c7b1f8bf616c26c31685afb65ab2d9c3d72a0f3397ac0e22f9a6f0ef8fa27
7
- data.tar.gz: c3de41e9727717bf657c38b200b447b2b395310aacf79012341a1a72b14c5d4764ab4b1fd5dd7c5b58a17a36c2c78bac4e6826e1fb2c108b596939ad117a838e
6
+ metadata.gz: 8c2afec17c99a8dad6e68837d20504b17ff62348853bf23c3c08d3954c7bd288049df0911ce98fd0efb36953c0f1fcf66305edb8c25e12d557b3c69741239bdb
7
+ data.tar.gz: c2bc4e33529e45741d06a98ce7cd34550cf82a79b86d848c5f33b9a6d34712ca681f535b2819be310ba5f5b7346f86d6195b906f2c40d1e2a3b3ec6dae6b79ce
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ coverage/
2
+ .byebug_history
3
+ .rspec_status
4
+ .tmp.xml
5
+ gb-issuer-default.gif
6
+ gb.css
7
+ htmlstyle.css
8
+ test.html
9
+ test.xml
data/Gemfile.lock CHANGED
@@ -3,6 +3,7 @@ PATH
3
3
  specs:
4
4
  asciidoctor-gb (0.3.0)
5
5
  asciidoctor-iso (>= 0.9.0)
6
+ gbbib
6
7
  isodoc (>= 0.8.0)
7
8
  twitter_cldr
8
9
 
@@ -13,17 +14,66 @@ GEM
13
14
  httpclient (~> 2.8, >= 2.8.3)
14
15
  json (>= 1.5.1)
15
16
  asciidoctor (1.5.7.1)
16
- asciidoctor-iso (0.9.0)
17
+ asciidoctor-csand (0.3.0)
18
+ asciidoctor (~> 1.5.7)
19
+ asciidoctor-iso (>= 0.9.0)
20
+ asciimath
21
+ htmlentities (~> 4.3.4)
22
+ image_size
23
+ isodoc (>= 0.8.0)
24
+ mime-types
25
+ nokogiri
26
+ ruby-jing
27
+ ruby-xslt
28
+ thread_safe
29
+ uuidtools
30
+ asciidoctor-csd (0.4.0)
31
+ asciidoctor-iso (>= 0.9.0)
32
+ isodoc (>= 0.8.0)
33
+ asciidoctor-iso (0.9.1)
17
34
  asciidoctor (~> 1.5.7)
18
35
  iso-bib-item (~> 0.1.6)
19
36
  isobib (~> 0.1.6)
20
37
  isodoc (>= 0.8)
21
38
  ruby-jing
39
+ asciidoctor-m3d (0.3.1)
40
+ asciidoctor (~> 1.5.7)
41
+ asciidoctor-iso (>= 0.9.0)
42
+ asciimath
43
+ htmlentities (~> 4.3.4)
44
+ image_size
45
+ isodoc (>= 0.8.0)
46
+ mime-types
47
+ nokogiri
48
+ ruby-jing
49
+ ruby-xslt
50
+ thread_safe
51
+ uuidtools
52
+ asciidoctor-rfc (0.9.0)
53
+ asciidoctor (~> 1.5.7)
54
+ htmlentities (~> 4.3.4)
55
+ nokogiri
56
+ ruby-jing
57
+ thread_safe
58
+ asciidoctor-rsd (0.3.1)
59
+ asciidoctor (~> 1.5.7)
60
+ asciidoctor-iso (>= 0.8.0)
61
+ asciimath
62
+ htmlentities (~> 4.3.4)
63
+ image_size
64
+ isodoc (>= 0.7.0)
65
+ mime-types
66
+ nokogiri
67
+ ruby-jing
68
+ ruby-xslt
69
+ thread_safe
70
+ uuidtools
22
71
  asciimath (1.0.4)
23
72
  ast (2.4.0)
24
73
  byebug (9.1.0)
25
74
  camertron-eprun (1.1.1)
26
75
  cldr-plurals-runtime-rb (1.0.1)
76
+ cnccs (0.1.1)
27
77
  coderay (1.1.2)
28
78
  diff-lcs (1.3)
29
79
  docile (1.3.1)
@@ -32,6 +82,9 @@ GEM
32
82
  nokogiri (>= 1.4.3)
33
83
  ffi (1.9.25)
34
84
  formatador (0.2.5)
85
+ gbbib (0.1.2)
86
+ cnccs
87
+ iso-bib-item
35
88
  guard (2.14.2)
36
89
  formatador (>= 0.2.4)
37
90
  listen (>= 2.7, < 4.0)
@@ -58,11 +111,11 @@ GEM
58
111
  htmlentities (4.3.4)
59
112
  httpclient (2.8.3)
60
113
  image_size (2.0.0)
61
- iso-bib-item (0.1.6)
114
+ iso-bib-item (0.1.8)
62
115
  duplicate
63
116
  isoics (~> 0.1.6)
64
117
  nokogiri
65
- isobib (0.1.6)
118
+ isobib (0.1.7)
66
119
  algoliasearch
67
120
  iso-bib-item (~> 0.1.2)
68
121
  isodoc (0.8)
@@ -87,6 +140,15 @@ GEM
87
140
  rb-inotify (~> 0.9, >= 0.9.7)
88
141
  ruby_dep (~> 1.2)
89
142
  lumberjack (1.0.13)
143
+ metanorma (0.2.3)
144
+ asciidoctor-csand (>= 0.3.0)
145
+ asciidoctor-csd (>= 0.4.0)
146
+ asciidoctor-gb (>= 0.3.0)
147
+ asciidoctor-iso (>= 0.9.1)
148
+ asciidoctor-m3d (>= 0.3.1)
149
+ asciidoctor-rfc (>= 0.9.0)
150
+ asciidoctor-rsd (>= 0.3.0)
151
+ isodoc (>= 0.8.0)
90
152
  method_source (0.9.0)
91
153
  mime-types (3.1)
92
154
  mime-types-data (~> 3.2015)
@@ -171,6 +233,7 @@ DEPENDENCIES
171
233
  equivalent-xml (~> 0.6)
172
234
  guard (~> 2.14)
173
235
  guard-rspec (~> 4.7)
236
+ metanorma
174
237
  rake (~> 12.0)
175
238
  rspec (~> 3.6)
176
239
  rubocop (~> 0.50)
data/README.adoc CHANGED
@@ -4,7 +4,9 @@ image:https://img.shields.io/gem/v/asciidoctor-gb.svg["Gem Version", link="https
4
4
  image:https://img.shields.io/travis/riboseinc/asciidoctor-gb/master.svg["Build Status", link="https://travis-ci.org/riboseinc/asciidoctor-gb"]
5
5
  image:https://codeclimate.com/github/riboseinc/asciidoctor-gb/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/riboseinc/asciidoctor-gb"]
6
6
 
7
- Ruby gem for generating
7
+ == Functionality
8
+
9
+ This gem generates
8
10
  https://en.wikipedia.org/wiki/Guobiao_standards[Guibiao standards]
9
11
  (Chinese national standards), using AsciiDoc.
10
12
 
@@ -24,10 +26,65 @@ The gem can also be used to generate Chinese local or sector standards, which
24
26
  have the same format; the gem formats the title page to have the correct
25
27
  metadata displayed.
26
28
 
27
- The gem generates Word and HTML output. The Word output of the gem is strictly
29
+ The following outputs are generated.
30
+ * (Optional) An HTML preview generated directly from the Asciidoctor document,
31
+ using native Asciidoc formatting.
32
+ ** http://asciimath.org[AsciiMathML] is to be used for mathematical formatting.
33
+ The gem uses the https://github.com/asciidoctor/asciimath[Ruby AsciiMath parser],
34
+ which is syntactically stricter than the common MathJax processor;
35
+ if you do not get expected results, try bracketting terms your in AsciiMathML
36
+ expressions.
37
+ * an XML representation of the document, intended as a document model for GB
38
+ International Standards.
39
+ * The XML representation is processed in turn to generate the following outputs
40
+ as end deliverable GB standard drafts.
41
+ ** HTML
42
+ ** Word
43
+
44
+ The Word output of the gem is strictly
28
45
  aligned to the GB/T 1.1 specification, including the fonts and font sizes
29
46
  prescribed, and the measurements for element positioning on the page.
30
47
 
48
+ == Usage
49
+
50
+ The preferred way to invoke this gem is via the `metanorma` script:
51
+
52
+ [source,console]
53
+ ----
54
+ $ metanorma --type gb a.adoc # output HTML and DOC
55
+ $ metanorma --type gb --extensions html a.adoc # output just HTML
56
+ $ metanorma --type gb --extensions doc a.adoc # output just DOC
57
+ $ metanorma --type gb --extensions xml a.adoc # output GB XML
58
+ ----
59
+
60
+ The gem translates the document into GB XML format, and then
61
+ validates its output against the GB XML document model; errors are
62
+ reported to console against the XML, and are intended for users to
63
+ check that they have provided all necessary components of the
64
+ document.
65
+
66
+ The gem then converts the XML into HTML and DOC.
67
+
68
+ The gem can also be invoked directly within asciidoctor, though this is deprecated:
69
+
70
+ [source,console]
71
+ ----
72
+ $ asciidoctor -b gb -r 'asciidoctor-gb' a.adoc
73
+ ----
74
+
75
+ === Installation
76
+
77
+ If you are using a Mac, the https://github.com/riboseinc/metanorma-macos-setup
78
+ repository has instructions on setting up your machine to run Metanorma
79
+ scripts such as this one. You need only run the following in a Terminal console:
80
+
81
+ [source,console]
82
+ ----
83
+ $ bash <(curl -s https://raw.githubusercontent.com/riboseinc/metanorma-macos-setup/master/metanorma-setup)
84
+ $ gem install asciidoctor-gb
85
+ ----
86
+
87
+
31
88
  == Differences from `asciidoctor-iso`
32
89
 
33
90
  === Document Attributes
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.require_paths = ["lib"]
28
28
 
29
29
  spec.add_dependency "asciidoctor-iso", ">= 0.9.0"
30
+ spec.add_dependency "gbbib"
30
31
  spec.add_dependency "isodoc", ">= 0.8.0"
31
32
  spec.add_dependency "twitter_cldr"
32
33
 
@@ -40,4 +41,5 @@ Gem::Specification.new do |spec|
40
41
  spec.add_development_dependency "rubocop", "~> 0.50"
41
42
  spec.add_development_dependency "simplecov", "~> 0.15"
42
43
  spec.add_development_dependency "timecop", "~> 0.9"
44
+ spec.add_development_dependency "metanorma"
43
45
  end
@@ -7,6 +7,7 @@ require_relative "./section_input.rb"
7
7
  require_relative "./front.rb"
8
8
  require_relative "./validate.rb"
9
9
  require "pp"
10
+ require "byebug"
10
11
 
11
12
  module Asciidoctor
12
13
  module Gb
@@ -186,19 +187,29 @@ module Asciidoctor
186
187
  end
187
188
 
188
189
  def cleanup(xmldoc)
190
+ lang = xmldoc.at("//language")&.text
191
+ @agencyclass = IsoDoc::Gb::Agencies.new(lang, {}, "")
189
192
  super
190
193
  contributor_cleanup(xmldoc)
191
194
  xmldoc
192
195
  end
193
196
 
197
+ def docidentifier_cleanup(xmldoc)
198
+ #byebug
199
+ id = xmldoc.at("//bibdata/docidentifier/project-number") or return
200
+ scope = xmldoc.at("//gbscope")&.text
201
+ prefix = xmldoc.at("//gbprefix")&.text
202
+ mandate = xmldoc.at("//gbmandate")&.text || "mandatory"
203
+ idtext = @agencyclass.docidentifier(scope, prefix, mandate, nil, id.text) || return
204
+ id.content = idtext.gsub(/\&#x2002;/, " ")
205
+ end
206
+
194
207
  def contributor_cleanup(xmldoc)
195
208
  issuer = xmldoc.at("//bibdata/contributor[role/@type = 'issuer']/organization/name")
196
209
  scope = xmldoc.at("//gbscope")&.text
197
210
  prefix = xmldoc.at("//gbprefix")&.text
198
211
  mandate = xmldoc.at("//gbmandate")&.text || "mandatory"
199
- lang = xmldoc.at("//language")&.text
200
212
  agency = issuer.content
201
- @agencyclass = IsoDoc::Gb::Agencies.new(lang, {}, "")
202
213
  agency = @agencyclass.standard_agency1(scope, prefix, mandate) if agency == "GB"
203
214
  agency = "GB" if agency.nil? || agency.empty?
204
215
  owner = xmldoc.at("//copyright/owner/organization/name")
@@ -1,3 +1,4 @@
1
+
1
2
  module Asciidoctor
2
3
  module Gb
3
4
  class Converter < ISO::Converter
@@ -1,3 +1,5 @@
1
+ require "gbbib"
2
+
1
3
  module Asciidoctor
2
4
  module Gb
3
5
 
@@ -55,6 +57,30 @@ module Asciidoctor
55
57
  end.join("\n")
56
58
  end
57
59
 
60
+ # @param xml [Nokogiri::XML::Builder]
61
+ # @param code [String]
62
+ #def fetch_ref(xml, code, _year, **opts)
63
+ #warn "fetching #{code}..."
64
+ #result = Gbbib::GbBibliography.search code
65
+ #hit = result.first
66
+ #if hit&.title&.match(%r{^[^\s]+\s[\d-]+}).to_s == code
67
+ ## hit.fetch.to_xml xml, opts
68
+ #xml.parent.add_child hit.fetch.to_xml(xml, opts)
69
+ #xml
70
+ #end
71
+ #end
72
+
73
+ #def fetch_ref1(code, year, opts)
74
+ #id = iso_id(code, year, opts[:all_parts])
75
+ #return nil if @bibdb.nil? # signals we will not be using isobib
76
+ #@bibdb[id] = Isobib::IsoBibliography.get(code, year, opts) unless @bibdb[id]
77
+ #@local_bibdb[id] = @bibdb[id] if !@local_bibdb.nil? &&
78
+ #!@local_bibdb[id]
79
+ #return @local_bibdb[id] unless @local_bibdb.nil?
80
+ #@bibdb[id]
81
+ #end
82
+
83
+
58
84
  =begin
59
85
  # spec of permissible section sequence
60
86
  SEQ = [
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Gb
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.1"
4
4
  end
5
5
  end
@@ -315,6 +315,27 @@ module IsoDoc
315
315
  end
316
316
  end
317
317
 
318
+ SCOPEPFX = {
319
+ :local => "DB",
320
+ "social-group".to_sym => "T",
321
+ :enterprise => "Q",
322
+ }.freeze
323
+
324
+ def docidentifier(scope, prefix, mandate, docyear, docnum)
325
+ dn = case scope
326
+ when "local"
327
+ "#{SCOPEPFX[scope.to_sym]}#{mandate_suffix(prefix, mandate)}/"\
328
+ "#{docnum}".gsub(%r{/([TZ])/}, "/\\1 ")
329
+ when "social-group", "enterprise"
330
+ "#{mandate_suffix(SCOPEPFX[scope.to_sym], mandate)}/"\
331
+ "#{prefix} #{docnum}"
332
+ else
333
+ "#{mandate_suffix(prefix, mandate)}&#x2002;#{docnum}"
334
+ end
335
+ dn += "&mdash;#{docyear}" if docyear
336
+ dn
337
+ end
338
+
318
339
  def gbtype_validate(root)
319
340
  scope = root.at("//gbscope")&.text
320
341
  prefix = root.at("//gbprefix")&.text
@@ -128,28 +128,6 @@ module IsoDoc
128
128
  end
129
129
  end
130
130
 
131
- SCOPEPFX = {
132
- :local => "DB",
133
- "social-group".to_sym => "T",
134
- :enterprise => "Q",
135
- }.freeze
136
-
137
- def docidentifier(scope, prefix, mandate, docyear)
138
- docnum = get[:docnumber]
139
- dn = case scope
140
- when "local"
141
- "#{SCOPEPFX[scope.to_sym]}#{@agencies.mandate_suffix(prefix, mandate)}/"\
142
- "#{docnum}".gsub(%r{/([TZ])/}, "/\\1 ")
143
- when "social-group", "enterprise"
144
- "#{@agencies.mandate_suffix(SCOPEPFX[scope.to_sym], mandate)}/"\
145
- "#{prefix} #{docnum}"
146
- else
147
- "#{@agencies.mandate_suffix(prefix, mandate)}&#x2002;#{docnum}"
148
- end
149
- dn += "&mdash;#{docyear}" if docyear
150
- set(:docidentifier, dn)
151
- end
152
-
153
131
  def gb_identifier(isoxml)
154
132
  scope = isoxml.at(ns("//gbscope"))&.text || "national"
155
133
  mandate = isoxml.at(ns("//gbmandate"))&.text || "mandatory"
@@ -158,7 +136,7 @@ module IsoDoc
158
136
  issuer = isoxml&.at(ns("//bibdata/contributor[role/@type = 'issuer']/"\
159
137
  "organization/name"))&.text || "GB"
160
138
  @agencies = Agencies.new(@lang, @labels, issuer)
161
- docidentifier(scope, prefix, mandate, docyear)
139
+ set(:docidentifier, @agencies.docidentifier(scope, prefix, mandate, docyear, get[:docnumber]))
162
140
  set(:issuer, issuer)
163
141
  set(:standard_class, @agencies.standard_class(scope, prefix, mandate))
164
142
  set(:standard_agency, @agencies.standard_agency(scope, prefix, mandate))
@@ -17,6 +17,10 @@ module Metanorma
17
17
  }
18
18
  end
19
19
 
20
+ def version
21
+ "Asciidoctor::Gb #{Asciidoctor::Gb::VERSION}"
22
+ end
23
+
20
24
  def input_to_isodoc(file)
21
25
  Metanorma::Input::Asciidoc.new.process(file, @asciidoctor_backend)
22
26
  end
@@ -32,4 +36,4 @@ module Metanorma
32
36
 
33
37
  end
34
38
  end
35
- end
39
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-gb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-20 00:00:00.000000000 Z
11
+ date: 2018-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor-iso
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.9.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: gbbib
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: isodoc
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +206,20 @@ dependencies:
192
206
  - - "~>"
193
207
  - !ruby/object:Gem::Version
194
208
  version: '0.9'
209
+ - !ruby/object:Gem::Dependency
210
+ name: metanorma
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
195
223
  description: |
196
224
  asciidoctor-gb lets you write GB standards (Chinese national standards)
197
225
  in AsciiDoc syntax.
@@ -203,6 +231,7 @@ executables: []
203
231
  extensions: []
204
232
  extra_rdoc_files: []
205
233
  files:
234
+ - ".gitignore"
206
235
  - ".hound.yml"
207
236
  - ".oss-guides.rubocop.yml"
208
237
  - ".rubocop.ribose.yml"
@@ -327,7 +356,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
327
356
  version: '0'
328
357
  requirements: []
329
358
  rubyforge_project:
330
- rubygems_version: 2.7.7
359
+ rubygems_version: 2.7.6
331
360
  signing_key:
332
361
  specification_version: 4
333
362
  summary: asciidoctor-gb lets you write GB standards in AsciiDoc.