Skip to content

Instantly share code, notes, and snippets.

@dereksnow
Forked from adamjspooner/_config.yml
Last active May 12, 2017 02:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dereksnow/7c89b7d2ad939ee98779 to your computer and use it in GitHub Desktop.
Save dereksnow/7c89b7d2ad939ee98779 to your computer and use it in GitHub Desktop.
stylus:
compress: true
path: ./path/to/styl
include_css: true
---
---
// See individual.styl below. Notice it has no YAML front matter.
@import 'individual'
html
margin 0
padding 0
# A Jekyll plugin to convert .styl to .css
# This plugin requires the stylus gem, do:
# $ [sudo] gem install stylus
# See _config.yml above for configuration options.
# Caveats:
# 1. Files intended for conversion must have empty YAML front matter a the top.
# See all.styl above.
# 2. You can not @import .styl files intended to be converted.
# See all.styl and individual.styl above.
module Jekyll
class StylusConverter < Converter
safe true
def setup
return if @setup
require 'stylus'
Stylus.compress = @config['stylus']['compress'] if
@config['stylus']['compress']
Stylus.paths << @config['stylus']['path'] if @config['stylus']['path']
@setup = true
rescue LoadError
STDERR.puts 'You are missing a library required for Stylus. Please run:'
STDERR.puts ' $ [sudo] gem install stylus'
raise FatalException.new('Missing dependency: stylus')
end
def matches(ext)
ext =~ /styl/i
end
def output_ext(ext)
'.css'
end
def convert(content)
begin
setup
if @config['stylus']['include_css']
Stylus.compile content, { 'include css' => true }
else
Stylus.compile content
end
rescue => e
puts "Stylus Exception: #{e.message}"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment