Created
July 24, 2022 15:11
-
-
Save cabo/c3927cafa495c6995973d9cc7653f5cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rexml/document' | |
require 'open3' | |
default_fn = "svg-fig-00" | |
d = REXML::Document.new(ARGF) | |
REXML::XPath.each(d.root, "//svg:svg", {"svg" => "http://www.w3.org/2000/svg"}) do |x| | |
fn = default_fn.succ! | |
# insert code to override fn with @name of ancestor | |
o, s = Open3.capture2("rsvg-convert -f pdf", stdin_data: x.to_s) | |
File.write("#{fn}.pdf", o) | |
puts "#{fn}.pdf -- #{s.inspect}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment