metanorma-iso 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 +4 -4
- data/.rubocop.yml +2 -7
- data/README.adoc +30 -364
- data/docs/adopting-spec.adoc +72 -0
- data/docs/adopting-toolchain.adoc +389 -0
- data/docs/asciiiso-syntax.adoc +305 -0
- data/docs/customisation.adoc +5 -643
- data/docs/guidance.adoc +73 -64
- data/docs/localizing-output.adoc +57 -0
- data/docs/navigation.adoc +23 -0
- data/docs/quickstart.adoc +106 -304
- data/docs/replacing-asciidoc.adoc +15 -0
- data/docs/styling-output-html.adoc +37 -0
- data/docs/styling-output-msword.adoc +38 -0
- data/lib/asciidoctor/iso/biblio.rng +10 -0
- data/lib/asciidoctor/iso/cleanup.rb +24 -0
- data/lib/asciidoctor/iso/front.rb +32 -5
- data/lib/asciidoctor/iso/isodoc.rng +3 -0
- data/lib/asciidoctor/iso/isostandard.rng +6 -0
- data/lib/asciidoctor/iso/validate.rb +2 -1
- data/lib/isodoc/iso/html/html_iso_titlepage.html +2 -2
- data/lib/isodoc/iso/html/style-human.scss +1 -1
- data/lib/isodoc/iso/html/style-iso.scss +1 -1
- data/lib/isodoc/iso/html/word_iso_titlepage.html +2 -2
- data/lib/isodoc/iso/metadata.rb +8 -13
- data/lib/metanorma/iso/version.rb +1 -1
- data/spec/asciidoctor-iso/base_spec.rb +17 -13
- data/spec/asciidoctor-iso/refs_spec.rb +0 -3
- data/spec/asciidoctor-iso/validate_spec.rb +2 -0
- data/spec/assets/iso.doc +12 -12
- data/spec/assets/iso.html +1 -1
- data/spec/examples/rice.preview.html +25 -25
- data/spec/isodoc/metadata_spec.rb +8 -6
- data/spec/isodoc/postproc_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -3
- metadata +10 -2
@@ -0,0 +1,15 @@
|
|
1
|
+
= I can translate my specifications into IsoDoc XML myself (i.e. I don't like AsciiDoc, or I already have my own toolchain). Can I only use IsoDoc XML to produce pretty output?
|
2
|
+
|
3
|
+
[TIP]
|
4
|
+
====
|
5
|
+
* Generate correct IsoDoc XML (make sure it validates!)
|
6
|
+
* Create just the `IsoDoc::...::HtmlConvert` and/or `IsoDoc::...::WordConvert` classes to convert the IsoDoc XML into target formats.
|
7
|
+
* Initialise the IsoDoc class passing the necessary information about fonts and scripts; the existing gems all illustrate this kind of initialisation.
|
8
|
+
* Create the target format using the method `.convert(filename, xml)`.
|
9
|
+
====
|
10
|
+
|
11
|
+
The Asciidoctor-to-XML and XML-to-Output classes are separate, so you can invoke just the latter without the former. Of course, you will need to make sure that the IsoDoc XML you are passing to the generators is valid.
|
12
|
+
|
13
|
+
The `IsoDoc::...::HtmlConvert` and/or `IsoDoc::...::WordConvert` are initialised in the existing gems with a hash giving the fonts to be used in the document (to be injected in the document SCSS stylesheets), the script of the document (to be used to pick the right font, in case of default font settings), and the `i18nyaml` YAML file for localisation. All existing gems have defaults set for these values on the Asciidoctor side invoking the class, so all parameters are optional.
|
14
|
+
|
15
|
+
Once you have the classes set up, all you need to do is invoke the conversion of XML to the target format, with the method `.convert(filename, xml)`, where XML is the IsoDoc XML.
|
@@ -0,0 +1,37 @@
|
|
1
|
+
= How can I style the resulting HTML output?
|
2
|
+
|
3
|
+
[TIP]
|
4
|
+
====
|
5
|
+
* Clone the metanorma-sample gem: https://github.com/riboseinc/metanorma-sample.
|
6
|
+
* Edit the `html_sample_titlepage.html` and `html_sample_intro.html` pages to match your organisation's branding.
|
7
|
+
** Leave the Liquid Template instructions alone (`{{`, `{%`) unless you know what you're doing with them: they are how the pages are populated with metadata.
|
8
|
+
* Edit the `default_fonts()` method in your `IsoDoc::...::HtmlConvert` class, to match your desired fonts.
|
9
|
+
* Edit the `default_file_locations()` method in your `IsoDoc::...::HtmlConvert` class, to match your desired stylesheets and HTML templates.
|
10
|
+
* Edit the `htmlstyle.scss` stylesheet to match your organisation's branding. The classes already in place there are used to style existing blocks of text; refer to the sample documents included in the gem (`spec/examples`) for their use.
|
11
|
+
====
|
12
|
+
|
13
|
+
Styling of output is intended to be configurable.
|
14
|
+
HTML stylesheets are expressed in https://sass-lang.com/guide[SCSS], with their fonts populated through the `default_fonts()` method in the `IsoDoc::...::HtmlConvert` class.
|
15
|
+
Frontispiece content is templated, populated from the metadata parsed in the `IsoDoc::...::Metadata` class, via https://shopify.github.io/liquid/[Liquid templates].
|
16
|
+
The default stylesheets and HTML templates themselves are nominated in the `default_file_locations()` method in the `IsoDoc::...::HtmlConvert` class.
|
17
|
+
That means you can change the styling of output documents readily, so long as you are aware of the functionality of the stylesheet.
|
18
|
+
|
19
|
+
* Styling information is stored in the `.../lib/isodoc/html` folder of the gem, and applies to both Word and HTML content. For HTML content, the relevant files are `html_..._titlepage.html` (title page HTML template), `html_..._intro.html` (introductory HTML template, typically restricted to Table of Contents), `scripts.html` (Javascript scripts), and `htmlstyle.scss` (the HTML stylesheet).
|
20
|
+
* The styling files to be loaded in are set in the `default_file_locations()` method of `IsoDoc::...::HtmlConvert`. The files can be overridden through document variables in the Asciidoc document.
|
21
|
+
* Additional files (e.g. logos) can be loaded in the `initialize()` method of `IsoDoc::...::HtmlConvert`; for them to be access during document generation, they need to be copied to the working directory. (They can be removed subsequently by adding them to the `@files_to_delete` array. All image files are copied into an `_html` subdirectory.)
|
22
|
+
* The HTML templates are populated through Liquid Templates: variables in `{{` correspond to the hash keys for metadata extracted in `IsoDoc::...::Metadata`, and its superclass `IsoDoc::Metadata` in the isodoc gem.
|
23
|
+
* The SCSS stylesheets treat fonts as variables. Those variables are set in `default_fonts()`, which generates variable assignments for SCSS. Stylesheets normally recognise three fonts: `$bodyfont` for body text, `$headerfont` for headers and captions (which may be the same font as `$bodyfont`), and `$monospacefont` for monospace text. Note that `default_fonts()` takes the options passed to initialise `HtmlConvert` as a paremeter; the document language and script can be used to make different font choices for different document scripts. (The existing gems refer to `Latn`, Latin script, and `Hans`, Simplified Chinese script.)
|
24
|
+
* Javascript scripts are populated in `scripts.html`; the scripts already in place in any gem you modify are in live use, and you should work out what they do before removing them. The AnchorJS script, for example, is used to generate navigable anchors in the document.
|
25
|
+
* Additional scripts and fonts may be loaded in the document head through the `html_head()` method of `IsoDoc::...::HtmlConvert`. The existing gems use the document head to load Jquery, the Table of Contents generation script, Google Fonts, and Font Awesome.
|
26
|
+
* The classes in the SCSS stylesheet correspond to static HTML content in the HTML templates, and dynamic HTML content in the `IsoDoc::...::HtmlConvert` class, and its superclasses `IsoDoc::HtmlConvert` and `IsoDoc::Common` in the isodoc gem.
|
27
|
+
|
28
|
+
An HTML document is populated as follows:
|
29
|
+
|
30
|
+
* HTML Head wrapper (in `IsoDoc::HtmlConvert`)
|
31
|
+
** `html_head()` content
|
32
|
+
** `@htmlstylesheet` CSS stylesheet (expected to be in SCSS, generated from SCSS in the `generate_css()` method of `Isodoc::HtmlConvert`).
|
33
|
+
* HTML Body
|
34
|
+
** `@htmlcoverpage` HTML template (optional, corresponds to `html_..._titlepage.html`)
|
35
|
+
** `@htmlintropage` HTML template (optional, corresponds to `html_..._intro.html`)
|
36
|
+
** Document proper (converted from Standoc XML)
|
37
|
+
** `@scripts` Javascript Scripts (optional, corresponds to `scripts.html`)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
= How can I style the resulting Microsoft Word output?
|
2
|
+
|
3
|
+
[TIP]
|
4
|
+
====
|
5
|
+
* There is no quick way of doing this.
|
6
|
+
* Everything you can do in Word, you can do in Word HTML. Save Word documents as Word HTML to see how.
|
7
|
+
* Clone the metanorma-sample gem: https://github.com/riboseinc/metanorma-sample.
|
8
|
+
* Edit the `word_sample_titlepage.html` and `word_sample_intro.html` pages to match your organisation's branding. With lots of iterations of saving Word documents as HTML, for trial and error.
|
9
|
+
** Leave the Liquid Template instructions alone (`{{`, `{%`) unless you know what you're doing with them: they are how the pages are populated with metadata.
|
10
|
+
* Edit the `default_fonts()` method in your `IsoDoc::...::WordConvert` class, to match your desired fonts.
|
11
|
+
* Edit the `default_file_locations()` method in your `IsoDoc::...::WordConvert` class, to match your desired stylesheets and file templates.
|
12
|
+
* Edit the `wordstyle.scss` and `sample.scss` stylesheets to match your organisation's branding. With lots of iterations of saving Word documents as HTML, for trial and error.
|
13
|
+
====
|
14
|
+
|
15
|
+
Word output in the document toolset is generated through Word HTML, the variant of HTML that you get when you save a Word document as HTML. (That is why documents are saved in `.doc`, not `.docx`.) This has the advantage over https://en.wikipedia.org/wiki/Office_Open_XML[OOXML], the native markup of DOCX, of using a well-known markup language, with a low barrier to entry: if you want to work out how to do something in Word HTML, do it in Word, save the document as HTML, and open up the HTML in a text editor. (For more on the choice of using Word HTML, see https://github.com/riboseinc/html2doc/wiki/Why-not-docx%3F.)
|
16
|
+
|
17
|
+
However Word HTML is not quite the HTML you are used to: it is a restricted, syntactically idiosyncratic variant of HTML 4, with a non-standard and weakened form of CSS. Doing any styling in Word HTML involves lots of trial and error, and paying close attention to how Word HTML does things in its CSS. We have documented a few of the clearer gotchas in https://github.com/riboseinc/html2doc/blob/master/README.adoc.
|
18
|
+
|
19
|
+
It's still better than learning OOXML.
|
20
|
+
|
21
|
+
The process for generating Word output is fairly similar to that for generating HTML, since both processes are generating a form of HTML; as we already noted, the two processes share a substantial amount of code. The main differences are in the handling of page-media features that CSS has lagged in (footnotes, pagination, headers and footers), and in the styling of lists, for which Word HTML uses custom (and undocumented) CSS classes prefixed with `@`, specifying inter alia the numbering for nine levels of nesting of the same list.
|
22
|
+
|
23
|
+
* Styling information is stored in the `.../lib/isodoc/html` folder of the gem, and applies to both Word and HTML content. For Word content, the relevant files are `word_..._titlepage.html` (title page HTML template), `word_..._intro.html` (introductory HTML template, typically restricted to Table of Contents), `wordstyle.scss` and `{name_of_standard}.scss` (the Word stylesheets), and `header.html` (document headers, footers, and endnote/footnote separators, referenced from the stylesheets).
|
24
|
+
* The styling files to be loaded in are set in the `default_file_locations()` method of `IsoDoc::...::WordConvert`.
|
25
|
+
* As with HTML generation, additional files (e.g. logos) can be loaded in the `initialize()` method of `IsoDoc::...::WordConvert`. The `initialize()` method also sets the `@` styles in the stylesheet to be used for unordered and ordered lists; a single such style is intended to capture the behaviour of all levels of indentation.
|
26
|
+
* As with HTML output, the HTML templates are populated through Liquid Templates: variables in `{{` correspond to the hash keys for metadata extracted in `IsoDoc::...::Metadata`, and its superclass `IsoDoc::Metadata` in the isodoc gem.
|
27
|
+
* As with HTML, the SCSS stylesheets treat fonts as variables, and are set in the `default_fonts()` method of `IsoDoc::...::WordConvert`.
|
28
|
+
* Document headers and footers are set in the `header.html` file. This is also an HTML template, which is populated with metadata attributes through Liquid Template. The structure of `header.html` is determined by Word, and elements of `header.html` need to be crossreferenced from the Word stylesheet. To inspect Word `header.html` files, save a Word document as HTML, and look inside the `{document_name}.fld` folder generated alongside the HTML output.
|
29
|
+
* The classes in the SCSS stylesheet correspond to static HTML content in the HTML templates, and dynamic HTML content in the `IsoDoc::...::WordConvert` class, and its superclasses `IsoDoc::WordConvert` and `IsoDoc::Common` in the isodoc gem.
|
30
|
+
|
31
|
+
A Word HTML document is populated as follows:
|
32
|
+
* HTML Head wrapper (in `IsoDoc::WordConvert`)
|
33
|
+
** `@wordstylesheet` CSS stylesheet (generated from SCSS through the `generate_css()` method of `Isodoc::WordConvert`); corresponds to `wordstyle.scss`.
|
34
|
+
** `@standstylesheet` CSS stylesheet (generated from SCSS through the `generate_css()` method of `Isodoc::WordConvert`); intended to override any generic CSS in `@wordstylesheet`. Optional, corresponds to `{name_of_standard}.scss`.
|
35
|
+
* HTML Body
|
36
|
+
** `@wordcoverpage` HTML template (optional, corresponds to `word_..._titlepage.html`). Included in `<div class=WordSection1>`.
|
37
|
+
** `@htmlintropage` HTML template (optional, corresponds to `word_..._intro.html`). Included in `<div class=WordSection2>`. In the existing gems, WordSection2 is paginated with roman numerals.
|
38
|
+
** Document proper (converted from Standoc XML). Included in `<div class=WordSection2>` (prefatory material) and `<div class=WordSection3>` (main document). In the existing gems, WordSection3 is paginated with roman numerals.
|
@@ -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>
|
@@ -34,6 +34,30 @@ module Asciidoctor
|
|
34
34
|
i, seen = other_footnote_renumber1(fn, i, seen)
|
35
35
|
end
|
36
36
|
end
|
37
|
+
|
38
|
+
def id_prefix(prefix, id)
|
39
|
+
prefix.join("/") + ( id.text.match(%{^/}) ? "" : " " ) + id.text
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_id_prefix(xmldoc)
|
43
|
+
prefix = []
|
44
|
+
xmldoc.xpath("//bibdata/contributor[role/@type = 'publisher']"\
|
45
|
+
"/organization").each do |x|
|
46
|
+
x1 = x.at("abbreviation")&.text || x.at("name")&.text
|
47
|
+
x1 == "ISO" and prefix.unshift("ISO") or prefix << x1
|
48
|
+
end
|
49
|
+
prefix
|
50
|
+
end
|
51
|
+
|
52
|
+
# ISO as a prefix goes first
|
53
|
+
def docidentifier_cleanup(xmldoc)
|
54
|
+
prefix = get_id_prefix(xmldoc)
|
55
|
+
id = xmldoc.at("//bibdata/docidentifier[@type = 'iso']") or return
|
56
|
+
id.content = id_prefix(prefix, id)
|
57
|
+
id = xmldoc.at("//bibdata/docidentifier[@type = 'iso-structured']/"\
|
58
|
+
"project-number") or return
|
59
|
+
id.content = id_prefix(prefix, id)
|
60
|
+
end
|
37
61
|
end
|
38
62
|
end
|
39
63
|
end
|
@@ -10,23 +10,50 @@ module Asciidoctor
|
|
10
10
|
module ISO
|
11
11
|
class Converter < Standoc::Converter
|
12
12
|
def metadata_id(node, xml)
|
13
|
+
iso_id(node, xml)
|
14
|
+
node.attr("tc-docnumber") and
|
15
|
+
xml.docidentifier(node.attr("tc-docnumber"),
|
16
|
+
**attr_code(type: "iso-tc"))
|
17
|
+
xml.docnumber node&.attr("docnumber")
|
18
|
+
end
|
19
|
+
|
20
|
+
def iso_id(node, xml)
|
21
|
+
return unless node.attr("docnumber")
|
13
22
|
part, subpart = node&.attr("partnumber")&.split(/-/)
|
14
|
-
|
23
|
+
dn = add_id_parts(node.attr("docnumber"), part, subpart)
|
24
|
+
dn = id_stage_prefix(dn, node)
|
25
|
+
xml.docidentifier dn, **attr_code(type: "iso")
|
26
|
+
xml.docidentifier **attr_code(type: "iso-structured") do |i|
|
15
27
|
i.project_number node.attr("docnumber"),
|
16
28
|
**attr_code(part: part, subpart: subpart)
|
17
|
-
if node.attr("tc-docnumber")
|
18
|
-
i.tc_document_number node.attr("tc-docnumber")
|
19
|
-
end
|
20
29
|
end
|
21
30
|
end
|
22
31
|
|
32
|
+
def add_id_parts(dn, part, subpart)
|
33
|
+
dn += "-#{part}" if part
|
34
|
+
dn += "-#{subpart}" if subpart
|
35
|
+
dn
|
36
|
+
end
|
37
|
+
|
38
|
+
def id_stage_prefix(dn, node)
|
39
|
+
if node.attr("docstage") && node.attr("docstage").to_i < 60
|
40
|
+
abbr = IsoDoc::Iso::Metadata.new("en", "Latn", {}).
|
41
|
+
stage_abbrev(node.attr("docstage"), node.attr("iteration"),
|
42
|
+
node.attr("draft"))
|
43
|
+
dn = "/#{abbr} #{dn}" # prefixes added in cleanup
|
44
|
+
else
|
45
|
+
dn += ":#{node.attr("copyright-year")}" if node.attr("copyright-year")
|
46
|
+
end
|
47
|
+
dn
|
48
|
+
end
|
49
|
+
|
23
50
|
def organization(org, orgname)
|
24
51
|
if ["ISO",
|
25
52
|
"International Organization for Standardization"].include? orgname
|
26
53
|
org.name "International Organization for Standardization"
|
27
54
|
org.abbreviation "ISO"
|
28
55
|
elsif ["IEC",
|
29
|
-
|
56
|
+
"International Electrotechnical Commission"].include? orgname
|
30
57
|
org.name "International Electrotechnical Commission"
|
31
58
|
org.abbreviation "IEC"
|
32
59
|
else
|
@@ -84,6 +84,9 @@
|
|
84
84
|
<zeroOrMore>
|
85
85
|
<ref name="docidentifier"/>
|
86
86
|
</zeroOrMore>
|
87
|
+
<optional>
|
88
|
+
<ref name="docnumber"/>
|
89
|
+
</optional>
|
87
90
|
<zeroOrMore>
|
88
91
|
<ref name="bdate"/>
|
89
92
|
</zeroOrMore>
|
@@ -163,6 +166,9 @@
|
|
163
166
|
<zeroOrMore>
|
164
167
|
<ref name="docidentifier"/>
|
165
168
|
</zeroOrMore>
|
169
|
+
<optional>
|
170
|
+
<ref name="docnumber"/>
|
171
|
+
</optional>
|
166
172
|
<zeroOrMore>
|
167
173
|
<ref name="bdate"/>
|
168
174
|
</zeroOrMore>
|
@@ -42,7 +42,8 @@ module Asciidoctor
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def title_subpart_validate(root)
|
45
|
-
|
45
|
+
docid = root.at("//bibdata/docidentifier[@type = 'iso']")
|
46
|
+
subpart = /-\d+-\d+/.match docid
|
46
47
|
iec = root.at("//bibdata/contributor[role/@type = 'publisher']/"\
|
47
48
|
"organization[abbreviation = 'IEC' or "\
|
48
49
|
"name = 'International Electrotechnical Commission']")
|
@@ -2,7 +2,7 @@
|
|
2
2
|
{% if tc_docnumber %}
|
3
3
|
<p class="coverpage_docnumber">{{ tc_docnumber }}</p>
|
4
4
|
{% else %}
|
5
|
-
<p class="coverpage_docnumber">{{ docnumber }}
|
5
|
+
<p class="coverpage_docnumber">{{ docnumber }}(E) {{ draftinfo }}</p>
|
6
6
|
{% endif %}
|
7
7
|
|
8
8
|
{% if revdate %}
|
@@ -10,7 +10,7 @@
|
|
10
10
|
{% endif %}
|
11
11
|
|
12
12
|
{% if tc_docnumber %}
|
13
|
-
<p class="coverpage_docnumber">{{ docnumber }}
|
13
|
+
<p class="coverpage_docnumber">{{ docnumber }}(E) {{ draftinfo }}</p>
|
14
14
|
{% endif %}
|
15
15
|
|
16
16
|
<p class="coverpage_techcommittee">{{ agency }}/{{ editorialgroup | join: "/" }}</p>
|
@@ -4,7 +4,7 @@ normal'><span lang="EN-GB" style='font-size:14.0pt;mso-no-proof:yes'>{{ tc_docnu
|
|
4
4
|
style='mso-bidi-font-weight:normal'><span lang="EN-GB" style='font-size:14.0pt'><o:p></o:p></span></b></p>
|
5
5
|
{% else %}
|
6
6
|
<p class="MsoNormal" align="right" style='text-align:right'><b style='mso-bidi-font-weight:
|
7
|
-
normal'><span lang="EN-GB" style='font-size:14.0pt;mso-no-proof:yes'>{{ docnumber }}
|
7
|
+
normal'><span lang="EN-GB" style='font-size:14.0pt;mso-no-proof:yes'>{{ docnumber }}(E) {{ draftinfo }}</span></b><b
|
8
8
|
style='mso-bidi-font-weight:normal'><span lang="EN-GB" style='font-size:14.0pt'><o:p></o:p></span></b></p>
|
9
9
|
{% endif %}
|
10
10
|
|
@@ -13,7 +13,7 @@ style='mso-bidi-font-weight:normal'><span lang="EN-GB" style='font-size:14.0pt'>
|
|
13
13
|
{% endif %}
|
14
14
|
|
15
15
|
{% if tc_docnumber %}
|
16
|
-
<p class="MsoNormal" align="right" style='text-align:right'><span lang="EN-GB" style='mso-no-proof:yes'>{{ docnumber }}
|
16
|
+
<p class="MsoNormal" align="right" style='text-align:right'><span lang="EN-GB" style='mso-no-proof:yes'>{{ docnumber }}(E) {{ draftinfo }}</span></p>
|
17
17
|
{% endif %}
|
18
18
|
|
19
19
|
<p class="MsoNormal" align="right" style='text-align:right'><span lang="EN-GB"
|
data/lib/isodoc/iso/metadata.rb
CHANGED
@@ -20,9 +20,10 @@ module IsoDoc
|
|
20
20
|
}.freeze
|
21
21
|
|
22
22
|
def stage_abbrev(stage, iter, draft)
|
23
|
+
return "" unless stage
|
23
24
|
stage = STAGE_ABBRS[stage.to_sym] || "??"
|
24
|
-
stage += iter
|
25
|
-
stage = "Pre" + stage if draft
|
25
|
+
stage += iter if iter
|
26
|
+
stage = "Pre" + stage if draft =~ /^0\./
|
26
27
|
stage
|
27
28
|
end
|
28
29
|
|
@@ -31,8 +32,8 @@ module IsoDoc
|
|
31
32
|
if docstatus
|
32
33
|
set(:stage, docstatus.text)
|
33
34
|
set(:stage_int, docstatus.text.to_i)
|
34
|
-
abbr = stage_abbrev(docstatus.text, isoxml
|
35
|
-
isoxml
|
35
|
+
abbr = stage_abbrev(docstatus.text, isoxml&.at(ns("//bibdata/status/iteration"))&.text,
|
36
|
+
isoxml&.at(ns("//version/draft"))&.text)
|
36
37
|
set(:stageabbr, abbr)
|
37
38
|
end
|
38
39
|
revdate = isoxml.at(ns("//version/revision-date"))
|
@@ -40,15 +41,9 @@ module IsoDoc
|
|
40
41
|
end
|
41
42
|
|
42
43
|
def docid(isoxml, _out)
|
43
|
-
dn =
|
44
|
-
|
45
|
-
|
46
|
-
abbr = get[:stageabbr]
|
47
|
-
docstatus = get[:stage]
|
48
|
-
(docstatus.to_i < 60) && dn = dn.sub(/ /, "/#{abbr} ")
|
49
|
-
end
|
50
|
-
set(:docnumber, dn)
|
51
|
-
tcdn = isoxml.at(ns("//bibdata/docidentifier/tc-document-number"))
|
44
|
+
dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'iso']"))
|
45
|
+
set(:docnumber, dn&.text)
|
46
|
+
tcdn = isoxml.at(ns("//bibdata/docidentifier[@type = 'iso-tc']"))
|
52
47
|
set(:tc_docnumber, tcdn&.text)
|
53
48
|
end
|
54
49
|
|
@@ -45,7 +45,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
it "processes default metadata" do
|
48
|
-
expect(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)).to be_equivalent_to <<~
|
48
|
+
expect(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)).to be_equivalent_to <<~"OUTPUT"
|
49
49
|
= Document title
|
50
50
|
Author
|
51
51
|
:docfile: test.adoc
|
@@ -56,7 +56,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
56
56
|
:partnumber: 1
|
57
57
|
:edition: 2
|
58
58
|
:revdate: 2000-01-01
|
59
|
-
:draft: 3.4
|
59
|
+
:draft: 0.3.4
|
60
60
|
:technical-committee: TC
|
61
61
|
:technical-committee-number: 1
|
62
62
|
:technical-committee-type: A
|
@@ -76,7 +76,6 @@ RSpec.describe Asciidoctor::ISO do
|
|
76
76
|
:workgroup-number_2: 31
|
77
77
|
:workgroup-type_2: C1
|
78
78
|
:secretariat: SECRETARIAT
|
79
|
-
:copyright-year: 2001
|
80
79
|
:docstage: 10
|
81
80
|
:docsubstage: 20
|
82
81
|
:iteration: 3
|
@@ -102,9 +101,11 @@ RSpec.describe Asciidoctor::ISO do
|
|
102
101
|
<title-main language="fr" format="text/plain">Titre Principal</title-main>
|
103
102
|
<title-part language="fr" format="text/plain">Part du Titre</title-part>
|
104
103
|
</title>
|
105
|
-
<docidentifier>
|
106
|
-
|
107
|
-
|
104
|
+
<docidentifier type="iso">ISO/PreNWIP3 1000-1</docidentifier>
|
105
|
+
<docidentifier type="iso-structured">
|
106
|
+
<project-number part="1">ISO 1000</project-number>
|
107
|
+
</docidentifier>
|
108
|
+
<docnumber>1000</docnumber>
|
108
109
|
<contributor>
|
109
110
|
<role type="author"/>
|
110
111
|
<organization>
|
@@ -127,7 +128,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
127
128
|
<iteration>3</iteration>
|
128
129
|
</status>
|
129
130
|
<copyright>
|
130
|
-
<from
|
131
|
+
<from>#{Date.today.year}</from>
|
131
132
|
<owner>
|
132
133
|
<organization>
|
133
134
|
<name>International Organization for Standardization</name>
|
@@ -156,7 +157,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
156
157
|
</bibdata><version>
|
157
158
|
<edition>2</edition>
|
158
159
|
<revision-date>2000-01-01</revision-date>
|
159
|
-
<draft>3.4</draft>
|
160
|
+
<draft>0.3.4</draft>
|
160
161
|
</version>
|
161
162
|
<sections/>
|
162
163
|
</iso-standard>
|
@@ -178,6 +179,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
178
179
|
:language: el
|
179
180
|
:script: Grek
|
180
181
|
:publisher: IEC,IETF,ISO
|
182
|
+
:copyright-year: 2001
|
181
183
|
INPUT
|
182
184
|
<?xml version="1.0" encoding="UTF-8"?>
|
183
185
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
@@ -188,10 +190,12 @@ RSpec.describe Asciidoctor::ISO do
|
|
188
190
|
<title>
|
189
191
|
|
190
192
|
</title>
|
191
|
-
<docidentifier>
|
193
|
+
<docidentifier type="iso">ISO/IEC/IETF 1000-1-1:2001</docidentifier>
|
194
|
+
<docidentifier type="iso-structured">
|
192
195
|
<project-number part="1" subpart="1">ISO/IEC/IETF 1000</project-number>
|
193
|
-
<tc-document-number>2000</tc-document-number>
|
194
196
|
</docidentifier>
|
197
|
+
<docidentifier type="iso-tc">2000</docidentifier>
|
198
|
+
<docnumber>1000</docnumber>
|
195
199
|
<contributor>
|
196
200
|
<role type="author"/>
|
197
201
|
<organization>
|
@@ -239,7 +243,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
239
243
|
<substage>60</substage>
|
240
244
|
</status>
|
241
245
|
<copyright>
|
242
|
-
<from>
|
246
|
+
<from>2001</from>
|
243
247
|
<owner>
|
244
248
|
<organization>
|
245
249
|
<name>International Electrotechnical Commission</name>
|
@@ -248,7 +252,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
248
252
|
</owner>
|
249
253
|
</copyright>
|
250
254
|
<copyright>
|
251
|
-
<from>
|
255
|
+
<from>2001</from>
|
252
256
|
<owner>
|
253
257
|
<organization>
|
254
258
|
<name>IETF</name>
|
@@ -256,7 +260,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
256
260
|
</owner>
|
257
261
|
</copyright>
|
258
262
|
<copyright>
|
259
|
-
<from>
|
263
|
+
<from>2001</from>
|
260
264
|
<owner>
|
261
265
|
<organization>
|
262
266
|
<name>International Organization for Standardization</name>
|