Skip to content
This repository

Better Regexp for extracting urls from css files #158

merged 2 commits into from about 2 years ago

2 participants

Jean Boussier Gonçalo Silva
Jean Boussier


When I tried to generate a static version of my presentation, showoff failed to parse URLs in my CSS because they were surrounded by quotes:

src: url("style/fonts/proximanova-bold-proxima.eot")

So this is a fix to ignore quotes around urls.


Gonçalo Silva goncalossilva merged commit 31eef32 into from March 05, 2012
Gonçalo Silva goncalossilva closed this March 05, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 3 additions and 1 deletion. Show diff stats Hide diff stats

  1. 4  lib/showoff.rb
4  lib/showoff.rb
@@ -446,7 +446,9 @@ def self.do_static(what)
446 446
         Dir.glob("#{pres_dir}/*.css").each do |css_path|
447 447
  do |file|
448 448
             data =
-            data.scan(/url\((.*)\)/).flatten.each do |path|
+            data.scan(/url\("?(.*?)"?\)/).flatten.each do |path|
+              path.gsub!(/(\#.*)$/, '') # get rid of the anchor
+              path.gsub!(/(\?.*)$/, '') # get rid of the query
450 452
               logger.debug path
451 453
               dir = File.dirname(path)
452 454
               FileUtils.makedirs(File.join(file_dir, dir))

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.