public
Last active

A Jekyll plugin to convert .styl to .css.

  • Download Gist
_config.yml
YAML
1 2 3
stylus:
compress: true
path: ./path/to/styl
all.styl
Stylus
1 2 3 4
---
---
// See individual.styl below. Notice it has no YAML front matter.
@import 'individual'
individual.styl
Stylus
1 2 3
html
margin 0
padding 0
stylus_converter.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
# 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
Stylus.compile content
rescue => e
puts "Stylus Exception: #{e.message}"
end
end
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.