Permalink
Browse files

Moved styles into their own css file.

It's a bit of a phaff to find the path to the CSS file. The method I'm
using works when the markdown-preview plugin is loaded with
Pathogen.vim, but I'm not sure if it will work if the plugin is loaded
the traditional way.
  • Loading branch information...
nelstrom committed Sep 17, 2010
1 parent 5a595af commit 98844ac2d201fc4e9cfa0a43dfdba6f8dd39a181
Showing with 51 additions and 48 deletions.
  1. +44 −0 plugin/markdown-preview.css
  2. +7 −48 plugin/vmp.vim
@@ -0,0 +1,44 @@
+body div#content {
+ margin : 0 auto;
+ width : 920px;
+ background-color : #f8f8f8;
+ padding : .7em;
+ font-size : 13.34px;
+ font-family : verdana, sans-serif;
+ border : 1px #E0E0E0 solid;
+}
+
+body div#content h2, body div#content h3, body div#content h4 {
+ padding-top : 10px;
+ border-top : 4px solid #E0E0E0;
+}
+
+body div#content pre {
+ padding : 5px;
+ border-style : solid;
+ border-width : 1px;
+ border-color : #E0E0E0;
+ background-color : #F8F8FF;
+}
+
+body div#content pre code {
+ padding : 5px;
+ background-color : #F8F8FF;
+ border : none;
+}
+
+body div#content code {
+ font-family : courier, fixed;
+ display : inline-block;
+ padding : 0px 2px 0px 2px;
+ background-color : #F8F8FF;
+ border : 1px #E0E0E0 solid;
+}
+
+body h4#title {
+ font-family : verdana, sans-serif;
+ display : block;
+ margin : 0 auto;
+ width : 920px;
+}
+
View
@@ -1,6 +1,7 @@
function! PreviewMKD()
ruby << RUBY
+
VIM.evaluate('&runtimepath').split(',').each do |path|
$LOAD_PATH.unshift(File.join(path, 'plugin', 'vim-markdown-preview'))
end
@@ -13,53 +14,9 @@ function! PreviewMKD()
VIM::Buffer.current.name.nil? ? (name = 'No Name.md') : (name = Vim::Buffer.current.name)
- style = <<-STYLE
- <style type="text/css">
- body div#content {
- margin : 0 auto;
- width : 920px;
- background-color : #f8f8f8;
- padding : .7em;
- font-size : 13.34px;
- font-family : verdana, sans-serif;
- border : 1px #E0E0E0 solid;
- }
-
- body div#content h2, body div#content h3, body div#content h4 {
- padding-top : 10px;
- border-top : 4px solid #E0E0E0;
- }
-
- body div#content pre {
- padding : 5px;
- border-style : solid;
- border-width : 1px;
- border-color : #E0E0E0;
- background-color : #F8F8FF;
- }
-
- body div#content pre code {
- padding : 5px;
- background-color : #F8F8FF;
- border : none;
- }
-
- body div#content code {
- font-family : courier, fixed;
- display : inline-block;
- padding : 0px 2px 0px 2px;
- background-color : #F8F8FF;
- border : 1px #E0E0E0 solid;
- }
-
- body h4#title {
- font-family : verdana, sans-serif;
- display : block;
- margin : 0 auto;
- width : 920px;
- }
- </style>
- STYLE
+ preview_path = VIM.evaluate('&runtimepath').split(',').select{|path| path =~ /vim-markdown-preview/}.first
+ cssfile = File.open("#{preview_path}/plugin/markdown-preview.css")
+ style = cssfile.read
layout = <<-LAYOUT
<!DOCTYPE html
@@ -68,7 +25,9 @@ function! PreviewMKD()
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- #{style}
+ <style type="text/css">
+ #{style}
+ </style>
<title> #{File.basename(name)} </title>
</head>

0 comments on commit 98844ac

Please sign in to comment.