Git Product home page Git Product logo

cssbeautify's People

Contributors

canop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cssbeautify's Issues

Please upgrade minimatch to 3.0.2+

When installing the module, since minimatch is a dependency, there's this warning:
"Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue"

Order all properties alphabetically?

Would it be possible to support re-ordering CSS declarations to be in alphabetical order? E.g.:

body {
  font-family: Georgia;
  color: blue;
  text-decoration: underline;
}

Would become:

body {
  color: blue;
  font-family: Georgia;
  text-decoration: underline;
}

At-rules have an extra semicolon at the end of the block

Consider the following two blocks, already formatted with CSS Beautify:

body {
    margin: 10px;
}

p {
    font-style: italic;
}

These rules do not end in a semicolon after the right curly bracket.

Now consider the same rules as the block of an at-rule:

@media print {
    body {
        margin: 10px;
    }

    p {
        font-style: italic;
    };
}

An extra semicolon is added after the last rule of the block, even though one is not necessary here (and was not part of the original source).

Nested @-rules

@-moz-document domain(foo.com){ 
@media (min-width:30em){x{foo:bar}
}
}

beautifies to

@-moz-document domain(foo.com) {
 @    media (min-width:30em) {
        x{foo: bar;
    }
}
}

and other nested @-rules have the same issue (separation of the "@" and loss of one level of indentation).

I'm reporting this because @-rules such as @media, @Keyframes, and @font-face are fairly common inside @-moz-document in user styles at userstyles.org

Bugzilla thread/post with links to documentation of nested @-rules

This is my first post on github - I hope I didn't do anything wrong. Please let me know if I did.

new line for comments and id selectors

Hi,
lib working great, exept for theses: I have noticed that cssbeautify will not create a new line for comments in the CSS:
/* My comment here */ .a-selector {etc..

Also, same thing happens with slectors starting by #:

a-unique-id span { etc...

This CSS breaks the parser

a#googleplus:hover,a#googleplus:active {
  background:transparent url(img/googleplus_a.png) no-repeat
}

/* Fixed layout for home page - don't*/
#home-top {
  height:336px;
  margin-bottom:100px
}

Test at http://www.senchalabs.org/cssbeautify/ and you'll see the CSS below the comments does not get changed. It's the apostrophe in "don't" that's doing it.

Grouping

This is not really an issue, just a suggestion.
I think it'd be cool to offer the option to group CSS properties, i.e.:

.class {
    width: 10px; height: 10px;
    margin: 0; padding: 0;
    top: 108px; left: 231px;
}

space after comma

With this CSS as input:

button,input,select,textarea{font-family:"museo-sans-rounded","Arial Rounded",sans-serif}

This is the output we currently get:

button,input,select,textarea {
    font-family: "museo-sans-rounded","Arial Rounded",sans-serif;
}

I would prefer to have a space or newline (perhaps toggleable) after each comma:

button, input, select, textarea {
    font-family: "museo-sans-rounded", "Arial Rounded", sans-serif;
}

Just be careful in your implementation of this to not 'fix' what shouldn't be fixed:

li:after {
    content: ",";
}

(don't add a space after the comma in the last example rule.)

@font-face fails to format correctly.

Given the string b{font-family:"a";src:url("b";)}@font-face{font-family:"a";src:url("b";)}

Expected output is:

b {
    font-family: "a";
    src: url("b";);
}

@font-face {
    font-family:"a";
    src:url("b");
}

Actual output:

b {
    font-family: "a";
    src: url("b";);
}

@font-face {
    font-family:"a";src:url("b");
}

The src property should wrap. Oddly it does work if @font-face is first.

Add Support for Sass

Is it possible to add support for this? Especially the scss nesting should not result in invalid css after running through cssbeautify. Im not sure if its interesting for others and worth the time implementing it.

Currently:

.item{
  width: 185px;
  cursor:pointer;

  &:active{
    border: 1px solid #6692BB;  
  }
}

results in:

.item {
    width: 185px;
    cursor: pointer;
    &: active{
    border: 1px solid #6692BB;
}
}

base64 beautification is broken

The code automatically breaks new lines on semicolons

if (str.charAt(str.length - 1) === '}' ||
        str.charAt(str.length - 1) === ';') {
formatted = str + '\n\n';

This means that inline base64 is broken upon beautification, since it contains a semicolon after the data type

body: { background-image:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)'}

becomes

body: {
    background-image: url(data:image/gif;
    base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)'
}

Color to RGB/HEX

You should definitely add an option, which lets you convert all colors either to RGB or to HEX.
That would help me a lot! =)

Add space before `!important`

Should add a space between rule and !important declaration.

STR

p{margin:1em!important}

Actual

p {
  margin: 1em!important;
}

Expected

p {
  margin: 1em !important;
}

Quote type

Options to force a quote type, either single or double, or undefined/auto to keep existing.

Usecase:

I use an existing CSS snippet which uses double-quote, but I prefer single.

update DNS for cssbeautify.com

Since GitHub changed its IP addresses for custom domains, cssbeautify.com is no longer reachable.

Also, would be nice if the gh-pages would be updated ;)

two bugs

I found two bugs

Don't formatted this code:
*{margin:0;padding:0;}

and not correct this:
div[xx*="{"]{color:red!important;}

generated extra space produces invalid CSS

I am using CSS beautify as part of this package for Sublime Text 3.
I have this code in a SASS file of mine.

.subnav-list {
    &:not(:first-of-type) {
        ...
    }
}

after prettifying it becomes this, which is invalid (note the extra space before first-of-type).

.subnav-list {
    &:not(: first-of-type) {
        ...
    }
}

@media query bug

The beautifier adds a semicolon inside the media query at the end. According to w3 css-validator, this is an error. Example:

@media (max-width: 767px) {
  h1 {
    font-size: 32px;
  }
}

Your beautifier will give:

@media (max-width: 767px) {
  h1 {
    font-size: 32px;
  };    /* The semicolon here will give an error. */
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.