Permalink
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...
1 parent 214c2f8 commit f5aa9d96ccef9e3e8b38407d67cdfe92e5a8a6ce @joho committed Jul 5, 2011
Showing with 6 additions and 0 deletions.
  1. +6 −0 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])

0 comments on commit f5aa9d9

Please sign in to comment.