Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Set a base href for the HTML preview

Use the path of the current file as a base href for the HTML preview so
you can use relative paths to images etc.
  • Loading branch information...
commit f5aa9d96ccef9e3e8b38407d67cdfe92e5a8a6ce 1 parent 214c2f8
@joho authored
Showing with 6 additions and 0 deletions.
  1. +6 −0 autoload/preview.vim
View
6 autoload/preview.vim
@@ -124,6 +124,7 @@ class Preview
def update_fnames
fname = VIM::Buffer.current.name
@base_name = File.basename(fname)
+ @base_path = fname.gsub(@base_name, "")
@ftype = fname[/\.([^.]+)$/, 1]
end
@@ -170,6 +171,7 @@ class Preview
<head>
<title>#{@base_name}</title>
#{css_tag}
+ #{base_tag}
</head>
<body>
<div id="main-container">
@@ -188,6 +190,10 @@ class Preview
end
end
+ def base_tag
+ %Q{<base href="file://localhost/#{@base_path}" />}
+ end
+
def option(name)
raise "Unknown option #{name.inspect}" unless OPTIONS.keys.include?(name)
VIM.evaluate(OPTIONS[name])
Please sign in to comment.
Something went wrong with that request. Please try again.