metanorma-iso 2.1.1 → 2.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/html2doc/lists.rb +145 -10
- data/lib/isodoc/iso/base_convert.rb +10 -0
- data/lib/isodoc/iso/html/html_iso_titlepage.html +2 -0
- data/lib/isodoc/iso/html/isodoc-dis.css +173 -257
- data/lib/isodoc/iso/html/isodoc-dis.scss +173 -249
- data/lib/isodoc/iso/html/isodoc.css +38 -13
- data/lib/isodoc/iso/html/isodoc.scss +38 -12
- data/lib/isodoc/iso/html/style-human.css +14 -1
- data/lib/isodoc/iso/html/style-human.scss +10 -1
- data/lib/isodoc/iso/html/style-iso.css +35 -23
- data/lib/isodoc/iso/html/style-iso.scss +31 -23
- data/lib/isodoc/iso/html/word_iso_intro-dis.html +1 -6
- data/lib/isodoc/iso/html/word_iso_titlepage-dis.html +24 -13
- data/lib/isodoc/iso/html/word_iso_titlepage-prf.html +58 -0
- data/lib/isodoc/iso/html/word_iso_titlepage.html +6 -2
- data/lib/isodoc/iso/html_convert.rb +5 -0
- data/lib/isodoc/iso/i18n-en.yaml +32 -4
- data/lib/isodoc/iso/i18n-fr.yaml +29 -3
- data/lib/isodoc/iso/i18n-ru.yaml +32 -4
- data/lib/isodoc/iso/i18n-zh-Hans.yaml +32 -3
- data/lib/isodoc/iso/i18n.rb +1 -1
- data/lib/isodoc/iso/iso.amendment.xsl +750 -307
- data/lib/isodoc/iso/iso.international-standard.xsl +750 -307
- data/lib/isodoc/iso/metadata.rb +63 -63
- data/lib/isodoc/iso/presentation_bibdata.rb +74 -0
- data/lib/isodoc/iso/presentation_xml_convert.rb +15 -4
- data/lib/isodoc/iso/presentation_xref.rb +8 -2
- data/lib/isodoc/iso/sections.rb +1 -1
- data/lib/isodoc/iso/word_cleanup.rb +3 -0
- data/lib/isodoc/iso/word_convert.rb +6 -3
- data/lib/isodoc/iso/word_dis_cleanup.rb +243 -0
- data/lib/isodoc/iso/word_dis_convert.rb +47 -108
- data/lib/isodoc/iso/xref.rb +34 -6
- data/lib/metanorma/iso/base.rb +14 -1
- data/lib/metanorma/iso/biblio.rng +134 -39
- data/lib/metanorma/iso/boilerplate-fr.xml +3 -0
- data/lib/metanorma/iso/boilerplate-ru.xml +3 -0
- data/lib/metanorma/iso/boilerplate.xml +3 -0
- data/lib/metanorma/iso/cleanup.rb +53 -13
- data/lib/metanorma/iso/front.rb +38 -6
- data/lib/metanorma/iso/front_id.rb +2 -0
- data/lib/metanorma/iso/isodoc.rng +32 -0
- data/lib/metanorma/iso/isostandard.rng +32 -12
- data/lib/metanorma/iso/validate_section.rb +0 -12
- data/lib/metanorma/iso/version.rb +1 -1
- data/spec/isodoc/amd_spec.rb +4 -30
- data/spec/isodoc/blocks_spec.rb +499 -2
- data/spec/isodoc/i18n_spec.rb +145 -80
- data/spec/isodoc/iso_spec.rb +50 -169
- data/spec/isodoc/metadata_spec.rb +223 -83
- data/spec/isodoc/postproc_spec.rb +41 -5
- data/spec/isodoc/section_spec.rb +9 -9
- data/spec/isodoc/word_dis_spec.rb +1332 -146
- data/spec/isodoc/xref_spec.rb +87 -13
- data/spec/metanorma/amd_spec.rb +39 -23
- data/spec/metanorma/base_spec.rb +174 -44
- data/spec/metanorma/blocks_spec.rb +21 -0
- data/spec/metanorma/cleanup_spec.rb +196 -196
- data/spec/metanorma/lists_spec.rb +2 -2
- data/spec/metanorma/section_spec.rb +2 -2
- data/spec/metanorma/validate_spec.rb +8 -19
- data/spec/spec_helper.rb +10 -7
- data/spec/vcr_cassettes/withdrawn_iso.yml +30 -30
- metadata +6 -8
- data/docs/asciiiso-syntax.adoc +0 -307
- data/docs/guidance.adoc +0 -487
- data/docs/navigation.adoc +0 -23
- data/docs/quickstart.adoc +0 -179
- data/lib/isodoc/iso/presentation_inline.rb +0 -90
data/docs/quickstart.adoc
DELETED
@@ -1,179 +0,0 @@
|
|
1
|
-
= Quickstart Guide
|
2
|
-
|
3
|
-
TIP: This guide has been authored for ISO standards, but most of it applies to all Metanorma standards. We indicate where guidance differs for different standards classes. See link:https://www.metanorma.com/software/Metanorma_processor/[List of Metanorma processors].
|
4
|
-
|
5
|
-
This is a guide on how to get started using Metanorma to create documents aligned with different standards classes (such as ISO, GB, CSD, etc), in Microsoft Word and HTML formats. This guide is written to apply generically across the standards classes that can be expressed in Metanorma; guidance specific to a particular standards class is given as TIPs.
|
6
|
-
|
7
|
-
Metanorma takes text in the _Asciidoctor markup language_ as input (consult the https://asciidoctor.org/docs/user-manual/[Asciidoctor User Manual] on the basics of this markup language).
|
8
|
-
Metanorma makes some adjustments to the text format for its requirements;
|
9
|
-
these adjustments (which we refer to as _Metanorma Asciidoctor_, or AsciiISO) are documented in relevant sections of this documentation.
|
10
|
-
Metanorma uses Asciidoctor to generate _Metanorma XML_, as an intermediate, semantic representation of standards content.
|
11
|
-
Metanorma XML in turn is processed by the https://github.com/metanorma/isodoc[isodoc] gem to generate output in Microsoft Word (`.doc`) and HTML (`.html`).
|
12
|
-
|
13
|
-
== Even quicker summary
|
14
|
-
|
15
|
-
In order to start a new Metanorma document, or migrate your document from Word:
|
16
|
-
|
17
|
-
. Install <<installation>> (for your specific Metanorma standards class)
|
18
|
-
. Clone the https://github.com/metanorma/isodoc-rice/[AsciiISO Rice]
|
19
|
-
|
20
|
-
To migrate:
|
21
|
-
|
22
|
-
. Use our https://github.com/metanorma/reverse_asciidoctor[reverse_asciidoctor] gem to help you convert a Word document into Asciidoctor. Be warned that the conversion will not be 100% clean, and you will have to manually fix some syntax (especially if your Word document contains an index, stray anchors, and equations).
|
23
|
-
. Move the content back to the cloned isodoc-rice.
|
24
|
-
. The isodoc-rice repository is set up for the ISO standards class; if you are not working with ISO, change its makefile to refer to the correct standards class (e.g. from `bundle exec metanorma -t iso -x doc,xml,html $^` to `bundle exec metanorma -t rsd -x doc,xml,html $^`
|
25
|
-
|
26
|
-
[[supported-standards]]
|
27
|
-
== Supported standards
|
28
|
-
|
29
|
-
|
30
|
-
As of this writing, Metanorma supports the following standards classes:
|
31
|
-
|
32
|
-
* https://github.com/metanorma/metanorma-iso[ISO and IEC] (`iso`)
|
33
|
-
* https://github.com/metanorma/metanorma-gb[Chinese National standards] (`gb`)
|
34
|
-
* https://github.com/metanorma/metanorma-csd[Calconnect] (`csd`)
|
35
|
-
* https://github.com/metanorma/metanorma-csand[Cloud Security Alliance] (`csand`)
|
36
|
-
* https://github.com/metanorma/metanorma-m3d[Messaging, Malware and Mobile Anti-Abuse Working Group (M^3^AAWG)] (`m3d`)
|
37
|
-
* https://github.com/metanorma/metanorma-rsd[Ribose] (`rsd`)
|
38
|
-
* https://github.com/metanorma/metanorma-acme[Acme (shell for user-customised standards)] (`acme`)
|
39
|
-
* https://github.com/metanorma/metanorma-mpfd[Mandatory Provident Fund Schemes Authority, Hong Kong (MPFA)] (`mpfd`)
|
40
|
-
* https://github.com/metanorma/metanorma-unece[United Nations Economic Commission for Europe] (`unece`)
|
41
|
-
|
42
|
-
== Installing on Linux and macOS
|
43
|
-
|
44
|
-
Install Metanorma-ISO gem and its dependencies:
|
45
|
-
|
46
|
-
You can install the metanorma-cli gem, and all its dependencies, through the Ruby gem installer:
|
47
|
-
|
48
|
-
|
49
|
-
[source,console]
|
50
|
-
--
|
51
|
-
gem install metanorma-cli
|
52
|
-
--
|
53
|
-
|
54
|
-
If you want the latest version (note: may not be stable due to active development),
|
55
|
-
you can install it from Github:
|
56
|
-
|
57
|
-
[source,console]
|
58
|
-
--
|
59
|
-
git clone https://github.com/metanorma/metanorma-cli.git
|
60
|
-
cd metanorma-cli
|
61
|
-
gem build *.gemspec
|
62
|
-
gem install *.gem
|
63
|
-
bundle update
|
64
|
-
--
|
65
|
-
|
66
|
-
The final `bundle update` step updates the dependent gems, and is necessary because those gems are even more heavily under development.
|
67
|
-
|
68
|
-
[TIP]
|
69
|
-
====
|
70
|
-
The Metanorma tool is a suite of https://en.wikipedia.org/wiki/RubyGems[Ruby gems], and works on the command line. The https://en.wikipedia.org/wiki/Ruby_programming_language[Ruby programming language] can be installed on Windows (e.g. https://rubyinstaller.org), but is typically run on a Unix command line—including Linux and MacOS. The following instructions are for the Unix console.
|
71
|
-
|
72
|
-
The starting poing of the Metanorma tool is the `metanorma-cli` gem (command line interface); it references various other gems that the tool is based on, including the converter from Asciidoctor to Metanorma XML (`metanorma-standoc`), the converters from Metanorma XML to HTML and Word (`isodoc`, `html2doc`), the variants of Metanorma for different standards classes (`metanorma-iso`, `metanorma-csd`, etc.), and tools for processing bibliographies (`relaton`, `isobib` etc.)
|
73
|
-
|
74
|
-
The Metanorma tools processing Asciidoctor, in turn, build on the https://asciidoctor.org[Asciidoctor gem], which interprets the Asciidoctor markup language in Ruby. Installing the Metanorma gem will install the Asciidoctor gem, if it is not already installed.
|
75
|
-
|
76
|
-
Ruby comes with Linux and MacOS. Asciidoctor-ISO uses at minimum Ruby 2.3.0, and you may need to update your Ruby instance to use that version. Refer to https://www.ruby-lang.org/en/documentation/installation/
|
77
|
-
====
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
== Setting up a new project
|
83
|
-
|
84
|
-
At its simplest, all you need is a text document in Asciidoctor-like AsciiISO format,
|
85
|
-
which you compile using the Metanorma-ISO gem.
|
86
|
-
|
87
|
-
To keep document dependencies in order, place your document in a distinct folder:
|
88
|
-
|
89
|
-
|
90
|
-
[source,console]
|
91
|
-
--
|
92
|
-
mkdir new_standard
|
93
|
-
cd new_standard
|
94
|
-
vi new_standard.adoc
|
95
|
-
--
|
96
|
-
|
97
|
-
To compile the document, execute the `asciidoctor` script, flagging it to use a specific standards class with the `-t` flag (refer to <<stupported-standards>> for the abbreviations used); e.g.
|
98
|
-
|
99
|
-
[source,console]
|
100
|
-
--
|
101
|
-
metanorma -t iso new_standard.adoc
|
102
|
-
--
|
103
|
-
|
104
|
-
This will generate two files from the `new_standard.adoc` document (provided it is well-formed):
|
105
|
-
|
106
|
-
* `new_standard.html`, a standalone HTML document,
|
107
|
-
* `new_standard.doc`, a Word document
|
108
|
-
(currently in the pre-2007 `.doc` format, but Microsoft Word will open it fine).
|
109
|
-
|
110
|
-
Both these files are generated via an intermediate XML file, `new_standard.xml`, which represents the structure of the document as it is formally defined by the standards body, and captured in the https://github.com/metanorma/metanorma-model-iso[Metanorma XML schema].
|
111
|
-
|
112
|
-
Even if there are no errors in the Asciidoctor syntax, the document may still raise warnings to the console as it is being validated. The validation comes from the formal definition of the standard class (e.g. ISO/IEC DIR 2 in the case of ISO and IEC), and consists of two parts: warnings about document content (e.g., for ISO, requiring space before a percentage sign; requiring that the scope not contain text that looks like a recommendation); and warnings about document structure. The latter are generated by running the generated XML against the ISOXML schema, and report the line numbers of the XML document where issues are observed.
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
Even if there are no errors in the syntax, the document may still raise warnings
|
117
|
-
to the console as it is being validated.
|
118
|
-
The validation comes from ISO/IEC DIR 2, and consists of two parts:
|
119
|
-
|
120
|
-
* Warnings about document content
|
121
|
-
(e.g., requiring space before a percentage sign,
|
122
|
-
or requiring that the scope not contain text that looks like a recommendation).
|
123
|
-
* Warnings about document structure
|
124
|
-
(found from running the generated XML against the ISOXML schema,
|
125
|
-
they report the line numbers of the XML document where issues are observed).
|
126
|
-
|
127
|
-
== Starting with an example project
|
128
|
-
|
129
|
-
Perhaps the simplest way to get started is to take an existing Metanorma-ISO document
|
130
|
-
and edit it, observing how it approaches various formatting tasks.
|
131
|
-
|
132
|
-
The https://www.iso.org/publication/PUB100407.html["Rice document"]
|
133
|
-
is the ISO's model document of an international standard.
|
134
|
-
An Metanorma-ISO version of the document is available
|
135
|
-
at https://github.com/metanorma/isodoc-rice/.
|
136
|
-
We suggest downloading the site, and editing it.
|
137
|
-
|
138
|
-
The `iso-rice-en.adoc` document consists of a document header,
|
139
|
-
and it references the separate `body/body-en.adoc` document for the document proper (`include::body/body-en.adoc[]`).
|
140
|
-
You can just continue on with the document text after the document header—so long as you remember to leave a blank line between the two.
|
141
|
-
|
142
|
-
== Learning the AsciiDoc-based syntax
|
143
|
-
|
144
|
-
To author AsciiDoc documents, you need to be familiar with the _core AsciiDoc syntax_,
|
145
|
-
as well as _the syntax extensions and conventions_ that are specific to Metanorma-ISO.
|
146
|
-
|
147
|
-
- Check out link:asciiiso-syntax[our AsciiISO syntax reference],
|
148
|
-
and link:guidance.adoc[Guidance for Authoring in Metanorma-ISO].
|
149
|
-
|
150
|
-
- See also https://asciidoctor.org/docs/user-manual/[Asciidoctor User Manual]
|
151
|
-
documenting Asciidoctor itself
|
152
|
-
and https://github.com/metanorma/metanorma-iso/blob/master/README.adoc[Metanorma-ISO README].
|
153
|
-
|
154
|
-
== Migrating existing documents from Microsoft Word
|
155
|
-
|
156
|
-
. Use our https://github.com/metanorma/reverse_asciidoctor[reverse_asciidoctor]
|
157
|
-
gem to help you convert a Word document into AsciiISO.
|
158
|
-
+
|
159
|
-
You will likely have to manually clean up some syntax
|
160
|
-
(especially if your Word document contains an index, stray anchors, and equations):
|
161
|
-
don’t rely on the automatic conversion to be 100% correct.
|
162
|
-
|
163
|
-
- Check out link:asciiiso-syntax[our AsciiISO syntax reference],
|
164
|
-
and link:guidance.adoc[Guidance for Authoring in Asciidoctor-ISO].
|
165
|
-
|
166
|
-
- See also https://asciidoctor.org/docs/user-manual/[Asciidoctor User Manual]
|
167
|
-
documenting Asciidoctor itself
|
168
|
-
and https://github.com/metanorma/metanorma-iso/blob/master/README.adoc[Metanorma-ISO README].
|
169
|
-
|
170
|
-
== Migrating existing documents from Microsoft Word:
|
171
|
-
|
172
|
-
. Use our https://github.com/metanorma/reverse_asciidoctor[reverse_asciidoctor]
|
173
|
-
gem to help you convert a Word document into AsciiISO.
|
174
|
-
|
175
|
-
You will likely have to manually clean up some syntax
|
176
|
-
(especially if your Word document contains an index, stray anchors, and equations):
|
177
|
-
don’t rely on the automatic conversion to be 100% correct.
|
178
|
-
. Move the content back to the cloned isodoc-rice.
|
179
|
-
|
@@ -1,90 +0,0 @@
|
|
1
|
-
module IsoDoc
|
2
|
-
module Iso
|
3
|
-
class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
|
4
|
-
def xref_init(lang, script, klass, labels, options)
|
5
|
-
@xrefs = Xref.new(lang, script, klass, labels, options)
|
6
|
-
end
|
7
|
-
|
8
|
-
def eref_delim(delim, type)
|
9
|
-
if delim == ";" then ";"
|
10
|
-
else type == "list" ? " " : delim
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def can_conflate_eref_rendering?(refs)
|
15
|
-
super or return false
|
16
|
-
|
17
|
-
first = subclause?(nil, refs.first.at(ns("./locality/@type"))&.text,
|
18
|
-
refs.first.at(ns("./locality/referenceFrom"))&.text)
|
19
|
-
refs.all? do |r|
|
20
|
-
subclause?(nil, r.at(ns("./locality/@type"))&.text,
|
21
|
-
r.at(ns("./locality/referenceFrom"))&.text) == first
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def locality_delimiter(loc)
|
26
|
-
loc&.next_element&.attribute("type")&.text == "list" and return " "
|
27
|
-
super
|
28
|
-
end
|
29
|
-
|
30
|
-
def eref_localities_conflated(refs, target, node)
|
31
|
-
droploc = node["droploc"]
|
32
|
-
node["droploc"] = true
|
33
|
-
ret = resolve_eref_connectives(eref_locality_stacks(refs, target,
|
34
|
-
node))
|
35
|
-
node["droploc"] = droploc
|
36
|
-
eref_localities1(target,
|
37
|
-
prefix_clause(target, refs.first.at(ns("./locality"))),
|
38
|
-
l10n(ret[1..-1].join), nil, node, @lang)
|
39
|
-
end
|
40
|
-
|
41
|
-
def prefix_clause(target, loc)
|
42
|
-
loc["type"] == "clause" or return loc["type"]
|
43
|
-
|
44
|
-
if subclause?(target, loc["type"],
|
45
|
-
loc&.at(ns("./referenceFrom"))&.text)
|
46
|
-
""
|
47
|
-
else
|
48
|
-
"clause"
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def subclause?(target, type, from)
|
53
|
-
(from&.match?(/\./) && type == "clause") ||
|
54
|
-
type == "list" || target&.match(/^IEV$|^IEC 60050-/)
|
55
|
-
end
|
56
|
-
|
57
|
-
def eref_localities1_zh(target, type, from, upto, node)
|
58
|
-
ret = " 第#{from}" if from
|
59
|
-
ret += "–#{upto}" if upto
|
60
|
-
if node["droploc"] != "true" && !subclause?(target, type, from)
|
61
|
-
ret += eref_locality_populate(type, node)
|
62
|
-
end
|
63
|
-
ret += ")" if type == "list"
|
64
|
-
ret
|
65
|
-
end
|
66
|
-
|
67
|
-
def eref_localities1(target, type, from, upto, node, lang = "en")
|
68
|
-
return nil if type == "anchor"
|
69
|
-
|
70
|
-
type = type.downcase
|
71
|
-
lang == "zh" and
|
72
|
-
return l10n(eref_localities1_zh(target, type, from, upto, node))
|
73
|
-
ret = if node["droploc"] != "true" && !subclause?(target, type,
|
74
|
-
from)
|
75
|
-
eref_locality_populate(type, node)
|
76
|
-
else ""
|
77
|
-
end
|
78
|
-
ret += " #{from}" if from
|
79
|
-
ret += "–#{upto}" if upto
|
80
|
-
ret += ")" if type == "list"
|
81
|
-
l10n(ret)
|
82
|
-
end
|
83
|
-
|
84
|
-
def prefix_container(container, linkend, target)
|
85
|
-
delim = @xrefs.anchor(target, :type) == "listitem" ? " " : ", "
|
86
|
-
l10n(@xrefs.anchor(container, :xref) + delim + linkend)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|