Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 3 files changed
  • 1 commit comment
  • 1 contributor
Showing with 15 additions and 1 deletion.
  1. +2 −0 class.csstidy.php
  2. +6 −1 class.csstidy_optimise.php
  3. +7 −0 data.inc.php
View
@@ -552,6 +552,7 @@ function parse($string) {
$all_properties = & $GLOBALS['csstidy']['all_properties'];
$at_rules = & $GLOBALS['csstidy']['at_rules'];
+ $quoted_string_properties = & $GLOBALS['csstidy']['quoted_string_properties'];
$this->css = array();
$this->print->input_css = $string;
@@ -711,6 +712,7 @@ function parse($string) {
$this->str_char = ($string{$i} === '(') ? ')' : $string{$i};
$this->status = 'instr';
$this->from = 'iv';
+ $this->quoted_string = in_array(strtolower($this->property), $quoted_string_properties);
} elseif ($string{$i} === ',') {
$this->sub_value = trim($this->sub_value) . ',';
} elseif ($string{$i} === '\\') {
@@ -359,7 +359,12 @@ function compress_numbers($subvalue) {
// Fix bad colors
if (in_array($this->property, $color_values)) {
- $temp[$l] = '#' . $temp[$l];
+ if (strlen($temp[$l]) == 3 || strlen($temp[$l]) == 6) {
+ $temp[$l] = '#' . $temp[$l];
+ }
+ else {
+ $temp[$l] = "0";
+ }
continue;
}
View
@@ -417,6 +417,13 @@
$GLOBALS['csstidy']['all_properties']['speak-punctuation'] = 'CSS2.0,CSS2.1';
$GLOBALS['csstidy']['all_properties']['speak-numeral'] = 'CSS2.0,CSS2.1';
+/**
+ * An array containing all properties that can accept a quoted string as a value.
+ *
+ * @global array $GLOBALS['csstidy']['quoted_string_properties']
+ */
+$GLOBALS['csstidy']['quoted_string_properties'] = array('content', 'font-family', 'quotes');
+
/**
* An array containing all predefined templates.
*

Showing you all comments on commits in this comparison.

Cerdic commented on 9a025b5 Apr 5, 2012

Not sure if it's really better to have {color:0} or {color:#1} from an initial {color:1} ?
Did you made this change just in order to have a valid css in output to CSSTidy or due to actual case where the initial result was bad ?

Wonder if the best solution would'nt be to keep the initial value if not valid... (shit in, shit out)