isodoc 1.2.4 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +69 -0
- data/README.adoc +1 -3
- data/isodoc.gemspec +3 -1
- data/lib/isodoc-yaml/i18n-en.yaml +1 -0
- data/lib/isodoc-yaml/i18n-fr.yaml +8 -7
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
- data/lib/isodoc/base_style/all.css +5 -1
- data/lib/isodoc/base_style/blocks.scss +2 -2
- data/lib/isodoc/base_style/reset.css +5 -1
- data/lib/isodoc/base_style/reset.scss +6 -1
- data/lib/isodoc/base_style/typography.scss +1 -1
- data/lib/isodoc/convert.rb +12 -97
- data/lib/isodoc/css.rb +95 -0
- data/lib/isodoc/function/inline.rb +0 -33
- data/lib/isodoc/function/lists.rb +2 -1
- data/lib/isodoc/function/references.rb +8 -13
- data/lib/isodoc/function/to_word_html.rb +2 -2
- data/lib/isodoc/html_function/postprocess.rb +12 -3
- data/lib/isodoc/i18n.rb +23 -51
- data/lib/isodoc/metadata.rb +44 -111
- data/lib/isodoc/metadata_contributor.rb +90 -0
- data/lib/isodoc/metadata_date.rb +11 -0
- data/lib/isodoc/presentation_function/bibdata.rb +96 -0
- data/lib/isodoc/presentation_function/block.rb +14 -9
- data/lib/isodoc/presentation_function/inline.rb +151 -34
- data/lib/isodoc/presentation_xml_convert.rb +6 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_convert.rb +0 -20
- data/lib/isodoc/word_function/body.rb +12 -0
- data/lib/isodoc/word_function/postprocess.rb +1 -1
- data/lib/isodoc/xref/xref_anchor.rb +8 -3
- data/lib/isodoc/xref/xref_counter.rb +20 -9
- data/lib/isodoc/xref/xref_gen.rb +4 -4
- data/lib/isodoc/xref/xref_sect_gen.rb +1 -1
- data/lib/isodoc/xslfo_convert.rb +6 -1
- data/spec/assets/html.scss +14 -0
- data/spec/assets/i18n.yaml +22 -5
- data/spec/isodoc/blocks_spec.rb +100 -221
- data/spec/isodoc/footnotes_spec.rb +4 -5
- data/spec/isodoc/i18n_spec.rb +89 -16
- data/spec/isodoc/inline_spec.rb +185 -163
- data/spec/isodoc/lists_spec.rb +1 -1
- data/spec/isodoc/metadata_spec.rb +69 -19
- data/spec/isodoc/postproc_spec.rb +33 -8
- data/spec/isodoc/presentation_xml_spec.rb +584 -1
- data/spec/isodoc/ref_spec.rb +328 -10
- data/spec/isodoc/section_spec.rb +9 -9
- data/spec/isodoc/table_spec.rb +1 -1
- data/spec/isodoc/terms_spec.rb +1 -1
- data/spec/isodoc/xref_spec.rb +35 -35
- data/spec/spec_helper.rb +6 -0
- metadata +36 -7
- data/.github/workflows/macos.yml +0 -42
- data/.github/workflows/ubuntu.yml +0 -62
- 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)
|
data/lib/isodoc/version.rb
CHANGED
data/lib/isodoc/word_convert.rb
CHANGED
@@ -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
|
40
|
-
when @labels["inequality"] then
|
43
|
+
when @labels["formula"] then "(#{lbl})"
|
44
|
+
when @labels["inequality"] then "(#{lbl})"
|
41
45
|
else
|
42
|
-
|
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 =
|
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
|
80
|
-
return
|
81
|
-
return
|
82
|
-
return
|
83
|
-
return
|
84
|
-
return
|
85
|
-
return
|
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
|
data/lib/isodoc/xref/xref_gen.rb
CHANGED
@@ -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)
|
data/lib/isodoc/xslfo_convert.rb
CHANGED
@@ -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)
|
data/spec/assets/html.scss
CHANGED
@@ -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
|
}
|
data/spec/assets/i18n.yaml
CHANGED
@@ -1,16 +1,33 @@
|
|
1
|
-
foreword:
|
1
|
+
foreword: Antaŭparolo
|
2
2
|
introduction: Enkonduko
|
3
|
-
clause:
|
4
|
-
table:
|
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
|
10
|
+
normref: Normaj citaĵoj
|
11
11
|
bibliography: Bibliografio
|
12
12
|
inform_annex: informa
|
13
|
-
all_parts:
|
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:
|
data/spec/isodoc/blocks_spec.rb
CHANGED
@@ -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 — 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'>  </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
|
2230
|
-
|
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
|
-
|
2285
|
-
|
2286
|
-
|
2287
|
-
<
|
2288
|
-
<
|
2289
|
-
|
2290
|
-
|
2291
|
-
<foreword>
|
2292
|
-
|
2293
|
-
|
2294
|
-
|
2295
|
-
|
2296
|
-
|
2297
|
-
|
2298
|
-
|
2299
|
-
|
2300
|
-
|
2301
|
-
|
2302
|
-
|
2303
|
-
|
2304
|
-
|
2305
|
-
|
2306
|
-
<
|
2307
|
-
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
|
2322
|
-
|
2323
|
-
|
2324
|
-
|
2325
|
-
|
2326
|
-
|
2327
|
-
|
2328
|
-
|
2329
|
-
|
2330
|
-
|
2331
|
-
|
2332
|
-
|
2333
|
-
|
2334
|
-
|
2335
|
-
|
2336
|
-
|
2337
|
-
|
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
|
-
|
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
|
+
  (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
|
-
 
|
2384
|
+
  if (success)
|
2445
2385
|
<br/>
|
2446
|
-
 
|
2447
|
-
success-response)
|
2386
|
+
  recommendation(label: success-response)
|
2448
2387
|
<br/>
|
2449
|
-
 
|
2388
|
+
  end
|
2450
2389
|
<br/>
|
2451
|
-
   
|
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
|
2668
|
-
|
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
|
-
|
2680
|
-
|
2681
|
-
|
2682
|
-
|
2683
|
-
|
2684
|
-
|
2685
|
-
|
2686
|
-
|
2687
|
-
|
2688
|
-
|
2689
|
-
|
2690
|
-
|
2691
|
-
|
2692
|
-
        
|
2693
|
-
<smallcap>B</smallcap>
|
2694
|
-
</p>
|
2695
|
-
<p id='_'>
|
2696
|
-
  
|
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 — Label</name><p id="_">  <strong>A</strong><br/>
|
2627
|
+
        <smallcap>B</smallcap></p>
|
2628
|
+
<p id="_">  <em>C</em></p></figure>
|
2629
|
+
</foreword></preface>
|
2630
|
+
</itu-standard>
|
2631
|
+
|
2703
2632
|
OUTPUT
|
2704
|
-
end
|
2705
2633
|
|
2706
|
-
|
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 — Label</name>
|
2716
|
-
<p id='_'>
|
2717
|
-
  
|
2718
|
-
<strong>A</strong>
|
2719
|
-
<br/>
|
2720
|
-
        
|
2721
|
-
<smallcap>B</smallcap>
|
2722
|
-
</p>
|
2723
|
-
<p id='_'>
|
2724
|
-
  
|
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::
|
2750
|
-
|
2751
|
-
|
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 — Label</name>
|
2758
|
-
<p id='_'>
|
2759
|
-
  
|
2760
|
-
<strong>A</strong>
|
2761
|
-
<br/>
|
2762
|
-
        
|
2763
|
-
<smallcap>B</smallcap>
|
2764
|
-
</p>
|
2765
|
-
<p id='_'>
|
2766
|
-
  
|
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>  <b>A</b><br/>
|
2776
2655
|
        <span style="font-variant:small-caps;">B</span></p>
|