0.0
No commit activity in last 3 years
No release in over 3 years
Beautify and format you css
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 0
 Project Readme

This is ruby port of CSS Beautify cssbeautify

CSS Beautify

CSS Beautify is a JavaScript implementation of reindenter and reformatter for styles written in CSS.

Given the following style:

menu{color:red} navigation{background-color:#333}

CSS Beautify will produce:

menu {
    color: red
}

navigation {
    background-color: #333
}

Install

With Rails:

gem 'cssbeautify'

Just irb or pry:

$ gem install cssbeautify

irb > require 'cssbeautify'
irb > CssBeautify.beautify("menu{color:red} navigation{background-color:#333}")
 => "menu {\n    color: red\n}\nnavigation {\n    background-color: #333\n}"

Using CssBeautify

result = CssBeautify.beautify(style, options);

options is an optional object to adjust the formatting. Known options so far are:

  • indent is a string used for the indentation of the declaration (default is 4 spaces)
  • openbrace defines the placement of open curly brace, either end-of-line (default) or separate-line.
  • autosemicolon always inserts a semicolon after the last ruleset (default is false)

Example call:

beautified = CssBeautify.beautify(
  'menu{opacity:.7}', 
  indent: '  ', 
  openbrace: 'separate-line', 
  autosemicolon: true
)