metanorma-iso 1.3.22 → 1.3.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +8 -7
- data/.github/workflows/ubuntu.yml +8 -7
- data/.github/workflows/windows.yml +8 -8
- data/Gemfile +2 -0
- data/lib/asciidoctor/iso/base.rb +22 -0
- data/lib/asciidoctor/iso/biblio.rng +89 -32
- data/lib/asciidoctor/iso/cleanup.rb +20 -3
- data/lib/asciidoctor/iso/front.rb +16 -107
- data/lib/asciidoctor/iso/front_id.rb +196 -0
- data/lib/asciidoctor/iso/isodoc.rng +475 -2
- data/lib/asciidoctor/iso/isostandard-amd.rng +98 -0
- data/lib/asciidoctor/iso/isostandard.rng +12 -1
- data/lib/asciidoctor/iso/macros.rb +21 -0
- data/lib/asciidoctor/iso/reqt.rng +23 -0
- data/lib/asciidoctor/iso/section.rb +18 -32
- data/lib/asciidoctor/iso/term_lookup_cleanup.rb +87 -0
- data/lib/asciidoctor/iso/validate.rb +41 -25
- data/lib/asciidoctor/iso/validate_requirements.rb +1 -1
- data/lib/asciidoctor/iso/validate_section.rb +2 -2
- data/lib/asciidoctor/iso/validate_style.rb +6 -5
- data/lib/asciidoctor/iso/validate_title.rb +1 -1
- data/lib/isodoc/iso/base_convert.rb +77 -107
- data/lib/isodoc/iso/html/header.html +10 -6
- data/lib/isodoc/iso/html/html_iso_titlepage.html +27 -18
- data/lib/isodoc/iso/html/isodoc.scss +53 -28
- data/lib/isodoc/iso/html/scripts.html +23 -21
- data/lib/isodoc/iso/html/style-human.scss +23 -0
- data/lib/isodoc/iso/html/style-iso.scss +18 -0
- data/lib/isodoc/iso/html/word_iso_intro.html +4 -0
- data/lib/isodoc/iso/html/word_iso_titlepage.html +23 -2
- data/lib/isodoc/iso/html/wordstyle.scss +80 -39
- data/lib/isodoc/iso/html_convert.rb +7 -9
- data/lib/isodoc/iso/iso.amendment.xsl +4597 -0
- data/lib/isodoc/iso/iso.international-standard.xsl +4597 -0
- data/lib/isodoc/iso/metadata.rb +71 -23
- data/lib/isodoc/iso/pdf_convert.rb +39 -0
- data/lib/isodoc/iso/sections.rb +66 -0
- data/lib/isodoc/iso/sts_convert.rb +29 -0
- data/lib/isodoc/iso/xref.rb +105 -0
- data/lib/metanorma-iso.rb +2 -0
- data/lib/metanorma/iso/processor.rb +16 -1
- data/lib/metanorma/iso/version.rb +1 -1
- data/metanorma-iso.gemspec +4 -1
- data/spec/asciidoctor-iso/amd_spec.rb +726 -0
- data/spec/asciidoctor-iso/base_spec.rb +38 -21
- data/spec/asciidoctor-iso/blocks_spec.rb +6 -6
- data/spec/asciidoctor-iso/cleanup_spec.rb +195 -174
- data/spec/asciidoctor-iso/inline_spec.rb +2 -1
- data/spec/asciidoctor-iso/macros_spec.rb +289 -0
- data/spec/asciidoctor-iso/refs_spec.rb +8 -5
- data/spec/asciidoctor-iso/section_spec.rb +8 -8
- data/spec/assets/iso.xml +64 -1
- data/spec/isodoc/amd_spec.rb +652 -0
- data/spec/isodoc/blocks_spec.rb +112 -27
- data/spec/isodoc/i18n_spec.rb +12 -20
- data/spec/isodoc/inline_spec.rb +4 -4
- data/spec/isodoc/iso_spec.rb +1 -1
- data/spec/isodoc/metadata_spec.rb +92 -4
- data/spec/isodoc/postproc_spec.rb +21 -120
- data/spec/isodoc/ref_spec.rb +9 -9
- data/spec/isodoc/section_spec.rb +36 -13
- data/spec/isodoc/table_spec.rb +30 -30
- data/spec/isodoc/terms_spec.rb +6 -6
- data/spec/isodoc/xref_spec.rb +43 -37
- data/spec/metanorma/processor_spec.rb +2 -2
- data/spec/spec_helper.rb +11 -0
- metadata +58 -5
- data/asciidoctor-iso.gemspec.old +0 -50
data/lib/isodoc/iso/metadata.rb
CHANGED
@@ -6,19 +6,25 @@ module IsoDoc
|
|
6
6
|
def initialize(lang, script, labels)
|
7
7
|
super
|
8
8
|
@metadata = {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
tc: "XXXX",
|
10
|
+
sc: "XXXX",
|
11
|
+
wg: "XXXX",
|
12
|
+
editorialgroup: [],
|
13
|
+
secretariat: "XXXX",
|
14
|
+
obsoletes: nil,
|
15
|
+
obsoletes_part: nil
|
16
|
+
}
|
17
17
|
end
|
18
18
|
|
19
|
-
def status_abbrev(stage, substage, iter, draft)
|
19
|
+
def status_abbrev(stage, substage, iter, draft, doctype)
|
20
20
|
return "" unless stage
|
21
|
-
|
21
|
+
if %w(technical-report technical-specification).include?(doctype)
|
22
|
+
stage = "DTS" if stage == "DIS"
|
23
|
+
stage = "FDTS" if stage == "FDIS"
|
24
|
+
end
|
25
|
+
if %w(PWI NWIP WD CD).include?(stage)
|
26
|
+
stage += iter if iter
|
27
|
+
end
|
22
28
|
stage = "Pre" + stage if draft =~ /^0\./
|
23
29
|
stage
|
24
30
|
end
|
@@ -33,7 +39,8 @@ module IsoDoc
|
|
33
39
|
set(:statusabbr, status_abbrev(docstatus["abbreviation"] || "??",
|
34
40
|
isoxml&.at(ns("//bibdata/status/substage"))&.text,
|
35
41
|
isoxml&.at(ns("//bibdata/status/iteration"))&.text,
|
36
|
-
isoxml&.at(ns("//version/draft"))&.text
|
42
|
+
isoxml&.at(ns("//version/draft"))&.text,
|
43
|
+
isoxml&.at(ns("//bibdata/ext/doctype"))&.text))
|
37
44
|
unpublished(docstatus.text) and
|
38
45
|
set(:stageabbr, docstatus["abbreviation"])
|
39
46
|
end
|
@@ -46,10 +53,14 @@ module IsoDoc
|
|
46
53
|
end
|
47
54
|
|
48
55
|
def docid(isoxml, _out)
|
49
|
-
dn = isoxml.at(ns("//bibdata/docidentifier[@type = '
|
56
|
+
dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'ISO']"))
|
50
57
|
set(:docnumber, dn&.text)
|
51
58
|
tcdn = isoxml.xpath(ns("//bibdata/docidentifier[@type = 'iso-tc']"))
|
52
59
|
set(:tc_docnumber, tcdn.map { |n| n.text })
|
60
|
+
dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'iso-with-lang']"))
|
61
|
+
set(:docnumber_lang, dn&.text)
|
62
|
+
dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'iso-reference']"))
|
63
|
+
set(:docnumber_reference, dn&.text)
|
53
64
|
end
|
54
65
|
|
55
66
|
# we don't leave this to i18n.rb, because we have both English and
|
@@ -61,6 +72,20 @@ module IsoDoc
|
|
61
72
|
end
|
62
73
|
end
|
63
74
|
|
75
|
+
def amd_label(lang)
|
76
|
+
case lang
|
77
|
+
when "en" then "AMENDMENT"
|
78
|
+
when "fr" then "AMENDMENT"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def corr_label(lang)
|
83
|
+
case lang
|
84
|
+
when "en" then "TECHNICAL CORRIGENDUM"
|
85
|
+
when "fr" then "RECTIFICATIF TECHNIQUE"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
64
89
|
def part_title(part, partnum, subpartnum, lang)
|
65
90
|
return "" unless part
|
66
91
|
suffix = @c.encode(part.text, :hexadecimal)
|
@@ -74,6 +99,14 @@ module IsoDoc
|
|
74
99
|
"#{part_label(lang)} #{partnum}"
|
75
100
|
end
|
76
101
|
|
102
|
+
def amd_prefix(num, lang)
|
103
|
+
"#{amd_label(lang)} #{num}"
|
104
|
+
end
|
105
|
+
|
106
|
+
def corr_prefix(num, lang)
|
107
|
+
"#{corr_label(lang)} #{num}"
|
108
|
+
end
|
109
|
+
|
77
110
|
def compose_title(main, intro, part, partnum, subpartnum, lang)
|
78
111
|
main = main.nil? ? "" : @c.encode(main.text, :hexadecimal)
|
79
112
|
intro &&
|
@@ -85,12 +118,23 @@ module IsoDoc
|
|
85
118
|
main
|
86
119
|
end
|
87
120
|
|
121
|
+
def title_nums(isoxml)
|
122
|
+
[isoxml.at(ns("//bibdata//project-number/@part")),
|
123
|
+
isoxml.at(ns("//bibdata//project-number/@subpart")),
|
124
|
+
isoxml.at(ns("//bibdata//project-number/@amendment")),
|
125
|
+
isoxml.at(ns("//bibdata//project-number/@corrigendum"))]
|
126
|
+
end
|
127
|
+
|
128
|
+
def title_parts(isoxml, lang)
|
129
|
+
[isoxml.at(ns("//bibdata//title[@type='title-intro' and @language='#{lang}']")),
|
130
|
+
isoxml.at(ns("//bibdata//title[@type='title-main' and @language='#{lang}']")),
|
131
|
+
isoxml.at(ns("//bibdata//title[@type='title-part' and @language='#{lang}']")),
|
132
|
+
isoxml.at(ns("//bibdata//title[@type='title-amd' and @language='#{lang}']"))]
|
133
|
+
end
|
134
|
+
|
88
135
|
def title(isoxml, _out)
|
89
|
-
intro = isoxml
|
90
|
-
|
91
|
-
part = isoxml.at(ns("//bibdata//title[@type='title-part' and @language='en']"))
|
92
|
-
partnumber = isoxml.at(ns("//bibdata//project-number/@part"))
|
93
|
-
subpartnumber = isoxml.at(ns("//bibdata//project-number/@subpart"))
|
136
|
+
intro, main, part, amd = title_parts(isoxml, "en")
|
137
|
+
partnumber, subpartnumber, amdnumber, corrnumber = title_nums(isoxml)
|
94
138
|
|
95
139
|
set(:doctitlemain, @c.encode(main ? main.text : "", :hexadecimal))
|
96
140
|
main = compose_title(main, intro, part, partnumber, subpartnumber, "en")
|
@@ -98,20 +142,24 @@ module IsoDoc
|
|
98
142
|
set(:doctitleintro, @c.encode(intro ? intro.text : "", :hexadecimal)) if intro
|
99
143
|
set(:doctitlepartlabel, part_prefix(partnumber, subpartnumber, "en"))
|
100
144
|
set(:doctitlepart, @c.encode(part.text, :hexadecimal)) if part
|
145
|
+
set(:doctitleamdlabel, amd_prefix(amdnumber, "en")) if amdnumber
|
146
|
+
set(:doctitleamd, @c.encode(amd.text, :hexadecimal)) if amd
|
147
|
+
set(:doctitlecorrlabel, corr_prefix(corrnumber, "en")) if corrnumber
|
101
148
|
end
|
102
149
|
|
103
150
|
def subtitle(isoxml, _out)
|
104
|
-
intro = isoxml
|
105
|
-
|
106
|
-
|
107
|
-
partnumber = isoxml.at(ns("//bibdata//project-number/@part"))
|
108
|
-
subpartnumber = isoxml.at(ns("//bibdata//project-number/@subpart"))
|
151
|
+
intro, main, part, amd = title_parts(isoxml, "fr")
|
152
|
+
partnumber, subpartnumber, amdnumber, corrnumber = title_nums(isoxml)
|
153
|
+
|
109
154
|
set(:docsubtitlemain, @c.encode(main ? main.text : "", :hexadecimal))
|
110
155
|
main = compose_title(main, intro, part, partnumber, subpartnumber, "fr")
|
111
156
|
set(:docsubtitle, main)
|
112
157
|
set(:docsubtitleintro, @c.encode(intro ? intro.text : "", :hexadecimal)) if intro
|
113
158
|
set(:docsubtitlepartlabel, part_prefix(partnumber, subpartnumber, "fr"))
|
114
159
|
set(:docsubtitlepart, @c.encode(part.text, :hexadecimal)) if part
|
160
|
+
set(:docsubtitleamdlabel, amd_prefix(amdnumber, "fr")) if amdnumber
|
161
|
+
set(:docsubtitleamd, @c.encode(amd.text, :hexadecimal)) if amd
|
162
|
+
set(:docsubtitlecorrlabel, corr_prefix(corrnumber, "fr")) if corrnumber
|
115
163
|
end
|
116
164
|
|
117
165
|
def author(xml, _out)
|
@@ -162,7 +210,7 @@ module IsoDoc
|
|
162
210
|
super
|
163
211
|
ics = []
|
164
212
|
isoxml.xpath(ns("//bibdata/ext/ics/code")).each { |i| ics << i.text }
|
165
|
-
set(:ics, ics.empty? ?
|
213
|
+
set(:ics, ics.empty? ? nil : ics.join(", "))
|
166
214
|
end
|
167
215
|
end
|
168
216
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative "base_convert"
|
2
|
+
require "isodoc"
|
3
|
+
|
4
|
+
module IsoDoc
|
5
|
+
module Iso
|
6
|
+
|
7
|
+
# A {Converter} implementation that generates HTML output, and a document
|
8
|
+
# schema encapsulation of the document for validation
|
9
|
+
#
|
10
|
+
class PdfConvert < IsoDoc::XslfoPdfConvert
|
11
|
+
def initialize(options)
|
12
|
+
@libdir = File.dirname(__FILE__)
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def pdf_stylesheet(docxml)
|
17
|
+
case doctype = docxml&.at(ns("//bibdata/ext/doctype"))&.text
|
18
|
+
when "amendment", "technical-corrigendum" then "itu.recommendation-annex.xsl"
|
19
|
+
else
|
20
|
+
"iso.international-standard.xsl"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def convert(filename, file = nil, debug = false)
|
25
|
+
file = File.read(filename, encoding: "utf-8") if file.nil?
|
26
|
+
docxml, outname_html, dir = convert_init(file, filename, debug)
|
27
|
+
/\.xml$/.match(filename) or
|
28
|
+
filename = Tempfile.open([outname_html, ".xml"], encoding: "utf-8") do |f|
|
29
|
+
f.write file
|
30
|
+
f.path
|
31
|
+
end
|
32
|
+
FileUtils.rm_rf dir
|
33
|
+
::Metanorma::Output::XslfoPdf.new.convert(
|
34
|
+
filename, outname_html + ".pdf", File.join(@libdir, pdf_stylesheet(docxml)))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
module Iso
|
3
|
+
module BaseConvert
|
4
|
+
def middle_title(out)
|
5
|
+
middle_title_main(out)
|
6
|
+
middle_title_amd(out)
|
7
|
+
end
|
8
|
+
|
9
|
+
def middle_title_main(out)
|
10
|
+
out.p(**{ class: "zzSTDTitle1" }) do |p|
|
11
|
+
p << @meta.get[:doctitleintro]
|
12
|
+
p << " — " if @meta.get[:doctitleintro] && @meta.get[:doctitlemain]
|
13
|
+
p << @meta.get[:doctitlemain]
|
14
|
+
p << " — " if @meta.get[:doctitlemain] && @meta.get[:doctitlepart]
|
15
|
+
end
|
16
|
+
a = @meta.get[:doctitlepart] and out.p(**{ class: "zzSTDTitle2" }) do |p|
|
17
|
+
b = @meta.get[:doctitlepartlabel] and p << "#{b}: "
|
18
|
+
p << "<br/><b>#{a}</b>"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def middle_title_amd(out)
|
23
|
+
a = @meta.get[:doctitleamdlabel] and out.p(**{ class: "zzSTDTitle2" }) do |p|
|
24
|
+
p << a
|
25
|
+
a = @meta.get[:doctitleamd] and p << ": #{a}"
|
26
|
+
end
|
27
|
+
a = @meta.get[:doctitlecorrlabel] and out.p(**{ class: "zzSTDTitle2" }) do |p|
|
28
|
+
p << a
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def annex(isoxml, out)
|
33
|
+
@amd and @suppressheadingnumbers = @oldsuppressheadingnumbers
|
34
|
+
super
|
35
|
+
@amd and @suppressheadingnumbers = true
|
36
|
+
end
|
37
|
+
|
38
|
+
def introduction(isoxml, out)
|
39
|
+
f = isoxml.at(ns("//introduction")) || return
|
40
|
+
num = f.at(ns(".//clause")) ? "0" : nil
|
41
|
+
title_attr = { class: "IntroTitle" }
|
42
|
+
page_break(out)
|
43
|
+
out.div **{ class: "Section3", id: f["id"] } do |div|
|
44
|
+
clause_name(num, @introduction_lbl, div, title_attr)
|
45
|
+
f.elements.each do |e|
|
46
|
+
parse(e, div) unless e.name == "title"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def foreword(isoxml, out)
|
52
|
+
f = isoxml.at(ns("//foreword")) || return
|
53
|
+
page_break(out)
|
54
|
+
out.div **attr_code(id: f["id"]) do |s|
|
55
|
+
s.h1(**{ class: "ForewordTitle" }) { |h1| h1 << @foreword_lbl }
|
56
|
+
f.elements.each { |e| parse(e, s) unless e.name == "title" }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def clause_parse_title(node, div, c1, out)
|
61
|
+
return inline_header_title(out, node, c1) if c1.nil?
|
62
|
+
super
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "isodoc"
|
2
|
+
require "mn2sts"
|
3
|
+
|
4
|
+
module IsoDoc
|
5
|
+
module Iso
|
6
|
+
|
7
|
+
# A {Converter} implementation that generates HTML output, and a document
|
8
|
+
# schema encapsulation of the document for validation
|
9
|
+
#
|
10
|
+
class StsConvert < IsoDoc::XslfoPdfConvert
|
11
|
+
def initialize(options)
|
12
|
+
@libdir = File.dirname(__FILE__)
|
13
|
+
end
|
14
|
+
|
15
|
+
def convert(filename, file = nil, debug = false)
|
16
|
+
file = File.read(filename, encoding: "utf-8") if file.nil?
|
17
|
+
docxml, outname_html, dir = convert_init(file, filename, debug)
|
18
|
+
/\.xml$/.match(filename) or
|
19
|
+
filename = Tempfile.open([outname_html, ".xml"], encoding: "utf-8") do |f|
|
20
|
+
f.write file
|
21
|
+
f.path
|
22
|
+
end
|
23
|
+
FileUtils.rm_rf dir
|
24
|
+
Mn2sts.convert(filename, outname_html + ".sts.xml")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,105 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
module Iso
|
3
|
+
module BaseConvert
|
4
|
+
def anchor_names(docxml)
|
5
|
+
if @amd
|
6
|
+
back_anchor_names(docxml)
|
7
|
+
note_anchor_names(docxml.xpath(ns("//annex//table | //annex//figure")))
|
8
|
+
note_anchor_names(docxml.xpath(ns("//annex")))
|
9
|
+
example_anchor_names(docxml.xpath(ns("//annex")))
|
10
|
+
list_anchor_names(docxml.xpath(ns("//annex")))
|
11
|
+
else
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def initial_anchor_names(d)
|
17
|
+
super
|
18
|
+
introduction_names(d.at(ns("//introduction")))
|
19
|
+
end
|
20
|
+
|
21
|
+
# we can reference 0-number clauses in introduction
|
22
|
+
def introduction_names(clause)
|
23
|
+
return if clause.nil?
|
24
|
+
clause.xpath(ns("./clause")).each_with_index do |c, i|
|
25
|
+
section_names1(c, "0.#{i + 1}", 2)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def annex_names(clause, num)
|
30
|
+
appendix_names(clause, num)
|
31
|
+
super
|
32
|
+
end
|
33
|
+
|
34
|
+
def appendix_names(clause, num)
|
35
|
+
clause.xpath(ns("./appendix")).each_with_index do |c, i|
|
36
|
+
@anchors[c["id"]] = anchor_struct(i + 1, nil, @appendix_lbl, "clause")
|
37
|
+
@anchors[c["id"]][:level] = 2
|
38
|
+
@anchors[c["id"]][:container] = clause["id"]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def section_names1(clause, num, level)
|
43
|
+
@anchors[clause["id"]] =
|
44
|
+
{ label: num, level: level, xref: num }
|
45
|
+
# subclauses are not prefixed with "Clause"
|
46
|
+
clause.xpath(ns("./clause | ./terms | ./term | ./definitions | "\
|
47
|
+
"./references")).
|
48
|
+
each_with_index do |c, i|
|
49
|
+
section_names1(c, "#{num}.#{i + 1}", level + 1)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def annex_names1(clause, num, level)
|
54
|
+
@anchors[clause["id"]] = { label: num, xref: num, level: level }
|
55
|
+
clause.xpath(ns("./clause | ./references")).each_with_index do |c, i|
|
56
|
+
annex_names1(c, "#{num}.#{i + 1}", level + 1)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def hierarchical_formula_names(clause, num)
|
61
|
+
c = IsoDoc::Function::XrefGen::Counter.new
|
62
|
+
clause.xpath(ns(".//formula")).each do |t|
|
63
|
+
next if t["id"].nil? || t["id"].empty?
|
64
|
+
@anchors[t["id"]] =
|
65
|
+
anchor_struct("#{num}#{hiersep}#{c.increment(t).print}", t,
|
66
|
+
t["inequality"] ? @inequality_lbl : @formula_lbl,
|
67
|
+
"formula", t["unnumbered"])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def figure_anchor(t, sublabel, label)
|
72
|
+
@anchors[t["id"]] = anchor_struct(
|
73
|
+
(sublabel ? "#{label} #{sublabel}" : label),
|
74
|
+
nil, @figure_lbl, "figure", t["unnumbered"])
|
75
|
+
sublabel && t["unnumbered"] != "true" and
|
76
|
+
@anchors[t["id"]][:label] = sublabel
|
77
|
+
end
|
78
|
+
|
79
|
+
def sequential_figure_names(clause)
|
80
|
+
c = IsoDoc::Function::XrefGen::Counter.new
|
81
|
+
j = 0
|
82
|
+
clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).
|
83
|
+
each do |t|
|
84
|
+
j = subfigure_increment(j, c, t)
|
85
|
+
sublabel = j.zero? ? nil : "#{(j+96).chr})"
|
86
|
+
next if t["id"].nil? || t["id"].empty?
|
87
|
+
figure_anchor(t, sublabel, c.print)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def hierarchical_figure_names(clause, num)
|
92
|
+
c = IsoDoc::Function::XrefGen::Counter.new
|
93
|
+
j = 0
|
94
|
+
clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).
|
95
|
+
each do |t|
|
96
|
+
j = subfigure_increment(j, c, t)
|
97
|
+
label = "#{num}#{hiersep}#{c.print}"
|
98
|
+
sublabel = j.zero? ? nil : "#{(j+96).chr})"
|
99
|
+
next if t["id"].nil? || t["id"].empty?
|
100
|
+
figure_anchor(t, sublabel, label)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
data/lib/metanorma-iso.rb
CHANGED
@@ -3,6 +3,8 @@ require_relative "asciidoctor/iso/converter"
|
|
3
3
|
require_relative "metanorma/iso/version"
|
4
4
|
require_relative "isodoc/iso/html_convert"
|
5
5
|
require_relative "isodoc/iso/word_convert"
|
6
|
+
require_relative "isodoc/iso/pdf_convert"
|
7
|
+
require_relative "isodoc/iso/sts_convert"
|
6
8
|
require "asciidoctor/extensions"
|
7
9
|
|
8
10
|
if defined? Metanorma
|
@@ -2,6 +2,15 @@ require "metanorma/processor"
|
|
2
2
|
|
3
3
|
module Metanorma
|
4
4
|
module Iso
|
5
|
+
def self.fonts_used
|
6
|
+
{
|
7
|
+
html: ["Cambria", "Times New Roman", "Cambria Math", "HanSans", "Courier New"],
|
8
|
+
html_alt: ["Cambria", "Times New Roman", "Cambria Math", "HanSans", "Courier New"],
|
9
|
+
doc: ["Cambria", "Times New Roman", "Cambria Math", "HanSans", "Courier New"],
|
10
|
+
pdf: ["Cambria", "Times New Roman", "Cambria Math", "HanSans", "Courier New"],
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
5
14
|
class Processor < Metanorma::Processor
|
6
15
|
|
7
16
|
def initialize
|
@@ -14,7 +23,9 @@ module Metanorma
|
|
14
23
|
super.merge(
|
15
24
|
html: "html",
|
16
25
|
html_alt: "alt.html",
|
17
|
-
doc: "doc"
|
26
|
+
doc: "doc",
|
27
|
+
pdf: "pdf",
|
28
|
+
sts: "sts.xml"
|
18
29
|
)
|
19
30
|
end
|
20
31
|
|
@@ -34,6 +45,10 @@ module Metanorma
|
|
34
45
|
IsoDoc::Iso::HtmlConvert.new(options.merge(alt: true)).convert(outname, isodoc_node)
|
35
46
|
when :doc
|
36
47
|
IsoDoc::Iso::WordConvert.new(options).convert(outname, isodoc_node)
|
48
|
+
when :pdf
|
49
|
+
IsoDoc::Iso::PdfConvert.new(options).convert(outname, isodoc_node)
|
50
|
+
when :sts
|
51
|
+
IsoDoc::Iso::StsConvert.new(options).convert(outname, isodoc_node)
|
37
52
|
else
|
38
53
|
super
|
39
54
|
end
|