Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allowing new slidedowns to take a :stylesheets option as an array of …

…paths
  • Loading branch information...
commit 3d2426de7fc667a483f084fbd1092dbe73f2568f 1 parent 4d0a58a
@qrush qrush authored
View
10 lib/slidedown.rb
@@ -11,6 +11,7 @@ class SlideDown
USAGE = "The SlideDown command line interface takes a .md (Markdown) file as its only required argument. It will convert the file to HTML in standard out. Options:
-t, --template [TEMPLATE] the .erb files in /templates directory. Default is -t default, which prints stylesheets and javascripts inline. The import template uses link and script tags."
+ attr_accessor :stylesheets
attr_reader :classes
def self.run!(argv = ARGV)
@@ -45,9 +46,10 @@ def self.render(source_path, template = "default")
end
# Ensures that the first slide has proper !SLIDE declaration
- def initialize(raw)
+ def initialize(raw, opts = {})
@raw = raw =~ /\A!SLIDE/ ? raw : "!SLIDE\n#{raw}"
extract_classes!
+ self.stylesheets = opts[:stylesheets] || local_stylesheets
end
def slides
@@ -71,8 +73,8 @@ def lines
@lines ||= @raw.split(/^!SLIDE\s*([a-z\s]*)$/).reject { |line| line.empty? }
end
- def stylesheets
- Dir[Dir.pwd + '/*.stylesheets'].map { |path| File.read(path) }
+ def local_stylesheets
+ Dir[Dir.pwd + '/*.stylesheets']
end
def jabascripts
@@ -87,7 +89,7 @@ def extract_classes!
end
@classes
end
-
+
def extract_notes!
@raw.gsub!(/^!NOTES\s*(.*)!SLIDE$/m) do |note|
'!SLIDE'
View
9 spec/slidedown_spec.rb
@@ -65,4 +65,13 @@
# slidedown.render('default')
Nokogiri(slidedown.render('default')).at('.highlight.js').should_not be_nil
end
+
+ it 'links css files' do
+ stylesheets = ["reset.css", "my.css"]
+ doggles = SlideDown.new("# doggles", :stylesheets => stylesheets)
+
+ stylesheets.each do |stylesheet|
+ Nokogiri(doggles.render('default')).at("link[rel='stylesheet'][href='#{stylesheet}']").should_not be_nil
+ end
+ end
end
View
4 templates/default.erb
@@ -5,9 +5,7 @@
<%= read('stylesheets/slides.css') %>
</style>
<% stylesheets.each do |style| %>
- <style type="text/css" media="screen">
- <%= style %>
- </style>
+ <link rel="stylesheet" href="<%= style %>" type="text/css" media="screen" charset="utf-8" />
<% end %>
<script type="text/javascript">
<%= read('javascripts/jquery-1.3.2.js') %>
Please sign in to comment.
Something went wrong with that request. Please try again.