Skip to content

Commit

Permalink
WIP: Draft eps2svg
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeymorozov committed Dec 12, 2023
1 parent 34a0ce0 commit 2cbb276
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
15 changes: 14 additions & 1 deletion lib/isodoc/presentation_function/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def figure_label(elem)
end

def eps2svg(img)
# pp "Running eps2svg"
pp "Running eps2svg"
return unless eps?(img["mimetype"])

img["mimetype"] = "image/svg+xml"
Expand Down Expand Up @@ -111,6 +111,19 @@ def eps_to_svg(node)
ret = imgfile_suffix(uri, "svg")
File.exist?(ret) and return ret
inkscape_convert(uri, ret, "--export-plain-svg --export-type='svg'")
# pp "called"
# if node.text.strip.empty?
# pp "text empty"
# uri = node["src"]
# ret = imgfile_suffix(uri, "svg")
# File.exist?(ret) and return ret
# Vectory::Eps.from_path(uri).to_svg.write(ret).path
# else
# pp "else"
# a = Base64.strict_encode64(node.children.to_xml)
# datauri_src = "data:application/postscript;base64,#{a}"
# Vectory::Datauri.new(datauri_src).to_vector.to_svg.write.path
# end
end

def svg_to_emf(node)
Expand Down
12 changes: 8 additions & 4 deletions spec/isodoc/presentation_xml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@
.to be_equivalent_to (output)
end

xit "converts EPS to SVG files" do
it "converts EPS to SVG files" do
input = <<~INPUT
<iso-standard xmlns="http://riboseinc.com/isoxml">
<bibdata/>
Expand Down Expand Up @@ -1012,7 +1012,8 @@
</iso-standard>
INPUT
output = <<~OUTPUT
<iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
<?xml version="1.0" encoding="UTF-8"?>
<iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
<bibdata/>
<preface> <clause type="toc" id="_" displayorder="1"> <title depth="1">Table of contents</title> </clause> </preface>
<sections>
Expand All @@ -1025,11 +1026,14 @@
</sections>
</iso-standard>
OUTPUT
expect(xmlpp(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options)
first = xmlpp(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true)
.sub(%r{<localized-strings>.*</localized-strings>}m, "")
.gsub(%r{src="[^"]+?\.emf"}, 'src="_.emf"')
.gsub(%r{src="[^"]+?\.svg"}, 'src="_.svg"'))))
.gsub(%r{src="[^"]+?\.svg"}, 'src="_.svg"')))
File.write("first", first)
File.write("second", output)
expect(first)
.to be_equivalent_to (output)
end

Expand Down

0 comments on commit 2cbb276

Please sign in to comment.