isodoc 1.0.6 → 1.0.7
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/Gemfile.lock +5 -5
- data/README.adoc +4 -3
- data/lib/isodoc/base_style/blocks.scss +17 -0
- data/lib/isodoc/function/blocks.rb +14 -0
- data/lib/isodoc/function/inline.rb +3 -10
- data/lib/isodoc/function/lists.rb +0 -1
- data/lib/isodoc/function/terms.rb +0 -2
- data/lib/isodoc/function/xref_gen.rb +4 -5
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/postprocess.rb +32 -12
- data/spec/isodoc/blocks_spec.rb +73 -25
- data/spec/isodoc/cleanup_spec.rb +10 -10
- data/spec/isodoc/footnotes_spec.rb +4 -4
- data/spec/isodoc/i18n_spec.rb +4 -4
- data/spec/isodoc/inline_spec.rb +9 -9
- data/spec/isodoc/lists_spec.rb +5 -5
- data/spec/isodoc/postproc_spec.rb +81 -22
- data/spec/isodoc/ref_spec.rb +1 -1
- data/spec/isodoc/section_spec.rb +8 -8
- data/spec/isodoc/table_spec.rb +4 -4
- data/spec/isodoc/terms_spec.rb +2 -3
- data/spec/isodoc/xref_spec.rb +27 -19
- data/spec/spec_helper.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61c4078b846eee8f29ef7322bcb1ac497c0418c4d7eaaba8d79ff4549b4d5b47
|
4
|
+
data.tar.gz: 311efba07534c2f7a6c35af286478a3beb31f082f50424ce4fdbfe0956eebb95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f30695762aa1626b376317e3e928b4dab2d7dca5493f8d9990df4d8daf6b1d7f958e21f3217e227a974b9af1db1c46921a1c9250f25164f63cd3c4edd6ba73d8
|
7
|
+
data.tar.gz: 20e1f4f1e19a51c828ad06d07814c5af1d37213b37615376e68bafddf0f9bcd5fba7cf991571de5f38bb8983b10f7be45eb8720b76f45bbc0899028e8267b6f7
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
isodoc (1.0.
|
4
|
+
isodoc (1.0.7)
|
5
5
|
asciimath
|
6
6
|
html2doc (~> 0.9.0)
|
7
7
|
htmlentities (~> 4.3.4)
|
@@ -28,7 +28,7 @@ GEM
|
|
28
28
|
nokogiri (>= 1.4.3)
|
29
29
|
ffi (1.11.1)
|
30
30
|
formatador (0.2.5)
|
31
|
-
guard (2.
|
31
|
+
guard (2.16.1)
|
32
32
|
formatador (>= 0.2.4)
|
33
33
|
listen (>= 2.7, < 4.0)
|
34
34
|
lumberjack (>= 1.0.12, < 2.0)
|
@@ -42,7 +42,7 @@ GEM
|
|
42
42
|
guard (~> 2.1)
|
43
43
|
guard-compat (~> 1.1)
|
44
44
|
rspec (>= 2.99.0, < 4.0)
|
45
|
-
html2doc (0.9.
|
45
|
+
html2doc (0.9.1)
|
46
46
|
asciimath (~> 1.0.9)
|
47
47
|
htmlentities (~> 4.3.4)
|
48
48
|
image_size
|
@@ -58,7 +58,7 @@ GEM
|
|
58
58
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
59
59
|
rb-inotify (~> 0.9, >= 0.9.10)
|
60
60
|
lumberjack (1.0.13)
|
61
|
-
metanorma (0.3.
|
61
|
+
metanorma (0.3.16)
|
62
62
|
asciidoctor
|
63
63
|
htmlentities
|
64
64
|
method_source (0.9.2)
|
@@ -67,7 +67,7 @@ GEM
|
|
67
67
|
mime-types-data (3.2019.1009)
|
68
68
|
mini_portile2 (2.4.0)
|
69
69
|
nenv (0.3.0)
|
70
|
-
nokogiri (1.10.
|
70
|
+
nokogiri (1.10.5)
|
71
71
|
mini_portile2 (~> 2.4.0)
|
72
72
|
notiffany (0.1.3)
|
73
73
|
nenv (~> 0.1)
|
data/README.adoc
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
= isodoc: Processor to generate HTML/Word from Metanorma XML
|
2
2
|
|
3
3
|
image:https://img.shields.io/gem/v/isodoc.svg["Gem Version", link="https://rubygems.org/gems/isodoc"]
|
4
|
-
image:https://
|
5
|
-
image:https://
|
6
|
-
image:https://github.com/metanorma/isodoc/workflows/windows/badge.svg["Build Status", link="https://github.com/metanorma/isodoc/actions?workflow=windows"]
|
4
|
+
image:https://travis-ci.com/metanorma/isodoc.svg["Build Status", link="https://travis-ci.com/metanorma/isodoc"]
|
5
|
+
image:https://ci.appveyor.com/api/projects/status/f93bvu6qfwxij07x?svg=true["Appveyor Build Status", link="https://ci.appveyor.com/project/metanorma/isodoc"]
|
7
6
|
image:https://codeclimate.com/github/metanorma/isodoc/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/isodoc"]
|
7
|
+
image:https://img.shields.io/github/issues-pr-raw/metanorma/isodoc.svg["Pull Requests", link="https://github.com/metanorma/isodoc/pulls"]
|
8
|
+
image:https://img.shields.io/github/commits-since/metanorma/isodoc/latest.svg["Commits since latest",link="https://github.com/metanorma/isodoc/releases"]
|
8
9
|
|
9
10
|
== Purpose
|
10
11
|
|
@@ -55,6 +55,23 @@
|
|
55
55
|
overflow: auto;
|
56
56
|
}
|
57
57
|
|
58
|
+
@mixin pseudocodeBlock($colorBg, $colorFg: null) {
|
59
|
+
.SourceTitle {
|
60
|
+
@include blockTitle();
|
61
|
+
}
|
62
|
+
|
63
|
+
@if $colorFg {
|
64
|
+
color: $colorFg;
|
65
|
+
}
|
66
|
+
|
67
|
+
background-color: $colorBg;
|
68
|
+
font-size: 0.8em;
|
69
|
+
line-height: 1.6em;
|
70
|
+
padding: 1.5em;
|
71
|
+
margin: 2em 0 1em 0;
|
72
|
+
overflow: auto;
|
73
|
+
}
|
74
|
+
|
58
75
|
@mixin exampleBlock($colorBg, $colorText, $padding: .5em, $offsetContent: 1.5em) {
|
59
76
|
background-color: $colorBg;
|
60
77
|
|
@@ -58,6 +58,8 @@ module IsoDoc::Function
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def figure_parse(node, out)
|
61
|
+
return pseudocode_parse(node, out) if node["class"] == "pseudocode" ||
|
62
|
+
node["type"] == "pseudocode"
|
61
63
|
@in_figure = true
|
62
64
|
out.div **attr_code(id: node["id"], class: "figure") do |div|
|
63
65
|
node.children.each do |n|
|
@@ -69,6 +71,18 @@ module IsoDoc::Function
|
|
69
71
|
@in_figure = false
|
70
72
|
end
|
71
73
|
|
74
|
+
def pseudocode_parse(node, out)
|
75
|
+
@in_figure = true
|
76
|
+
name = node.at(ns("./name"))
|
77
|
+
out.div **attr_code(id: node["id"], class: "pseudocode") do |div|
|
78
|
+
node.children.each do |n|
|
79
|
+
parse(n, div) unless n.name == "name"
|
80
|
+
end
|
81
|
+
sourcecode_name_parse(node, div, name) if name
|
82
|
+
end
|
83
|
+
@in_figure = false
|
84
|
+
end
|
85
|
+
|
72
86
|
def example_label(node, div, name)
|
73
87
|
n = get_anchors[node["id"]]
|
74
88
|
div.p **{ class: "example-title" } do |p|
|
@@ -23,22 +23,17 @@ module IsoDoc::Function
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def prefix_container(container, linkend, _target)
|
26
|
-
#l10n(get_anchors[container][:xref] + ", " + linkend)
|
27
26
|
l10n(anchor(container, :xref) + ", " + linkend)
|
28
27
|
end
|
29
28
|
|
30
29
|
def anchor_linkend(node, linkend)
|
31
|
-
if node["citeas"].nil? && node["bibitemid"]
|
32
|
-
#get_anchors.has_key?(node["bibitemid"])
|
33
|
-
#return get_anchors.dig(node["bibitemid"] ,:xref)
|
30
|
+
if node["citeas"].nil? && node["bibitemid"]
|
34
31
|
return anchor(node["bibitemid"] ,:xref) || "???"
|
35
|
-
#elsif node["target"] && get_anchors.has_key?(node["target"])
|
36
32
|
elsif node["target"] && !/.#./.match(node["target"])
|
37
|
-
#linkend = get_anchors[node["target"]][:xref]
|
38
33
|
linkend = anchor(node["target"], :xref)
|
39
|
-
#container = get_anchors[node["target"]][:container]
|
40
34
|
container = anchor(node["target"], :container, false)
|
41
|
-
(container && get_note_container_id(node) != container
|
35
|
+
(container && get_note_container_id(node) != container &&
|
36
|
+
@anchors[node["target"]]) &&
|
42
37
|
linkend = prefix_container(container, linkend, node["target"])
|
43
38
|
end
|
44
39
|
linkend || "???"
|
@@ -47,8 +42,6 @@ module IsoDoc::Function
|
|
47
42
|
def get_linkend(node)
|
48
43
|
link = anchor_linkend(node, docid_l10n(node["target"] || node["citeas"]))
|
49
44
|
link += eref_localities(node.xpath(ns("./locality")), link)
|
50
|
-
#text = node.children.select { |c| c.text? && !c.text.empty? }
|
51
|
-
#link = text.join(" ") unless text.nil? || text.empty?
|
52
45
|
contents = node.children.select { |c| c.name != "locality" }
|
53
46
|
return link if contents.nil? || contents.empty?
|
54
47
|
Nokogiri::XML::NodeSet.new(node.document, contents).to_xml
|
@@ -43,8 +43,6 @@ module IsoDoc::Function
|
|
43
43
|
out.div **{ class: "Note" } do |div|
|
44
44
|
first = node.first_element_child
|
45
45
|
div.p do |p|
|
46
|
-
#anchor = get_anchors[node['id']]
|
47
|
-
#p << "#{anchor&.dig(:label) || '???'}: "
|
48
46
|
p << "#{anchor(node['id'], :label) || '???'}: "
|
49
47
|
para_then_remainder(first, node, p, div)
|
50
48
|
end
|
@@ -133,9 +133,8 @@ module IsoDoc::Function
|
|
133
133
|
def anchor_names(docxml)
|
134
134
|
initial_anchor_names(docxml)
|
135
135
|
back_anchor_names(docxml)
|
136
|
-
# preempt clause notes with all other types of note
|
137
|
-
note_anchor_names(docxml.xpath(ns("//table | //
|
138
|
-
"//figure")))
|
136
|
+
# preempt clause notes with all other types of note (ISO default)
|
137
|
+
note_anchor_names(docxml.xpath(ns("//table | //figure")))
|
139
138
|
note_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
|
140
139
|
example_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
|
141
140
|
list_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
|
@@ -144,7 +143,7 @@ module IsoDoc::Function
|
|
144
143
|
def sequential_figure_names(clause)
|
145
144
|
c = Counter.new
|
146
145
|
j = 0
|
147
|
-
clause.xpath(ns(".//figure")).each do |t|
|
146
|
+
clause.xpath(ns(".//figure[not(@class = 'pseudocode')]")).each do |t|
|
148
147
|
if t.parent.name == "figure" then j += 1
|
149
148
|
else
|
150
149
|
j = 0
|
@@ -250,7 +249,7 @@ module IsoDoc::Function
|
|
250
249
|
def hierarchical_figure_names(clause, num)
|
251
250
|
c = Counter.new
|
252
251
|
j = 0
|
253
|
-
clause.xpath(ns(".//figure")).each do |t|
|
252
|
+
clause.xpath(ns(".//figure[not(@class = 'pseudocode')]")).each do |t|
|
254
253
|
if t.parent.name == "figure" then j += 1
|
255
254
|
else
|
256
255
|
j = 0
|
data/lib/isodoc/version.rb
CHANGED
@@ -49,30 +49,36 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
49
49
|
def word_admonition_images(docxml)
|
50
50
|
docxml.xpath("//div[@class = 'Admonition']//img").each do |i|
|
51
51
|
i["width"], i["height"] =
|
52
|
-
Html2Doc.image_resize(i, File.join(@localdir, i["src"]),
|
52
|
+
Html2Doc.image_resize(i, File.join(@localdir, i["src"]),
|
53
|
+
@maxheight, 300)
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
56
57
|
def word_cleanup(docxml)
|
57
58
|
word_annex_cleanup(docxml)
|
58
59
|
word_preface(docxml)
|
60
|
+
word_table_align(docxml)
|
59
61
|
word_table_separator(docxml)
|
60
62
|
word_admonition_images(docxml)
|
61
63
|
word_list_continuations(docxml)
|
62
64
|
word_example_cleanup(docxml)
|
65
|
+
word_pseudocode_cleanup(docxml)
|
63
66
|
word_image_caption(docxml)
|
64
67
|
docxml
|
65
68
|
end
|
66
69
|
|
70
|
+
def style_update(node, css)
|
71
|
+
node["style"] = node["style"] ? node["style"].sub(/;?$/, ";#{css}") : css
|
72
|
+
end
|
73
|
+
|
67
74
|
def word_image_caption(docxml)
|
68
|
-
docxml.xpath("//p[@class = 'FigureTitle' or @class = 'SourceTitle']").
|
75
|
+
docxml.xpath("//p[@class = 'FigureTitle' or @class = 'SourceTitle']").
|
76
|
+
each do |t|
|
69
77
|
if t.previous_element.name == "img"
|
70
78
|
img = t.previous_element
|
71
79
|
t.previous_element.swap("<p class=\'figure\'>#{img.to_xml}</p>")
|
72
80
|
end
|
73
|
-
t.previous_element
|
74
|
-
t.previous_element["style"].sub(/;?$/, ";page-break-after:avoid;") :
|
75
|
-
"page-break-after:avoid;"
|
81
|
+
style_update(t.previous_element, "page-break-after:avoid;")
|
76
82
|
end
|
77
83
|
end
|
78
84
|
|
@@ -81,19 +87,26 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
81
87
|
list_add(docxml.xpath("//ol[not(ancestor::ul) and not(ancestor::ol)]"), 1)
|
82
88
|
end
|
83
89
|
|
84
|
-
def list_add(xpath,
|
90
|
+
def list_add(xpath, lvl)
|
85
91
|
xpath.each do |list|
|
86
|
-
(list.xpath(".//li") - list.xpath(".//ol//li | .//ul//li")).each do |
|
87
|
-
|
92
|
+
(list.xpath(".//li") - list.xpath(".//ol//li | .//ul//li")).each do |l|
|
93
|
+
l.xpath("./p | ./div/p").each_with_index do |p, i|
|
88
94
|
next if p == 0
|
89
|
-
p["class"] = "ListContLevel#{
|
95
|
+
p["class"] = "ListContLevel#{lvl}"
|
90
96
|
end
|
91
|
-
list_add(
|
92
|
-
list_add(
|
97
|
+
list_add(l.xpath(".//ul") - l.xpath(".//ul//ul | .//ol//ul"), lvl + 1)
|
98
|
+
list_add(l.xpath(".//ol") - l.xpath(".//ul//ol | .//ol//ol"), lvl + 1)
|
93
99
|
end
|
94
100
|
end
|
95
101
|
end
|
96
102
|
|
103
|
+
def word_table_align(docxml)
|
104
|
+
docxml.xpath("//td[@align]/p | //th[@align]/p").each do |p|
|
105
|
+
next if p["align"]
|
106
|
+
style_update(p, "text-align: #{p.parent["align"]}")
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
97
110
|
EMPTY_PARA = "<p style='margin-top:0cm;margin-right:0cm;"\
|
98
111
|
"margin-bottom:0cm;margin-left:0.0pt;margin-bottom:.0001pt;"\
|
99
112
|
"line-height:1.0pt;mso-line-height-rule:exactly'>"\
|
@@ -120,6 +133,12 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
120
133
|
end
|
121
134
|
end
|
122
135
|
|
136
|
+
def word_pseudocode_cleanup(docxml)
|
137
|
+
docxml.xpath("//div[@class = 'pseudocode']//p[not(@class)]").each do |p|
|
138
|
+
p["class"] = "pseudocode"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
123
142
|
def word_preface(docxml)
|
124
143
|
word_cover(docxml) if @wordcoverpage
|
125
144
|
word_intro(docxml, @wordToClevels) if @wordintropage
|
@@ -138,7 +157,8 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
138
157
|
end
|
139
158
|
|
140
159
|
def word_intro(docxml, level)
|
141
|
-
intro = insert_toc(File.read(@wordintropage, encoding: "UTF-8"),
|
160
|
+
intro = insert_toc(File.read(@wordintropage, encoding: "UTF-8"),
|
161
|
+
docxml, level)
|
142
162
|
intro = populate_template(intro, :word)
|
143
163
|
introxml = to_word_xhtml_fragment(intro)
|
144
164
|
docxml.at('//div[@class="WordSection2"]').children.first.previous =
|
data/spec/isodoc/blocks_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
RSpec.describe IsoDoc do
|
4
4
|
it "processes unlabelled notes" do
|
5
|
-
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
5
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
6
6
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
7
7
|
<preface><foreword>
|
8
8
|
<note>
|
@@ -27,7 +27,7 @@ RSpec.describe IsoDoc do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "processes unlabelled notes (Word)" do
|
30
|
-
expect(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
30
|
+
expect(xmlpp(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
31
31
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
32
32
|
<preface><foreword>
|
33
33
|
<note>
|
@@ -64,7 +64,7 @@ RSpec.describe IsoDoc do
|
|
64
64
|
|
65
65
|
|
66
66
|
it "processes labelled notes" do
|
67
|
-
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
67
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
68
68
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
69
69
|
<preface><foreword>
|
70
70
|
<note id="note1">
|
@@ -89,7 +89,7 @@ INPUT
|
|
89
89
|
end
|
90
90
|
|
91
91
|
it "processes sequences of notes" do
|
92
|
-
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
92
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
93
93
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
94
94
|
<preface><foreword>
|
95
95
|
<note id="note1">
|
@@ -120,7 +120,7 @@ INPUT
|
|
120
120
|
end
|
121
121
|
|
122
122
|
it "processes multi-para notes" do
|
123
|
-
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
123
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
124
124
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
125
125
|
<preface><foreword>
|
126
126
|
<note>
|
@@ -147,7 +147,7 @@ INPUT
|
|
147
147
|
end
|
148
148
|
|
149
149
|
it "processes non-para notes" do
|
150
|
-
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
150
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
151
151
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
152
152
|
<preface><foreword>
|
153
153
|
<note>
|
@@ -180,7 +180,7 @@ INPUT
|
|
180
180
|
end
|
181
181
|
|
182
182
|
it "processes non-para notes (Word)" do
|
183
|
-
expect(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
183
|
+
expect(xmlpp(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
184
184
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
185
185
|
<preface><foreword>
|
186
186
|
<note>
|
@@ -223,7 +223,7 @@ INPUT
|
|
223
223
|
end
|
224
224
|
|
225
225
|
it "processes figures" do
|
226
|
-
expect(strip_guid(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to <<~"OUTPUT"
|
226
|
+
expect(xmlpp(strip_guid(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
227
227
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
228
228
|
<preface><foreword>
|
229
229
|
<figure id="figureA-1">
|
@@ -283,7 +283,7 @@ B</pre>
|
|
283
283
|
end
|
284
284
|
|
285
285
|
it "processes figures (Word)" do
|
286
|
-
expect(strip_guid(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to <<~"OUTPUT"
|
286
|
+
expect(xmlpp(strip_guid(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
287
287
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
288
288
|
<preface><foreword>
|
289
289
|
<figure id="figureA-1">
|
@@ -345,7 +345,7 @@ B</pre>
|
|
345
345
|
end
|
346
346
|
|
347
347
|
it "processes examples" do
|
348
|
-
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
348
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
349
349
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
350
350
|
<preface><foreword>
|
351
351
|
<example id="samplecode">
|
@@ -373,7 +373,7 @@ B</pre>
|
|
373
373
|
|
374
374
|
|
375
375
|
it "processes sequences of examples" do
|
376
|
-
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
376
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
377
377
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
378
378
|
<preface><foreword>
|
379
379
|
<example id="samplecode">
|
@@ -414,7 +414,7 @@ B</pre>
|
|
414
414
|
end
|
415
415
|
|
416
416
|
it "processes sourcecode" do
|
417
|
-
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
417
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
418
418
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
419
419
|
<preface><foreword>
|
420
420
|
<sourcecode lang="ruby" id="samplecode">
|
@@ -438,7 +438,7 @@ B</pre>
|
|
438
438
|
end
|
439
439
|
|
440
440
|
it "processes sourcecode (Word)" do
|
441
|
-
expect(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
441
|
+
expect(xmlpp(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
442
442
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
443
443
|
<preface><foreword>
|
444
444
|
<sourcecode lang="ruby" id="samplecode">
|
@@ -479,7 +479,7 @@ B</pre>
|
|
479
479
|
end
|
480
480
|
|
481
481
|
it "processes sourcecode with escapes preserved" do
|
482
|
-
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
482
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
483
483
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
484
484
|
<preface><foreword>
|
485
485
|
<sourcecode id="samplecode">
|
@@ -503,7 +503,7 @@ B</pre>
|
|
503
503
|
end
|
504
504
|
|
505
505
|
it "processes sourcecode with annotations" do
|
506
|
-
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
506
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
507
507
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
508
508
|
<preface><foreword>
|
509
509
|
<sourcecode id="_">puts "Hello, world." <callout target="A">1</callout>
|
@@ -531,7 +531,7 @@ B</pre>
|
|
531
531
|
end
|
532
532
|
|
533
533
|
it "processes admonitions" do
|
534
|
-
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
534
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
535
535
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
536
536
|
<preface><foreword>
|
537
537
|
<admonition id="_70234f78-64e5-4dfc-8b6f-f3f037348b6a" type="caution">
|
@@ -556,7 +556,7 @@ B</pre>
|
|
556
556
|
end
|
557
557
|
|
558
558
|
it "processes admonitions with titles" do
|
559
|
-
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
559
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
560
560
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
561
561
|
<preface><foreword>
|
562
562
|
<admonition id="_70234f78-64e5-4dfc-8b6f-f3f037348b6a" type="caution">
|
@@ -583,7 +583,7 @@ B</pre>
|
|
583
583
|
|
584
584
|
|
585
585
|
it "processes formulae" do
|
586
|
-
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
586
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
587
587
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
588
588
|
<preface><foreword>
|
589
589
|
<formula id="_be9158af-7e93-4ee2-90c5-26d31c181934" unnumbered="true">
|
@@ -629,7 +629,7 @@ B</pre>
|
|
629
629
|
end
|
630
630
|
|
631
631
|
it "processes paragraph alignments" do
|
632
|
-
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
632
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
633
633
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
634
634
|
<preface><foreword>
|
635
635
|
<p align="left" id="_08bfe952-d57f-4150-9c95-5d52098cc2a8">Vache Equipment<br/>
|
@@ -657,7 +657,7 @@ World</p>
|
|
657
657
|
end
|
658
658
|
|
659
659
|
it "processes paragraph alignments (Word)" do
|
660
|
-
expect(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
660
|
+
expect(xmlpp(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
661
661
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
662
662
|
<preface><foreword>
|
663
663
|
<p align="left" id="_08bfe952-d57f-4150-9c95-5d52098cc2a8">Vache Equipment<br/>
|
@@ -698,7 +698,7 @@ World</p>
|
|
698
698
|
|
699
699
|
|
700
700
|
it "processes blockquotes" do
|
701
|
-
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
701
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
702
702
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
703
703
|
<preface><foreword>
|
704
704
|
<quote id="_044bd364-c832-4b78-8fea-92242402a1d1">
|
@@ -728,7 +728,7 @@ World</p>
|
|
728
728
|
end
|
729
729
|
|
730
730
|
it "processes term domains" do
|
731
|
-
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
731
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
732
732
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
733
733
|
<sections>
|
734
734
|
<terms>
|
@@ -754,7 +754,7 @@ World</p>
|
|
754
754
|
end
|
755
755
|
|
756
756
|
it "processes permissions" do
|
757
|
-
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
757
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
758
758
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
759
759
|
<preface><foreword>
|
760
760
|
<permission id="_">
|
@@ -840,7 +840,7 @@ World</p>
|
|
840
840
|
end
|
841
841
|
|
842
842
|
it "processes requirements" do
|
843
|
-
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
843
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
844
844
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
845
845
|
<preface><foreword>
|
846
846
|
<requirement id="A" unnumbered="true">
|
@@ -925,7 +925,7 @@ World</p>
|
|
925
925
|
end
|
926
926
|
|
927
927
|
it "processes recommendation" do
|
928
|
-
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
928
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
929
929
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
930
930
|
<preface><foreword>
|
931
931
|
<recommendation id="_" obligation="shall,could">
|
@@ -1009,5 +1009,53 @@ World</p>
|
|
1009
1009
|
OUTPUT
|
1010
1010
|
end
|
1011
1011
|
|
1012
|
+
it "processes pseudocode" do
|
1013
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
1014
|
+
<itu-standard xmlns="http://riboseinc.com/isoxml">
|
1015
|
+
<bibdata>
|
1016
|
+
<language>en</language>
|
1017
|
+
</bibdata>
|
1018
|
+
<preface><foreword>
|
1019
|
+
<figure id="_" class="pseudocode"><name>Label</name><p id="_"> <strong>A</strong><br/>
|
1020
|
+
<smallcap>B</smallcap></p>
|
1021
|
+
<p id="_"> <em>C</em></p></figure>
|
1022
|
+
</preface></itu-standard>
|
1023
|
+
INPUT
|
1024
|
+
#{HTML_HDR}
|
1025
|
+
<br/>
|
1026
|
+
<div>
|
1027
|
+
<h1 class="ForewordTitle">Foreword</h1>
|
1028
|
+
<div id="_" class="pseudocode"><p id="_">  <b>A</b><br/>
|
1029
|
+
        <span style="font-variant:small-caps;">B</span></p>
|
1030
|
+
<p id="_">  <i>C</i></p><p class="SourceTitle" style="text-align:center;">Label</p></div>
|
1031
|
+
</div>
|
1032
|
+
<p class="zzSTDTitle1"/>
|
1033
|
+
</div>
|
1034
|
+
</body>
|
1035
|
+
</html>
|
1036
|
+
OUTPUT
|
1037
|
+
end
|
1038
|
+
|
1039
|
+
it "processes pseudocode (Word)" do
|
1040
|
+
FileUtils.rm_f "test.doc"
|
1041
|
+
IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", false)
|
1042
|
+
<itu-standard xmlns="http://riboseinc.com/isoxml">
|
1043
|
+
<bibdata>
|
1044
|
+
<language>en</language>
|
1045
|
+
</bibdata>
|
1046
|
+
<preface><foreword>
|
1047
|
+
<figure id="_" class="pseudocode"><name>Label</name><p id="_"> <strong>A</strong><br/>
|
1048
|
+
<smallcap>B</smallcap></p>
|
1049
|
+
<p id="_"> <em>C</em></p></figure>
|
1050
|
+
</preface></itu-standard>
|
1051
|
+
INPUT
|
1052
|
+
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")
|
1053
|
+
<div class="pseudocode"><a name="_" id="_"></a><p class="pseudocode"><a name="_" id="_"></a>  <b>A</b><br/>
|
1054
|
+
        <span style="font-variant:small-caps;">B</span></p>
|
1055
|
+
<p class="pseudocode" style="page-break-after:avoid;"><a name="_" id="_"></a>  <i>C</i></p><p class="SourceTitle" style="text-align:center;">Label</p></div>
|
1056
|
+
OUTPUT
|
1057
|
+
end
|
1058
|
+
|
1059
|
+
|
1012
1060
|
|
1013
1061
|
end
|