/usr/share/bluefish/css_decompressor is in bluefish-data 2.2.10-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | #!/usr/bin/python2.7
# -*- coding: utf-8 -*-
#
# Copyright (C) 2015-2016 Rafael Senties Martinelli <rafael@senties-martinelli.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License 3 as published by
# the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
__version__ = '1.4~0'
import sys
from cssmin import *
def inside_brackets(start, end, text):
for i in range(start, end):
if text[i]=='}':
return True
elif text[i]=='{':
return False
return False
def decompress_css(text):
for char in ('\t','\n'):
text=text.replace(char,'')
indent_level=0
new_text=''
text_lenght=len(text)
for i, char in enumerate(text):
chars={k:'' for k in range(-4,4)}
new_text_last_char=new_text[-1:]
for k in range(-4,4):
try:
chars[k]=text[i+k]
except:
pass
if not new_text_last_char in (' ',':') and (
(char in (',','%','>') and not chars[1] in (';',' ')) and \
(new_text_last_char in (' ',':')) or \
(char == 's' and chars[-1].isdigit() and not chars[1]+chars[2]=='ol') or \
(char == ':' and not chars[1] == ' ' and inside_brackets(i, text_lenght, text)) or \
(char in ('n','x') and chars[-4].isdigit() and ''.join(chars[x] for x in range(-3,1)) in ('vmin','vmax')) or \
(char == 'm' and chars[-3].isdigit() and ''.join(chars[x] for x in range(-2,1)) == 'rem') or \
(char == ')' and not chars[1] in (' ',';')) or \
(char in ('m','x','n','t','c','h','v') and not chars[-3]==' ' and chars[-2].isdigit() \
and chars[-1]+char in ('em','ex','px','cm','mm','in','pt','pc','ch','vh','vw') and chars[1] != ';')
):
char+=' '
elif not new_text_last_char in (' ',':') and (\
(char == '#' and chars[-1] == ':') or \
(char == '.' and not chars[-1].isdigit() and chars[1].isdigit()) or \
(char == '!' and ''.join(chars[x] for x in range(1,4)) == 'imp')
):
char = ' '+char
elif char == ',':
char = ', '
elif char == '>':
char = ' > '
elif char == '{':
indent_level+=1
if new_text_last_char != ' ':
char =' {\n'+'\t'*indent_level
else:
char ='{\n'+'\t'*indent_level
elif char == '}':
indent_level-=1
char ='\n'+'\t'*indent_level+'}'
if chars[1] != '}':
char+='\n'+'\t'*indent_level
if indent_level==0:
char+='\n'
elif char == ';':
char = ';\n'+'\t'*indent_level
new_text+=char
return new_text
if __name__ == '__main__':
input=sys.stdin.read()
#with open('test.css') as f:
#input=f.read().strip()
text=decompress_css(input)
sys.stdout.write(text)
#with open('test.css','w') as f:
#f.write(text)
|