isodoc 1.4.2 → 1.5.4
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 +11 -41
- data/isodoc.gemspec +2 -1
- data/lib/isodoc/convert.rb +1 -0
- data/lib/isodoc/function/blocks.rb +4 -0
- data/lib/isodoc/function/inline.rb +1 -1
- data/lib/isodoc/function/references.rb +1 -1
- data/lib/isodoc/function/to_word_html.rb +1 -0
- data/lib/isodoc/function/utils.rb +2 -2
- data/lib/isodoc/presentation_function/block.rb +16 -4
- data/lib/isodoc/presentation_function/inline.rb +21 -23
- data/lib/isodoc/presentation_function/section.rb +1 -1
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/inline.rb +6 -0
- data/lib/isodoc/word_function/postprocess_cover.rb +1 -1
- data/lib/twitter-cldr/patch.rb +39 -0
- data/spec/isodoc/blocks_spec.rb +144 -1
- data/spec/isodoc/inline_spec.rb +4 -1
- data/spec/isodoc/presentation_xml_spec.rb +10 -6
- metadata +22 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8da1e26ad7132ffa08da0fcea2d5690591d195fed192f9de480f142045526f00
|
4
|
+
data.tar.gz: 6f7790baee1639e89aa09f8234a17dd024cac0a9d47ad95039f2caa273264d94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f72f7cbc23636918dade5e52ceb6e1115cdd018b4a051ffd965162d11c081b6e7dfcafe04cf583373e55d5f2262d4393823497b7a5ed4a0a8d248dc5c1574a6
|
7
|
+
data.tar.gz: 249e6bb5247039595870c52969c49bc4acbb40a1dcae798a4f925ab6fa5ea4640a22a8defdd60ad64134159a21f26088268324ce2381f00aa79db673ffcb3695
|
data/.github/workflows/rake.yml
CHANGED
@@ -16,17 +16,17 @@ jobs:
|
|
16
16
|
strategy:
|
17
17
|
fail-fast: false
|
18
18
|
matrix:
|
19
|
-
ruby: [ '2.6', '2.5', '2.4' ]
|
19
|
+
ruby: [ '2.7', '2.6', '2.5', '2.4' ]
|
20
20
|
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
21
21
|
experimental: [ false ]
|
22
22
|
include:
|
23
|
-
- ruby: '
|
23
|
+
- ruby: '3.0'
|
24
24
|
os: 'ubuntu-latest'
|
25
25
|
experimental: true
|
26
|
-
- ruby: '
|
26
|
+
- ruby: '3.0'
|
27
27
|
os: 'windows-latest'
|
28
28
|
experimental: true
|
29
|
-
- ruby: '
|
29
|
+
- ruby: '3.0'
|
30
30
|
os: 'macos-latest'
|
31
31
|
experimental: true
|
32
32
|
steps:
|
@@ -35,49 +35,19 @@ jobs:
|
|
35
35
|
- uses: ruby/setup-ruby@v1
|
36
36
|
with:
|
37
37
|
ruby-version: ${{ matrix.ruby }}
|
38
|
+
bundler-cache: true
|
38
39
|
|
39
|
-
- uses:
|
40
|
-
with:
|
41
|
-
path: vendor/bundle
|
42
|
-
key: bundle-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}
|
43
|
-
restore-keys: bundle-${{ matrix.os }}-${{ matrix.ruby }}
|
44
|
-
|
45
|
-
- run: bundle config set path 'vendor/bundle'
|
46
|
-
|
47
|
-
- run: bundle install --jobs 4 --retry 3
|
48
|
-
|
49
|
-
- name: Install Inkscape macOS
|
50
|
-
if: matrix.os == 'macos-latest'
|
51
|
-
run: |
|
52
|
-
brew cask install inkscape
|
53
|
-
inkscape --version
|
54
|
-
|
55
|
-
- name: Install Inkscape Ubuntu
|
56
|
-
if: matrix.os == 'ubuntu-latest'
|
57
|
-
run: |
|
58
|
-
sudo add-apt-repository ppa:inkscape.dev/stable
|
59
|
-
sudo apt update
|
60
|
-
sudo apt install inkscape
|
61
|
-
inkscape --version
|
62
|
-
|
63
|
-
- name: Install Inkscape Windows
|
64
|
-
if: matrix.os == 'windows-latest'
|
65
|
-
run: |
|
66
|
-
choco install --no-progress -y inkscape
|
67
|
-
inkscape --version
|
40
|
+
- uses: metanorma/metanorma-build-scripts/inkscape-setup-action@master
|
68
41
|
|
69
42
|
- run: bundle exec rake
|
70
43
|
|
71
44
|
tests-passed:
|
72
45
|
needs: rake
|
73
46
|
runs-on: ubuntu-latest
|
74
|
-
continue-on-error: true
|
75
47
|
steps:
|
76
|
-
-
|
77
|
-
uses: Sibz/github-status-action@v1
|
48
|
+
- uses: peter-evans/repository-dispatch@v1
|
78
49
|
with:
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
sha: ${{ github.event.pull_request.head.sha || github.sha }}
|
50
|
+
token: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
|
51
|
+
repository: ${{ github.repository }}
|
52
|
+
event-type: notify
|
53
|
+
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
|
data/isodoc.gemspec
CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_dependency "thread_safe"
|
35
35
|
spec.add_dependency "uuidtools"
|
36
36
|
spec.add_dependency "html2doc", "~> 1.0.0"
|
37
|
-
spec.add_dependency "liquid"
|
37
|
+
spec.add_dependency "liquid", "~> 4"
|
38
38
|
spec.add_dependency "twitter_cldr"
|
39
39
|
spec.add_dependency "roman-numerals"
|
40
40
|
spec.add_dependency "metanorma", "~> 1.2.0"
|
@@ -50,4 +50,5 @@ Gem::Specification.new do |spec|
|
|
50
50
|
spec.add_development_dependency "rubocop", "= 0.54.0"
|
51
51
|
spec.add_development_dependency "simplecov", "~> 0.15"
|
52
52
|
spec.add_development_dependency "timecop", "~> 0.9"
|
53
|
+
spec.add_development_dependency "rexml"
|
53
54
|
end
|
data/lib/isodoc/convert.rb
CHANGED
@@ -39,7 +39,7 @@ module IsoDoc::Function
|
|
39
39
|
"uri[@type = 'citation']"))
|
40
40
|
return href unless url
|
41
41
|
href = suffix_url(url.text)
|
42
|
-
anchor = node&.at(ns(".//locality[@type = 'anchor']"))&.text
|
42
|
+
anchor = node&.at(ns(".//locality[@type = 'anchor']"))&.text&.strip
|
43
43
|
anchor and href += "##{anchor}"
|
44
44
|
href
|
45
45
|
end
|
@@ -87,7 +87,7 @@ module IsoDoc::Function
|
|
87
87
|
|
88
88
|
def omit_docid_prefix(prefix)
|
89
89
|
return true if prefix.nil? || prefix.empty?
|
90
|
-
return %w(ISO IEC ITU W3C metanorma).include? prefix
|
90
|
+
return %w(ISO IEC IEV ITU W3C metanorma rfc-anchor).include? prefix
|
91
91
|
end
|
92
92
|
|
93
93
|
def date_note_process(b, ref)
|
@@ -225,6 +225,7 @@ module IsoDoc::Function
|
|
225
225
|
when "passthrough" then passthrough_parse(node, out)
|
226
226
|
when "amend" then amend_parse(node, out)
|
227
227
|
when "tab" then clausedelimspace(out) # in Presentation XML only
|
228
|
+
when "svg" then svg_parse(node, out) # introduced in Presentation XML only
|
228
229
|
else
|
229
230
|
error_parse(node, out)
|
230
231
|
end
|
@@ -152,8 +152,8 @@ module IsoDoc::Function
|
|
152
152
|
def populate_template(docxml, _format = nil)
|
153
153
|
meta = @meta
|
154
154
|
.get
|
155
|
-
.merge(@labels
|
156
|
-
.merge(@meta.labels
|
155
|
+
.merge(@labels ? {labels: @labels} : {})
|
156
|
+
.merge(@meta.labels ? {labels: @meta.labels} : {})
|
157
157
|
.merge(fonts_options || {})
|
158
158
|
template = liquid(docxml)
|
159
159
|
template.render(meta.map { |k, v| [k.to_s, empty2nil(v)] }.to_h)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "base64"
|
2
|
+
|
1
3
|
module IsoDoc
|
2
4
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
3
5
|
def lower2cap(s)
|
@@ -6,14 +8,24 @@ module IsoDoc
|
|
6
8
|
end
|
7
9
|
|
8
10
|
def figure(docxml)
|
9
|
-
docxml.xpath(ns("//
|
10
|
-
|
11
|
+
docxml.xpath(ns("//image")).each { |f| svg_extract(f) }
|
12
|
+
docxml.xpath(ns("//figure")).each { |f| figure1(f) }
|
13
|
+
docxml.xpath(ns("//svgmap")).each do |s|
|
14
|
+
if f = s.at(ns("./figure")) then s.replace(f)
|
15
|
+
else
|
16
|
+
s.remove
|
17
|
+
end
|
11
18
|
end
|
12
19
|
end
|
13
20
|
|
21
|
+
def svg_extract(f)
|
22
|
+
return unless %r{^data:image/svg\+xml;base64,}.match(f["src"])
|
23
|
+
svg = Base64.strict_decode64(f["src"].sub(%r{^data:image/svg\+xml;base64,}, ""))
|
24
|
+
f.replace(svg.sub(/<\?xml[^>]*>/, ""))
|
25
|
+
end
|
26
|
+
|
14
27
|
def figure1(f)
|
15
|
-
return sourcecode1(f) if f["class"] == "pseudocode" ||
|
16
|
-
f["type"] == "pseudocode"
|
28
|
+
return sourcecode1(f) if f["class"] == "pseudocode" || f["type"] == "pseudocode"
|
17
29
|
return if labelled_ancestor(f) && f.ancestors("figure").empty?
|
18
30
|
return if f.at(ns("./figure")) and !f.at(ns("./name"))
|
19
31
|
lbl = @xrefs.anchor(f['id'], :label, false) or return
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require "twitter_cldr"
|
2
|
+
require "bigdecimal"
|
3
|
+
require_relative "../../twitter-cldr/patch"
|
2
4
|
|
3
5
|
module IsoDoc
|
4
6
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
@@ -10,8 +12,7 @@ module IsoDoc
|
|
10
12
|
if node["citeas"].nil? && node["bibitemid"]
|
11
13
|
return @xrefs.anchor(node["bibitemid"] ,:xref) || "???"
|
12
14
|
elsif node["target"] && node["droploc"]
|
13
|
-
return @xrefs.anchor(node["target"], :value) ||
|
14
|
-
@xrefs.anchor(node["target"], :label) ||
|
15
|
+
return @xrefs.anchor(node["target"], :value) || @xrefs.anchor(node["target"], :label) ||
|
15
16
|
@xrefs.anchor(node["target"], :xref) || "???"
|
16
17
|
elsif node["target"] && !/.#./.match(node["target"])
|
17
18
|
linkend = anchor_linkend1(node)
|
@@ -22,9 +23,8 @@ module IsoDoc
|
|
22
23
|
def anchor_linkend1(node)
|
23
24
|
linkend = @xrefs.anchor(node["target"], :xref)
|
24
25
|
container = @xrefs.anchor(node["target"], :container, false)
|
25
|
-
(container && get_note_container_id(node) != container &&
|
26
|
-
|
27
|
-
linkend = prefix_container(container, linkend, node["target"])
|
26
|
+
(container && get_note_container_id(node) != container && @xrefs.get[node["target"]]) &&
|
27
|
+
linkend = prefix_container(container, linkend, node["target"])
|
28
28
|
capitalise_xref(node, linkend)
|
29
29
|
end
|
30
30
|
|
@@ -35,13 +35,11 @@ module IsoDoc
|
|
35
35
|
return linkend if linkend[0,1].match(/\p{Upper}/)
|
36
36
|
prec = nearest_block_parent(node).xpath("./descendant-or-self::text()") &
|
37
37
|
node.xpath("./preceding::text()")
|
38
|
-
(prec.empty? || /(?!<[^.].)\.\s+$/.match(prec.map { |p| p.text }.join)) ?
|
39
|
-
linkend&.capitalize : linkend
|
38
|
+
(prec.empty? || /(?!<[^.].)\.\s+$/.match(prec.map { |p| p.text }.join)) ? linkend&.capitalize : linkend
|
40
39
|
end
|
41
40
|
|
42
41
|
def nearest_block_parent(node)
|
43
|
-
until %w(p title td th name formula
|
44
|
-
li dt dd sourcecode pre).include?(node.name)
|
42
|
+
until %w(p title td th name formula li dt dd sourcecode pre).include?(node.name)
|
45
43
|
node = node.parent
|
46
44
|
end
|
47
45
|
node
|
@@ -89,8 +87,7 @@ module IsoDoc
|
|
89
87
|
def eref_localities0(r, i, target, delim)
|
90
88
|
if r["type"] == "whole" then l10n("#{delim} #{@i18n.wholeoftext}")
|
91
89
|
else
|
92
|
-
eref_localities1(target, r["type"], r.at(ns("./referenceFrom")),
|
93
|
-
r.at(ns("./referenceTo")), delim, @lang)
|
90
|
+
eref_localities1(target, r["type"], r.at(ns("./referenceFrom")), r.at(ns("./referenceTo")), delim, @lang)
|
94
91
|
end
|
95
92
|
end
|
96
93
|
|
@@ -106,8 +103,7 @@ module IsoDoc
|
|
106
103
|
# TODO: move to localization file
|
107
104
|
def eref_localities1(target, type, from, to, delim, lang = "en")
|
108
105
|
return "" if type == "anchor"
|
109
|
-
lang == "zh" and
|
110
|
-
return l10n(eref_localities1_zh(target, type, from, to, delim))
|
106
|
+
lang == "zh" and return l10n(eref_localities1_zh(target, type, from, to, delim))
|
111
107
|
ret = delim
|
112
108
|
loc = @i18n.locality[type] || type.sub(/^locality:/, "").capitalize
|
113
109
|
ret += " #{loc}"
|
@@ -163,23 +159,23 @@ module IsoDoc
|
|
163
159
|
# TwitterCldr::DataReaders::NumberDataReader.new(locale).symbols
|
164
160
|
def localize_maths(f, locale)
|
165
161
|
f.xpath(".//m:mn", MATHML).each do |x|
|
166
|
-
num =
|
162
|
+
num = BigDecimal(x.text)
|
167
163
|
precision = /\./.match(x.text) ? x.text.sub(/^.*\./, "").size : 0
|
168
164
|
x.children = localized_number(num, locale, precision)
|
169
165
|
end
|
170
166
|
end
|
171
167
|
|
172
|
-
# By itself
|
168
|
+
# By itself twitter-cldr does not support fraction part digits grouping
|
173
169
|
# and custom delimeter, will decorate fraction part manually
|
174
170
|
def localized_number(num, locale, precision)
|
175
|
-
|
171
|
+
TwitterCldr::Localized::LocalizedNumber.localize(BigDecimal)
|
172
|
+
localized = (precision == 0) ? num.localize(locale).to_s :
|
176
173
|
num.localize(locale).to_decimal.to_s(:precision => precision)
|
177
174
|
twitter_cldr_reader_symbols = twitter_cldr_reader(locale)
|
178
175
|
return localized unless twitter_cldr_reader_symbols[:decimal]
|
179
176
|
integer, fraction = localized.split(twitter_cldr_reader_symbols[:decimal])
|
180
177
|
return localized if fraction.nil? || fraction.length.zero?
|
181
|
-
[integer, decorate_fraction_part(fraction, locale)].
|
182
|
-
join(twitter_cldr_reader_symbols[:decimal])
|
178
|
+
[integer, decorate_fraction_part(fraction, locale)].join(twitter_cldr_reader_symbols[:decimal])
|
183
179
|
end
|
184
180
|
|
185
181
|
def decorate_fraction_part(fract, locale)
|
@@ -211,7 +207,11 @@ module IsoDoc
|
|
211
207
|
def mathml1(f, locale)
|
212
208
|
localize_maths(f, locale)
|
213
209
|
return unless f.elements.size == 1 && f.elements.first.name == "mn"
|
214
|
-
f.
|
210
|
+
if f.parent.name == "stem"
|
211
|
+
f.parent.replace(f.at("./m:mn", MATHML).children)
|
212
|
+
else
|
213
|
+
f.replace(f.at("./m:mn", MATHML).children)
|
214
|
+
end
|
215
215
|
end
|
216
216
|
|
217
217
|
def variant(docxml)
|
@@ -225,8 +225,7 @@ module IsoDoc
|
|
225
225
|
end
|
226
226
|
|
227
227
|
def variant1(node)
|
228
|
-
if (!node["lang"] || node["lang"] == @lang) &&
|
229
|
-
(!node["script"] || node["script"] == @script)
|
228
|
+
if (!node["lang"] || node["lang"] == @lang) && (!node["script"] || node["script"] == @script)
|
230
229
|
elsif found_matching_variant_sibling(node)
|
231
230
|
node["remove"] = "true"
|
232
231
|
else
|
@@ -239,8 +238,7 @@ module IsoDoc
|
|
239
238
|
foll = node.xpath("./following-sibling::xmlns:variant")
|
240
239
|
found = false
|
241
240
|
(prev + foll).each do |n|
|
242
|
-
found = true if n["lang"] == @lang &&
|
243
|
-
(!n["script"] || n["script"] == @script)
|
241
|
+
found = true if n["lang"] == @lang && (!n["script"] || n["script"] == @script)
|
244
242
|
end
|
245
243
|
found
|
246
244
|
end
|
data/lib/isodoc/version.rb
CHANGED
@@ -22,6 +22,12 @@ module IsoDoc::WordFunction
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
def svg_parse(node, out)
|
26
|
+
svg = Base64.strict_encode64(node.to_xml)
|
27
|
+
r = node.replace("<img src='data:image/svg+xml;base64,#{svg}' mimetype='image/svg+xml'/>").first
|
28
|
+
image_parse(r, out, nil)
|
29
|
+
end
|
30
|
+
|
25
31
|
def imgsrc(node)
|
26
32
|
ret = svg_to_emf(node) and return ret
|
27
33
|
return node["src"] unless %r{^data:}.match node["src"]
|
@@ -96,7 +96,7 @@ module IsoDoc::WordFunction
|
|
96
96
|
def generate_header(filename, _dir)
|
97
97
|
return nil unless @header
|
98
98
|
template = IsoDoc::Common.liquid(File.read(@header, encoding: "UTF-8"))
|
99
|
-
meta = @meta.get.merge(@labels
|
99
|
+
meta = @meta.get.merge(@labels ? { labels: @labels } : {}).merge(@meta.labels ? { labels: @meta.labels } : {})
|
100
100
|
meta[:filename] = filename
|
101
101
|
params = meta.map { |k, v| [k.to_s, v] }.to_h
|
102
102
|
Tempfile.open(%w(header html), :encoding => "utf-8") do |f|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module ::TwitterCldr
|
2
|
+
module Formatters
|
3
|
+
class NumberFormatter
|
4
|
+
def parse_number(number, options = {})
|
5
|
+
precision = options[:precision] || precision_from(number)
|
6
|
+
rounding = options[:rounding] || 0
|
7
|
+
if number.is_a? BigDecimal
|
8
|
+
number = precision == 0 ?
|
9
|
+
round_to(number, precision, rounding).abs.fix.to_s("F") :
|
10
|
+
round_to(number, precision, rounding).abs.round(precision).to_s("F")
|
11
|
+
else
|
12
|
+
number = "%.#{precision}f" % round_to(number, precision, rounding).abs
|
13
|
+
end
|
14
|
+
number.split(".")
|
15
|
+
end
|
16
|
+
|
17
|
+
def round_to(number, precision, rounding = 0)
|
18
|
+
factor = 10 ** precision
|
19
|
+
result = number.is_a?(BigDecimal) ?
|
20
|
+
((number * factor).fix / factor) :
|
21
|
+
((number * factor).round.to_f / factor)
|
22
|
+
if rounding > 0
|
23
|
+
rounding = rounding.to_f / factor
|
24
|
+
result = number.is_a?(BigDecimal) ?
|
25
|
+
((result * (1.0 / rounding)).fix / (1.0 / rounding)) :
|
26
|
+
((result * (1.0 / rounding)).round.to_f / (1.0 / rounding))
|
27
|
+
end
|
28
|
+
result
|
29
|
+
end
|
30
|
+
|
31
|
+
def precision_from(num)
|
32
|
+
return 0 if num.is_a?(BigDecimal) && num.fix == num
|
33
|
+
parts = (num.is_a?(BigDecimal) ? num.to_s("F") : num.to_s ).split(".")
|
34
|
+
parts.size == 2 ? parts[1].size : 0
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
data/spec/isodoc/blocks_spec.rb
CHANGED
@@ -768,6 +768,93 @@ B</pre>
|
|
768
768
|
expect(xmlpp(strip_guid(IsoDoc::WordConvert.new({}).convert("test", presxml, true).gsub(/['"][^'".]+\.(gif|xml)['"]/, "'_.\\1'").gsub(/mso-bookmark:_Ref\d+/, "mso-bookmark:_Ref")))).to be_equivalent_to xmlpp(word)
|
769
769
|
end
|
770
770
|
|
771
|
+
it "processes SVG" do
|
772
|
+
input = <<~INPUT
|
773
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
774
|
+
<preface><foreword>
|
775
|
+
<figure id="figureA-1">
|
776
|
+
<image src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj4KICA8Y2lyY2xlIGZpbGw9IiMwMDkiIHI9IjQ1IiBjeD0iNTAiIGN5PSI1MCIvPgogIDxwYXRoIGQ9Ik0zMywyNkg3OEEzNywzNywwLDAsMSwzMyw4M1Y1N0g1OVY0M0gzM1oiIGZpbGw9IiNGRkYiLz4KPC9zdmc+Cg==" id="_d3731866-1a07-435a-a6c2-1acd41023a4e" mimetype="image/svg+xml" height="auto" width="auto"/>
|
777
|
+
</figure>
|
778
|
+
</foreword></preface>
|
779
|
+
</iso-standard>
|
780
|
+
INPUT
|
781
|
+
|
782
|
+
presxml = <<~OUTPUT
|
783
|
+
<iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
|
784
|
+
<preface>
|
785
|
+
<foreword>
|
786
|
+
<figure id='figureA-1'>
|
787
|
+
<name>Figure 1</name>
|
788
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'>
|
789
|
+
<circle fill='#009' r='45' cx='50' cy='50'/>
|
790
|
+
<path d='M33,26H78A37,37,0,0,1,33,83V57H59V43H33Z' fill='#FFF'/>
|
791
|
+
</svg>
|
792
|
+
</figure>
|
793
|
+
</foreword>
|
794
|
+
</preface>
|
795
|
+
</iso-standard>
|
796
|
+
OUTPUT
|
797
|
+
|
798
|
+
html = <<~HTML
|
799
|
+
#{HTML_HDR}
|
800
|
+
<br/>
|
801
|
+
<div>
|
802
|
+
<h1 class='ForewordTitle'>Foreword</h1>
|
803
|
+
<div id='figureA-1' class='figure'>
|
804
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'>
|
805
|
+
<circle fill='#009' r='45' cx='50' cy='50'/>
|
806
|
+
<path d='M33,26H78A37,37,0,0,1,33,83V57H59V43H33Z' fill='#FFF'/>
|
807
|
+
</svg>
|
808
|
+
<p class='FigureTitle' style='text-align:center;'>Figure 1</p>
|
809
|
+
</div>
|
810
|
+
</div>
|
811
|
+
<p class='zzSTDTitle1'/>
|
812
|
+
</div>
|
813
|
+
</body>
|
814
|
+
</html>
|
815
|
+
HTML
|
816
|
+
|
817
|
+
doc = <<~DOC
|
818
|
+
<html xmlns:epub='http://www.idpf.org/2007/ops' lang='en'>
|
819
|
+
<head>
|
820
|
+
<style>
|
821
|
+
</style>
|
822
|
+
</head>
|
823
|
+
<body lang='EN-US' link='blue' vlink='#954F72'>
|
824
|
+
<div class='WordSection1'>
|
825
|
+
<p> </p>
|
826
|
+
</div>
|
827
|
+
<p>
|
828
|
+
<br clear='all' class='section'/>
|
829
|
+
</p>
|
830
|
+
<div class='WordSection2'>
|
831
|
+
<p>
|
832
|
+
<br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
|
833
|
+
</p>
|
834
|
+
<div>
|
835
|
+
<h1 class='ForewordTitle'>Foreword</h1>
|
836
|
+
<div id='figureA-1' class='figure'>
|
837
|
+
<img src='_.emf'/>
|
838
|
+
<p class='FigureTitle' style='text-align:center;'>Figure 1</p>
|
839
|
+
</div>
|
840
|
+
</div>
|
841
|
+
<p> </p>
|
842
|
+
</div>
|
843
|
+
<p>
|
844
|
+
<br clear='all' class='section'/>
|
845
|
+
</p>
|
846
|
+
<div class='WordSection3'>
|
847
|
+
<p class='zzSTDTitle1'/>
|
848
|
+
</div>
|
849
|
+
</body>
|
850
|
+
</html>
|
851
|
+
DOC
|
852
|
+
|
853
|
+
expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true).gsub(/\</, "<"))).to be_equivalent_to xmlpp(presxml)
|
854
|
+
expect(xmlpp(strip_guid(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true)))).to be_equivalent_to xmlpp(html)
|
855
|
+
expect(xmlpp(strip_guid(IsoDoc::WordConvert.new({}).convert("test", presxml, true).gsub(/['"][^'".]+(?<!odf1)(?<!odf)\.emf['"]/, "'_.emf'").gsub(/['"][^'".]+\.(gif|xml)['"]/, "'_.\\1'")))).to be_equivalent_to xmlpp(doc)
|
856
|
+
end
|
857
|
+
|
771
858
|
it "converts SVG (Word)" do
|
772
859
|
FileUtils.rm_rf "spec/assets/odf1.emf"
|
773
860
|
expect(xmlpp(strip_guid(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true).gsub(/['"][^'".]+(?<!odf1)(?<!odf)\.emf['"]/, "'_.emf'").gsub(/['"][^'".]+\.(gif|xml)['"]/, "'_.\\1'").gsub(/mso-bookmark:_Ref\d+/, "mso-bookmark:_Ref")))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
@@ -2687,7 +2774,7 @@ expect(( File.read("test.html").gsub(%r{^.*<h1 class="ForewordTitle">Foreword</h
|
|
2687
2774
|
expect(File.exist?("test.html.err")).to be true
|
2688
2775
|
end
|
2689
2776
|
|
2690
|
-
it "
|
2777
|
+
it "ignores passthrough with incompatible format" do
|
2691
2778
|
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
2692
2779
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
2693
2780
|
<preface><foreword>
|
@@ -2707,6 +2794,62 @@ expect(( File.read("test.html").gsub(%r{^.*<h1 class="ForewordTitle">Foreword</h
|
|
2707
2794
|
OUTPUT
|
2708
2795
|
end
|
2709
2796
|
|
2797
|
+
it "processes svgmap" do
|
2798
|
+
expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~INPUT, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(<<~OUTPUT)
|
2799
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
2800
|
+
<sections>
|
2801
|
+
<svgmap id='_'>
|
2802
|
+
<target href='http://www.example.com'>
|
2803
|
+
<xref target='ref1'>Computer</xref>
|
2804
|
+
</target>
|
2805
|
+
</svgmap>
|
2806
|
+
<figure id='_'>
|
2807
|
+
<image src='action_schemaexpg1.svg' id='_' mimetype='image/svg+xml' height='auto' width='auto'/>
|
2808
|
+
</figure>
|
2809
|
+
<svgmap id='_'>
|
2810
|
+
<figure id='_'>
|
2811
|
+
<image src='action_schemaexpg2.svg' id='_' mimetype='image/svg+xml' height='auto' width='auto' alt='Workmap'/>
|
2812
|
+
</figure>
|
2813
|
+
<target href='mn://support_resource_schema'>
|
2814
|
+
<eref bibitemid='express_action_schema' citeas=''>
|
2815
|
+
<localityStack>
|
2816
|
+
<locality type='anchor'>
|
2817
|
+
<referenceFrom>action_schema.basic</referenceFrom>
|
2818
|
+
</locality>
|
2819
|
+
</localityStack>
|
2820
|
+
Coffee
|
2821
|
+
</eref>
|
2822
|
+
</target>
|
2823
|
+
</svgmap>
|
2824
|
+
</sections>
|
2825
|
+
<bibliography>
|
2826
|
+
<references hidden='true' normative='false'>
|
2827
|
+
<bibitem id='express_action_schema' type='internal'>
|
2828
|
+
<docidentifier type='repository'>express/action_schema</docidentifier>
|
2829
|
+
</bibitem>
|
2830
|
+
</references>
|
2831
|
+
</bibliography>
|
2832
|
+
</iso-standard>
|
2833
|
+
INPUT
|
2834
|
+
<iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
|
2835
|
+
<sections>
|
2836
|
+
<figure id='_'>
|
2837
|
+
<image src='action_schemaexpg1.svg' id='_' mimetype='image/svg+xml' height='auto' width='auto'/>
|
2838
|
+
</figure>
|
2839
|
+
<figure id='_'>
|
2840
|
+
<image src='action_schemaexpg2.svg' id='_' mimetype='image/svg+xml' height='auto' width='auto' alt='Workmap'/>
|
2841
|
+
</figure>
|
2842
|
+
</sections>
|
2843
|
+
<bibliography>
|
2844
|
+
<references hidden='true' normative='false'>
|
2845
|
+
<bibitem id='express_action_schema' type='internal'>
|
2846
|
+
<docidentifier type='repository'>express/action_schema</docidentifier>
|
2847
|
+
</bibitem>
|
2848
|
+
</references>
|
2849
|
+
</bibliography>
|
2850
|
+
</iso-standard>
|
2851
|
+
OUTPUT
|
2710
2852
|
|
2853
|
+
end
|
2711
2854
|
|
2712
2855
|
end
|
data/spec/isodoc/inline_spec.rb
CHANGED
@@ -124,7 +124,10 @@ OUTPUT
|
|
124
124
|
<preface><foreword>
|
125
125
|
<p><index primary="A" secondary="B" tertiary="C"/></p>
|
126
126
|
</foreword></preface>
|
127
|
-
<sections
|
127
|
+
<sections/>
|
128
|
+
<indexsect>
|
129
|
+
<title>Index</title>
|
130
|
+
</indexsect>
|
128
131
|
</iso-standard>
|
129
132
|
INPUT
|
130
133
|
<iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
|
@@ -25,7 +25,10 @@ it "localises numbers in MathML" do
|
|
25
25
|
<title language="en">test</title>
|
26
26
|
</bibdata>
|
27
27
|
<preface>
|
28
|
-
<p
|
28
|
+
<p>
|
29
|
+
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>64212149677264515</mn></math></stem>
|
30
|
+
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>642121496772645.15</mn></math></stem>
|
31
|
+
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>30000</mn></math></stem>
|
29
32
|
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>P</mi><mfenced open="(" close=")"><mrow><mi>X</mi><mo>≥</mo><msub><mrow><mi>X</mi></mrow><mrow><mo>max</mo></mrow></msub></mrow></mfenced><mo>=</mo><munderover><mrow><mo>∑</mo></mrow><mrow><mrow><mi>j</mi><mo>=</mo><msub><mrow><mi>X</mi></mrow><mrow><mo>max</mo></mrow></msub></mrow></mrow><mrow><mn>1000</mn></mrow></munderover><mfenced open="(" close=")"><mtable><mtr><mtd><mn>1000</mn></mtd></mtr><mtr><mtd><mi>j</mi></mtd></mtr></mtable></mfenced><msup><mrow><mi>p</mi></mrow><mrow><mi>j</mi></mrow></msup><msup><mrow><mfenced open="(" close=")"><mrow><mn>1</mn><mo>−</mo><mi>p</mi></mrow></mfenced></mrow><mrow><mrow><mn>1.003</mn><mo>−</mo><mi>j</mi></mrow></mrow></msup></math></stem></p>
|
30
33
|
</preface>
|
31
34
|
</iso-standard>
|
@@ -37,7 +40,8 @@ it "localises numbers in MathML" do
|
|
37
40
|
|
38
41
|
<preface>
|
39
42
|
<p>
|
40
|
-
|
43
|
+
64,212,149,677,264,515
|
44
|
+
642,121,496,772,645.15 30,000
|
41
45
|
<stem type='MathML'>
|
42
46
|
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
43
47
|
<mi>P</mi>
|
@@ -248,7 +252,7 @@ end
|
|
248
252
|
|
249
253
|
<preface>
|
250
254
|
<p>
|
251
|
-
|
255
|
+
30,000
|
252
256
|
<stem type='MathML'>
|
253
257
|
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
254
258
|
<mi>P</mi>
|
@@ -382,7 +386,7 @@ it "localises numbers in MathML in French" do
|
|
382
386
|
<language>fr</language>
|
383
387
|
</bibdata>
|
384
388
|
<preface>
|
385
|
-
<p><
|
389
|
+
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>30000</mn></math>
|
386
390
|
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>P</mi><mfenced open="(" close=")"><mrow><mi>X</mi><mo>≥</mo><msub><mrow><mi>X</mi></mrow><mrow><mo>max</mo></mrow></msub></mrow></mfenced><mo>=</mo><munderover><mrow><mo>∑</mo></mrow><mrow><mrow><mi>j</mi><mo>=</mo><msub><mrow><mi>X</mi></mrow><mrow><mo>max</mo></mrow></msub></mrow></mrow><mrow><mn>1000</mn></mrow></munderover><mfenced open="(" close=")"><mtable><mtr><mtd><mn>1000</mn></mtd></mtr><mtr><mtd><mi>j</mi></mtd></mtr></mtable></mfenced><msup><mrow><mi>p</mi></mrow><mrow><mi>j</mi></mrow></msup><msup><mrow><mfenced open="(" close=")"><mrow><mn>1</mn><mo>−</mo><mi>p</mi></mrow></mfenced></mrow><mrow><mrow><mn>1.003</mn><mo>−</mo><mi>j</mi></mrow></mrow></msup></math></stem></p>
|
387
391
|
</preface>
|
388
392
|
</iso-standard>
|
@@ -395,7 +399,7 @@ it "localises numbers in MathML in French" do
|
|
395
399
|
|
396
400
|
<preface>
|
397
401
|
<p>
|
398
|
-
|
402
|
+
30 000
|
399
403
|
<stem type='MathML'>
|
400
404
|
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
401
405
|
<mi>P</mi>
|
@@ -506,7 +510,7 @@ it "customises localisation of numbers" do
|
|
506
510
|
|
507
511
|
<preface>
|
508
512
|
<p>
|
509
|
-
|
513
|
+
30'000
|
510
514
|
<stem type='MathML'>
|
511
515
|
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
512
516
|
<mi>P</mi>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isodoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4
|
4
|
+
version: 1.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciimath
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: liquid
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '4'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '4'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: twitter_cldr
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -304,6 +304,20 @@ dependencies:
|
|
304
304
|
- - "~>"
|
305
305
|
- !ruby/object:Gem::Version
|
306
306
|
version: '0.9'
|
307
|
+
- !ruby/object:Gem::Dependency
|
308
|
+
name: rexml
|
309
|
+
requirement: !ruby/object:Gem::Requirement
|
310
|
+
requirements:
|
311
|
+
- - ">="
|
312
|
+
- !ruby/object:Gem::Version
|
313
|
+
version: '0'
|
314
|
+
type: :development
|
315
|
+
prerelease: false
|
316
|
+
version_requirements: !ruby/object:Gem::Requirement
|
317
|
+
requirements:
|
318
|
+
- - ">="
|
319
|
+
- !ruby/object:Gem::Version
|
320
|
+
version: '0'
|
307
321
|
description: |
|
308
322
|
isodoc converts documents in the IsoDoc document model into
|
309
323
|
Microsoft Word and HTML.
|
@@ -404,6 +418,7 @@ files:
|
|
404
418
|
- lib/isodoc/xref/xref_gen_seq.rb
|
405
419
|
- lib/isodoc/xref/xref_sect_gen.rb
|
406
420
|
- lib/isodoc/xslfo_convert.rb
|
421
|
+
- lib/twitter-cldr/patch.rb
|
407
422
|
- spec/assets/header.html
|
408
423
|
- spec/assets/html.scss
|
409
424
|
- spec/assets/htmlcover.html
|
@@ -454,7 +469,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
454
469
|
- !ruby/object:Gem::Version
|
455
470
|
version: '0'
|
456
471
|
requirements: []
|
457
|
-
rubygems_version: 3.
|
472
|
+
rubygems_version: 3.1.4
|
458
473
|
signing_key:
|
459
474
|
specification_version: 4
|
460
475
|
summary: Convert documents in IsoDoc into Word and HTML in AsciiDoc.
|