lib/vimwiki_markdown/template.rb in vimwiki_markdown-0.0.2 vs lib/vimwiki_markdown/template.rb in vimwiki_markdown-0.0.3
- old
+ new
@@ -5,10 +5,11 @@
def initialize(options)
@options = options
get_template_contents
+ validate_template
end
def to_s
fixtags(template)
end
@@ -22,13 +23,23 @@
file = File.open(options.template_filename, "r")
@template = file.read
end
def fixtags(template)
- @template = template.gsub('%title%',title).gsub('%pygments%', Pygments.css('.highlight'))
+ @template = template.gsub('%title%',title).gsub('%pygments%',pygments_wrapped_in_tags)
end
+ def pygments_wrapped_in_tags
+ "<style type=\"text/css\">
+ #{Pygments.css('.highlight')}
+ </style>"
+ end
+
def title
options.title
+ end
+
+ def validate_template
+ raise MissingRequiredParamError.new("ERROR: vimwiki template must contain %pygments% placeholder token. Please visit https://github.com/patrickdavey/vimwiki_markdown for more information") unless @template =~ /%pygments%/
end
end
end