metanorma-iso 2.0.6.1 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -94,12 +94,15 @@ module IsoDoc
94
94
  end
95
95
 
96
96
  def index_entries_see(entries, label)
97
- see_sort = entries&.dig(label)&.each_with_object({}) do |w, v|
97
+ see_sort = entries&.dig(label) or return nil
98
+
99
+ x = see_sort.each_with_object({}) do |w, v|
98
100
  v[sortable(w).downcase] = w
99
101
  end
100
- see_sort&.keys&.localize(@lang.to_sym)&.sort&.to_a&.map do |k|
101
- see_sort[k]
102
- end&.join(", ")
102
+ x.keys.localize(@lang.to_sym).sort.to_a.map do |k|
103
+ #see_sort[k]
104
+ x[k]
105
+ end.join(", ")
103
106
  end
104
107
 
105
108
  def see_lbl
@@ -1396,8 +1396,9 @@
1396
1396
  </fo:block>
1397
1397
  </xsl:when>
1398
1398
  <xsl:otherwise>
1399
+ <xsl:value-of select="$linebreak"/>
1399
1400
  <xsl:value-of select="$part-text"/>
1400
- <xsl:text> </xsl:text>
1401
+ <xsl:text> </xsl:text>
1401
1402
  </xsl:otherwise>
1402
1403
  </xsl:choose>
1403
1404
  </xsl:if>
@@ -1729,7 +1730,8 @@
1729
1730
  </xsl:when>
1730
1731
  <xsl:otherwise>
1731
1732
  <!-- <xsl:value-of select="translate(., $thin_space, ' ')"/> -->
1732
- <xsl:value-of select="."/>
1733
+ <!-- <xsl:value-of select="."/> -->
1734
+ <xsl:call-template name="text"/>
1733
1735
  </xsl:otherwise>
1734
1736
  </xsl:choose>
1735
1737
 
@@ -3347,8 +3349,27 @@
3347
3349
  <xsl:sort select="@displayorder" data-type="number"/>
3348
3350
  <xsl:apply-templates select="."/>
3349
3351
  </xsl:for-each>
3350
- </xsl:template><xsl:template match="text()">
3351
- <xsl:value-of select="."/>
3352
+ </xsl:template><xsl:variable name="tag_open">###fo:inline###</xsl:variable><xsl:variable name="tag_close">###/fo:inline###</xsl:variable><xsl:template match="text()" name="text">
3353
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
3354
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
3355
+ <xsl:call-template name="replace_fo_inline">
3356
+ <xsl:with-param name="text" select="$text"/>
3357
+ </xsl:call-template>
3358
+ </xsl:template><xsl:template name="replace_fo_inline">
3359
+ <xsl:param name="text"/>
3360
+ <xsl:choose>
3361
+ <xsl:when test="contains($text, $tag_open)">
3362
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
3363
+ <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
3364
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
3365
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
3366
+ <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
3367
+ <xsl:call-template name="replace_fo_inline">
3368
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
3369
+ </xsl:call-template>
3370
+ </xsl:when>
3371
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
3372
+ </xsl:choose>
3352
3373
  </xsl:template><xsl:template match="*[local-name()='br']">
3353
3374
  <xsl:value-of select="$linebreak"/>
3354
3375
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
@@ -7094,7 +7115,8 @@
7094
7115
  <fo:inline><xsl:apply-templates/></fo:inline>
7095
7116
  </xsl:template><xsl:template match="*[local-name() = 'modification']/text()">
7096
7117
  <xsl:if test="normalize-space() != ''">
7097
- <xsl:value-of select="."/>
7118
+ <!-- <xsl:value-of select="."/> -->
7119
+ <xsl:call-template name="text"/>
7098
7120
  </xsl:if>
7099
7121
  </xsl:template><xsl:template match="*[local-name() = 'quote']">
7100
7122
  <fo:block-container margin-left="0mm">
@@ -1396,8 +1396,9 @@
1396
1396
  </fo:block>
1397
1397
  </xsl:when>
1398
1398
  <xsl:otherwise>
1399
+ <xsl:value-of select="$linebreak"/>
1399
1400
  <xsl:value-of select="$part-text"/>
1400
- <xsl:text> </xsl:text>
1401
+ <xsl:text> </xsl:text>
1401
1402
  </xsl:otherwise>
1402
1403
  </xsl:choose>
1403
1404
  </xsl:if>
@@ -1729,7 +1730,8 @@
1729
1730
  </xsl:when>
1730
1731
  <xsl:otherwise>
1731
1732
  <!-- <xsl:value-of select="translate(., $thin_space, ' ')"/> -->
1732
- <xsl:value-of select="."/>
1733
+ <!-- <xsl:value-of select="."/> -->
1734
+ <xsl:call-template name="text"/>
1733
1735
  </xsl:otherwise>
1734
1736
  </xsl:choose>
1735
1737
 
@@ -3347,8 +3349,27 @@
3347
3349
  <xsl:sort select="@displayorder" data-type="number"/>
3348
3350
  <xsl:apply-templates select="."/>
3349
3351
  </xsl:for-each>
3350
- </xsl:template><xsl:template match="text()">
3351
- <xsl:value-of select="."/>
3352
+ </xsl:template><xsl:variable name="tag_open">###fo:inline###</xsl:variable><xsl:variable name="tag_close">###/fo:inline###</xsl:variable><xsl:template match="text()" name="text">
3353
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
3354
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
3355
+ <xsl:call-template name="replace_fo_inline">
3356
+ <xsl:with-param name="text" select="$text"/>
3357
+ </xsl:call-template>
3358
+ </xsl:template><xsl:template name="replace_fo_inline">
3359
+ <xsl:param name="text"/>
3360
+ <xsl:choose>
3361
+ <xsl:when test="contains($text, $tag_open)">
3362
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
3363
+ <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
3364
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
3365
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
3366
+ <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
3367
+ <xsl:call-template name="replace_fo_inline">
3368
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
3369
+ </xsl:call-template>
3370
+ </xsl:when>
3371
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
3372
+ </xsl:choose>
3352
3373
  </xsl:template><xsl:template match="*[local-name()='br']">
3353
3374
  <xsl:value-of select="$linebreak"/>
3354
3375
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
@@ -7094,7 +7115,8 @@
7094
7115
  <fo:inline><xsl:apply-templates/></fo:inline>
7095
7116
  </xsl:template><xsl:template match="*[local-name() = 'modification']/text()">
7096
7117
  <xsl:if test="normalize-space() != ''">
7097
- <xsl:value-of select="."/>
7118
+ <!-- <xsl:value-of select="."/> -->
7119
+ <xsl:call-template name="text"/>
7098
7120
  </xsl:if>
7099
7121
  </xsl:template><xsl:template match="*[local-name() = 'quote']">
7100
7122
  <fo:block-container margin-left="0mm">
@@ -56,14 +56,10 @@ module IsoDoc
56
56
  end
57
57
 
58
58
  def docid(isoxml, _out)
59
- dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'ISO']"))
60
- set(:docnumber, dn&.text)
61
- tcdn = isoxml.xpath(ns("//bibdata/docidentifier[@type = 'iso-tc']"))
62
- set(:tc_docnumber, tcdn.map(&:text))
63
- dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'iso-with-lang']"))
64
- set(:docnumber_lang, dn&.text)
65
- dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'iso-reference']"))
66
- set(:docnumber_reference, dn&.text)
59
+ set(:docnumber, isoxml&.at(ns("//bibdata/docidentifier[@type = 'ISO']"))&.text)
60
+ set(:tc_docnumber, isoxml.xpath(ns("//bibdata/docidentifier[@type = 'iso-tc']")).map(&:text))
61
+ set(:docnumber_lang, isoxml&.at(ns("//bibdata/docidentifier[@type = 'iso-with-lang']"))&.text)
62
+ set(:docnumber_reference, isoxml&.at(ns("//bibdata/docidentifier[@type = 'iso-reference']"))&.text)
67
63
  end
68
64
 
69
65
  # we don't leave this to i18n.rb, because we have both English and
@@ -166,10 +162,7 @@ module IsoDoc
166
162
  end
167
163
 
168
164
  def subtitle(isoxml, _out)
169
- lang = case @lang
170
- when "fr", "ru" then "en"
171
- else "fr"
172
- end
165
+ lang = @lang == "en" ? "fr" : "en"
173
166
  intro, main, part, amd = title_parts(isoxml, lang)
174
167
  partnumber, subpartnumber, amdnumber, corrnumber = title_nums(isoxml)
175
168
 
@@ -10,14 +10,19 @@ module IsoDoc
10
10
  @suffix = "sts.xml"
11
11
  end
12
12
 
13
- def convert(in_fname, file = nil, debug = false, out_fname = nil)
14
- file = File.read(in_fname, encoding: "utf-8") if file.nil?
15
- _docxml, filename, dir = convert_init(file, in_fname, debug)
13
+ def inputfile(in_fname, filename)
16
14
  /\.xml$/.match?(in_fname) or
17
15
  in_fname = Tempfile.open([filename, ".xml"], encoding: "utf-8") do |f|
18
16
  f.write file
19
17
  f.path
20
18
  end
19
+ in_fname
20
+ end
21
+
22
+ def convert(in_fname, file = nil, debug = false, out_fname = nil)
23
+ file = File.read(in_fname, encoding: "utf-8") if file.nil?
24
+ _docxml, filename, dir = convert_init(file, in_fname, debug)
25
+ in_fname = inputfile(in_fname, filename)
21
26
  FileUtils.rm_rf dir
22
27
  MnConvert.convert(in_fname,
23
28
  { input_format: MnConvert::InputFormat::MN,
@@ -45,6 +45,18 @@ module IsoDoc
45
45
  olstyle: "l2" }
46
46
  end
47
47
 
48
+ def convert1(docxml, filename, dir)
49
+ @dis = /^[45].$/.match?(docxml&.at(ns("//bibdata/status/stage"))&.text)
50
+ if @dis
51
+ @wordstylesheet_name = html_doc_path("wordstyle-dis.scss")
52
+ @standardstylesheet_name = html_doc_path("isodoc-dis.scss")
53
+ @wordcoverpage = html_doc_path("word_iso_titlepage-dis.html")
54
+ @wordintropage = html_doc_path("word_iso_intro-dis.html")
55
+ @header = html_doc_path("header-dis.html")
56
+ end
57
+ super
58
+ end
59
+
48
60
  def make_body(xml, docxml)
49
61
  body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72" }
50
62
  xml.body **body_attr do |body|
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "2.0.6.1".freeze
3
+ VERSION = "2.0.7".freeze
4
4
  end
5
5
  end
@@ -272,7 +272,7 @@ RSpec.describe IsoDoc do
272
272
  </note>
273
273
  <bibitem id="ISO3696" type="standard">
274
274
  <title format="text/plain">Water for analytical laboratory use</title>
275
- <docidentifier type='metanorma-ordinal'>[1]</docidentifier>
275
+ <docidentifier type='metanorma-ordinal'>[3]</docidentifier>
276
276
  <docidentifier type="ISO">ISO 3696</docidentifier>
277
277
  <contributor>
278
278
  <role type="publisher"/>
@@ -295,7 +295,7 @@ RSpec.describe IsoDoc do
295
295
  </bibitem>
296
296
  <bibitem id="ref11">
297
297
  <title>Internet Calendaring and Scheduling Core Object Specification (iCalendar)</title>
298
- <docidentifier type='metanorma-ordinal'>[2]</docidentifier>
298
+ <docidentifier type='metanorma-ordinal'>[4]</docidentifier>
299
299
  <docidentifier type="IETF">IETF RFC 10</docidentifier>
300
300
  </bibitem>
301
301
  <bibitem id="ref12">
@@ -363,7 +363,7 @@ RSpec.describe IsoDoc do
363
363
  <p>
364
364
  <span class="note_label">NOTE</span>&#160; This is another annotation of document ISSN.</p>
365
365
  </div>
366
- <p class="Biblio" id="ISO3696">[1]&#160; ISO 3696,
366
+ <p class="Biblio" id="ISO3696">[3]&#160; ISO 3696,
367
367
  <i>Water for analytical laboratory use</i></p>
368
368
  <p class="Biblio" id="ref10">[10]&#160; <span style="font-variant:small-caps;">Standard No I.C.C 167</span>
369
369
  .
@@ -371,7 +371,7 @@ RSpec.describe IsoDoc do
371
371
  (see
372
372
  <a href="http://www.icc.or.at">http://www.icc.or.at</a>
373
373
  )</p>
374
- <p class="Biblio" id="ref11">[2]&#160; IETF RFC 10,
374
+ <p class="Biblio" id="ref11">[4]&#160; IETF RFC 10,
375
375
  <i>Internet Calendaring and Scheduling Core Object Specification (iCalendar)</i></p>
376
376
  <p class="Biblio" id="ref12">Citn&#160; IETF RFC 20, CitationWorks. 2019.
377
377
  <i>How to cite a reference</i>
@@ -384,8 +384,12 @@ RSpec.describe IsoDoc do
384
384
  </body>
385
385
  </html>
386
386
  OUTPUT
387
- expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({}).convert("test", input, true))
388
- .sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(presxml)
389
- expect(xmlpp(IsoDoc::Iso::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
387
+ expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({})
388
+ .convert("test", input, true))
389
+ .sub(%r{<localized-strings>.*</localized-strings>}m, ""))
390
+ .to be_equivalent_to xmlpp(presxml)
391
+ expect(xmlpp(IsoDoc::Iso::HtmlConvert.new({})
392
+ .convert("test", presxml, true)))
393
+ .to be_equivalent_to xmlpp(html)
390
394
  end
391
395
  end
@@ -280,7 +280,7 @@ RSpec.describe Metanorma::ISO do
280
280
  OUTPUT
281
281
  end
282
282
 
283
- it "processes metadata, amendment" do
283
+ it "processes metadata, amendment, stage 30" do
284
284
  output = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
285
285
  = Document title
286
286
  Author
@@ -350,7 +350,7 @@ RSpec.describe Metanorma::ISO do
350
350
  OUTPUT
351
351
  end
352
352
 
353
- it "processes metadata, amendment" do
353
+ it "processes metadata, amendment, stage 40" do
354
354
  output = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
355
355
  = Document title
356
356
  Author
@@ -419,7 +419,7 @@ RSpec.describe Metanorma::ISO do
419
419
  OUTPUT
420
420
  end
421
421
 
422
- it "processes metadata, amendment" do
422
+ it "processes metadata, amendment, published" do
423
423
  output = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
424
424
  = Document title
425
425
  Author
@@ -487,7 +487,7 @@ RSpec.describe Metanorma::ISO do
487
487
  OUTPUT
488
488
  end
489
489
 
490
- it "processes metadata, corrigendum" do
490
+ it "processes metadata, corrigendum, stage 30" do
491
491
  output = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
492
492
  = Document title
493
493
  Author
@@ -503,7 +503,6 @@ RSpec.describe Metanorma::ISO do
503
503
  :corrigendum-number: 3
504
504
  INPUT
505
505
  expect(xmlpp(output.sub(%r{<boilerplate>.*</boilerplate>}m, ""))).to be_equivalent_to xmlpp(<<~"OUTPUT")
506
- #{' '}
507
506
  <iso-standard type="semantic" version="#{Metanorma::ISO::VERSION}" xmlns="https://www.metanorma.org/ns/iso">
508
507
  <bibdata type="standard">
509
508
  <docidentifier type="ISO">ISO 17301-1:2030/CD Cor.3</docidentifier>
@@ -557,7 +556,7 @@ RSpec.describe Metanorma::ISO do
557
556
  OUTPUT
558
557
  end
559
558
 
560
- it "processes metadata, corrigendum" do
559
+ it "processes metadata, corrigendum, stage 50" do
561
560
  output = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
562
561
  = Document title
563
562
  Author
@@ -626,7 +625,7 @@ RSpec.describe Metanorma::ISO do
626
625
  OUTPUT
627
626
  end
628
627
 
629
- it "processes metadata, corrigendum" do
628
+ it "processes metadata, corrigendum, published" do
630
629
  output = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
631
630
  = Document title
632
631
  Author