isodoc 1.2.4 → 1.3.0

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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +69 -0
  3. data/README.adoc +1 -3
  4. data/isodoc.gemspec +3 -1
  5. data/lib/isodoc-yaml/i18n-en.yaml +1 -0
  6. data/lib/isodoc-yaml/i18n-fr.yaml +8 -7
  7. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
  8. data/lib/isodoc/base_style/all.css +5 -1
  9. data/lib/isodoc/base_style/blocks.scss +2 -2
  10. data/lib/isodoc/base_style/reset.css +5 -1
  11. data/lib/isodoc/base_style/reset.scss +6 -1
  12. data/lib/isodoc/base_style/typography.scss +1 -1
  13. data/lib/isodoc/convert.rb +12 -97
  14. data/lib/isodoc/css.rb +95 -0
  15. data/lib/isodoc/function/inline.rb +0 -33
  16. data/lib/isodoc/function/lists.rb +2 -1
  17. data/lib/isodoc/function/references.rb +8 -13
  18. data/lib/isodoc/function/to_word_html.rb +2 -2
  19. data/lib/isodoc/html_function/postprocess.rb +12 -3
  20. data/lib/isodoc/i18n.rb +23 -51
  21. data/lib/isodoc/metadata.rb +44 -111
  22. data/lib/isodoc/metadata_contributor.rb +90 -0
  23. data/lib/isodoc/metadata_date.rb +11 -0
  24. data/lib/isodoc/presentation_function/bibdata.rb +96 -0
  25. data/lib/isodoc/presentation_function/block.rb +14 -9
  26. data/lib/isodoc/presentation_function/inline.rb +151 -34
  27. data/lib/isodoc/presentation_xml_convert.rb +6 -0
  28. data/lib/isodoc/version.rb +1 -1
  29. data/lib/isodoc/word_convert.rb +0 -20
  30. data/lib/isodoc/word_function/body.rb +12 -0
  31. data/lib/isodoc/word_function/postprocess.rb +1 -1
  32. data/lib/isodoc/xref/xref_anchor.rb +8 -3
  33. data/lib/isodoc/xref/xref_counter.rb +20 -9
  34. data/lib/isodoc/xref/xref_gen.rb +4 -4
  35. data/lib/isodoc/xref/xref_sect_gen.rb +1 -1
  36. data/lib/isodoc/xslfo_convert.rb +6 -1
  37. data/spec/assets/html.scss +14 -0
  38. data/spec/assets/i18n.yaml +22 -5
  39. data/spec/isodoc/blocks_spec.rb +100 -221
  40. data/spec/isodoc/footnotes_spec.rb +4 -5
  41. data/spec/isodoc/i18n_spec.rb +89 -16
  42. data/spec/isodoc/inline_spec.rb +185 -163
  43. data/spec/isodoc/lists_spec.rb +1 -1
  44. data/spec/isodoc/metadata_spec.rb +69 -19
  45. data/spec/isodoc/postproc_spec.rb +33 -8
  46. data/spec/isodoc/presentation_xml_spec.rb +584 -1
  47. data/spec/isodoc/ref_spec.rb +328 -10
  48. data/spec/isodoc/section_spec.rb +9 -9
  49. data/spec/isodoc/table_spec.rb +1 -1
  50. data/spec/isodoc/terms_spec.rb +1 -1
  51. data/spec/isodoc/xref_spec.rb +35 -35
  52. data/spec/spec_helper.rb +6 -0
  53. metadata +36 -7
  54. data/.github/workflows/macos.yml +0 -42
  55. data/.github/workflows/ubuntu.yml +0 -62
  56. data/.github/workflows/windows.yml +0 -44
@@ -1,6 +1,7 @@
1
1
  require_relative "presentation_function/block"
2
2
  require_relative "presentation_function/inline"
3
3
  require_relative "presentation_function/section"
4
+ require_relative "presentation_function/bibdata"
4
5
 
5
6
  module IsoDoc
6
7
  class PresentationXMLConvert < ::IsoDoc::Convert
@@ -14,10 +15,12 @@ module IsoDoc
14
15
  @xrefs.parse docxml
15
16
  info docxml, nil
16
17
  conversions(docxml)
18
+ docxml.root["type"] = "presentation"
17
19
  docxml.to_xml
18
20
  end
19
21
 
20
22
  def conversions(docxml)
23
+ bibdata docxml
21
24
  section docxml
22
25
  block docxml
23
26
  inline docxml
@@ -48,7 +51,10 @@ module IsoDoc
48
51
  xref docxml
49
52
  eref docxml
50
53
  origin docxml
54
+ concept docxml
51
55
  quotesource docxml
56
+ mathml docxml
57
+ variant docxml
52
58
  end
53
59
 
54
60
  def postprocess(result, filename, dir)
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "1.2.4".freeze
2
+ VERSION = "1.3.0".freeze
3
3
  end
@@ -4,26 +4,6 @@ require_relative "word_function/body.rb"
4
4
  require_relative "word_function/postprocess.rb"
5
5
 
6
6
  module IsoDoc
7
-
8
- =begin
9
- module WordConvertModule
10
- # http://tech.tulentsev.com/2012/02/ruby-how-to-override-class-method-with-a-module/
11
- # https://www.ruby-forum.com/topic/148303
12
- #
13
- # The following is ugly indeed, but the only way I can split module override methods
14
- # across files
15
- def self.included base
16
- base.class_eval do
17
-
18
- eval File.open(File.join(File.dirname(__FILE__),"wordconvertmodule.rb")).read
19
- eval File.open(File.join(File.dirname(__FILE__),"comments.rb")).read
20
- eval File.open(File.join(File.dirname(__FILE__),"footnotes.rb")).read
21
- eval File.open(File.join(File.dirname(__FILE__),"postprocess.rb")).read
22
- end
23
- end
24
- end
25
- =end
26
-
27
7
  class WordConvert < ::IsoDoc::Convert
28
8
  include WordFunction::Comments
29
9
  include WordFunction::Footnotes
@@ -196,6 +196,18 @@ module IsoDoc::WordFunction
196
196
  out.parent.at("./table")["class"] = "formula_dl"
197
197
  end
198
198
 
199
+ def formula_parse1(node, out)
200
+ out.div **attr_code(class: "formula") do |div|
201
+ div.p do |p|
202
+ parse(node.at(ns("./stem")), div)
203
+ insert_tab(div, 1)
204
+ if lbl = node&.at(ns("./name"))&.text
205
+ div << "(#{lbl})"
206
+ end
207
+ end
208
+ end
209
+ end
210
+
199
211
  def li_parse(node, out)
200
212
  out.li **attr_code(id: node["id"]) do |li|
201
213
  if node["uncheckedcheckbox"] == "true"
@@ -183,7 +183,7 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
183
183
  def generate_header(filename, _dir)
184
184
  return nil unless @header
185
185
  template = IsoDoc::Common.liquid(File.read(@header, encoding: "UTF-8"))
186
- meta = @meta.get
186
+ meta = @meta.get.merge(@labels || {}).merge(@meta.labels || {})
187
187
  meta[:filename] = filename
188
188
  params = meta.map { |k, v| [k.to_s, v] }.to_h
189
189
  Tempfile.open(%w(header html), :encoding => "utf-8") do |f|
@@ -35,11 +35,15 @@ module IsoDoc::XrefGen
35
35
  end
36
36
 
37
37
  def anchor_struct_xref(lbl, elem)
38
+ l10n("#{elem} #{anchor_struct_value(lbl, elem)}")
39
+ end
40
+
41
+ def anchor_struct_value(lbl, elem)
38
42
  case elem
39
- when @labels["formula"] then l10n("#{elem} (#{lbl})")
40
- when @labels["inequality"] then l10n("#{elem} (#{lbl})")
43
+ when @labels["formula"] then "(#{lbl})"
44
+ when @labels["inequality"] then "(#{lbl})"
41
45
  else
42
- l10n("#{elem} #{lbl}")
46
+ lbl
43
47
  end
44
48
  end
45
49
 
@@ -50,6 +54,7 @@ module IsoDoc::XrefGen
50
54
  ret[:xref].gsub!(/ $/, "")
51
55
  ret[:container] = @klass.get_clause_id(container) unless container.nil?
52
56
  ret[:type] = type
57
+ ret[:value] = anchor_struct_value(lbl, elem)
53
58
  ret
54
59
  end
55
60
  end
@@ -2,8 +2,8 @@ require "roman-numerals"
2
2
 
3
3
  module IsoDoc::XrefGen
4
4
  class Counter
5
- def initialize
6
- @num = 0
5
+ def initialize(num = 0)
6
+ @num = num
7
7
  @letter = ""
8
8
  @subseq = ""
9
9
  @letter_override = nil
@@ -76,13 +76,24 @@ module IsoDoc::XrefGen
76
76
  "#{@base}#{@number_override || @num}#{@letter_override || @letter}"
77
77
  end
78
78
 
79
- def listlabel(depth)
80
- return @num.to_s if [2, 7].include? depth
81
- return (96 + @num).chr.to_s if [1, 6].include? depth
82
- return (64 + @num).chr.to_s if [4, 9].include? depth
83
- return RomanNumerals.to_roman(@num).downcase if [3, 8].include? depth
84
- return RomanNumerals.to_roman(@num).upcase if [5, 10].include? depth
85
- return @num.to_s
79
+ def ol_type(list, depth)
80
+ return list["type"].to_sym if list["type"]
81
+ return :arabic if [2, 7].include? depth
82
+ return :alphabet if [1, 6].include? depth
83
+ return :alphabet_upper if [4, 9].include? depth
84
+ return :roman if [3, 8].include? depth
85
+ return :roman_upper if [5, 10].include? depth
86
+ return :arabic
87
+ end
88
+
89
+ def listlabel(list, depth)
90
+ case ol_type(list, depth)
91
+ when :arabic then @num.to_s
92
+ when :alphabet then (96 + @num).chr.to_s
93
+ when :alphabet_upper then (64 + @num).chr.to_s
94
+ when :roman then RomanNumerals.to_roman(@num).downcase
95
+ when :roman_upper then RomanNumerals.to_roman(@num).upcase
96
+ end
86
97
  end
87
98
  end
88
99
  end
@@ -36,7 +36,7 @@ module IsoDoc::XrefGen
36
36
  return if n["id"].nil? || n["id"].empty?
37
37
  c.increment(n)
38
38
  @anchors[n["id"]] =
39
- { label: termnote_label(c.print), type: "termnote",
39
+ { label: termnote_label(c.print), type: "termnote", value: c.print,
40
40
  xref: l10n("#{anchor(t['id'], :xref)}, "\
41
41
  "#{@labels["note_xref"]} #{c.print}") }
42
42
  end
@@ -52,7 +52,7 @@ module IsoDoc::XrefGen
52
52
  c.increment(n)
53
53
  idx = examples.size == 1 && !n["number"] ? "" : c.print
54
54
  @anchors[n["id"]] = {
55
- type: "termexample", label: idx,
55
+ type: "termexample", label: idx, value: c.print,
56
56
  xref: l10n("#{anchor(t['id'], :xref)}, "\
57
57
  "#{@labels["example_xref"]} #{c.print}") }
58
58
  end
@@ -123,9 +123,9 @@ module IsoDoc::XrefGen
123
123
  end
124
124
 
125
125
  def list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list)
126
- c = Counter.new
126
+ c = Counter.new(list["start"] ? list["start"].to_i - 1 : 0)
127
127
  list.xpath(ns("./li")).each do |li|
128
- label = c.increment(li).listlabel(depth)
128
+ label = c.increment(li).listlabel(list, depth)
129
129
  label = "#{prev_label}.#{label}" unless prev_label.empty?
130
130
  label = "#{list_anchor[:xref]} #{label}" if refer_list
131
131
  li["id"] and @anchors[li["id"]] =
@@ -113,7 +113,7 @@ module IsoDoc::XrefGen
113
113
 
114
114
  def annex_names(clause, num)
115
115
  @anchors[clause["id"]] = { label: annex_name_lbl(clause, num),
116
- type: "clause",
116
+ type: "clause", value: num.to_s,
117
117
  xref: "#{@labels["annex"]} #{num}", level: 1 }
118
118
  if a = single_annex_special_section(clause)
119
119
  annex_names1(a, "#{num}", 1)
@@ -23,6 +23,10 @@ module IsoDoc
23
23
  nil
24
24
  end
25
25
 
26
+ def pdf_options(docxml)
27
+ ""
28
+ end
29
+
26
30
  def convert(input_filename, file = nil, debug = false, output_filename = nil)
27
31
  file = File.read(input_filename, encoding: "utf-8") if file.nil?
28
32
  docxml, filename, dir = convert_init(file, input_filename, debug)
@@ -34,7 +38,8 @@ module IsoDoc
34
38
  FileUtils.rm_rf dir
35
39
  ::Metanorma::Output::XslfoPdf.new.convert(input_filename,
36
40
  output_filename || "#{filename}.#{@suffix}",
37
- File.join(@libdir, pdf_stylesheet(docxml)))
41
+ File.join(@libdir, pdf_stylesheet(docxml)),
42
+ pdf_options(docxml))
38
43
  end
39
44
 
40
45
  def xref_parse(node, out)
@@ -3,4 +3,18 @@
3
3
 
4
4
  p {
5
5
  font-family: $bodyfont;
6
+ font-size: $normalfontsize;
7
+ }
8
+ code {
9
+ font-family: $monospacefont;
10
+ font-size: $monospacefontsize;
11
+ }
12
+ aside {
13
+ font-size: $footnotefontsize;
14
+ }
15
+ h1 {
16
+ font-family: $headerfont;
17
+ }
18
+ p.note {
19
+ font-size: $smallerfontsize;
6
20
  }
@@ -1,16 +1,33 @@
1
- foreword: Antaŭparolo
1
+ foreword: Antaŭparolo
2
2
  introduction: Enkonduko
3
- clause: klaŭzo
4
- table: Tabelo
3
+ clause: klaŭzo
4
+ table: tabelo
5
5
  source: SOURCE
6
6
  modified: modified
7
7
  scope: Amplekso
8
8
  symbols: Simboloj kai mallongigitaj terminoj
9
9
  annex: Aldono
10
- normref: Normaj citaĵoj
10
+ normref: Normaj citaĵoj
11
11
  bibliography: Bibliografio
12
12
  inform_annex: informa
13
- all_parts: ĉiuj partoj
13
+ all_parts: ĉiuj partoj
14
+ norm_annex: normative
15
+ note: NOTO
14
16
  locality: {
15
17
  table: Tabelo
16
18
  }
19
+ doctype_dict: {
20
+ brochure: broŝuro,
21
+ conference proceedings: konferencaktoj
22
+ }
23
+ stage_dict: {
24
+ published: publikigita
25
+ }
26
+ substage_dict: {
27
+ withdrawn: fortirita
28
+ }
29
+ array:
30
+ - elem1
31
+ - elem2
32
+ - {elem3: elem4, elem5: elem6}
33
+ void:
@@ -84,19 +84,19 @@ RSpec.describe IsoDoc do
84
84
  </standard-document>
85
85
  INPUT
86
86
  presxml = <<~OUTPUT
87
- <standard-document xmlns="https://www.metanorma.org/ns/standoc">
87
+ <standard-document xmlns="https://www.metanorma.org/ns/standoc" type="presentation">
88
88
  <bibdata type="standard">
89
89
  <title language="en" format="text/plain">Document title</title>
90
- <language>en</language>
91
- <script>Latn</script>
90
+ <language current="true">en</language>
91
+ <script current="true">Latn</script>
92
92
  <status>
93
- <stage>published</stage>
93
+ <stage language="">published</stage>
94
94
  </status>
95
95
  <copyright>
96
96
  <from>2020</from>
97
97
  </copyright>
98
98
  <ext>
99
- <doctype>article</doctype>
99
+ <doctype language="">article</doctype>
100
100
  </ext>
101
101
  </bibdata>
102
102
  <sections>
@@ -234,7 +234,7 @@ RSpec.describe IsoDoc do
234
234
  </body>
235
235
  </html>
236
236
  OUTPUT
237
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
237
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(presxml)
238
238
  expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
239
239
  end
240
240
 
@@ -249,7 +249,7 @@ RSpec.describe IsoDoc do
249
249
  </iso-standard>
250
250
  INPUT
251
251
  <?xml version='1.0'?>
252
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
252
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
253
253
  <preface>
254
254
  <foreword>
255
255
  <note id='A' keep-with-next='true' keep-lines-together='true'>
@@ -352,7 +352,7 @@ OUTPUT
352
352
  </iso-standard>
353
353
  INPUT
354
354
  <?xml version='1.0'?>
355
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
355
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
356
356
  <preface>
357
357
  <foreword>
358
358
  <note id='note1'>
@@ -640,7 +640,7 @@ B</pre>
640
640
  </iso-standard>
641
641
  INPUT
642
642
  <?xml version='1.0'?>
643
- <iso-standard xmlns="http://riboseinc.com/isoxml">
643
+ <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
644
644
  <preface><foreword>
645
645
  <figure id="figureA-1" keep-with-next="true" keep-lines-together="true">
646
646
  <name>Figure 1&#xA0;&#x2014; Split-it-right <em>sample</em> divider<fn reference="1"><p>X</p></fn></name>
@@ -940,7 +940,7 @@ OUTPUT
940
940
  </iso-standard>
941
941
  INPUT
942
942
  <?xml version='1.0'?>
943
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
943
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
944
944
  <preface>
945
945
  <foreword>
946
946
  <example id='samplecode' keep-with-next='true' keep-lines-together='true'>
@@ -1056,7 +1056,7 @@ OUTPUT
1056
1056
  </iso-standard>
1057
1057
  INPUT
1058
1058
  <?xml version='1.0'?>
1059
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
1059
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
1060
1060
  <preface>
1061
1061
  <foreword>
1062
1062
  <example id='samplecode'>
@@ -1092,7 +1092,7 @@ Que?
1092
1092
  </iso-standard>
1093
1093
  INPUT
1094
1094
  <?xml version='1.0'?>
1095
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
1095
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
1096
1096
  <preface>
1097
1097
  <foreword>
1098
1098
  <sourcecode lang='ruby' id='samplecode'>
@@ -1330,7 +1330,7 @@ Que?
1330
1330
  </iso-standard>
1331
1331
  INPUT
1332
1332
  <?xml version='1.0'?>
1333
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
1333
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
1334
1334
  <preface>
1335
1335
  <foreword>
1336
1336
  <formula id='_be9158af-7e93-4ee2-90c5-26d31c181934' unnumbered='true' keep-with-next='true' keep-lines-together='true'>
@@ -1455,6 +1455,7 @@ end
1455
1455
  <div id='_be9158af-7e93-4ee2-90c5-26d31c181934' style='page-break-after: avoid;page-break-inside: avoid;'><div class='formula'>
1456
1456
  <p>
1457
1457
  <span class='stem'>(#(r = 1 %)#)</span>
1458
+ <span style='mso-tab-count:1'>&#160; </span>
1458
1459
  </p>
1459
1460
  </div>
1460
1461
  <p>where</p>
@@ -1583,7 +1584,7 @@ it "processes blockquotes (Presentation XML)" do
1583
1584
  </iso-standard>
1584
1585
  INPUT
1585
1586
  <?xml version='1.0'?>
1586
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
1587
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
1587
1588
  <preface>
1588
1589
  <foreword>
1589
1590
  <quote id='_044bd364-c832-4b78-8fea-92242402a1d1'>
@@ -1722,7 +1723,7 @@ it "processes blockquotes (Presentation XML)" do
1722
1723
  </iso-standard>
1723
1724
  INPUT
1724
1725
  <?xml version='1.0'?>
1725
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
1726
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
1726
1727
  <preface>
1727
1728
  <foreword>
1728
1729
  <permission id='_' keep-with-next='true' keep-lines-together='true'>
@@ -2082,7 +2083,7 @@ Inherits: <a href='#rfc2616'>RFC 2616 (HTTP/1.1)</a>
2082
2083
  </iso-standard>
2083
2084
  INPUT
2084
2085
  <?xml version='1.0'?>
2085
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
2086
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
2086
2087
  <preface>
2087
2088
  <foreword>
2088
2089
  <requirement id='A' unnumbered='true' keep-with-next='true' keep-lines-together='true'>
@@ -2226,8 +2227,8 @@ end
2226
2227
  OUTPUT
2227
2228
  end
2228
2229
 
2229
- it "processes requirements in French (Presentation XML)" do
2230
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2230
+ it "processes requirements in French" do
2231
+ input = <<~INPUT
2231
2232
  <iso-standard xmlns="http://riboseinc.com/isoxml">
2232
2233
  <bibdata>
2233
2234
  <language>fr</language>
@@ -2281,125 +2282,63 @@ end
2281
2282
  </foreword></preface>
2282
2283
  </iso-standard>
2283
2284
  INPUT
2284
- <?xml version='1.0'?>
2285
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
2286
- <bibdata>
2287
- <language>fr</language>
2288
- <script>Latn</script>
2289
- </bibdata>
2290
- <preface>
2291
- <foreword>
2292
- <requirement id='A' unnumbered='true'>
2293
- <name>Exigence</name>
2294
- <title>A New Requirement</title>
2295
- <label>/ogc/recommendation/wfs/2</label>
2296
- <inherit>/ss/584/2015/level/1</inherit>
2297
- <subject>user</subject>
2298
- <description>
2299
- <p id='_'>
2300
- I recommend
2301
- <em>this</em>
2302
- .
2303
- </p>
2304
- </description>
2305
- <specification exclude='true' type='tabular'>
2306
- <p id='_'>This is the object of the recommendation:</p>
2307
- <table id='_'>
2308
- <tbody>
2309
- <tr>
2310
- <td style='text-align:left;'>Object</td>
2311
- <td style='text-align:left;'>Value</td>
2312
- </tr>
2313
- <tr>
2314
- <td style='text-align:left;'>Mission</td>
2315
- <td style='text-align:left;'>Accomplished</td>
2316
- </tr>
2317
- </tbody>
2318
- </table>
2319
- </specification>
2320
- <description>
2321
- <p id='_'>As for the measurement targets,</p>
2322
- </description>
2323
- <measurement-target exclude='false'>
2324
- <p id='_'>The measurement target shall be measured as:</p>
2325
- <formula id='B'>
2326
- <name>1</name>
2327
- <stem type='AsciiMath'>r/1 = 0</stem>
2328
- </formula>
2329
- </measurement-target>
2330
- <verification exclude='false'>
2331
- <p id='_'>The following code will be run for verification:</p>
2332
- <sourcecode id='_'>
2333
- CoreRoot(success): HttpResponse if (success) recommendation(label:
2334
- success-response) end
2335
- </sourcecode>
2336
- </verification>
2337
- <import exclude='true'>
2338
- <sourcecode id='_'>success-response()</sourcecode>
2339
- </import>
2340
- </requirement>
2341
- </foreword>
2342
- </preface>
2343
- </iso-standard>
2285
+
2286
+ presxml = <<~OUTPUT
2287
+ <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
2288
+ <bibdata>
2289
+ <language current="true">fr</language>
2290
+ <script current="true">Latn</script>
2291
+ </bibdata>
2292
+ <preface><foreword>
2293
+ <requirement id="A" unnumbered="true"><name>Exigence</name>
2294
+ <title>A New Requirement</title>
2295
+ <label>/ogc/recommendation/wfs/2</label>
2296
+ <inherit>/ss/584/2015/level/1</inherit>
2297
+ <subject>user</subject>
2298
+ <description>
2299
+ <p id="_">I recommend <em>this</em>.</p>
2300
+ </description>
2301
+ <specification exclude="true" type="tabular">
2302
+ <p id="_">This is the object of the recommendation:</p>
2303
+ <table id="_">
2304
+ <tbody>
2305
+ <tr>
2306
+ <td style="text-align:left;">Object</td>
2307
+ <td style="text-align:left;">Value</td>
2308
+ </tr>
2309
+ <tr>
2310
+ <td style="text-align:left;">Mission</td>
2311
+ <td style="text-align:left;">Accomplished</td>
2312
+ </tr>
2313
+ </tbody>
2314
+ </table>
2315
+ </specification>
2316
+ <description>
2317
+ <p id="_">As for the measurement targets,</p>
2318
+ </description>
2319
+ <measurement-target exclude="false">
2320
+ <p id="_">The measurement target shall be measured as:</p>
2321
+ <formula id="B"><name>1</name>
2322
+ <stem type="AsciiMath">r/1 = 0</stem>
2323
+ </formula>
2324
+ </measurement-target>
2325
+ <verification exclude="false">
2326
+ <p id="_">The following code will be run for verification:</p>
2327
+ <sourcecode id="_">CoreRoot(success): HttpResponse
2328
+ if (success)
2329
+ recommendation(label: success-response)
2330
+ end
2331
+ </sourcecode>
2332
+ </verification>
2333
+ <import exclude="true">
2334
+ <sourcecode id="_">success-response()</sourcecode>
2335
+ </import>
2336
+ </requirement>
2337
+ </foreword></preface>
2338
+ </iso-standard>
2344
2339
  OUTPUT
2345
- end
2346
2340
 
2347
- it "processes requirements in French (HTML)" do
2348
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2349
- <iso-standard xmlns="http://riboseinc.com/isoxml">
2350
- <bibdata>
2351
- <language>fr</language>
2352
- <script>Latn</script>
2353
- </bibdata>
2354
- <preface><foreword>
2355
- <requirement id="A" unnumbered="true">
2356
- <name>Exigence</name>
2357
- <title>A New Requirement</title>
2358
- <label>/ogc/recommendation/wfs/2</label>
2359
- <inherit>/ss/584/2015/level/1</inherit>
2360
- <subject>user</subject>
2361
- <description>
2362
- <p id="_">I recommend <em>this</em>.</p>
2363
- </description>
2364
- <specification exclude="true" type="tabular">
2365
- <p id="_">This is the object of the recommendation:</p>
2366
- <table id="_">
2367
- <tbody>
2368
- <tr>
2369
- <td style="text-align:left;">Object</td>
2370
- <td style="text-align:left;">Value</td>
2371
- </tr>
2372
- <tr>
2373
- <td style="text-align:left;">Mission</td>
2374
- <td style="text-align:left;">Accomplished</td>
2375
- </tr>
2376
- </tbody>
2377
- </table>
2378
- </specification>
2379
- <description>
2380
- <p id="_">As for the measurement targets,</p>
2381
- </description>
2382
- <measurement-target exclude="false">
2383
- <p id="_">The measurement target shall be measured as:</p>
2384
- <formula id="B">
2385
- <stem type="AsciiMath">r/1 = 0</stem>
2386
- </formula>
2387
- </measurement-target>
2388
- <verification exclude="false">
2389
- <p id="_">The following code will be run for verification:</p>
2390
- <sourcecode id="_">CoreRoot(success): HttpResponse
2391
- if (success)
2392
- recommendation(label: success-response)
2393
- end
2394
- </sourcecode>
2395
- </verification>
2396
- <import exclude="true">
2397
- <sourcecode id="_">success-response()</sourcecode>
2398
- </import>
2399
- </requirement>
2400
- </foreword></preface>
2401
- </iso-standard>
2402
- INPUT
2341
+ html = <<~OUTPUT
2403
2342
  #{HTML_HDR.gsub(/"en"/, '"fr"')}
2404
2343
  <br/>
2405
2344
  <div>
@@ -2432,6 +2371,7 @@ end
2432
2371
  <div id='B'><div class='formula'>
2433
2372
  <p>
2434
2373
  <span class='stem'>(#(r/1 = 0)#)</span>
2374
+ &#160; (1)
2435
2375
  </p>
2436
2376
  </div>
2437
2377
  </div>
@@ -2441,14 +2381,12 @@ end
2441
2381
  <pre id='_' class='prettyprint '>
2442
2382
  CoreRoot(success): HttpResponse
2443
2383
  <br/>
2444
- &#160;&#160;&#160;&#160;&#160; if (success)
2384
+ &#160; if (success)
2445
2385
  <br/>
2446
- &#160;&#160;&#160;&#160;&#160; recommendation(label:
2447
- success-response)
2386
+ &#160; recommendation(label: success-response)
2448
2387
  <br/>
2449
- &#160;&#160;&#160;&#160;&#160; end
2388
+ &#160; end
2450
2389
  <br/>
2451
- &#160;&#160;&#160;
2452
2390
  </pre>
2453
2391
  </div>
2454
2392
  </div>
@@ -2458,6 +2396,8 @@ end
2458
2396
  </body>
2459
2397
  </html>
2460
2398
  OUTPUT
2399
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(presxml)
2400
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
2461
2401
  end
2462
2402
 
2463
2403
  it "processes recommendation (Presentation XML)" do
@@ -2513,7 +2453,7 @@ end
2513
2453
  </iso-standard>
2514
2454
  INPUT
2515
2455
  <?xml version='1.0'?>
2516
- <iso-standard xmlns='http://riboseinc.com/isoxml'>
2456
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
2517
2457
  <preface>
2518
2458
  <foreword>
2519
2459
  <recommendation id='_' obligation='shall,could' keep-with-next='true' keep-lines-together='true'>
@@ -2664,8 +2604,8 @@ end
2664
2604
  OUTPUT
2665
2605
  end
2666
2606
 
2667
- it "processes pseudocode (Presentation XML)" do
2668
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2607
+ it "processes pseudocode" do
2608
+ input = <<~INPUT
2669
2609
  <itu-standard xmlns="http://riboseinc.com/isoxml">
2670
2610
  <bibdata>
2671
2611
  <language>en</language>
@@ -2676,59 +2616,22 @@ end
2676
2616
  <p id="_">  <em>C</em></p></figure>
2677
2617
  </preface></itu-standard>
2678
2618
  INPUT
2679
- <?xml version='1.0'?>
2680
- <itu-standard xmlns='http://riboseinc.com/isoxml'>
2681
- <bibdata>
2682
- <language>en</language>
2683
- </bibdata>
2684
- <preface>
2685
- <foreword>
2686
- <figure id='_' class='pseudocode' keep-with-next='true' keep-lines-together='true'>
2687
- <name>Figure 1&#xA0;&#x2014; Label</name>
2688
- <p id='_'>
2689
- &#xA0;&#xA0;
2690
- <strong>A</strong>
2691
- <br/>
2692
- &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;
2693
- <smallcap>B</smallcap>
2694
- </p>
2695
- <p id='_'>
2696
- &#xA0;&#xA0;
2697
- <em>C</em>
2698
- </p>
2699
- </figure>
2700
- </foreword>
2701
- </preface>
2702
- </itu-standard>
2619
+
2620
+ presxml = <<~OUTPUT
2621
+ <itu-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
2622
+ <bibdata>
2623
+ <language current="true">en</language>
2624
+ </bibdata>
2625
+ <preface><foreword>
2626
+ <figure id="_" class="pseudocode" keep-with-next="true" keep-lines-together="true"><name>Figure 1&#xA0;&#x2014; Label</name><p id="_">&#xA0;&#xA0;<strong>A</strong><br/>
2627
+ &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;<smallcap>B</smallcap></p>
2628
+ <p id="_">&#xA0;&#xA0;<em>C</em></p></figure>
2629
+ </foreword></preface>
2630
+ </itu-standard>
2631
+
2703
2632
  OUTPUT
2704
- end
2705
2633
 
2706
- it "processes pseudocode (HTML)" do
2707
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2708
- <itu-standard xmlns='http://riboseinc.com/isoxml'>
2709
- <bibdata>
2710
- <language>en</language>
2711
- </bibdata>
2712
- <preface>
2713
- <foreword>
2714
- <figure id='_' class='pseudocode' keep-with-next='true' keep-lines-together='true'>
2715
- <name>Figure 1&#xA0;&#x2014; Label</name>
2716
- <p id='_'>
2717
- &#xA0;&#xA0;
2718
- <strong>A</strong>
2719
- <br/>
2720
- &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;
2721
- <smallcap>B</smallcap>
2722
- </p>
2723
- <p id='_'>
2724
- &#xA0;&#xA0;
2725
- <em>C</em>
2726
- </p>
2727
- </figure>
2728
- </foreword>
2729
- </preface>
2730
- </itu-standard>
2731
- INPUT
2634
+ html = <<~OUTPUT
2732
2635
  #{HTML_HDR}
2733
2636
  <br/>
2734
2637
  <div>
@@ -2742,35 +2645,11 @@ INPUT
2742
2645
  </body>
2743
2646
  </html>
2744
2647
  OUTPUT
2745
- end
2746
2648
 
2747
- it "processes pseudocode (Word)" do
2748
2649
  FileUtils.rm_f "test.doc"
2749
- IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", false)
2750
- <itu-standard xmlns='http://riboseinc.com/isoxml'>
2751
- <bibdata>
2752
- <language>en</language>
2753
- </bibdata>
2754
- <preface>
2755
- <foreword>
2756
- <figure id='_' class='pseudocode' keep-with-next='true' keep-lines-together='true'>
2757
- <name>Figure 1&#xA0;&#x2014; Label</name>
2758
- <p id='_'>
2759
- &#xA0;&#xA0;
2760
- <strong>A</strong>
2761
- <br/>
2762
- &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;
2763
- <smallcap>B</smallcap>
2764
- </p>
2765
- <p id='_'>
2766
- &#xA0;&#xA0;
2767
- <em>C</em>
2768
- </p>
2769
- </figure>
2770
- </foreword>
2771
- </preface>
2772
- </itu-standard>
2773
- INPUT
2650
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(presxml)
2651
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
2652
+ IsoDoc::WordConvert.new({}).convert("test", presxml, false)
2774
2653
  expect(xmlpp( File.read("test.doc").gsub(%r{^.*<h1 class="ForewordTitle">Foreword</h1>}m, "").gsub(%r{</div>.*}m, "</div>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2775
2654
  <div class="pseudocode" style='page-break-after: avoid;page-break-inside: avoid;'><a name="_" id="_"></a><p class="pseudocode"><a name="_" id="_"></a>&#xA0;&#xA0;<b>A</b><br/>
2776
2655
  &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;<span style="font-variant:small-caps;">B</span></p>