asciidoctor-gb 0.1.5 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.tb.yml +20 -10
  3. data/LICENSE +25 -0
  4. data/README.adoc +262 -34
  5. data/asciidoctor-gb.gemspec +2 -1
  6. data/bin/rspec +18 -0
  7. data/lib/asciidoctor/gb/biblio.rng +602 -0
  8. data/lib/asciidoctor/gb/converter.rb +104 -70
  9. data/lib/asciidoctor/gb/front.rb +109 -61
  10. data/lib/asciidoctor/gb/gbstandard.rng +135 -31
  11. data/lib/asciidoctor/gb/html/gb-logos/gb-issuer-default.gif +0 -0
  12. data/lib/asciidoctor/gb/html/gb-logos/gb-issuer-default.png +0 -0
  13. data/lib/asciidoctor/gb/html/gb-logos/gb-issuer-default.svg +980 -0
  14. data/lib/asciidoctor/gb/html/{gb.css → gb.scss} +133 -219
  15. data/lib/asciidoctor/gb/html/html_gb_intro.html +1 -37
  16. data/lib/asciidoctor/gb/html/html_gb_titlepage.html +6 -5
  17. data/lib/asciidoctor/gb/html/{htmlstyle.css → htmlstyle.scss} +85 -3
  18. data/lib/asciidoctor/gb/html/word_gb_intro.html +1 -1
  19. data/lib/asciidoctor/gb/html/word_gb_titlepage.html +320 -166
  20. data/lib/asciidoctor/gb/html/{wordstyle.css → wordstyle.scss} +605 -429
  21. data/lib/asciidoctor/gb/isodoc.rng +36 -564
  22. data/lib/asciidoctor/gb/isostandard.rng +198 -91
  23. data/lib/asciidoctor/gb/section_input.rb +21 -56
  24. data/lib/asciidoctor/gb/validate.rb +115 -0
  25. data/lib/asciidoctor/gb/version.rb +1 -1
  26. data/lib/asciidoctor-gb.rb +2 -1
  27. data/lib/isodoc/gb/agencies.rb +327 -0
  28. data/lib/isodoc/gb/block_output.rb +86 -0
  29. data/lib/isodoc/gb/gbcleanup.rb +87 -0
  30. data/lib/isodoc/gb/gbconvert.rb +153 -0
  31. data/lib/isodoc/gb/gbwordconvert.rb +89 -0
  32. data/lib/isodoc/gb/html/blank.png +0 -0
  33. data/lib/isodoc/gb/html/footer.png +0 -0
  34. data/lib/isodoc/gb/html/gb-logos/gb-issuer-default.gif +0 -0
  35. data/lib/isodoc/gb/html/gb-logos/gb-issuer-default.png +0 -0
  36. data/lib/isodoc/gb/html/gb-logos/gb-issuer-default.svg +980 -0
  37. data/lib/isodoc/gb/html/gb-logos/gb-standard-db.gif +0 -0
  38. data/lib/isodoc/gb/html/gb-logos/gb-standard-db.png +0 -0
  39. data/lib/isodoc/gb/html/gb-logos/gb-standard-db.svg +1 -0
  40. data/lib/isodoc/gb/html/gb-logos/gb-standard-gb.gif +0 -0
  41. data/lib/isodoc/gb/html/gb-logos/gb-standard-gb.png +0 -0
  42. data/lib/isodoc/gb/html/gb-logos/gb-standard-gb.svg +1 -0
  43. data/lib/isodoc/gb/html/gb-logos/gb-standard-gjb.gif +0 -0
  44. data/lib/isodoc/gb/html/gb-logos/gb-standard-gjb.png +0 -0
  45. data/lib/isodoc/gb/html/gb-logos/gb-standard-gjb.svg +1 -0
  46. data/lib/isodoc/gb/html/gb-logos/gb-standard-gm.gif +0 -0
  47. data/lib/isodoc/gb/html/gb-logos/gb-standard-gm.png +0 -0
  48. data/lib/isodoc/gb/html/gb-logos/gb-standard-gm.svg +1 -0
  49. data/lib/isodoc/gb/html/gb-logos/gb-standard-jjf.gif +0 -0
  50. data/lib/isodoc/gb/html/gb-logos/gb-standard-jjf.png +0 -0
  51. data/lib/isodoc/gb/html/gb-logos/gb-standard-jjf.svg +1 -0
  52. data/lib/isodoc/gb/html/gb-logos/gb-standard-zb.gif +0 -0
  53. data/lib/isodoc/gb/html/gb-logos/gb-standard-zb.png +0 -0
  54. data/lib/isodoc/gb/html/gb-logos/gb-standard-zb.svg +13 -0
  55. data/lib/isodoc/gb/html/gb.scss +556 -0
  56. data/lib/isodoc/gb/html/header.html +216 -0
  57. data/lib/isodoc/gb/html/html_gb_intro.html +9 -0
  58. data/lib/isodoc/gb/html/html_gb_titlepage.html +99 -0
  59. data/lib/isodoc/gb/html/htmlstyle.scss +269 -0
  60. data/lib/isodoc/gb/html/logo.png +0 -0
  61. data/lib/isodoc/gb/html/scripts.html +71 -0
  62. data/lib/isodoc/gb/html/word_gb_intro.html +3 -0
  63. data/lib/isodoc/gb/html/word_gb_titlepage.html +388 -0
  64. data/lib/isodoc/gb/html/wordstyle.scss +2543 -0
  65. data/lib/isodoc/gb/i18n-en.yaml +12 -0
  66. data/lib/isodoc/gb/i18n-zh-Hans.yaml +12 -0
  67. data/lib/isodoc/gb/i18n.rb +20 -0
  68. data/lib/isodoc/gb/metadata.rb +216 -0
  69. data/lib/{asciidoctor → isodoc}/gb/section_output.rb +22 -4
  70. data/lib/isodoc/gb/xref_gen.rb +17 -0
  71. metadata +75 -15
  72. data/lib/asciidoctor/gb/agencies.rb +0 -186
  73. data/lib/asciidoctor/gb/gbconvert.rb +0 -86
  74. data/lib/asciidoctor/gb/metadata.rb +0 -186
  75. data/lib/asciidoctor/gb/xref_gen.rb +0 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e74c10bb5c5ef4dcbb40fa28b9a2b95315ef490
4
- data.tar.gz: d4e2cf404084836479de5227a6edc20386a7d3cf
3
+ metadata.gz: dde71ee22c7d9f57a034fff500279cd20f9f63f4
4
+ data.tar.gz: 8bec67da431dc355fe300e148d5aad1671ade332
5
5
  SHA512:
6
- metadata.gz: d7b096f300072f93091ad9c45f4a2f1c89aa899f2fcedc8a66dc360c2d2312f3aae30bfabcea163106afa885efd1eb2af3e6aade90d13cff629b34a570b2ae52
7
- data.tar.gz: f94152cb53559addd5c825a53cec42470969457543b4cb0f1257d3138bc0193bf076663aa50065e3da8db7e9153577b89abe9f1e92448e0d96a0237a9e497957
6
+ metadata.gz: ec348da462b2dee6d45ecbcdf4511d4b8d1af91d30488d68ab844859b16c7c0fc8260ca49c7d31367a5bbfb3de9fa649e999b302a58d8f7e12e510caa1c7751e
7
+ data.tar.gz: ed293d2f15a9fb3bf81d73df1385f01e0836c05d8f6e9c54e85b1f29fc44865a63a3eabb244a0054a55f89511cb0e41b07a42084880b5af6a2408e762ff5e007
data/.rubocop.tb.yml CHANGED
@@ -352,8 +352,18 @@ Style/TrailingCommaInArguments:
352
352
  - no_comma
353
353
  Enabled: true
354
354
 
355
- Style/TrailingCommaInLiteral:
356
- Description: 'Checks for trailing comma in array and hash literals.'
355
+ Style/TrailingCommaInArrayLiteral:
356
+ Description: 'Checks for trailing comma in array literals.'
357
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
358
+ EnforcedStyleForMultiline: comma
359
+ SupportedStylesForMultiline:
360
+ - comma
361
+ - consistent_comma
362
+ - no_comma
363
+ Enabled: true
364
+
365
+ Style/TrailingCommaInHashLiteral:
366
+ Description: 'Checks for trailing comma in hash literals.'
357
367
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
358
368
  EnforcedStyleForMultiline: comma
359
369
  SupportedStylesForMultiline:
@@ -398,6 +408,13 @@ Layout/AlignParameters:
398
408
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-double-indent'
399
409
  Enabled: false
400
410
 
411
+ Layout/ConditionPosition:
412
+ Description: >-
413
+ Checks for condition placed in a confusing position relative to
414
+ the keyword.
415
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#same-line-condition'
416
+ Enabled: false
417
+
401
418
  Layout/DotPosition:
402
419
  Description: 'Checks the position of the dot in multi-line method calls.'
403
420
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains'
@@ -450,13 +467,6 @@ Lint/CircularArgumentReference:
450
467
  Description: "Don't refer to the keyword argument in the default value."
451
468
  Enabled: false
452
469
 
453
- Lint/ConditionPosition:
454
- Description: >-
455
- Checks for condition placed in a confusing position relative to
456
- the keyword.
457
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#same-line-condition'
458
- Enabled: false
459
-
460
470
  Lint/DeprecatedClassMethods:
461
471
  Description: 'Check for deprecated class method calls.'
462
472
  Enabled: false
@@ -523,7 +533,7 @@ Lint/UnderscorePrefixedVariableName:
523
533
  Description: 'Do not use prefix `_` for a variable that is used.'
524
534
  Enabled: false
525
535
 
526
- Lint/UnneededDisable:
536
+ Lint/UnneededCopDisableDirective:
527
537
  Description: >-
528
538
  Checks for rubocop:disable comments that can be removed.
529
539
  Note: this cop is not disabled when disabling all cops.
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ BSD 2-Clause License
2
+
3
+ Copyright (c) 2018, Ribose
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.adoc CHANGED
@@ -1,45 +1,157 @@
1
- = asciidoctor-gb
1
+ = asciidoctor-gb: Authoring Chinese standards (GuoBiao, sector...) in AsciiDoc
2
2
 
3
3
  image:https://img.shields.io/gem/v/asciidoctor-gb.svg["Gem Version", link="https://rubygems.org/gems/asciidoctor-gb"]
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
- Gem for generating https://en.wikipedia.org/wiki/Guobiao_standards[Guibiao standards]
8
- (Chinese national standards), using Asciidoc. This gem inherits from
9
- https://github.com/riboseinc/asciidoctor-iso, a gem used to generate ISO standards
10
- using Asciidoc. The two standards formats are closely aligned. Refer to the ISO gem
11
- for guidance, including https://github.com/riboseinc/asciidoctor-iso/wiki/Guidance-for-authoring
7
+ Ruby gem for generating
8
+ https://en.wikipedia.org/wiki/Guobiao_standards[Guibiao standards]
9
+ (Chinese national standards), using AsciiDoc.
12
10
 
13
- The Gem can also be used to generate Chinese local or sector standards, which have the
14
- same format; the gem formats the title page to have the correct metadata displayed.
11
+ This gem implements the https://github.com/riboseinc/gbdoc[GbDoc] data model,
12
+ which inherits from
13
+ https://github.com/riboseinc/isodoc-models[IsoDoc and StandardDocument].
15
14
 
16
- == Differences from asciidoctor-iso
15
+ The code of this gem inherits from
16
+ https://github.com/riboseinc/asciidoctor-iso[asciidoctor-iso], a gem used to
17
+ generate ISO standards using Asciidoc.
18
+
19
+ The two standards formats are closely aligned. Refer to the ISO gem
20
+ for guidance, including
21
+ https://github.com/riboseinc/asciidoctor-iso/wiki/Guidance-for-authoring[IsoDoc: Guidance for authoring]
22
+
23
+ The gem can also be used to generate Chinese local or sector standards, which
24
+ have the same format; the gem formats the title page to have the correct
25
+ metadata displayed.
26
+
27
+ The gem generates Word and HTML output. The Word output of the gem is strictly
28
+ aligned to the GB/T 1.1 specification, including the fonts and font sizes
29
+ prescribed, and the measurements for element positioning on the page.
30
+
31
+ == Differences from `asciidoctor-iso`
17
32
 
18
33
  === Document Attributes
19
34
 
20
- In the following, "GB standard" should be read to refer to any Chinese national, sector or local standard. Asterisked document attributes are mandatory.
21
-
22
- `:title-intro-zh:`, `:title-main-zh:`*, `:title-part-zh:`:: These are the title introduction, main title, and part title in Chinese. (They replace their French counterparts in asciidoctor-iso.)
23
- `:title-intro-en:`, `:title-main-en:`*, `:title-part-en:`:: These are the title introduction, main title, and part title in English. (They form the document subtitle, instead of the document title as in asciidoctor-iso.)
24
- `:technical-committee-type:`:: The type of the technical committee (`technical` or `provisional`).
25
- `:iso-standard`: A corresponding ISO standard that the GB standard relates to. Format is full document code, then optionally comma followed by document title; e.g. `ISO/IEC 27001:2013, Information security management systems`
26
- `:equivalence:`:: The relation of the GB standard to the corresponding ISO standard (`equivalent`, `identical`, `nonequivalent`). Defaults to `equivalent`.
27
- `:obsoletes`:: A corresponding GB standard that this GB standard obsoletes. Format is full document code, then optionally comma followed by document title; e.g. `GB/T 22080-2008`
28
- `:obsoletes-parts:`: A list of bibliographic localities in the corresponding GB standard that this GB standard obsoletes. These are formatted the same way as the localities in citations; e.g. `clause 7-9, clause 11`
29
- `:scope:`:: The scope of the GB standard (`national`, `sector`, `professional`, `local`, `enterprise`). Defaults to `national`.
30
- `:mandate:`:: The mandate of the GB standard (`mandatory`, `recommended`, `guidelines`). Defaults to `mandatory`.
31
- `:prefix:*`:: The prefix classifying the GB standard. (Refer to https://github.com/riboseinc/gbdoc/blob/master/models/gb-standard-national-prefix.adoc, https://github.com/riboseinc/gbdoc/blob/master/models/gb-standard-sector-prefix.adoc, https://github.com/riboseinc/gbdoc/blob/master/models/gb-standard-local-prefix.adoc.)
32
- `:published-date:`* :: The date on which the GB standard was published.
33
- `:activated-date:`* :: The date on which the GB standard was activated.
34
- `:library-ics:`* :: The international categorisation number for the GB standard
35
- `:library-l:`* :: The L-identifier (library) for the GB standard
35
+ In the following, "GB standard" should be read to refer to any Chinese
36
+ national, sector or local standard. Asterisked document attributes are
37
+ mandatory.
38
+
39
+ `:title-intro-zh:`, `:title-main-zh:`*, `:title-part-zh:`::
40
+ These are the title introduction, main title, and part title in Chinese.
41
+ The intro and part titles are optional.
42
+ (They replace their French counterparts in
43
+ https://github.com/riboseinc/asciidoctor-iso[asciidoctor-iso].)
44
+
45
+ `:title-intro-en:`, `:title-main-en:`*, `:title-part-en:`::
46
+ These are the title introduction, main title, and part title in English.
47
+ The intro and part titles are optional.
48
+ (They form the document subtitle, instead of the document title as in
49
+ https://github.com/riboseinc/asciidoctor-iso[asciidoctor-iso].)
50
+
51
+ `:technical-committee-type:`::
52
+ The type of the technical committee (`technical` or `provisional`).
53
+
54
+ `:iso-standard:`::
55
+ (optional) A corresponding ISO standard that the GB standard relates to. Format
56
+ is full document code, then optionally comma followed by document title;
57
+ e.g. `ISO/IEC 27001:2013, Information security management systems`
58
+
59
+ `:equivalence:`::
60
+ (optional, only valid if there is a corresponding `:iso-standard:`)
61
+ The relation of the GB standard to the corresponding ISO standard
62
+ (`equivalent`, `identical`, `nonequivalent`). Defaults to `equivalent`.
63
+
64
+ `:obsoletes:`::
65
+ (optional)
66
+ A corresponding GB standard that this GB standard obsoletes. Format is full
67
+ document code, then optionally comma followed by document title;
68
+ e.g. `GB/T 22080-2008`
69
+
70
+ `:obsoletes-parts:`::
71
+ A list of bibliographic localities in the corresponding GB standard that this
72
+ GB standard obsoletes. These are formatted the same way as the localities in
73
+ citations; e.g. `clause 7-9, clause 11`
74
+
75
+ `:scope:`::
76
+ The scope of the GB standard (`national`, `sector`, `professional`, `local`,
77
+ `enterprise`). Defaults to `national`.
78
+
79
+ `:mandate:`::
80
+ The mandate of the GB standard (`mandatory`, `recommended`, `guidelines`).
81
+ Defaults to `mandatory`.
82
+
83
+ `:topic:`::
84
+ The topic of the GB standard (`basic`, `health-and-safety`, `environment-protection`, `engineering-and-construction`, `product`, `method`, `management-techniques`, `other`). Defaults to `basic`.
85
+
86
+ `:prefix:`::
87
+ The prefix classifying the GB standard.
88
+ (Refer to
89
+ https://github.com/riboseinc/gbdoc/blob/master/models/gb-standard-national-prefix.adoc[GB National Standard Prefixes],
90
+ https://github.com/riboseinc/gbdoc/blob/master/models/gb-standard-sector-prefix.adoc[GB Sector Standard Prefixes],
91
+ https://github.com/riboseinc/gbdoc/blob/master/models/gb-standard-local-prefix.adoc[GB Local Standard Prefixes],
92
+ https://github.com/riboseinc/asciidoctor-gb/issues/54[GB Social and Enterprise Standard Prefixes].)
93
+ Any `/Z` or `/T` suffix (indicating "recommended" and "guidelines" mandate) is
94
+ ignored unless the `:mandate:` attribute is not given. Any `Q/` or `T/` prefix for social and enterprise
95
+ standards is ignored unless the `:scope:` attribute is not given.
96
+
97
+ `:issued-date:`::
98
+ The date on which the GB standard was issued (authorised for publication by the issuing authority).
99
+
100
+ `:published-date:`::
101
+ The date on which the GB standard was published (distributed by the publisher).
102
+
103
+ `:implemented-date:`::
104
+ The date on which the GB standard became active.
105
+
106
+ `:created-date:`::
107
+ The date on which the first version of the GB standard was created.
108
+
109
+ `:updated-date:`::
110
+ The date on which the current version of the GB standard was updated.
111
+
112
+ `:obsoleted-date:`::
113
+ The date on which the GB standard was obsoleted/revoked.
114
+
115
+ `:confirmed-date:`::
116
+ The date on which the GB standard was reviewed and approved by the issuing authority.
117
+
118
+ `:library-ics:`::
119
+ The ICS (International Categorization for Standards) number for the GB standard. There may be more than one ICS for a document; if so, they should be comma-delimited. (Unlike the case for ISO, the ICS identifier is output to the front page of the GB standard.)
120
+
121
+ `:library-ccs:`::
122
+ The CCS (Chinese Categorization Scheme) code for the GB standard. See https://github.com/riboseinc/cn-ccs-codes
123
+
124
+ `:plan-number:`::
125
+ The Plan Number (计划单号) for the GB standard.
126
+
127
+ `:issuer:`::
128
+ The issuer of the standard. This is the authority which authors, manages, and issues the standard. For social standards, this is the social group; for enterprise standards, this is the company. The issuer appears on the standard frontispiece. By default, the issuer is inferred from the prefix of the standard; this attribute overrides the value inferred from the prefix. It is required for social and entperprise standards.
129
+
130
+ `:publisher:`::
131
+ The publisher of the standard, which distributes the standard. This is distinct from the issuer, the authority which authors, manages, and issues the standard.
132
+
133
+ `:proposer:`::
134
+ The party which proposed the standard.
135
+
136
+ `:authority:`::
137
+ The authority which sponsored the standard.
138
+
139
+ `:author:`::
140
+ The individuals who drafted the standard.
141
+
142
+ `:author-committee:`::
143
+ The committees which drafted the standard.
144
+
145
+ `:title-font:`::
146
+ The font to use for the standard class and issuer on the (Word) cover page; described in GB/T 1.1 as
147
+ "custom font". If not provided, the font is inferred from the scope of the standard, aligning
148
+ with existing practice: SimSun for national scope, SimHei for all other scopes.
36
149
 
37
150
  === Language macros
38
151
 
39
- In Terms and Definitions, preferred terms, alternate terms and deprecated
40
- terms are expected to be given in both Chinese and English. By default,
41
- the gem does this by detecting space-delimited runs of Han or Latin script
42
- text:
152
+ In Terms and Definitions, preferred terms, alternate terms and deprecated terms
153
+ are expected to be given in both Chinese and English. By default, the gem does
154
+ this by detecting space-delimited runs of Han or Latin script text:
43
155
 
44
156
  [source,asciidoc]
45
157
  --
@@ -54,7 +166,7 @@ alt:[rough rice 糙米]
54
166
  However if there is script mixing in a term -- if the Chinese term contains
55
167
  a Latin script acronym or a mathematical expression, for example -- the
56
168
  Chinese term will not be detected correctly. To address this, the formatting macros
57
- +`[zh]#...#`+ and +`[en]#...#`+ are used. If they are present, then the content
169
+ `+[zh]#...#+` and `+[en]#...#+` are used. If they are present, then the content
58
170
  of those macros is treated as the Chinese and English equivalents of the
59
171
  parent node instead:
60
172
 
@@ -70,8 +182,124 @@ alt:[[en]#rough rice# [zh]#糙米#]
70
182
  <admitted language="zh">糙米</admitted> <admitted language="en">rough rice</admitted>
71
183
  --
72
184
 
73
- Unfortunately no further markup is permitted within the +`[zh]#...#`+ and +`[en]#...#`+
74
- macros by Asciidoctor, and Asciidoctor does not correctly nest inline macros within other
75
- inline macros (so +`alt:[en:[_xyz_] zh:[xyz]`+ would not give correct behaviour either.)
185
+ Unfortunately no further markup is permitted within the `+[zh]#...#+` and
186
+ `+[en]#...#+` macros by Asciidoctor, and Asciidoctor does not correctly nest
187
+ inline macros within other inline macros (so `+alt:[en:[_xyz_] zh:[xyz]+`
188
+ would not give correct behaviour either.)
189
+
190
+ Localisation strings can be used anywhere else in the document where the
191
+ grammar permits localised strings (notably in bibliographic data). For example,
192
+ a bibliographic title can be given in two languages as follows. (Note that formatting appears outside the language macros.)
193
+
194
+ [source,asciidoc]
195
+ --
196
+ [[[ISO7301,ISO 7301:2011]]], _[zh]#大米 - 规格# [en]#Rice -- Specification#_
197
+ --
198
+
199
+ [source,xml]
200
+ --
201
+ <bibitem id="ISO7301" type="standard">
202
+ <title language="zh">大米 - 规格</title> <title language="en">Rice&#x2011;Specification</title>
203
+ <docidentifier>ISO 7301</docidentifier>
204
+ <date type="published">
205
+ <from>2011</from>
206
+ </date>
207
+ <contributor>
208
+ <role type="publisher"/>
209
+ <organization>
210
+ <name>International Organization for Standardization</name>
211
+ <abbreviation>ISO</abbreviation>
212
+ </organization>
213
+ </contributor>
214
+ </bibitem>
215
+ --
216
+
217
+ The gem also supports `+[zh-Hant]#...#+` and `+[zh-Hans]#...#+` to
218
+ differentiate traditional and simplified script in ISOXML; `zh-Hant` is
219
+ provisionally supported through changing font in the output.
220
+
221
+ == Caveats
222
+
223
+ === Microsoft Word
224
+
225
+ The Word output is meticulously aligned to the GB/T 1.1 specification, which is highly
226
+ prescriptive on the positioning of elements on the page. This means that the Word output
227
+ uses http://www.addbalance.com/word/frames_textboxes.htm[frames] and
228
+ https://en.wikipedia.org/wiki/Vector_Markup_Language[VML] extensively, as the best mechanism
229
+ Word HTNL has to ensure precise positioning of elements. However, the use of frames
230
+ makes Word documents more cumbersome to edit; it is envisaged that the bulk of document
231
+ editing should be happening in Asciidoctor, with Word treated as a write-only output format.
232
+
233
+ The use of VML and frames is mostly confined to the cover page, which is the most heavily
234
+ prescribed by GB/T 1.1. However, Word as of 2016 suppresses space before a paragraph
235
+ after a page break (though not a section break--which means that the Foreword, Introduction,
236
+ Document Title, Annex and Bibliography titles would all either lose their mandated initial
237
+ space in Word, or else would all have to be treated as separate sections. For that reason,
238
+ those headings are instead treated by this gem as frames (in-line with their following text),
239
+ which preserve their initial spacing.
240
+
241
+ === GB/T 1.1 Compliance
242
+
243
+ GB/T 1.1-2009 prescribes the format of GB standards meticulously, and is based on ISO/IEC DIR 2-2004
244
+ (though it is not equivalent, and ISO/EIC DIR 2 is less prescriptive about layout).
245
+ GB issued a template program for generating compliant Word documents
246
+ in 2010; this program no longer executes on Windows. (This gem has extracted its stylesheet for
247
+ use in formatting output, but the stylesheet itself had to be modified in places to comply with
248
+ GB/T 1.1.)
249
+
250
+ Compliance of GB standards with GB/T 1.1 has been patchy. This has been exacerbated by the fact that
251
+ ISO/IEC DIR 2 was substantially revised in 2011 and again in 2016. Although GB/T 1.1 has not been
252
+ updated to align with ISO/IEC DIR 2-2016, published GB standards increasingly are formatted according
253
+ to ISO in most areas where ISO and GB now conflict.
254
+
255
+ This gem attempts to align with current best practice of GB standards, and does so in consultation with
256
+ GB. GB/T 19018-2017 has been used as the exemplar standard.
257
+
258
+ The following area the areas where the gem's Word output aligns with or deviates from GB/T 1.1-2009.
259
+
260
+ * https://github.com/riboseinc/asciidoctor-gb/issues/58[Measurements (GB/T 1.1 Annex I.)] The gem
261
+ scrupulously aligns with the measurements prescribed in GB/T, to a greater extent than the 2010
262
+ template tool. As already noted, it makes extensive use of frames to ensure correct vertical positioning
263
+ of headers, and of elements on the cover page.
264
+
265
+ * https://github.com/riboseinc/asciidoctor-gb/issues/56[Fonts (GB/T 1.1 Annex J.)] The gem aligns
266
+ with the fonts and font sizes prescribed in GB/T. (The only exception is the standard name, for which a
267
+ point size of 72 is quite unrealistic: 26pt is used instead, in compliance with the preexisting Word
268
+ template.) For Simplified Chinese script, the gem uses by default SimSun as its "serif" font, and SimHei
269
+ has its "sans-serif" font; this reflects practice in the
270
+ Word templates used for GB. For Latin script, it uses Cambria as its serif font, and Calibri as its
271
+ sans-serif font; this is to minimise disruption moving between scripts. (Note that the stylesheets
272
+ make minimal use of boldface and italics, as these are not well-matched with Chinese typography;
273
+ the sans-serif font occupies the niche that boldface occupies in ISO Latin-script documents.)
274
+ +
275
+ GB/T 1.1 prescribes a "custom font" for the standard class and standard issuer on the cover page.
276
+ By default, this is the serif font for standards with national scope, and the sans-serif font for
277
+ all other scopes. All font selections can be overriden in the document attributes (`:bodyfont:`,
278
+ `:headerfont:`, `:titlefont:`.)`
279
+
280
+ * https://github.com/riboseinc/asciidoctor-gb/issues/57[Layout (GB/T 1.1 Clause 9.)]. The gem complies
281
+ with GB/T 1.1, with the following exceptions where it follows ISO/IEC DIR 2-2016 practice instead:
282
+
283
+ ** 9.3: There are no separate tables of figures, tables of tables, or tables of annexes. Table of Contents
284
+ indentation in the 2010 stylesheet did not comply with GB/T 1.1.
285
+
286
+ ** 9.5.2: Normal references and Bibliography references are indented like normal paragraphs, instead of
287
+ having a hanging indent ("on overflow they should be indented to the top level"); in fact, GB/T 1.1
288
+ does not follow this in its own references list.
289
+
290
+ ** 9.5.3: Terms and Definitions is aligned with ISO/IEC DIR 2: there is provision for alternate and
291
+ deprecated terms, and term sources are notated in brackets whether they are modified or direct citations
292
+ from the source document, instead of being treated as a note in the latter case.
293
+ (https://github.com/riboseinc/asciidoctor-gb/issues/67) Clauses numbers are separated from the term
294
+ source reference by a dash. References to terms defined elsewhere in the Terms and Definitions clause
295
+ are accompanied with clause references.
296
+
297
+ ** 9.9.3: Figure footnotes are not longer treated as footnotes, but are instead merged into the figure
298
+ key, as is done in ISO/IEC DIR 2. Footnote indentation and note indentation in the 2010 stylesheet
299
+ did not comply with GB/T 1.1.
300
+
301
+ ** 9.9.4: Example labels do not appear on a separate line. Examples like notes have a hanging indent,
302
+ so that their content is left-aligned.
76
303
 
77
- The gem also supports +`[zh-Hant]#...#`+ and +`[zh-Hans]#...#`+ to differentiate traditional and simplified script in ISOXML; `zh-Hant` is provisionally supported through changing font in the output.
304
+ ** 9.9.5: Formulas are centered in the page, but are not connected with the formula number with a
305
+ dotted tab.
@@ -31,11 +31,12 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency "htmlentities", "~> 4.3.4"
32
32
  spec.add_dependency "image_size"
33
33
  spec.add_dependency "mime-types"
34
- spec.add_dependency "nokogiri", "~> 1.8.1"
34
+ spec.add_dependency "nokogiri"
35
35
  spec.add_dependency "ruby-jing"
36
36
  spec.add_dependency "ruby-xslt"
37
37
  spec.add_dependency "thread_safe"
38
38
  spec.add_dependency "uuidtools"
39
+ spec.add_dependency "twitter_cldr"
39
40
  spec.add_dependency "asciidoctor-iso"
40
41
  spec.add_dependency "isodoc"
41
42
 
data/bin/rspec ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rspec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require "pathname"
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path(
11
+ "../../Gemfile", Pathname.new(__FILE__).realpath
12
+ )
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rspec-core", "rspec")
18
+