Skip to content

Instantly share code, notes, and snippets.

@joshuacronemeyer
Created October 19, 2017 17:01
Show Gist options
  • Save joshuacronemeyer/eda8aa02f7b6c70979d335447196ffc4 to your computer and use it in GitHub Desktop.
Save joshuacronemeyer/eda8aa02f7b6c70979d335447196ffc4 to your computer and use it in GitHub Desktop.
munging SVG seatmaps
require 'nokogiri'
class ProcessSvgVenueMap
def initialize(file)
@file = file
@doc=Nokogiri::XML.parse(@file)
end
def remove_css
@doc.search("svg", "defs").remove
background_image = @doc.xpath('//@style')
p "The background image you need is here #{background_image.text}" if background_image
background_image.remove
@doc.xpath('//@data-reactid').remove
end
def doc_xml
@doc.to_xml
end
end
filename = 'air_canada_center_map.svg'
file = File.read(filename)
process_map = ProcessSvgVenueMap.new(file)
process_map.remove_css
File.write(filename, process_map.doc_xml)
@joshuacronemeyer
Copy link
Author

this doesn't work. i was playing around with nokogiri... it just didn't seem to be able to find the elements i was interested in with xpath or any other selectors. WIP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment