metanorma-standoc 1.0.8 → 1.0.9

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: 224cd7ca429d40a2ab00d82a364e88799f10fe25ab5590a71a80302140dbbc92
4
- data.tar.gz: 51e3067befe646bf8bf072f1b28ea98bd9ffdee0c402e4447eb285df39197cd7
3
+ metadata.gz: 8fdc800133b8aec3e4931bada3fe492a537f19c2807767b5124c8f4e39b3649b
4
+ data.tar.gz: ead7bf5902bd28d515fbade4cf7093e1aa88ef5a22faf179f32dae4f42c6da17
5
5
  SHA512:
6
- metadata.gz: 76fd5c9ba4a47de3cbaca82fbf8fa355dc8b3e00b10fe50cc6482e675e7c49288b85f849d74df33fddb433eddee4554cbeeac6c473119920620bdd956143b4e4
7
- data.tar.gz: 62eefb42214c569b86eaec612a2769c7141686a78e4c2c7c6a62cec6dd819e75db6d856703dedd1b327c90e5ebd2878f74e21ac81af62627a40f417300af4b53
6
+ metadata.gz: 2c51bf19c625ff3822b45ced863b8d27b231789b2d500abe68bc063b1f92be5f4f9b052bba8fc1d656386c336327ee7f08958cffefb36d12c60079a3dde725b1
7
+ data.tar.gz: d22b6b4f30f2cbff1b415190d12ed8c1c2d5a41d25ed5c6da7ed1d2738f5cdaa2dec58d0bb2c210ce2f2682792b4606eb48e6a47bd2f56835fee7c3b3ff2cf3c
data/.rubocop.yml CHANGED
@@ -3,13 +3,8 @@
3
3
  # All project-specific additions and overrides should be specified in this file.
4
4
 
5
5
  inherit_from:
6
- # Thoughtbot's style guide from: https://github.com/thoughtbot/guides
7
- - ".rubocop.tb.yml"
8
- # Overrides from Ribose
9
- - ".rubocop.ribose.yml"
6
+ - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
10
7
  AllCops:
11
- DisplayCopNames: false
12
- StyleGuideCopsOnly: false
13
- TargetRubyVersion: 2.5
8
+ TargetRubyVersion: 2.3
14
9
  Rails:
15
10
  Enabled: true
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metanorma-standoc (1.0.8)
4
+ metanorma-standoc (1.0.9)
5
5
  asciidoctor (~> 1.5.7)
6
6
  iev (~> 0.2.0)
7
7
  isodoc (~> 0.9.0)
@@ -17,7 +17,7 @@ GEM
17
17
  algoliasearch (1.23.2)
18
18
  httpclient (~> 2.8, >= 2.8.3)
19
19
  json (>= 1.5.1)
20
- asciidoctor (1.5.7.1)
20
+ asciidoctor (1.5.8)
21
21
  asciimath (1.0.6)
22
22
  ast (2.4.0)
23
23
  byebug (10.0.2)
@@ -31,7 +31,7 @@ GEM
31
31
  nokogiri (>= 1.4.3)
32
32
  ffi (1.9.25)
33
33
  formatador (0.2.5)
34
- gb-agencies (0.0.3)
34
+ gb-agencies (0.0.5)
35
35
  gbbib (0.4.1)
36
36
  cnccs (~> 0.1.1)
37
37
  gb-agencies (~> 0.0.1)
@@ -51,7 +51,7 @@ GEM
51
51
  guard-compat (~> 1.1)
52
52
  rspec (>= 2.99.0, < 4.0)
53
53
  hashdiff (0.3.7)
54
- html2doc (0.8.5)
54
+ html2doc (0.8.6)
55
55
  asciimath
56
56
  htmlentities (~> 4.3.4)
57
57
  image_size
@@ -78,12 +78,12 @@ GEM
78
78
  algoliasearch
79
79
  iecbib (~> 0.2.1)
80
80
  iso-bib-item (~> 0.4.2)
81
- isodoc (0.9.5)
81
+ isodoc (0.9.8)
82
82
  asciimath
83
- html2doc (~> 0.8.1)
83
+ html2doc (~> 0.8.6)
84
84
  htmlentities (~> 4.3.4)
85
85
  liquid
86
- metanorma (~> 0.2.7)
86
+ metanorma (~> 0.3.0)
87
87
  nokogiri
88
88
  rake (~> 12.0)
89
89
  roman-numerals
@@ -100,8 +100,8 @@ GEM
100
100
  rb-inotify (~> 0.9, >= 0.9.7)
101
101
  ruby_dep (~> 1.2)
102
102
  lumberjack (1.0.13)
103
- metanorma (0.2.11)
104
- method_source (0.9.0)
103
+ metanorma (0.3.0)
104
+ method_source (0.9.2)
105
105
  mime-types (3.2.2)
106
106
  mime-types-data (~> 3.2015)
107
107
  mime-types-data (3.2018.0812)
@@ -114,10 +114,10 @@ GEM
114
114
  shellany (~> 0.0)
115
115
  optout (0.0.2)
116
116
  parallel (1.12.1)
117
- parser (2.5.1.2)
117
+ parser (2.5.3.0)
118
118
  ast (~> 2.4.0)
119
119
  powerpack (0.1.2)
120
- pry (0.11.3)
120
+ pry (0.12.1)
121
121
  coderay (~> 1.1.0)
122
122
  method_source (~> 0.9.0)
123
123
  public_suffix (3.0.3)
@@ -162,7 +162,7 @@ GEM
162
162
  ruby_deep_clone (0.8.0)
163
163
  ruby_dep (1.5.0)
164
164
  safe_yaml (1.0.4)
165
- sass (3.6.0)
165
+ sass (3.7.2)
166
166
  sass-listen (~> 4.0.0)
167
167
  sass-listen (4.0.0)
168
168
  rb-fsevent (~> 0.9, >= 0.9.4)
@@ -178,7 +178,7 @@ GEM
178
178
  simplecov-html (0.10.2)
179
179
  sterile (1.0.13)
180
180
  nokogiri
181
- thor (0.20.0)
181
+ thor (0.20.3)
182
182
  thread_safe (0.3.6)
183
183
  timecop (0.9.1)
184
184
  unicode-display_width (1.4.0)
@@ -198,7 +198,7 @@ DEPENDENCIES
198
198
  equivalent-xml (~> 0.6)
199
199
  guard (~> 2.14)
200
200
  guard-rspec (~> 4.7)
201
- metanorma (~> 0.2.6)
201
+ metanorma (~> 0.3.0)
202
202
  metanorma-standoc!
203
203
  rake (~> 12.0)
204
204
  rspec (~> 3.6)
@@ -209,4 +209,4 @@ DEPENDENCIES
209
209
  webmock
210
210
 
211
211
  BUNDLED WITH
212
- 1.16.6
212
+ 1.17.1
data/README.adoc CHANGED
@@ -8,6 +8,116 @@ WARNING: This gem is still under development.
8
8
 
9
9
  Gem for serialising the https://github.com/riboseinc/metanorma-model-standoc[Metanorma Standoc] model.
10
10
 
11
+ == Functionality
12
+
13
+ This gem processes Metanorma documents following a template for generating standards documents, according
14
+ to a range of standards classes. This gem provides underlying generic functionality; behaviour specific
15
+ to each standards class is refined in the gem specific to that standards class (e.g. https://github.com/riboseinc/metanorma-iso).
16
+ The following outputs are generated.
17
+
18
+ * Metanorma XML representation of the document, intended as a document model for
19
+ Standards. The Metanorma XML representation is processed in turn, to generate one or more of
20
+ the following outputs as end deliverables, depending on each standards class gem:
21
+ * Microsoft Word output (`.doc`)
22
+ * HTML output (`.html`)
23
+ * PDF (`.pdf`)
24
+
25
+ The following input formats are supported:
26
+
27
+ * http://asciidoctor.org/[Asciidoctor]
28
+
29
+ This README provides an overview of the functionality of the gem; see also
30
+ https://github.com/riboseinc/metanorma-iso/blob/master/docs/guidance.adoc[Guidance for authoring].
31
+ https://github.com/riboseinc/metanorma-iso/blob/master/docs/quickstart.adoc[Quickstart guide]
32
+ gives a summary overview.
33
+
34
+ NOTE: http://asciimath.org[AsciiMathML] is used for mathematical formatting.
35
+ The gem uses the https://github.com/asciidoctor/asciimath[Ruby AsciiMath parser],
36
+ which is syntactically stricter than the common MathJax processor;
37
+ if you do not get expected results, try bracketting terms your in AsciiMathML
38
+ expressions.
39
+
40
+ === Installation
41
+
42
+ If you are using a Mac, the https://github.com/riboseinc/metanorma-macos-setup
43
+ repository has instructions on setting up your machine to run Metanorma
44
+ scripts such as this one. You need only run the following in a Terminal console:
45
+
46
+ [source,console]
47
+ ----
48
+ $ bash <(curl -s https://raw.githubusercontent.com/riboseinc/metanorma-macos-setup/master/metanorma-setup)
49
+ $ gem install metanorma-standoc
50
+ $ gem install metanorma-cli
51
+ ----
52
+
53
+ The metanorma-cli gem is the command-line interface for the Metanorma tool suite
54
+ (incorporating the `metanorma` executable seen above).
55
+
56
+ == Approach
57
+ === Document model
58
+
59
+ The https://github.com/riboseinc/metanorma-model-iso[Metanorma document model] used in document generation
60
+ intends to introduce rigour into the standards authoring process; existing
61
+ document templates do not support such rigour down to the element level. It also introduces
62
+ flexibility by decoupling the document structure from its presentation.
63
+
64
+ Formal definitions of standards prescribe the contents of standards to a level
65
+ amenable to an explicit document model. The ISO International Standard format,
66
+ ss prescribed in
67
+ http://www.iec.ch/members_experts/refdocs/iec/isoiecdir-2%7Bed7.0%7Den.pdf[ISO/IEC DIR 2 "Principles and rules for the structure and drafting of ISO and IEC documents"],
68
+ is one of the more detailed such prescriptions available. A formal document
69
+ model would allow checking for consistency in format and content, and expedite
70
+ authoring and quality control of ISO standards. Authoring standards through a
71
+ more abstract formal model also permit enhanced functionality such as
72
+ cross-reference link checking and auto-numbering of sections, figures, tables and formulas.
73
+ Outputting a document in different languages also becomes straightforward.
74
+
75
+ === Asciidoctor
76
+
77
+ Asciidoctor has been selected as the authoring tool to generate the document
78
+ model representation of standards. It is a document formatting tool like
79
+ Markdown and DocBook, which combines the relative ease of use of the former
80
+ (using relatively lightweight markup), and the rigour and expressively of the
81
+ latter (it has a well-defined syntax, and was in fact initially developed as a
82
+ DocBook document authoring tool). Asciidoctor has built-in capability to output
83
+ Text and HTML; so it can be used to preview the file as it is being
84
+ authored. However the gem natively outputs HTML and Word output, so there should
85
+ not be much need for this.
86
+
87
+ Asciidoctor has some formatting constraints because of its own document model,
88
+ that users need to be aware. For example, Asciidoc has a strict division between
89
+ inline and block elements, which disallows certain kinds of nesting; so a list
90
+ cannot be embedded within a paragraph, it can only constitute its own paragraph
91
+ (though lists themselves can be nested within each other). Asciidoctor also disallows
92
+ multiple paragraphs in footnotes,
93
+ http://discuss.asciidoctor.org/footnotes-with-paragraph-breaks-td4130.html[by design].
94
+ (The document model does not impose this constraint, so you could edit the generated
95
+ XML to break up paragraphs within a footnote.)
96
+
97
+ == Different behaviour from native Asciidoctor
98
+
99
+ === Autonumbering
100
+
101
+ Autonumbering in Metanorma extends to formulas (which are encoded as "stem" blocks) and notes.
102
+ Autonumbering is applied in the conversion from Metanorma XML to output formats (`isodoc`);
103
+ by default it restarts for each annex, but is continuous for the main body of text.
104
+
105
+ === Unsupported blocks
106
+
107
+ Sidebars (`aside`) are not supported, and have been repurposed for reviewer comments.
108
+ Page breaks (`thematic break`) are not supported; ASCII art/preformatted text (`literal`)
109
+ are not supported in most standards classes.
110
+
111
+ === Footnotes
112
+
113
+ Table and figure footnotes are treated diffferently from all other footnotes: they are
114
+ rendered at the bottom of the table or figure, and they are numbered separately.
115
+
116
+ === References
117
+
118
+ References to well-defined standards codes use the document identifiers for citations
119
+ (e.g. `ISO 20483:2013`); generic references in bibliographies use bracketed numbers `[1]`.
120
+
11
121
  [[model_additions]]
12
122
  == Asciidoctor model additions
13
123
 
@@ -61,8 +171,8 @@ _paddy_ (<<paddy>>) from which the husk only has been removed
61
171
  If the Terms and Definitions of a standard are partly or fully sourced from
62
172
  another standard, that standard is cited in a `source` attribute to the section,
63
173
  which is set to the reference anchor of the standard (given under the Normative
64
- Referencecs)..
65
- The boilerplate of the Terms and Definitions section is adjusted accordingly.
174
+ Referencecs).
175
+ Any boilerplate of the Terms and Definitions section is adjusted accordingly.
66
176
 
67
177
  [source,asciidoctor]
68
178
  --
@@ -358,3 +468,206 @@ command line:
358
468
  If PlantUML is not installed locally, the source PlantUML is incorporated into
359
469
  the output document as sourcecode.
360
470
 
471
+ == Bibliography integration
472
+
473
+ Bibliographic entries for standards are expected to use the standard document
474
+ identifier as the item label; e.g.
475
+
476
+ [source,asciidoctor]
477
+ --
478
+ * [[[ref1,ISO 712]]], _Cereals and cereal products -- Determination of moisture content -- Reference method_
479
+ --
480
+
481
+ By default, the https://github.com/riboseinc/relaton[`relaton`] gem is used to look up the reference details for
482
+ standards known to have online bibliographies. For bibliographic standards to be looked up via relaton,
483
+ the standard document identifier needs to be encoded in a format recognised by relaton as a key:
484
+
485
+ * For ISO: `ISO(identifier)`, or any identifier prefixed with `ISO`
486
+ * For IEC: `IEC(identifier)`, or any identifier prefixed with `IEC`
487
+ * For IETF: `IETF(identifier)` (e.g. `IETF(I-D.-burger-xcon-mmodels)`), or any identifier prefixed with `RFC`
488
+ * For GB: `CN(identifier)` (e.g. `CN(JB/T 13368-2018)`)
489
+
490
+ The full bibliographic details of the item are screenscraped from the online bibliography and inserted into the XML file
491
+ (although only the title of the reference is used in rendering).
492
+
493
+ In addition, if any entries in Terms and Definitions cite the International Electrotechnical Vocabulary (IEV),
494
+ the http://www.electropedia.org[IEV Electropedia] termbank is queried during validation, to confirm
495
+ that the cited entries are the same as what is cited online; those queries are routed through the `iev` gem
496
+
497
+ TODO: update
498
+
499
+ [[cache]]
500
+ The results of all `relaton` searches done to date, across all documents,
501
+ are cached in the global cache file `~/.relaton-bib.pstore`,
502
+ so they do not need to be re-fetched each time a document is processed.
503
+ (The web query takes a few seconds per reference.)
504
+
505
+ The results of all `relaton` searches done to date in a given directory
506
+ are stored in the same directory as the current document,
507
+ as the file `{filename}.relaton.pstore`. The local cache overrides entries in
508
+ the global cache, and can be manually edited. The local cache is only used
509
+ if the `:local-cache:` or `:local-cache-only:` document attribute is set.
510
+
511
+ If the document attribute `:no-isobib:` is set, the reference details for
512
+ items are not looked up via `isobib`, and the `isobib` caches are not used.
513
+ If the document attribute `:no-isobib-cache:` is set, the reference details for
514
+ items are still looked up via `isobib`, but the `isobib` caches are not used.
515
+
516
+ Any entry in the cache that corresponds to an undated ISO reference fetches its details
517
+ from the latest available entry on the ISO web site. If the entry is more than 60
518
+ days old, it is refetched.
519
+
520
+ The results of all `iev` searches done to date across all documents are cached
521
+ in the global cache fule `~/iev.pstore`, and the results of all `iev` searches
522
+ done to date for the current document are stored in the same directory as the
523
+ current document, in the file `(filename).iev.pstore`.
524
+
525
+ == Document Attributes
526
+
527
+ The gem relies on Asciidoctor document attributes to provide necessary
528
+ metadata about the document. These include:
529
+
530
+ `:nodoc:`:: Do not generate Word and HTML output, only generate XML output.
531
+ Can be used as a command-line option (like all other document attributes):
532
+ `asciidoctor -a nodoc -b iso -r "metanorma-iso" a.adoc`
533
+
534
+ `:novalid:`:: Suppress validation.
535
+
536
+ `:flush-caches:`:: If set, delete and reinitialise the <<cache,cache>> of `relaton` searches.
537
+
538
+ `:no-isobib:`:: If set, do not use the `relaton` or `iev` gem functionality to look up
539
+ ISO and IEV references online, nor the <<cache,cache>> of `relaton` and `iev` searches.
540
+
541
+ `:no-isobib-cache:`:: If set, use the `relaton` and `iev` gem functionality to look up
542
+ ISO and IEV references online, but do not use the <<cache,cache>> of `relaton` and `iev` searches.
543
+
544
+ `:local-cache:`:: Use the local relaton and iev search caches to override the global `relaton` and `iev` search
545
+ caches.
546
+
547
+ `:local-cache-only:`:: Use the local relaton and iev search caches to the exclusion of the global `relaton` and `iev` search
548
+ caches.
549
+
550
+ `:i18nyaml:`:: Name of YAML file of internationalisation text, to use instead
551
+ of the built-in English, French or Chinese text used to label parts of the document
552
+ (e.g. "Table", "Foreword", boilerplate text for Normative References, etc.)
553
+ Use if you wish to output an standard in a language other than those three.
554
+ A sample YAML file for English, with "Foreword" replaced with "Frontispiece",
555
+ is available at https://github.com/riboseinc/metanorma-iso/blob/master/spec/examples/english.yaml[]
556
+
557
+ `:docnumber:`:: The numeric component of the document identifier (mandatory). The full identifier is formed by prefixing and suffixing this element with other strings derived from metadata.
558
+
559
+ `:edition:`:: The document edition
560
+
561
+ `:revdate:`:: The date the document was last updated
562
+
563
+ `:copyright-year:`:: The year which will be claimed as when the copyright for
564
+ the document was issued
565
+
566
+ `:library-ics:` :: The ICS (International Categorization for Standards) number for the standard. There may be more than one ICS for a document; if so, they should be comma-delimited. (The ics identifier is added to the document metadata, but is not output to the current document templates.)
567
+
568
+ `:title:` :: The title of the document
569
+
570
+ `:doctype:`:: The document type; e.g. "standard", "guide", "report".
571
+
572
+ `:status:` :: The status of the document; e.g. "draft", "published".
573
+
574
+ `:technical-committee:`:: The name of the relevant technical committee
575
+
576
+ `:draft:`:: The document draft (used in addition to document stage, for multiple iterations: expected format _X.Y_)
577
+
578
+ `:issued-date:`::
579
+ The date on which the standard was issued (authorised for publication by the issuing authority).
580
+
581
+ `:published-date:`::
582
+ The date on which the standard was published (distributed by the publisher).
583
+
584
+ `:implemented-date:`::
585
+ The date on which the standard became active.
586
+
587
+ `:created-date:`::
588
+ The date on which the first version of the standard was created.
589
+
590
+ `:updated-date:`::
591
+ The date on which the current version of the standard was updated.
592
+
593
+ `:obsoleted-date:`::
594
+ The date on which the standard was obsoleted/revoked.
595
+
596
+ `:confirmed-date:`::
597
+ The date on which the standard was reviewed and approved by the issuing authority.
598
+
599
+ `:unchanged-date:`::
600
+ The date on which the standard was last renewed without any changes in content.
601
+
602
+ `:circulated-date:`::
603
+ The date on which the unpublished standard was last circulated officially as a preprint. For standards, this is associated with the latest transition to a formally defined preparation stage, such as Working Draft or Committee Draft.
604
+
605
+ `:date:`::
606
+ An arbitrary date in the production of the standard. Content of the attribute should be a token, giving the type of date, then space, then the date itself. Multiple dates can be added as `:date_2:`, `date_3`, etc.
607
+
608
+ `:uri:`:: The URI to which this standard is published.
609
+ `:xml-uri:`:: The URI to which the (Metanorma) XML representation of this standard is published.
610
+ `:html-uri:`:: The URI to which the HTML representation of this standard is published.
611
+ `:pdf-uri:`:: The URI to which the PDF representation of this standard is published.
612
+ `:doc-uri:`:: The URI to which the DOC representation of this standard is published.
613
+ `:relaton-uri:`:: The URI to which the Relaton XML representation of this standard is published.
614
+
615
+ `:language:` :: The language of the document (`en` or `fr`). Defaults to `en`.
616
+
617
+ `:script:` :: The script of the document (defaults to `Latn`). Must be supplied as
618
+ `Hans` for Simplified Chinese.
619
+
620
+ `:publisher:`:: The standards agency publishing the standard; can be multiple
621
+ (comma-delimited). Defaults to `ISO`.
622
+
623
+ `:body-font:`:: Font for body text; will be inserted into CSS. Defaults to
624
+ Cambria for Latin script, SimSun for Simplified Chinese.
625
+
626
+ `:header-font:`:: Font for headers; will be inserted into CSS. Defaults to
627
+ Cambria for Latin script, SimHei for Simplified Chinese.
628
+
629
+ `:monospace-font`:: Font for monospace; will be inserted into CSS. Defaults to
630
+ Courier New.
631
+
632
+ `:htmlstylesheet`:: SCSS stylesheet to use for HTML output. Defaults to built in stylesheet,
633
+ which adheres with ISO formatting requirements. Recommend against overriding this.
634
+
635
+ `:htmlcoverpage`:: HTML template for cover page. Defaults to built in template. Recommend against overriding this.
636
+
637
+ `:htmlintropage`:: HTML template for introductory section. Defaults to built in template. Recommend against overriding this.
638
+
639
+ `:scripts`:: Javascript scripts for HTML output. Defaults to built in scripts. Recommend against overriding this.
640
+ `:scripts-pdf`:: Javascript scripts for HTML > PDF output. Defaults to built in scripts. Recommend against overriding this.
641
+
642
+ `:wordstylesheet`:: Primary SCSS stylesheet to use for Word output. Defaults to built in stylesheet,
643
+ which adheres with ISO formatting requirements. Recommend against overriding this.
644
+
645
+ `:standardstylesheet`:: Secondary SCSS stylesheet use for Word output. Defaults to built in stylesheet,
646
+ which adheres with ISO formatting requirements. Recommend against overriding this.
647
+
648
+ `:header`:: Header and footer file for Word output. Defaults to built in template. Recommend against overriding this.
649
+
650
+ `:wordcoverpage`:: Word template for cover page. Defaults to built in template. Recommend against overriding this.
651
+
652
+ `:wordintropage`:: Word template for introductory section. Defaults to built in template. Recommend against overriding this.
653
+
654
+ `:ulstyle`:: Word CSS selector for unordered lists in supplied stylesheets. Defaults to value for built in stylesheet. Recommend against overriding this.
655
+
656
+ `:olstyle`:: Word CSS selector for ordered lists in supplied stylesheets. Defaults to value for built in stylesheet. Recommend against overriding this.
657
+
658
+ `:data-uri-image`:: Encode all images in HTML output as inline data-URIs.
659
+
660
+ The attribute `:draft:`, if present, includes review notes in the XML output;
661
+ these are otherwise suppressed.
662
+
663
+ The document proper can reference the values of document attributes, which is convenient
664
+ for reusability. For example,
665
+
666
+ [source,asciidoc]
667
+ --
668
+ This document was prepared by Technical Committee ISO/TC {technical-committee-number}, _{technical-committee}_, Subcommittee SC {subcommittee-number}, _{subcommittee}_.
669
+ --
670
+
671
+ If the corresponding document attributes are not populated in the header, then the references
672
+ themselves will not be populated.
673
+
@@ -476,6 +476,9 @@
476
476
  <zeroOrMore>
477
477
  <ref name="docidentifier"/>
478
478
  </zeroOrMore>
479
+ <optional>
480
+ <ref name="docnumber"/>
481
+ </optional>
479
482
  <zeroOrMore>
480
483
  <ref name="bdate"/>
481
484
  </zeroOrMore>
@@ -637,6 +640,8 @@
637
640
  <value>transmitted</value>
638
641
  <value>copied</value>
639
642
  <value>unchanged</value>
643
+ <value>circulated</value>
644
+ <text/>
640
645
  </choice>
641
646
  </attribute>
642
647
  <choice>
@@ -673,6 +678,11 @@
673
678
  <text/>
674
679
  </element>
675
680
  </define>
681
+ <define name="docnumber">
682
+ <element name="docnumber">
683
+ <text/>
684
+ </element>
685
+ </define>
676
686
  <define name="bclassification">
677
687
  <element name="classification">
678
688
  <optional>
@@ -43,25 +43,13 @@ module Asciidoctor
43
43
  xmldoc
44
44
  end
45
45
 
46
- # ISO as a prefix goes first
47
46
  def docidentifier_cleanup(xmldoc)
48
- id = xmldoc.at("//bibdata/docidentifier/project-number")
49
- return unless id
50
-
51
- prefix = []
52
- xmldoc.xpath("//bibdata/contributor[role/@type = 'publisher']"\
53
- "/organization").each do |x|
54
- x1 = x.at("abbreviation")&.text || x.at("name")&.text
55
- x1 == "ISO" and prefix.unshift("ISO") or prefix << x1
56
- end
57
-
58
- id.content = prefix.join("/") + " " + id.text
59
47
  end
60
48
 
61
49
  TEXT_ELEMS =
62
- %w{status language script version author name callout phone
63
- email street city state country postcode identifier referenceFrom
64
- referenceTo docidentifier prefix initial addition surname forename
50
+ %w{status language script version author name callout phone email
51
+ street city state country postcode identifier referenceFrom
52
+ referenceTo docidentifier docnumber prefix initial addition surname forename
65
53
  title draft secretariat title-main title-intro title-part}.freeze
66
54
 
67
55
  # it seems Nokogiri::XML is treating the content of <script> as cdata,
@@ -102,16 +102,6 @@ module Asciidoctor
102
102
  "name = 'International Organization for Standardization' or "\
103
103
  "name = 'International Electrotechnical Commission']".freeze
104
104
 
105
- def date_range(date)
106
- from = date.at("./from")
107
- to = date.at("./to")
108
- on = date.at("./on")
109
- return on.text if on
110
- ret = "#{from.text}&ndash;"
111
- ret += to.text if to
112
- ret
113
- end
114
-
115
105
  def reference_names(xmldoc)
116
106
  xmldoc.xpath("//bibitem[not(ancestor::bibitem)]").each do |ref|
117
107
  isopub = ref.at(ISO_PUBLISHER_XPATH)
@@ -11,10 +11,11 @@ module Asciidoctor
11
11
  module Front
12
12
  def metadata_id(node, xml)
13
13
  part, subpart = node&.attr("partnumber")&.split(/-/)
14
- xml.docidentifier do |i|
15
- i.project_number node.attr("docnumber"),
16
- **attr_code(part: part, subpart: subpart)
17
- end
14
+ id = node.attr("docnumber") || ""
15
+ id += "-#{part}" if part
16
+ id += "-#{subpart}" if subpart
17
+ xml.docidentifier id
18
+ xml.docnumber node.attr("docnumber")
18
19
  end
19
20
 
20
21
  def metadata_version(node, xml)
@@ -104,10 +105,34 @@ module Asciidoctor
104
105
  node.attr("relaton-uri") && xml.source(node.attr("relaton-uri"), type: "relaton")
105
106
  end
106
107
 
108
+ def metadata_date1(node, xml, type)
109
+ date = node.attr("#{type}-date")
110
+ date and xml.date **{ type: type } do |d|
111
+ d.on date
112
+ end
113
+ end
114
+
115
+ DATETYPES = %w{ published accessed created implemented obsoleted
116
+ confirmed updated issued circulated unchanged
117
+ }.freeze
118
+
119
+ def metadata_date(node, xml)
120
+ DATETYPES.each { |t| metadata_date1(node, xml, t) }
121
+ node.attributes.keys.each do |a|
122
+ next unless a == "date" || /^date_\d+$/.match(a)
123
+ type, date = node.attr(a).split(/ /, 2)
124
+ type or next
125
+ xml.date **{ type: type } do |d|
126
+ d.on date
127
+ end
128
+ end
129
+ end
130
+
107
131
  def metadata(node, xml)
108
132
  title node, xml
109
133
  metadata_source(node, xml)
110
134
  metadata_id(node, xml)
135
+ metadata_date(node, xml)
111
136
  metadata_author(node, xml)
112
137
  metadata_publisher(node, xml)
113
138
  xml.language (node.attr("language") || "en")
@@ -1034,6 +1034,9 @@
1034
1034
  <zeroOrMore>
1035
1035
  <ref name="docidentifier"/>
1036
1036
  </zeroOrMore>
1037
+ <optional>
1038
+ <ref name="docnumber"/>
1039
+ </optional>
1037
1040
  <zeroOrMore>
1038
1041
  <ref name="bdate"/>
1039
1042
  </zeroOrMore>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Standoc
3
- VERSION = "1.0.8".freeze
3
+ VERSION = "1.0.9".freeze
4
4
  end
5
5
  end
@@ -43,7 +43,7 @@ Gem::Specification.new do |spec|
43
43
  spec.add_development_dependency "rubocop", "~> 0.50"
44
44
  spec.add_development_dependency "simplecov", "~> 0.15"
45
45
  spec.add_development_dependency "timecop", "~> 0.9"
46
- spec.add_development_dependency "metanorma", "~> 0.2.6"
46
+ spec.add_development_dependency "metanorma", "~> 0.3.0"
47
47
  spec.add_development_dependency "vcr"
48
48
  spec.add_development_dependency "webmock"
49
49
  end
@@ -43,6 +43,18 @@ RSpec.describe Asciidoctor::Standoc do
43
43
  :partnumber: 1
44
44
  :edition: 2
45
45
  :revdate: 2000-01-01
46
+ :published-date: 1000-01-01
47
+ :accessed-date: 1001-01-01
48
+ :created-date: 1002-01-01
49
+ :implemented-date: 1003-01-01
50
+ :obsoleted-date: 1004-01-01
51
+ :confirmed-date: 1005-01-01
52
+ :updated-date: 1006-01-01
53
+ :issued-date: 1007-01-01
54
+ :circulated-date: 1008-01-01
55
+ :unchanged-date: 1009-01-01
56
+ :date: Fred 1010-01-01
57
+ :date_2: Jack 1010-01-01
46
58
  :draft: 3.4
47
59
  :technical-committee: TC
48
60
  :technical-committee-number: 1
@@ -75,9 +87,44 @@ RSpec.describe Asciidoctor::Standoc do
75
87
  <standard-document xmlns="http://riboseinc.com/isoxml">
76
88
  <bibdata type="article">
77
89
  <title language="en" format="text/plain">Main Title — Title</title>
78
- <docidentifier>
79
- <project-number part="1"> 1000</project-number>
80
- </docidentifier>
90
+ <docidentifier>1000-1</docidentifier>
91
+ <docnumber>1000</docnumber>
92
+ <date type="published">
93
+ <on>1000-01-01</on>
94
+ </date>
95
+ <date type="accessed">
96
+ <on>1001-01-01</on>
97
+ </date>
98
+ <date type="created">
99
+ <on>1002-01-01</on>
100
+ </date>
101
+ <date type="implemented">
102
+ <on>1003-01-01</on>
103
+ </date>
104
+ <date type="obsoleted">
105
+ <on>1004-01-01</on>
106
+ </date>
107
+ <date type="confirmed">
108
+ <on>1005-01-01</on>
109
+ </date>
110
+ <date type="updated">
111
+ <on>1006-01-01</on>
112
+ </date>
113
+ <date type="issued">
114
+ <on>1007-01-01</on>
115
+ </date>
116
+ <date type="circulated">
117
+ <on>1008-01-01</on>
118
+ </date>
119
+ <date type="unchanged">
120
+ <on>1009-01-01</on>
121
+ </date>
122
+ <date type="Fred">
123
+ <on>1010-01-01</on>
124
+ </date>
125
+ <date type="Jack">
126
+ <on>1010-01-01</on>
127
+ </date>
81
128
  <language>en</language>
82
129
  <script>Latn</script>
83
130
  <status format="plain">published</status>
@@ -136,9 +183,8 @@ RSpec.describe Asciidoctor::Standoc do
136
183
  <source type="pdf">D</source>
137
184
  <source type="doc">E</source>
138
185
  <source type="relaton">F</source>
139
- <docidentifier>
140
- <project-number part="1" subpart="1">ISO/IEC/IETF 1000</project-number>
141
- </docidentifier>
186
+ <docidentifier>1000-1-1</docidentifier>
187
+ <docnumber>1000</docnumber>
142
188
  <contributor>
143
189
  <role type="author"/>
144
190
  <organization>
@@ -271,12 +317,12 @@ RSpec.describe Asciidoctor::Standoc do
271
317
  expect(html).to match(%r[h1[^{]+\{[^{]+font-family: Comic Sans;]m)
272
318
  expect(html).to match(%r[an empty word cover page])
273
319
  expect(html).to match(%r[an empty word intro page])
274
- expect(html).to match(%r[Content-Location: file:///C:/Doc/test_files/header.html
320
+ expect(html).to include(%[Content-Location: file:///C:/Doc/test_files/header.html
275
321
  Content-Transfer-Encoding: base64
276
322
  Content-Type: text/html charset="utf-8"
277
323
 
278
- Ci8qIGFuIGVtcHR5IGhlYWRlciAqLwoKU1RBUlQgRE9DIElEOiAgOiBFTkQgRE9DIElECgpGSUxF
279
- TkFNRTogdGVzdAoK
324
+ Ci8qIGFuIGVtcHR5IGhlYWRlciAqLwoKU1RBUlQgRE9DIElEOiA6IEVORCBET0MgSUQKCkZJTEVO
325
+ QU1FOiB0ZXN0Cgo=
280
326
  ])
281
327
  end
282
328
 
@@ -512,9 +512,6 @@ RSpec.describe Asciidoctor::Standoc do
512
512
  <?xml version="1.0" encoding="UTF-8"?>
513
513
  <standard-document xmlns="http://riboseinc.com/isoxml">
514
514
  <bibdata type="article">
515
- <docidentifier>
516
- <project-number> </project-number>
517
- </docidentifier>
518
515
  <language>en</language>
519
516
  <script>Latn</script>
520
517
  <status format="plain">published</status>
data/spec/spec_helper.rb CHANGED
@@ -106,9 +106,6 @@ BLANK_HDR = <<~"HDR"
106
106
  <?xml version="1.0" encoding="UTF-8"?>
107
107
  <standard-document xmlns="http://riboseinc.com/isoxml">
108
108
  <bibdata type="article">
109
- <docidentifier>
110
- <project-number> </project-number>
111
- </docidentifier>
112
109
  <language>en</language>
113
110
  <script>Latn</script>
114
111
  <status format="plain">published</status>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-standoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-26 00:00:00.000000000 Z
11
+ date: 2018-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -240,14 +240,14 @@ dependencies:
240
240
  requirements:
241
241
  - - "~>"
242
242
  - !ruby/object:Gem::Version
243
- version: 0.2.6
243
+ version: 0.3.0
244
244
  type: :development
245
245
  prerelease: false
246
246
  version_requirements: !ruby/object:Gem::Requirement
247
247
  requirements:
248
248
  - - "~>"
249
249
  - !ruby/object:Gem::Version
250
- version: 0.2.6
250
+ version: 0.3.0
251
251
  - !ruby/object:Gem::Dependency
252
252
  name: vcr
253
253
  requirement: !ruby/object:Gem::Requirement