Code Monkey home page Code Monkey logo

csstidy's People

Contributors

amiga-500 avatar azettl avatar bytestream avatar cerdic avatar cfinke avatar christophwurst avatar claviska avatar dsferruzza avatar flug avatar jaydiablo avatar marcimat avatar need4video avatar nuxodin avatar phenix-factory avatar phpgangsta avatar richeryang avatar sunflowerfuchs avatar weikinhuang 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

csstidy's Issues

Indent inside media queries

Hi, I'm using this fork of CSSTidy for DirtyMarkup, as the original was abandoned, doesn't support media queries, etc. So thanks for your work on this project!

Quick feature request for indenting media queries. The current output looks like this:

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

Desired output is:

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

It looks like this would require a new formatter in the template files, or maybe it could be assumed that whatever the indent level is for properties could simply be doubled.

What are your thoughts on this?

Keyframes doesn't work

Hi,

I'm not sure whether this is the right place to report bugs, so feel free to point me elsewhere if needed. I have a very simple CSS file:

@keyframes blink {
  0% { background: #7e7; }
  50% { background: none; }
  100% { background: #7e7; }
}

When throwing this file at CSSTidy, it gives me this result:

-----------------------------------

50% {
background:none;
}

100% {
background:#7e7;
}
-----------------------------------

1: Invalid @-rule: keyframes (removed)
2: Invalid property in CSS2.1: 0background

-----------------------------------

which is obviously not right, because @keyframes blink is valid syntax, right?

Transition subvalue number compression error

Hi.

The compression changes 0s to 0 which is invalid in transition. for example:
transition: color 0.4s ease 0s;
will become
transition: color 0.4s ease 0;
which doesn't work

center est indépendant de la référence left/right

L'option reverse_left_and_right ajoute un disgracieux autant qu'inutile right en reference quand on a une position center:

.foo {
    background-position: center center;
}

devient :

.foo {
    background-position: center right center;
}

Question about minimal optimization

I use cssmin which does too much with certain bootstrap.css'es (and evtl. also others - sometimes strange problems with some css'es)

How can i adjust csstidy , so that it just removes / *.... * / and //... and unecessary spaces and otherwise changes as little as possible - regarding code optimization ? The code may be a little bigger - i use mod_deflate anyway.

Add a script to run it from command line as C++ csstidy drop in replacement

I was using the CSSTidy C++ version to compress my CSS but this version had problem with format in @font-face. After taking a quick look to your up to date PHP version, I was thinking that this problem was fix in it (actually it's not fix, check my next issue).

So, I decided to use it instead of the C++ one. But I needed to call from the command line (like the C++ version) because I'm using it through django_compressor. The solution was to write a script to run it from the command line. I tried to do it in way that it will be mostly a drop in replacement of the C++ version.

You can found my script here: https://gist.github.com/2789689

It's NOT well tested and I don't think I will put more work on it because I can't use your CSSTidy PHP version for the moment. But feel free to do whatever you want with it, just keep my name in the credits please.

N.B.: I should add that the PHP and C++ versions are not totally equivalent. If I'm not wrong, the C++ version remove duplicate properties like this:

.duplicate{
    display: none;
    display: none;
}

The PHP version don't do that. I saw other differences like quotation around @font-face font-family name, etc.

Notice sur class.csstidy_optimise.php : reverse_left_and_right_background_position( )

En utilisant une fonction de transformation rtl, on obtient :
Notice: Undefined offset: 1 in … class.csstidy_optimise.php on line 1286

Dans la méthode reverse_left_and_right_background_position($value)

  • $value = "0 0"
  • $values = []

La trace indique qu’on arrive avec background: #fff, si ça peut aider...

^ array:27 [▼
  0 => array:7 [▼
    "file" => "class.csstidy_optimise.php"
    "line" => 1234
    "function" => "reverse_left_and_right_background_position"
    "class" => "csstidy_optimise"
    "object" => csstidy_optimise {#151 ▶}
    "type" => "->"
    "args" => array:1 [▼
      0 => "0 0"
    ]
  ]
  1 => array:7 [▼
    "file" => "class.csstidy_optimise.php"
    "line" => 1077
    "function" => "reverse_left_and_right_background"
    "class" => "csstidy_optimise"
    "object" => csstidy_optimise {#151 ▶}
    "type" => "->"
    "args" => array:1 [▼
      0 => "#fff"
    ]
  ]
  2 => array:7 [▼
    "file" => "class.csstidy_optimise.php"
    "line" => 79
    "function" => "reverse_left_and_right"
    "class" => "csstidy_optimise"
    "object" => csstidy_optimise {#151 ▶}
    "type" => "->"
    "args" => array:1 [▼
      0 => array:9 [▼
        "display" => "block"
        "margin" => "0"
        "padding" => "0"
        "min-height" => "3.2em"
        "background" => "#fff"
        "border" => "1px solid #ddd"
        "border-color" => "hsla(0,0%,0%,0.1)"
        "border-bottom-color" => "hsla(0,0%,0%,0.05)"
        "border-radius" => "6px 6px 0 0"
      ]
    ]
  ]

php8.2 Compatibility Issues

class.csstidy.php
8192: Creation of dynamic property csstidy::$template is deprecated
Missing
public $template;

class.csstidy_optimise.php
Missing
public $css;
public $sub_value;
public $at;
public $selector;
public $property;
public $value;
class.csstidy_print.php
Missing
public $css;
public $template;
public $tokens;
public $charset;
public $import;
public $namespace;

ctype_alpha() is wrong

The replacement definition for the ctype_alpha() function is wrong. In its current state, it will only check for the existence of a letter in the checked string, but it does not check if ALL characters are letters.
It should be something like

function ctype_alpha( $text ) {
    return ( 1 === preg_match( '/^[a-zA-Z]+$/', $text ) );
}

$version still showing v1.5.2

This is not an issue but noticed the $version member variable is still set to "1.5.2" instead of "1.5.5" (current version)

File: class.csstidy.php
Line #: 150

Currently:

public $version = '1.5.2';

Should be:

public $version = '1.5.5';

Methods with the same name as their class will not be constructors in a future version of PHP

CSS Tidy generates these errors when running setting WP_DEBUG: TRUE.

csstidy has a deprecated constructor in /app/public/wp-content/plugins/wp-foft-loader/includes/csstidy/class.csstidy.php on line 61

csstidy_print has a deprecated constructor in /app/public/wp-content/plugins/wp-foft-loader/includes/csstidy/class.csstidy_print.php on line 39

csstidy_optimise has a deprecated constructor in /app/public/wp-content/plugins/wp-foft-loader/includes/csstidy/class.csstidy_optimise.php on line 39

Warning: Cannot modify header information - headers already sent by (output started at /path/to/plugin/includes/csstidy/class.csstidy_print.php:39) in /wp-includes/pluggable.php on line 1251

Warning: Cannot modify header information - headers already sent by (output started at /path/to/plugin/includes/csstidy/class.csstidy_print.php:39) in /wp-includes/pluggable.php on line 1254

Contact information for responsible disclosure

I have found a security vulnerability and would like to inform you about it in a non-public way, but I couldn't find any current contact information anywhere. Is there an e-mail address I can write to?

License problem

The whole package is licensed with the LGPL, but in data.inc.php the quoted license is the standard GPL, which conflicts and actually makes it impossible for the whole package being LGPL.

Could you clear this up and correct the licensing for the whole package or the file?

Remove unnecessary backslashes

First of all, it's great to see this project is still alive. I'm really enjoying the changes made after v1.3 :)

There's however a (new) minor issue with the "Remove unnecessary backslashes" checkbox.

Using this with a "custom layout", this feature simply doesn't work anymore. Also after submitting the "Process CSS" button it will automatically uncheck itself again.

BUG - @import

Normally the @import looks like this:

@import url("my.css");

When this runs through CSSTidy it changes it to:

@import "my.css";

HOWEVER, if you start with:

@import "my.css";

Then CSSTidy changes it to:

@import my.css;

Notice the double-quotes have been stripped. When this is done the imports no longer work.

This is a bug.

The fix can be found at PR #45

Nested @media rules not supported

@media print {
  #navigation { display: none }
  @media (max-width: 12cm) {
    .note { float: none }
  }
}

Produce

@media print {
	#navigation
	{
		display:none
	}
}

@media (max-width: 12cm) {
	.note
	{
		float:none
	}
}

Which is a mistake in CSS 3.0

Bad include path breaks command line executable

I have csstidy 2.0.1 installed via composer. The command line executable is broken. The include path for class.csstidy.php is incorrect on line 42 of cerdic/css-tidy/bin/pcsstidy.

$ vendor/bin/pcsstidy --help
PHP Warning:  include(class.csstidy.php): failed to open stream: No such file or directory in /var/www/html/dev/vendor/cerdic/css-tidy/bin/pcsstidy on line 42
PHP Stack trace:
PHP   1. {main}() /var/www/html/dev/vendor/bin/pcsstidy:0
PHP   2. include() /var/www/html/dev/vendor/bin/pcsstidy:112
PHP Warning:  include(): Failed opening 'class.csstidy.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/dev/vendor/cerdic/css-tidy/bin/pcsstidy on line 42
PHP Stack trace:
PHP   1. {main}() /var/www/html/dev/vendor/bin/pcsstidy:0
PHP   2. include() /var/www/html/dev/vendor/bin/pcsstidy:112
PHP Fatal error:  Uncaught Error: Class 'csstidy' not found in /var/www/html/dev/vendor/cerdic/css-tidy/bin/pcsstidy:43
Stack trace:
#0 /var/www/html/dev/vendor/bin/pcsstidy(112): include()
#1 {main}
  thrown in /var/www/html/dev/vendor/cerdic/css-tidy/bin/pcsstidy on line 43

font-face src-property

E.g. Bootstrap Glyphicons font-face.

Before:

@font-face {
    font-family: 'Glyphicons Halflings';
    src: url('../fonts/glyphicons-halflings-regular.eot');
    src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),
         url('../fonts/glyphicons-halflings-regular.woff') format('woff'),
         url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'),
         url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}

After (w/o minification for clarity)

@font-face {
    font-family: "Glyphicons Halflings";
    src: url("") format("embedded-opentype"),
         url("../fonts/glyphicons-halflings-regular.woff") format("woff"),
         url("../fonts/glyphicons-halflings-regular.ttf") format("truetype"),
         url("") format("svg");
}

The problems:

  • shows only last src-property
  • url like ...eot?#... and ...svg#... not shows

CSS variables is not supported

Hi there

I use CSS variables in my code and it shows the following log.

{"2":[{"m":"Removed invalid property: --color","t":"Warning"}]}

Is there any way to support CSS variables except turning off discard_invalid_properties? Thanks!

Example

Before

:root {
  --color: red;
}

After

:root {}

Security

I've sent you a couple of emails at your c****c@y******m [redacted for your privacy] address regarding some possible security issues in the CSSTidy codebase. Did you get them?

Issue with multiple scripts/runs

I am glad the project is still maintained.

Interesting, that it still has the same bug as the original one, though.
You cannot use the class twice, for 2 css files in a row. the second file would always be empty upon parse():

$this->_Tidy->parse($content);
$css = $this->_Tidy->css;

...
unset($this->_Tidy); // try to avoid the bug by destroying
return $css;

in the second run with another script it returns an empty array.
thing is, If I switch the two files, the other one (now first) works fine.
So its definitly in the csstidy class somewhere
even destroying the object, unsetting the globals supervar etc won't help.

PS: would it be possible to rewrite it to not use $GLOBALS etc? I think the way of doing it this way and jumping outside its clean scope is not best practice anymore and should be avoided. the class can perfectly store the references inside some protected variables.

!important space is vanished

Hi, I found some bug.

the interval between "value" and "!important" vanishes.

For example,
a {color:red !important} becomes a {color:red!important}

Thanks for your great work :)

V2.1 .exe

Hello, I love this tool, but don't know how to build for Windows. Is there any way you could upload v2.1.0 (or latest version)?

I found older version on SourceForge: https://sourceforge.net/projects/csstidy/
But it is not supporting CSS3 well.

Font-face src using relative URL

In my css files I have relative URLs for background images and these get converted into absolute URL perfectly.

My problem is for font-face src, is it possible to also set this to be converted into absolute URL?

The reason for this is because my minified css file is saved in a different location to the original css files.

Comment in selector partly broken

In following selector

/* ici */
.cartouche, .surlignable,
/*.liste h2,*/
ul.liste-items li.hentry,
p.pagination,
#comments,
p.repondre,
.ps,
.hyperlien,
#descriptif_site_spip,
.page_login .formulaire_spip,
.page_login #formulaire_menu_lang,
.resultats,
.documents_joints,
.chapo,
.page_article .formulaire_ecrire_auteur {
    padding: 30px;
}

/*.liste h2,*/ becomes /.liste h2,*/
and the rule is broken

Properties not being supported

As a quick test I've tried using some css properties and notice that they are not in the data.inc.php file (sorry - don't know which CSS they relate to).

grid-area
grid-template-columns
grid-template-rows
grid-template-areas (important note - these require line breaks to be retained)
-ms-grid-columns
-ms-grid-column
-ms-grid-column-span
-ms-grid-rows
-ms-grid-row
-ms-flex-line-pack
align-content
-webkit-transition
-o-transition
-webkit-touch-callout
-webkit-user-select
-khtml-user-select
-moz-user-select
-ms-user-select
user-select
-webkit-appearance

Corrupting rgb() color definition

When using " compress colors" option it does not recognize rgb() notation properly.

considering example :

white10 { color: rgba(255, 255, 255, 10%); }
white20 { color: rgb(255 255 255 / 20%);   }
white30 { color: rgb(255, 255, 255, 30%);  }

Output :

Optimised color: Changed "rgb(255 255 255 / 20%)" to "red"
Optimised color: Changed "rgb(255,255,255,30%)" to "#fff"

white10{color:rgba(255,255,255,10%)}
white20{color:red}
white30{color:#fff}

Should be:

white10{color:#ffffff1a}
white20{color:#fff3}
white30{color:#ffffff4d}

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.