csstidy-1.4/0000755000175000017500000000000010660376407012063 5ustar kevinkevincsstidy-1.4/TODO0000644000175000017500000000010410644712706012544 0ustar kevinkevinCSSTidy --- TODO Todo: * Add CSS validation end of file TODO csstidy-1.4/AUTHORS0000644000175000017500000000021110644712706013123 0ustar kevinkevinAuthors of CSSTidy. csstidy Florian Schmitz Thierry Charbonnel Will Mitchell AUTHORS ends here csstidy-1.4/BUGS0000644000175000017500000000022510644712706012543 0ustar kevinkevinCSSTidy BUGS -- known bugs. 2006-06-11 See the CSSTidy bug tracker at http://sourceforge.net/tracker/?atid=771415&group_id=148404 BUGS ends here. csstidy-1.4/ChangeLog0000644000175000017500000000726210644712706013642 0ustar kevinkevin2006-06-12 Will Mitchell * Integrated the SCons build system * Added AUTHOR, BUGS, ChangeLog, INSTALL, NEWS, README, TODO files 2006-05-19 Florian Schmitz * Release 1.2 stable * Chinese language (PHP) * preserve CSS mode (keeps some hacks and especially comments alive) * seperate selectors for C++ * possibility to add a timestamp to the CSS file * improved templates and PHP interface * fixed random file name problem (PHP) 2006-02-27 Florian Schmitz * Release 1.1.1 Stable * fixed a bug in merge_selectors() which could corrupt CSS code 2006-02-03 Florian Schmitz * Release 1.1 Stable * saving comments is now possible (further improvements to that probably in the next version) * stdin input (filename: - ) and a silent mode (--silent=true) 2006-01-02 Florian Schmitz * Release 1.1 alpha * message log (you are notified about most optimisations) * CSS 1.0 for remove invalid properties * fixed bug (correction of wrong newlines) * save comments (one new CSS hack is supported when enableing this) * input from stdin (if filename is "-") and silent mode (--silent=true) v.1.0 Florian Schmitz * Release 1.0 * detect end of file and add missing tokens * added setting for font-weight compression * minor code changes * french translation for the web-interface * fixed font:1em/normal * improved parsing of invalid CSS * web-interface: CSS-level is remembered * PHP5 fix for lang.inc.php * a few preparations for version 1.1 v.1.0beta Florian Schmitz * Release 1.0 beta * different IE-hack handling * cleaned up code * @namespace support * acid2 fixes * unicode support v.0.99 * fixed bug and added optimisation: remove unnecessary semicolons * fixed bug: /* /* / * fixed bugs caused by the missing-unit-fix * added font-weight compression (not very effective but anyway :-P ) * improved whitespace removal before , in selectors and media types * added: discard invalid properties * only safe optimisations by default v.0.98.1 * fixed bug: "font:1em/1 sans-serif;" v.0.98 * fixed bug: background:red green; * improvements to merge_css_blocks() and rm_subkey(), print_css(), ... * added: remove last ; in every block * added: CSS 3 units * added: automatic newline fixing for strings * added: support for "=" and not only ":" (for all those who do not check their styles in compliant browsers) * added ! important compression * added: parser now adds missing ; at the end of values * added: documentation * added: catch common mistake ommiting units (e.g. "50" --> "50px") * added: fix bad colors (add missing #) * added: fix bad color names * fixed: + and - sign not recognised * fixed parse error for: @charset "utf-8" ; * fixed: could not disable background optimisation * fixed: possibly empty selectors after background optimisation (a{background:transparent} ie.) v.0.97 * added background optimisation (mostly CSS3 compliant) * fixed bug: upper-/lowercase in hex codes were not the same * fixed bug: -moz-border-radius always removed from stylesheet * fixed bug: background:url("foo).bar") was invalid CSS * renamed $this->currrent_X to $this->cur_X v.0.96 * added Tantek-Hack protection * fixed bug in compress_numbers() v.0.95 * improved speed and cleaned up code * added hex code -> color name conversion * fixed bug: uppercase color names not recognised * fixed bug: line-height:1.0 not optimised (line-height:1) * removed value seperation on "," which was added in order to work with the CSS3 background-property. This will be done in another way. * fixed bug: optimise2 was dependent of optimise ChangeLog ends here csstidy-1.4/COPYING0000644000175000017500000004313310644712706013120 0ustar kevinkevin GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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 St, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. csstidy-1.4/INSTALL0000644000175000017500000000074110644712706013114 0ustar kevinkevinINSTALLING CSSTIDY ~~~~~~~~~~~~~~~ - Requirements * Python, for SCons (http://www.python.org/) * SCons (http://www.scons.org/) * C++ compiler (g++ or MingW) - Optional Tools * None at the moment. - Compiling * Type scons - Problems * Get help on the mailing list: http://lists.sourceforge.net/lists/listinfo/csstidy-news * Report bugs in the bug tracker: http://sourceforge.net/tracker/?atid=771415&group_id=148404 csstidy-1.4/NEWS0000644000175000017500000000042210644712706012556 0ustar kevinkevinCSSTidy NEWS -- history of user-visible changes. 2006-05-19 Please send CSSTidy bug reports to http://cdburnerxp.se/bugs/index.php?tasks=all&project=2 Version 1.3 * SCons support added * There is now a `NEWS' file (this one), giving a history of user-visible changes. csstidy-1.4/README0000644000175000017500000000077010644712706012745 0ustar kevinkevinCSSTidy is an opensource CSS parser and optimiser. It is available as executable file (available for Windows, Linux and OSX) which can be controlled per command line and as PHP script (both with almost the same functionality). In opposite to most other CSS parsers, no regular expressions are used and thus CSSTidy has full CSS2 support and a higher reliability. See the file INSTALL for building and installation instructions. CSSTidy is free software. See the file COPYING for copying conditions. csstidy-1.4/SConstruct0000644000175000017500000000166210644712706014120 0ustar kevinkevin#This file is adapted from http://www.scons.org/wiki/SconstructMultiple #get the mode flag from the command line #default to 'release' if the user didn't specify mymode = ARGUMENTS.get('mode', 'release') #holds current mode #check if the user has been naughty: only 'debug' or 'release' allowed if not (mymode in ['debug', 'release']): print "Error: expected 'debug' or 'release', found: " + mymode Exit(1) #tell the user what we're doing print '**** Compiling in ' + mymode + ' mode...' debugcflags = ['-Wall', '-g', '-pedantic'] #extra compile flags for debug releasecflags = ['-O2'] #extra compile flags for release env = Environment() #make sure the sconscripts can get to the variables Export('env', 'mymode', 'debugcflags', 'releasecflags') #put all .sconsign files in one place env.SConsignFile() #specify the sconscript for CSSTidy project = 'csstidy' SConscript(project + '/SConscript', exports=['project']) csstidy-1.4/csstidy/0000755000175000017500000000000010660376374013550 5ustar kevinkevincsstidy-1.4/csstidy/background.cpp0000644000175000017500000001557210644712706016400 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "csspp_globals.hpp" using namespace std; extern map background_prop_default; map dissolve_short_bg(string istring) { vector repeat,attachment,clip,origin,pos,str_values; repeat.push_back("repeat"); repeat.push_back("repeat-x"); repeat.push_back("repeat-y"); repeat.push_back("no-repeat"); repeat.push_back("space"); attachment.push_back("scroll"); attachment.push_back("fixed"); attachment.push_back("local"); clip.push_back("border"); clip.push_back("padding"); origin.push_back("border"); origin.push_back("padding"); origin.push_back("content"); pos.push_back("top"); pos.push_back("center"); pos.push_back("bottom"); pos.push_back("left"); pos.push_back("right"); string important = ""; map ret; map have; ret["background-image"] = ""; ret["background-size"] = ""; ret["background-repeat"] = ""; ret["background-position"] = ""; ret["background-attachment"] = ""; ret["background-clip"] = ""; ret["background-origin"] = ""; ret["background-color"] = ""; if(is_important(istring)) { important = "!important"; istring = gvw_important(istring); } str_values = explode_ws(',',istring); for(int i = 0; i < str_values.size(); i++) { have["clip"] = false; have["pos"] = false; have["color"] = false; have["bg"] = false; vector temp_values = explode_ws(' ',trim(str_values[i])); for(int j = 0; j < temp_values.size(); j++) { if(have["bg"] == false && ((temp_values[j]).substr(0,4) == "url(" || temp_values[j] == "none")) { ret["background-image"] += temp_values[j]; ret["background-image"] += ","; have["bg"] = true; } else if(in_str_array(repeat,temp_values[j])) { ret["background-repeat"] += temp_values[j]; ret["background-repeat"] += ","; } else if(in_str_array(attachment,temp_values[j])) { ret["background-attachment"] += temp_values[j]; ret["background-attachment"] += ","; } else if(in_str_array(clip,temp_values[j]) && !have["clip"]) { ret["background-clip"] += temp_values[j]; ret["background-clip"] += ","; have["clip"] = true; } else if(in_str_array(origin,temp_values[j])) { ret["background-origin"] += temp_values[j]; ret["background-origin"] += ","; } else if(temp_values[j][0] == '(') { ret["background-size"] += (temp_values[j]).substr(1,temp_values[j].length()-2); ret["background-size"] += ","; } else if(in_str_array(pos,temp_values[j]) || isdigit(temp_values[j][0]) || temp_values[j][0] == 0) { ret["background-position"] += temp_values[j]; if(!have["pos"]) ret["background-position"] += " "; else ret["background-position"] += ","; have["pos"] = true; } else if(!have["color"]) { ret["background-color"] += temp_values[j]; ret["background-color"] += ","; have["color"] = true; } } } for(map::iterator it = background_prop_default.begin(); it != background_prop_default.end(); it++ ) { if(ret[it->first] != "") { ret[it->first] = (ret[it->first]).substr(0,ret[it->first].length()-1); ret[it->first] += important; } else { ret[it->first] = it->second; ret[it->first] += important; } } return ret; } vector explode_ws(char sep,string istring) { // 1 = st // 2 = str int status = 1; char to; vector output; output.push_back(""); int num = 0; int len = istring.length(); for(int i = 0;i < len; i++) { switch(status) { case 1: if(istring[i] == sep && !escaped(istring,i)) { ++num; output.push_back(""); } else if(istring[i] == '"' || istring[i] == '\'' || istring[i] == '(' && !escaped(istring,i)) { status = 2; to = (istring[i] == '(') ? ')' : istring[i]; output[num] += istring[i]; } else { output[num] += istring[i]; } break; case 2: if(istring[i] == to && !escaped(istring,i)) { status = 1; } output[num] += istring[i]; break; } } return output; } void merge_bg(umap& css_input) { // Max number of background images. CSS3 not yet fully implemented int number_of_values = max((explode_ws(',',css_input["background-image"]).size()),(explode_ws(',',css_input["background-color"])).size()); // Array with background images to check if BG image exists vector bg_img_array = explode_ws(',',gvw_important(css_input["background-image"])); string new_bg_value,important = ""; for(int i = 0; i < number_of_values; i++) { for(map::iterator it = background_prop_default.begin(); it != background_prop_default.end(); it++ ) { // Skip if property does not exist if(!css_input.has(it->first)) { continue; } string cur_value = css_input[it->first]; // Skip some properties if there is no background image if((bg_img_array.size() <= i || bg_img_array[i] == "none") && (it->first == "background-size" || it->first == "background-position" || it->first == "background-attachment" || it->first == "background-repeat")) { continue; } // Remove !important if(is_important(cur_value)) { important = "!important"; cur_value = gvw_important(cur_value); } // Do not add default values if(cur_value == it->second) { continue; } vector temp = explode_ws(',',cur_value); if(temp.size() > i) { if(it->first == "background-size") { new_bg_value += "("; new_bg_value += temp[i]; new_bg_value += ") "; } else { new_bg_value += temp[i]; new_bg_value += " "; } } } new_bg_value = trim(new_bg_value); if(i != number_of_values-1) new_bg_value += ","; } // Delete all background-properties for(map::iterator it = background_prop_default.begin(); it != background_prop_default.end(); it++ ) { css_input.erase(it->first); } // Add new background property if(new_bg_value != "") { css_input["background"] = new_bg_value + important; } } csstidy-1.4/csstidy/background.hpp0000644000175000017500000000212710644712706016375 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HEADER_CSS_BACKGROUND #define HEADER_CSS_BACKGROUND // Dissolves the background property map dissolve_short_bg(const string istring); // Same as explode, but not within a string vector explode_ws(char sep,string istring); void merge_bg(umap& css_input); #endif // HEADER_CSS_BACKGROUND csstidy-1.4/csstidy/conversions.cpp0000644000175000017500000001031110644712704016611 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "csspp_globals.hpp" string strtolower(string istring) { int str_size = istring.length(); for(int i = 0; i < str_size; i++) { istring[i] = chartolower(istring[i]); } return istring; } char chartolower(const char c) { switch(c) { case 'A': return 'a'; case 'B': return 'b'; case 'C': return 'c'; case 'D': return 'd'; case 'E': return 'e'; case 'F': return 'f'; case 'G': return 'g'; case 'H': return 'h'; case 'I': return 'i'; case 'J': return 'j'; case 'K': return 'k'; case 'L': return 'l'; case 'M': return 'm'; case 'N': return 'n'; case 'O': return 'o'; case 'P': return 'p'; case 'Q': return 'q'; case 'R': return 'r'; case 'S': return 's'; case 'T': return 't'; case 'U': return 'u'; case 'V': return 'v'; case 'W': return 'w'; case 'X': return 'x'; case 'Y': return 'y'; case 'Z': return 'z'; default: return c; } } string strtoupper(string istring) { int str_size = istring.length(); for(int i = 0; i < str_size; i++) { istring[i] = chartoupper(istring[i]); } return istring; } char chartoupper(const char c) { switch(c) { case 'a': return 'A'; case 'b': return 'B'; case 'c': return 'C'; case 'd': return 'D'; case 'e': return 'E'; case 'f': return 'F'; case 'g': return 'G'; case 'h': return 'H'; case 'i': return 'I'; case 'j': return 'J'; case 'k': return 'K'; case 'l': return 'L'; case 'm': return 'M'; case 'n': return 'N'; case 'o': return 'O'; case 'p': return 'P'; case 'q': return 'Q'; case 'r': return 'R'; case 's': return 'S'; case 't': return 'T'; case 'u': return 'U'; case 'v': return 'V'; case 'w': return 'W'; case 'x': return 'X'; case 'y': return 'Y'; case 'z': return 'Z'; default: return c; } } /* Didn't find any usable function for this, so here is my version :) */ string dechex(const int i) { stringstream sstream; sstream << hex << i; return sstream.str(); } double hexdec(string istring) { double ret = 0; istring = trim(istring); for(int i = istring.length()-1; i >= 0; --i) { int num = 0; switch(tolower(istring[i])) { case 'a': num = 10; break; case 'b': num = 11; break; case 'c': num = 12; break; case 'd': num = 13; break; case 'e': num = 14; break; case 'f': num = 15; break; case '1': num = 1; break; case '2': num = 2; break; case '3': num = 3; break; case '4': num = 4; break; case '5': num = 5; break; case '6': num = 6; break; case '7': num = 7; break; case '8': num = 8; break; case '9': num = 9; break; case '0': num = 0; break; } ret += num*pow((double) 16, (double) istring.length()-i-1); } return ret; } string f2str(const float f) { stringstream sstream; sstream.flags (ios::fixed); sstream << f; string converted = sstream.str(); // now strip remaining zeros at the end std::string::size_type last = converted.find_last_not_of("0"); /// must succeed converted = converted.substr( 0, last + 1); // and the dot if no zeros remain last = converted.find_last_not_of("."); /// must succeed converted = converted.substr( 0, last + 1); return converted; } float str2f(const string istring) { return atof(istring.c_str()); } string char2str(const char c) { string ret = ""; ret += c; return ret; } string char2str(const char *c) { stringstream sstream; sstream << c; return sstream.str(); } csstidy-1.4/csstidy/conversions.hpp0000644000175000017500000000272710644712706016634 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HEADER_CSS_CONVERT #define HEADER_CSS_CONVERT // Returns the lowercase version of a string string strtolower(string istring); // Apparently faster replacement for tolower char chartolower(const char c); // Returns the uppercase version of a string string strtoupper(string istring); char chartoupper(const char c); // Converts an integer to a hex-string string dechex(const int i); // Converts a hexadecimal number (string) to a decimal number double hexdec(string istring); // Converts float to string string f2str(const float f); // Converts a string to float float str2f(const string istring); // Converts a char to a string string char2str(const char c); #endif // HEADER_CSS_CONVERT csstidy-1.4/csstidy/cssopt.cpp0000644000175000017500000001524210644712704015564 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "csspp_globals.hpp" using namespace std; extern vector unit_values,color_values; extern map replace_colors,all_properties; string shorthand(string value) { string important = ""; if(is_important(value)) { value = gvw_important(value); important = "!important"; } vector values = explode(" ",value); switch(values.size()) { case 4: if(values[0] == values[1] && values[0] == values[2] && values[0] == values[3]) { return values[0] + important; } else if(values[1] == values[3] && values[0] == values[2]) { return values[0] + " " + values[1] + important; } else if(values[1] == values[3]) { return values[0] + " " + values[1] + " " + values[2] + important; } else return value + important; break; case 3: if(values[0] == values[1] && values[0] == values[2]) { return values[0] + important; } else if(values[0] == values[2]) { return values[0] + " " + values[1] + important; } else return value + important; break; case 2: if(values[0] == values[1]) { return values[0] + important; } else return value + important; break; default: return value + important; } } string compress_numbers(string subvalue, string property) { string units[] = {"in", "cm", "mm", "pt", "pc", "px", "rem", "%", "ex", "gd", "em", "vw", "vh", "vm", "deg", "grad", "rad", "ms", "s", "khz", "hz" }; // sync for loop vector temp; if(property == "font") { temp = explode("/",subvalue); } else { temp.push_back(subvalue); } for (int i = 0; i < temp.size(); ++i) { if(!(temp[i].length() > 0 && (ctype_digit(temp[i][0]) || temp[i][0] == '+' || temp[i][0] == '-' ) )) { continue; } if(in_str_array(color_values,property)) { temp[i] = "#" + temp[i]; } if(str2f(temp[i]) == 0) { temp[i] = "0"; } else { bool unit_found = false; temp[i] = strtolower(temp[i]); for(int j = 0; j < 21; ++j ) { if(temp[i].find(units[j]) != string::npos) { temp[i] = f2str(str2f(temp[i])) + units[j]; unit_found = true; break; } } if(!unit_found && in_str_array(unit_values,property)) { temp[i] = f2str(str2f(temp[i])); temp[i] += "px"; } else if(!unit_found) { temp[i] = f2str(str2f(temp[i])); } // Remove leading zero if (abs( (int) str2f(temp[i])) < 1) { if (str2f(temp[i]) < 0) { temp[i] = '-' + temp[i].substr(2); } else { temp[i] = temp[i].substr(1); } } } } return (temp.size() > 1) ? temp[0] + "/" + temp[1] : ((temp.size() > 0) ? temp[0] : ""); } bool property_is_next(string istring, int pos) { istring = istring.substr(pos,istring.length()-pos); pos = istring.find_first_of(':',0); if(pos == string::npos) { return false; } istring = strtolower(trim(istring.substr(0,pos))); return (all_properties.count(istring) > 0); } string cut_color(string color) { if(strtolower(color.substr(0,4)) == "rgb(") { vector color_tmp = explode(",",color.substr(4,color.length()-5)); for (int i = 0; i < color_tmp.size(); ++i) { color_tmp[i] = trim(color_tmp[i]); if(color_tmp[i].at(color_tmp[i].length()-1) == '%') { color_tmp[i] = f2str(round(255 * atoi(color_tmp[i].c_str())/100,0)); } if(atoi(color_tmp[i].c_str()) > 255) color_tmp[i] = 255; } color = "#"; for (int i = 0; i < color_tmp.size(); ++i) { if(atoi(color_tmp[i].c_str()) < 16) { color += "0" + dechex(atoi(color_tmp[i].c_str())); } else { color += dechex(atoi(color_tmp[i].c_str())); } } } // Fix bad color names if(replace_colors.count(strtolower(color)) > 0) { color = replace_colors[strtolower(color)]; } if(color.length() == 7) { string color_temp = strtoupper(color); if(color_temp[0] == '#' && color_temp[1] == color_temp[2] && color_temp[3] == color_temp[4] && color_temp[5] == color_temp[6]) { color = "#"; color += color_temp[2]; color += color_temp[3]; color += color_temp[5]; } } string temp = strtolower(color); /* color name -> hex code */ if(temp == "black") return "#000"; if(temp == "fuchsia") return "#F0F"; if(temp == "white") return "#FFF"; if(temp == "yellow") return "#FF0"; /* hex code -> color name */ if(temp == "#800000") return "maroon"; if(temp == "#ffa500") return "orange"; if(temp == "#808000") return "olive"; if(temp == "#800080") return "purple"; if(temp == "#008000") return "green"; if(temp == "#000080") return "navy"; if(temp == "#008080") return "teal"; if(temp == "#c0c0c0") return "silver"; if(temp == "#808080") return "gray"; if(temp == "#f00") return "red"; return color; } int c_font_weight(string& value) { string important = ""; if(is_important(value)) { important = "!important"; value = gvw_important(value); } if(value == "bold") { value = "700"+important; return 700; } else if(value == "normal") { value = "400"+important; return 400; } return 0; } void merge_selectors(sstore& input) { for(sstore::iterator i = input.begin(), e = input.end(); i != e;) { string newsel = ""; // Check if properties also exist in another selector vector keys; for(sstore::iterator j = input.begin(); j != input.end(); j++ ) { if(j->first == i->first) { continue; } if(input[j->first] == input[i->first]) { keys.push_back(j->first); } } if(keys.size() > 0) { newsel = i->first; for(int k = 0; k < keys.size(); ++k) { input.erase(keys[k]); newsel += "," + keys[k]; } input[newsel] = i->second; input.erase(i); e = input.end(); } else { i++; } } } csstidy-1.4/csstidy/cssopt.hpp0000644000175000017500000000277310644712706015600 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HEADER_CSS_OPT #define HEADER_CSS_OPT // Color compression function. Converts all rgb() values to #-values and uses the short-form if possible. Also replaces color names and codes. string cut_color(string color); // Compresses shorthand values. Example: margin:1px 1px 1px 1px -> margin:1px string shorthand(string value); // Compresses numbers (ie. 1.0 -> 1 or 1.100 -> 1.1 string compress_numbers(string subvalue, string property = ""); // Checks if the next word in a string from pos is a CSS property bool property_is_next(string istring, const int pos); // Compress font-weight int c_font_weight(string& value); // Merges selectors which have the same properties void merge_selectors(sstore& input); #endif // HEADER_CSS_OPT csstidy-1.4/csstidy/csspp_globals.cpp0000644000175000017500000000000010644712706017070 0ustar kevinkevincsstidy-1.4/csstidy/csspp_globals.hpp0000644000175000017500000000241510644712750017110 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #define CSSTIDY_VERSION "1.3" #include #include #include #include #include #include #include #include #include #include #include #include "umap.hpp" #include "datastruct.hpp" #include "trim.hpp" #include "conversions.hpp" #include "misc.hpp" #include "important.hpp" #include "file_functions.hpp" #include "cssopt.hpp" #include "csstidy.hpp" #include "parse_css.hpp" #include "background.hpp" csstidy-1.4/csstidy/csspp_private.h0000644000175000017500000000111010644753356016575 0ustar kevinkevin/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */ /* DO NOT EDIT ! */ #ifndef CSSPP_PRIVATE_H #define CSSPP_PRIVATE_H /* VERSION DEFINITIONS */ #define VER_STRING "1.3.0.2232" #define VER_MAJOR 1 #define VER_MINOR 3 #define VER_RELEASE 0 #define VER_BUILD 2232 #define COMPANY_NAME "" #define FILE_VERSION "1.3" #define FILE_DESCRIPTION "CSS Parser and Optimiser" #define INTERNAL_NAME "" #define LEGAL_COPYRIGHT "" #define LEGAL_TRADEMARKS "" #define ORIGINAL_FILENAME "" #define PRODUCT_NAME "CSSTidy" #define PRODUCT_VERSION "1.3" #endif /*CSSPP_PRIVATE_H*/ csstidy-1.4/csstidy/csspp_private.rc0000644000175000017500000000135710644753356016767 0ustar kevinkevin/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */ /* DO NOT EDIT! */ #include // include for version info constants // // TO CHANGE VERSION INFORMATION, EDIT PROJECT OPTIONS... // 1 VERSIONINFO FILEVERSION 1,3,0,2232 PRODUCTVERSION 1,3,0,2232 FILETYPE VFT_APP { BLOCK "StringFileInfo" { BLOCK "080904E4" { VALUE "CompanyName", "" VALUE "FileVersion", "1.3" VALUE "FileDescription", "CSS Parser and Optimiser" VALUE "InternalName", "" VALUE "LegalCopyright", "" VALUE "LegalTrademarks", "" VALUE "OriginalFilename", "" VALUE "ProductName", "CSSTidy" VALUE "ProductVersion", "1.3" } } BLOCK "VarFileInfo" { VALUE "Translation", 0x0809, 1252 } } csstidy-1.4/csstidy/csspp_private.res0000644000175000017500000000147010644753402017140 0ustar kevinkevinL".rsrcÜ<@À¡‚“F€¡‚“F0€¡‚“F HX„„4VS_VERSION_INFO½ïþ¸¸äStringFileInfoÀ080904E4"CompanyName(FileVersion1.3ZFileDescriptionCSS Parser and Optimiser"InternalName&LegalCopyright*LegalTrademarks*OriginalFilename0ProductNameCSSTidy,ProductVersion1.3DVarFileInfo$Translation äH.rsrccsstidy-1.4/csstidy/csstidy.cpp0000644000175000017500000001774410644712706015746 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "csspp_globals.hpp" extern map< string, vector > shorthands; csstidy::csstidy() { properties = 0; selectors = 0; charset = ""; namesp = ""; line = 1; tokens = "{};:()@='\"/,\\!$%&*+.<>?[]^`|~"; css_level = "CSS2.1"; settings["remove_bslash"] = 1; settings["compress_colors"] = 1; settings["compress_font-weight"] = 1; settings["lowercase_s"] = 0; settings["optimise_shorthands"] = 1; settings["remove_last_;"] = 0; settings["case_properties"] = 0; settings["sort_properties"] = 0; settings["sort_selectors"] = 0; settings["merge_selectors"] = 2; settings["discard_invalid_properties"] = 0; settings["allow_html_in_templates"] = 0; settings["silent"] = 0; settings["preserve_css"] = 0; settings["timestamp"] = 0; csstemplate.push_back(""); //string before @rule csstemplate.push_back(" {\n"); //bracket after @-rule csstemplate.push_back(""); //string before selector csstemplate.push_back(" {\n"); //bracket after selector csstemplate.push_back(""); //string before property csstemplate.push_back(""); //string after property+before value csstemplate.push_back(";\n"); //string after value csstemplate.push_back("}"); //closing bracket - selector csstemplate.push_back("\n\n"); //space between blocks {...} csstemplate.push_back("\n}\n\n"); //closing bracket @-rule csstemplate.push_back(""); //indent in @-rule csstemplate.push_back(""); // before comment csstemplate.push_back("\n"); //after comment csstemplate.push_back("\n"); // after last line @-rule } void csstidy::add_token(const token_type ttype, const string data, const bool force) { if(settings["preserve_css"] || force) { token temp; temp.type = ttype; temp.data = (ttype == COMMENT) ? data : trim(data); csstokens.push_back(temp); } } void csstidy::copy(const string media, const string selector, const string media_new, const string selector_new) { for(int k = 0; k < css[media][selector].size(); k++) { string property = css[media][selector].at(k); string value = css[media][selector][property]; add(media_new,selector_new,property,value); } } void csstidy::add(const string& media, const string& selector, const string& property, const string& value) { if(settings["preserve_css"]) { return; } if(css[media][selector].has(property)) { if( !is_important(css[media][selector][property]) || (is_important(css[media][selector][property]) && is_important(value)) ) { css[media][selector].erase(property); css[media][selector][property] = trim(value); } } else { css[media][selector][property] = trim(value); } } void csstidy::log(const string msg, const message_type type, int iline) { message new_msg; new_msg.m = msg; new_msg.t = type; if(iline == 0) { iline = line; } if(logs.count(line) > 0) { for(int i = 0; i < logs[line].size(); ++i) { if(logs[line][i].m == new_msg.m && logs[line][i].t == new_msg.t) { return; } } } logs[line].push_back(new_msg); } string csstidy::unicode(string& istring,int& i) { ++i; string add = ""; bool replaced = false; while(i < istring.length() && (ctype_xdigit(istring[i]) || ctype_space(istring[i])) && add.length()< 6) { add += istring[i]; if(ctype_space(istring[i])) { break; } i++; } if(hexdec(add) > 47 && hexdec(add) < 58 || hexdec(add) > 64 && hexdec(add) < 91 || hexdec(add) > 96 && hexdec(add) < 123) { string msg = "Replaced unicode notation: Changed \\" + rtrim(add) + " to "; add = static_cast(hexdec(add)); msg += add; log(msg,Information); replaced = true; } else { add = trim("\\" + add); } if(ctype_xdigit(istring[i+1]) && ctype_space(istring[i]) && !replaced || !ctype_space(istring[i])) { i--; } if(add != "\\" || !settings["remove_bslash"] || in_str_array(tokens,istring[i+1])) { return add; } if(add == "\\") { log("Removed unnecessary backslash",Information); } return ""; } bool csstidy::is_token(string& istring,const int i) { return (in_str_array(tokens,istring[i]) && !escaped(istring,i)); } void csstidy::merge_4value_shorthands(string media, string selector) { for(map< string, vector >::iterator i = shorthands.begin(); i != shorthands.end(); ++i ) { string temp; if(css[media][selector].has(i->second[0]) && css[media][selector].has(i->second[1]) && css[media][selector].has(i->second[2]) && css[media][selector].has(i->second[3])) { string important = ""; for(int j = 0; j < 4; ++j) { string val = css[media][selector][i->second[j]]; if(is_important(val)) { important = "!important"; temp += gvw_important(val)+ " "; } else { temp += val + " "; } css[media][selector].erase(i->second[j]); } add(media, selector, i->first, shorthand(trim(temp + important))); } } } map csstidy::dissolve_4value_shorthands(string property, string value) { map ret; extern map< string, vector > shorthands; if(shorthands[property][0] == "0") { ret[property] = value; return ret; } string important = ""; if(is_important(value)) { value = gvw_important(value); important = "!important"; } vector values = explode(" ",value); if(values.size() == 4) { for(int i=0; i < 4; ++i) { ret[shorthands[property][i]] = values[i] + important; } } else if(values.size() == 3) { ret[shorthands[property][0]] = values[0] + important; ret[shorthands[property][1]] = values[1] + important; ret[shorthands[property][3]] = values[1] + important; ret[shorthands[property][2]] = values[2] + important; } else if(values.size() == 2) { for(int i = 0; i < 4; ++i) { ret[shorthands[property][i]] = ((i % 2 != 0)) ? values[1] + important : values[0] + important; } } else { for(int i = 0; i < 4; ++i) { ret[shorthands[property][i]] = values[0] + important; } } return ret; } void csstidy::explode_selectors() { // Explode multiple selectors if (settings["merge_selectors"] == 1) { vector new_sels; int lastpos = 0; sel_separate.push_back(cur_selector.length()); for (int i = 0; i < sel_separate.size(); ++i) { if (i == sel_separate.size()-1) { sel_separate[i] += 1; } new_sels.push_back(cur_selector.substr(lastpos,sel_separate[i]-lastpos-1)); lastpos = sel_separate[i]; } if (new_sels.size() > 1) { for (int i = 0; i < new_sels.size(); ++i) { for (pstore::iterator j = css[cur_at][cur_selector].begin(); j != css[cur_at][cur_selector].end(); ++j) { add(cur_at, new_sels[i], j->first, j->second); } } css[cur_at].erase(cur_selector); } } sel_separate = vector(); } csstidy-1.4/csstidy/csstidy.dev0000644000175000017500000001017410644753542015733 0ustar kevinkevin[Project] FileName=csstidy.dev Name=csstidy UnitCount=26 Type=1 Ver=1 ObjFiles= Includes= Libs= PrivateResource=csspp_private.rc ResourceIncludes= MakeIncludes= Compiler= CppCompiler= Linker= IsCpp=1 Icon= ExeOutput= ObjectOutput= OverrideOutput=0 OverrideOutputName=csstidy.exe HostApplication= Folders= CommandLine=test.txt UseCustomMakefile=0 CustomMakefile= IncludeVersionInfo=1 SupportXPThemes=0 CompilerSet=0 CompilerSettings=1000000001100000000000 [Unit1] FileName=main.cpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [VersionInfo] Major=1 Minor=3 Release=0 Build=2232 LanguageID=2057 CharsetID=1252 CompanyName= FileVersion=1.3 FileDescription=CSS Parser and Optimiser InternalName= LegalCopyright= LegalTrademarks= OriginalFilename= ProductName=CSSTidy ProductVersion=1.3 AutoIncBuildNr=1 [Unit2] FileName=datastruct.hpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit5] FileName=cssopt.hpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit6] FileName=important.hpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit8] FileName=csspp_globals.hpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit9] FileName=trim.cpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit11] FileName=file_functions.cpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit12] FileName=print_css.cpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit13] FileName=conversions.hpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit14] FileName=conversions.cpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit15] FileName=misc.cpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit16] FileName=cssopt.cpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit17] FileName=parse_css.cpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit18] FileName=csspp_globals.cpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit19] FileName=prepare.hpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit21] FileName=background.hpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit22] FileName=background.cpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit10] FileName=trim.hpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit23] FileName=umap.cpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit24] FileName=umap.hpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit25] FileName=csstidy.hpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit26] FileName=csstidy.cpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit27] FileName=csstidy.cpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit3] FileName=file_functions.hpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit4] FileName=misc.hpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit29] FileName=csstidy_print.cpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit20] FileName=prepare.cpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit7] FileName=important.cpp CompileCpp=1 Folder= Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= csstidy-1.4/csstidy/csstidy.hpp0000644000175000017500000000526210644712706015743 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HEADER_CSSTIDY #define HEADER_CSSTIDY class csstidy { public: int properties,selectors,input_size,output_size; string charset,namesp, css_level; vector import, csstemplate; map > logs; map settings; private: css_struct css; vector csstokens; string tokens, cur_selector, cur_at, cur_property, cur_sub_value, cur_value, cur_string; int line; vector sel_separate; void add_token(const token_type ttype, const string data, const bool force = false); void _convert_raw_css(); // Add a message to the message log void log(const string msg, const message_type type, int iline = 0); int _seeknocomment(const int key, const int move); string _htmlsp(const string istring, const bool plain); string optimise_subvalue(string subvalue, const string property); void explode_selectors(); // Parses unicode notations string unicode(string& istring,int& i); // Checks if the chat in istring at i is a token bool is_token(string& istring,const int i); public: csstidy(); // Adds a property-value pair to an existing CSS structure void add(const string& media, const string& selector, const string& property, const string& value); void copy(const string media, const string selector, const string media_new, const string selector_new); // Prints CSS code void print_css(string filename = ""); // Parse a piece of CSS code void parse_css(string css_input); /* Merges properties like margin */ void merge_4value_shorthands(string media, string selector); /* Dissolves properties like padding:10px 10px 10px to padding-top:10px;padding-bottom:10px;... */ map dissolve_4value_shorthands(string property, string value); }; #endif // HEADER_CSSTIDY csstidy-1.4/csstidy/datastruct.hpp0000644000175000017500000000243410644712706016435 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ using namespace std; #ifndef HEADER_CSS_STRUCT #define HEADER_CSS_STRUCT typedef umap pstore; typedef umap sstore; typedef umap css_struct; enum parse_status { is,ip,iv,instr,ic,at }; enum message_type { Information,Warning,Error }; enum token_type { AT_START, AT_END, SEL_START, SEL_END, PROPERTY, VALUE, COMMENT }; struct token { token_type type; string data; }; struct message { string m; message_type t; }; #endif // HEADER_CSS_STRUCT csstidy-1.4/csstidy/file_functions.cpp0000644000175000017500000000255710644712704017265 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "csspp_globals.hpp" using namespace std; string file_get_contents(const string filename) { ifstream file_input(filename.c_str(),ios::binary); string line, file_contents = ""; if(file_input.bad()) { return ""; } else { while(file_input.good()) { getline(file_input,line); file_contents += (line + "\n"); } } file_input.close(); return file_contents; } bool file_exists(const char *filename) { ifstream file_input(filename); if(file_input.is_open()) { file_input.close(); return true; } file_input.close(); return false; } csstidy-1.4/csstidy/file_functions.hpp0000644000175000017500000000174010644712704017263 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HEADER_CSS_FILE #define HEADER_CSS_FILE // Get contents of a file string file_get_contents(const string filename); // Checks if a file exists bool file_exists(const char *filename); #endif // HEADER_CSS_FILE csstidy-1.4/csstidy/important.cpp0000644000175000017500000000271010644712706016264 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "csspp_globals.hpp" using namespace std; bool is_important(string value) { // Remove whitespaces value = rtrim(strtolower(value)); if(value.length() > 9 && value.substr(value.length()-9,9) == "important") { value = rtrim(value.substr(0,value.length()-9)); if(value.substr(value.length()-1,1) == "!") { return true; } } return false; } string gvw_important(string value) { if(is_important(value)) { value = trim(value); value = value.substr(0,value.length()-9); value = trim(value); value = value.substr(0,value.length()-1); value = trim(value); } return value; } string c_important(string value) { if(is_important(value)) { value = gvw_important(value) + "!important"; } return value; } csstidy-1.4/csstidy/important.hpp0000644000175000017500000000212110644712706016265 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HEADER_CSS_IMPORTANT #define HEADER_CSS_IMPORTANT // Checks if value is important bool is_important(string value); // Get value without !important string gvw_important(string value); // Compresses !important (for example if someone uses "! important") string c_important(string value); #endif //HEADER_CSS_IMPORTANT csstidy-1.4/csstidy/main.cpp0000644000175000017500000001547110644712706015203 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ using namespace std; #include "csspp_globals.hpp" #include "prepare.hpp" map< string, vector > predefined_templates; int main(int argc, char *argv[]) { prepare(); predefined_templates["high"].push_back(""); predefined_templates["high"].push_back(" {\n"); predefined_templates["high"].push_back(""); predefined_templates["high"].push_back("{"); predefined_templates["high"].push_back(""); predefined_templates["high"].push_back(""); predefined_templates["high"].push_back(";"); predefined_templates["high"].push_back("}"); predefined_templates["high"].push_back("\n"); predefined_templates["high"].push_back("\n}\n"); predefined_templates["high"].push_back(""); predefined_templates["high"].push_back(""); // before comment predefined_templates["high"].push_back(""); //after comment predefined_templates["high"].push_back("\n"); // after last line @-rule predefined_templates["highest"].push_back(""); predefined_templates["highest"].push_back("{"); predefined_templates["highest"].push_back(""); predefined_templates["highest"].push_back("{"); predefined_templates["highest"].push_back(""); predefined_templates["highest"].push_back(""); predefined_templates["highest"].push_back(";"); predefined_templates["highest"].push_back("}"); predefined_templates["highest"].push_back(""); predefined_templates["highest"].push_back("}"); predefined_templates["highest"].push_back(""); predefined_templates["highest"].push_back(""); // before comment predefined_templates["highest"].push_back(""); //after comment predefined_templates["highest"].push_back(""); // after last line @-rule predefined_templates["low"].push_back(""); predefined_templates["low"].push_back(" {\n"); predefined_templates["low"].push_back(""); predefined_templates["low"].push_back("\n{\n"); predefined_templates["low"].push_back("\t"); predefined_templates["low"].push_back(""); predefined_templates["low"].push_back(";\n"); predefined_templates["low"].push_back("}"); predefined_templates["low"].push_back("\n\n"); predefined_templates["low"].push_back("\n}\n\n"); predefined_templates["low"].push_back("\t"); predefined_templates["low"].push_back(""); // before comment predefined_templates["low"].push_back("\n"); //after comment predefined_templates["low"].push_back("\n"); // after last line @-rule csstidy csst; if(argc > 1) { string filein = argv[1]; if(filein != "-" && !file_exists(argv[1])) { cout << "The file \"" << filein << "\" does not exist." << endl; return EXIT_FAILURE; } string output_filename; for(int i = 2; i < argc; ++i) { bool output_file = true; for(map::iterator j = csst.settings.begin(); j != csst.settings.end(); ++j ) { if(trim(argv[i]) == "--" + j->first + "=false" || trim(argv[i]) == "--" + j->first + "=0") { csst.settings[j->first] = 0; output_file = false; } else if(trim(argv[i]) == "--" + j->first + "=true" || trim(argv[i]) == "--" + j->first + "=1") { csst.settings[j->first] = 1; output_file = false; } else if(trim(argv[i]) == "--" + j->first + "=2") { csst.settings[j->first] = 2; output_file = false; } } if(trim(argv[i]).substr(0,12) == "--css_level=") { csst.css_level = strtoupper(trim(argv[i]).substr(12)); output_file = false; } else if(trim(argv[i]).substr(0,11) == "--template=") { string template_value = trim(argv[i]).substr(11); if(template_value == "high" || template_value == "highest" || template_value == "low") { csst.csstemplate = predefined_templates[template_value]; } else if(template_value != "default") { string tpl_content = file_get_contents(template_value); if(tpl_content != "") { vector tpl_arr = explode("|",tpl_content,true); csst.csstemplate = tpl_arr; } } output_file = false; } if(output_file) { output_filename = trim(argv[i]); } } string css_file; if(filein == "-") { string temp; do { getline(cin, temp, '\n'); css_file += (temp + "\n"); } while(cin); } else { css_file = file_get_contents(argv[1]); } csst.parse_css(css_file); // Print CSS to screen if no output file is specified if(output_filename == "") { csst.print_css(); } else { csst.print_css(output_filename); } return EXIT_SUCCESS; } cout << endl << "Usage:" << endl << endl << "csstidy input_filename [\n"; for(map::iterator j = csst.settings.begin(); j != csst.settings.end(); ++j ) { if (j->first == "optimise_shorthands" || j->first == "merge_selectors" || j->first == "case_properties") { continue; } cout << " --" << j->first; if(j->second == true) { cout << "=[true|false] |\n"; } else { cout << "=[false|true] |\n"; } } cout << " --merge_selectors=[2|1|0] |\n"; cout << " --case_properties=[0|1|2] |\n"; cout << " --optimise_shorthands=[1|2|0] |\n"; cout << " --template=[default|filename|low|high|highest] |\n"; cout << " output_filename ]*" << endl; return EXIT_SUCCESS; } csstidy-1.4/csstidy/misc.cpp0000644000175000017500000001234410644712706015206 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "csspp_globals.hpp" bool escaped(const string &istring, const int pos) { return !(s_at(istring,pos-1) != '\\' || escaped(istring,pos-1)); } // Save replacement for .at() char s_at(const string &istring, const int pos) { if(pos > (istring.length()-1) && pos < 0) { return 0; } else { return istring[pos]; } } vector explode(const string e,string s, const bool check) { vector ret; int iPos = s.find(e, 0); int iPit = e.length(); while(iPos > -1) { if(iPos != 0 || check) { ret.push_back(s.substr(0,iPos)); } s.erase(0,iPos+iPit); iPos = s.find(e, 0); } if(s != "" || check) { ret.push_back(s); } return ret; } string implode(const string e,const vector s) { string ret; for(int i = 0; i < s.size(); i++) { ret += s[i]; if(i != (s.size()-1)) ret += e; } return ret; } float round(const float &number, const int num_digits) { float doComplete5i, doComplete5(number * powf(10.0f, (float) (num_digits + 1))); if(number < 0.0f) doComplete5 -= 5.0f; else doComplete5 += 5.0f; doComplete5 /= 10.0f; modff(doComplete5, &doComplete5i); return doComplete5i / powf(10.0f, (float) num_digits); } string str_replace(const string find, const string replace, string str) { int len = find.length(); int replace_len = replace.length(); int pos = str.find(find); while(pos != string::npos) { str.replace(pos, len, replace); pos = str.find(find, pos + replace_len); } return str; } string str_replace(const vector& find, const string replace, string str) { int replace_len = replace.length(); for(int i = 0; i < find.size(); ++i) { int len = find[i].length(); int pos = str.find(find[i]); while(pos != string::npos) { str.replace(pos, len, replace); pos = str.find(find[i], pos + replace_len); } } return str; } bool in_char_arr(const char* haystack, const char needle) { for(int i = 0; i < strlen(haystack); ++i) { if(haystack[i] == needle) { return true; } } return false; } bool in_str_array(const string& haystack, const char needle) { return (haystack.find_first_of(needle,0) != string::npos); } bool in_str_array(const vector& haystack, const string needle) { for(int i = 0; i < haystack.size(); ++i) { if(haystack[i] == needle) { return true; } } return false; } string htmlspecialchars(string istring, int quotes) { istring = str_replace("&","&",istring); istring = str_replace("<","<",istring); istring = str_replace(">",">",istring); if(quotes > 0) istring = str_replace("\"",""",istring); if(quotes > 1) istring = str_replace("'","'",istring); return istring; } int max(const int i1, const int i2) { if(i1 > i2) { return i1; } else { return i2; } } bool ctype_space(const char c) { return (c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == 11); } bool ctype_digit(const char c) { return (c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9'); } vector unserialise_sa(const string istring) { int strlen = istring.length(); int strpos = 0; vector ret; while(strlen > 0) { string digit_tmp = ""; for(int i = strpos; ctype_digit(s_at(istring,i)); i++) { digit_tmp += istring[i]; --strlen; ++strpos; } // : --strlen; ++strpos; int next_length = static_cast(str2f(digit_tmp)); next_length += strpos; string string_tmp = ""; for(int i = strpos; (i explode(const string e, string s, const bool check = false); // Implodes a string at e std::string implode(const string e, const vector s); // Replaces with in string str_replace(const string find, const string replace, string str); // Replaces all values of with in string str_replace(const vector& find, const string replace, string str); // Checks if a string exists in a string-array bool in_char_arr(const char* haystack, const char needle); bool in_str_array(const string& haystack, const char needle); bool in_str_array(const vector& haystack, const string needle); // Replaces certain chars with their entities string htmlspecialchars(string istring, int quotes = 0); // Rounds a float value float round(const float &number, const int num_digits); // Replacement for max (so that I don't have to include unnecessary things) int max(const int i1, const int i2); /* isspace() and isdigit() do not work correctly with UTF-8 strings */ bool ctype_space(const char c); bool ctype_digit(const char c); bool ctype_xdigit(char c); bool ctype_alpha(char c); /* Unserialise string arrays */ vector unserialise_sa(const string istring); /* Serialise a string */ string serialise_sa(const string istring); #endif // HEADER_CSS_MISC csstidy-1.4/csstidy/parse_css.cpp0000644000175000017500000003403010644712750016230 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "csspp_globals.hpp" using namespace std; /* is = in selector * ip = in property * iv = in value * instr = in string (-> ",',( => ignore } and ; etc.) * ic = in comment (ignore everything) * at = in @-block */ extern map all_properties,replace_colors; extern map< string, vector > shorthands; extern map at_rules; void csstidy::parse_css(string css_input) { input_size = css_input.length(); css_input = str_replace("\r\n","\n",css_input); // Replace all double-newlines css_input += "\n"; parse_status status = is, from; cur_property = ""; string temp_add,cur_comment,temp; vector cur_sub_value_arr; char str_char; bool str_in_str = false; bool invalid_at = false; bool pn = false; int str_size = css_input.length(); for(int i = 0; i < str_size; ++i) { if(css_input[i] == '\n' || css_input[i] == '\r') { ++line; } switch(status) { /* Case in-at-block */ case at: if(is_token(css_input,i)) { if(css_input[i] == '/' && s_at(css_input,i+1) == '*') { status = ic; i += 2; from = at; } else if(css_input[i] == '{') { status = is; add_token(AT_START, cur_at); } else if(css_input[i] == ',') { cur_at = trim(cur_at) + ","; } else if(css_input[i] == '\\') { cur_at += unicode(css_input,i); } } else { int lastpos = cur_at.length()-1; if(lastpos == -1 || !( (ctype_space(cur_at[lastpos]) || is_token(cur_at,lastpos) && cur_at[lastpos] == ',') && ctype_space(css_input[i]))) { cur_at += css_input[i]; } } break; /* Case in-selector */ case is: if(is_token(css_input,i)) { if(css_input[i] == '/' && s_at(css_input,i+1) == '*' && trim(cur_selector) == "") { status = ic; ++i; from = is; } else if(css_input[i] == '@' && trim(cur_selector) == "") { // Check for at-rule invalid_at = true; for(map::iterator j = at_rules.begin(); j != at_rules.end(); ++j ) { if(strtolower(css_input.substr(i+1,j->first.length())) == j->first) { (j->second == at) ? cur_at = "@" + j->first : cur_selector = "@" + j->first; status = j->second; i += j->first.length(); invalid_at = false; } } if(invalid_at) { cur_selector = "@"; string invalid_at_name = ""; for(int j = i+1; j < str_size; ++j) { if(!ctype_alpha(css_input[j])) { break; } invalid_at_name += css_input[j]; } log("Invalid @-rule: " + invalid_at_name + " (removed)",Warning); } } else if(css_input[i] == '"' || css_input[i] == '\'') { cur_string = css_input[i]; status = instr; str_char = css_input[i]; from = is; } else if(invalid_at && css_input[i] == ';') { invalid_at = false; status = is; } else if(css_input[i] == '{') { status = ip; add_token(SEL_START, cur_selector); ++selectors; } else if(css_input[i] == '}') { add_token(AT_END, cur_at); cur_at = ""; cur_selector = ""; sel_separate = vector(); } else if(css_input[i] == ',') { cur_selector = trim(cur_selector) + ","; sel_separate.push_back(cur_selector.length()); } else if(css_input[i] == '\\') { cur_selector += unicode(css_input,i); } // remove unnecessary universal selector, FS#147 else if(!(css_input[i] == '*' && (s_at(css_input,i+1) == '.' || s_at(css_input,i+1) == '[' || s_at(css_input,i+1) == ':' || s_at(css_input,i+1) == '#'))) { cur_selector += css_input[i]; } } else { int lastpos = cur_selector.length()-1; if(!( (ctype_space(cur_selector[lastpos]) || is_token(cur_selector,lastpos) && cur_selector[lastpos] == ',') && ctype_space(css_input[i]))) { cur_selector += css_input[i]; } } break; /* Case in-property */ case ip: if(is_token(css_input,i)) { if(css_input[i] == ':' || css_input[i] == '=' && cur_property != "") // IE really accepts =, so csstidy will fix those mistakes { status = iv; bool valid = !settings["discard_invalid_properties"] || (all_properties.count(cur_property) > 0 && all_properties[cur_property].find(css_level,0) != string::npos); if(valid) { add_token(PROPERTY, cur_property); } } else if(css_input[i] == '/' && s_at(css_input,i+1) == '*' && cur_property == "") { status = ic; ++i; from = ip; } else if(css_input[i] == '}') { explode_selectors(); status = is; invalid_at = false; add_token(SEL_END, cur_selector); cur_selector = ""; cur_property = ""; } else if(css_input[i] == ';') { cur_property = ""; } else if(css_input[i] == '\\') { cur_property += unicode(css_input,i); } } else if(!ctype_space(css_input[i])) { cur_property += css_input[i]; } break; /* Case in-value */ case iv: pn = ((css_input[i] == '\n' || css_input[i] == '\r') && property_is_next(css_input,i+1) || i == str_size-1); if(pn) { log("Added semicolon to the end of declaration",Warning); } if(is_token(css_input,i) || pn) { if(css_input[i] == '/' && s_at(css_input,i+1) == '*') { status = ic; ++i; from = iv; } else if(css_input[i] == '"' || css_input[i] == '\'' || css_input[i] == '(') { str_char = (css_input[i] == '(') ? ')' : css_input[i]; cur_string = css_input[i]; status = instr; from = iv; } else if(css_input[i] == '\\') { cur_sub_value += unicode(css_input,i); } else if(css_input[i] == ';' || pn) { if(cur_selector.substr(0,1) == "@" && at_rules.count(cur_selector.substr(1)) > 0 && at_rules[cur_selector.substr(1)] == iv) { cur_sub_value_arr.push_back(trim(cur_sub_value)); status = is; if(cur_selector == "@charset") charset = cur_sub_value_arr[0]; if(cur_selector == "@namespace") namesp = implode(" ",cur_sub_value_arr); if(cur_selector == "@import") import.push_back(implode(" ",cur_sub_value_arr)); cur_sub_value_arr.clear(); cur_sub_value = ""; cur_selector = ""; sel_separate = vector(); } else { status = ip; } } else if (css_input[i] == '!') { cur_sub_value = optimise_subvalue(cur_sub_value,cur_property); cur_sub_value_arr.push_back(trim(cur_sub_value)); cur_sub_value = "!"; } else if(css_input[i] != '}') { cur_sub_value += css_input[i]; } if( (css_input[i] == '}' || css_input[i] == ';' || pn) && !cur_selector.empty()) { ++properties; if(cur_at == "") { cur_at = "standard"; } // Kill all whitespace cur_at = trim(cur_at); cur_selector = trim(cur_selector); cur_value = trim(cur_value); cur_property = trim(cur_property); cur_sub_value = trim(cur_sub_value); // case settings if(settings["lowercase_s"]) { cur_selector = strtolower(cur_selector); } cur_property = strtolower(cur_property); if(cur_sub_value != "") { cur_sub_value = optimise_subvalue(cur_sub_value,cur_property); cur_sub_value_arr.push_back(cur_sub_value); cur_sub_value = ""; } cur_value = implode(" ",cur_sub_value_arr); // Compress !important temp = c_important(cur_value); if(temp != cur_value) { log("Optimised !important",Information); } cur_value = temp; // Optimise shorthand properties if(shorthands.count(cur_property) > 0) { temp = shorthand(cur_value); if(temp != cur_value) { log("Optimised shorthand notation (" + cur_property + "): Changed \"" + cur_value + "\" to \"" + temp + "\"",Information); } cur_value = temp; } // Compress font-weight (tiny compression) if(cur_property == "font-weight" && settings["compress_font-weight"]) { int c_fw = c_font_weight(cur_value); if(c_fw == 400) { log("Optimised font-weight: Changed \"bold\" to \"700\"",Information); } else if(c_fw == 700) { log("Optimised font-weight: Changed \"normal\" to \"400\"",Information); } } bool valid = (all_properties.count(cur_property) > 0 && all_properties[cur_property].find(css_level,0) != string::npos); if((!invalid_at || settings["preserve_css"]) && (!settings["discard_invalid_properties"] || valid)) { add(cur_at,cur_selector,cur_property,cur_value); add_token(VALUE, cur_value); // Further Optimisation if(cur_property == "background" && settings["optimise_shorthands"] > 1) { map temp = dissolve_short_bg(cur_value); css[cur_at][cur_selector].erase("background"); for(map::iterator it = temp.begin(); it != temp.end(); ++it ) { add(cur_at,cur_selector,it->first,it->second); } } if(shorthands.count(cur_property) > 0 && settings["optimise_shorthands"] > 0) { map temp = dissolve_4value_shorthands(cur_property,cur_value); for(map::iterator it = temp.begin(); it != temp.end(); ++it ) { add(cur_at,cur_selector,it->first,it->second); } if(shorthands[cur_property][0] != "0") { css[cur_at][cur_selector].erase(cur_property); } } } if(!valid) { if(settings["discard_invalid_properties"]) { log("Removed invalid property: " + cur_property,Warning); } else { log("Invalid property in " + strtoupper(css_level) + ": " + cur_property,Warning); } } //Split multiple selectors here if necessary cur_property = ""; cur_sub_value_arr.clear(); cur_value = ""; } if(css_input[i] == '}') { explode_selectors(); add_token(SEL_END, cur_selector); status = is; invalid_at = false; cur_selector = ""; } } else if(!pn) { cur_sub_value += css_input[i]; if(ctype_space(css_input[i])) { if(trim(cur_sub_value) != "") { cur_sub_value = optimise_subvalue(cur_sub_value,cur_property); cur_sub_value_arr.push_back(trim(cur_sub_value)); } cur_sub_value = ""; } } break; /* Case in-string */ case instr: if(str_char == ')' && (css_input[i] == '"' || css_input[i] == '\'') && str_in_str == false && !escaped(css_input,i)) { str_in_str = true; } else if(str_char == ')' && (css_input[i] == '"' || css_input[i] == '\'') && str_in_str == true && !escaped(css_input,i)) { str_in_str = false; } temp_add = ""; temp_add += css_input[i]; if( (css_input[i] == '\n' || css_input[i] == '\r') && !(css_input[i-1] == '\\' && !escaped(css_input,i-1)) ) { temp_add = "\\A "; log("Fixed incorrect newline in string",Warning); } if (!(str_char == ')' && char2str(css_input[i]).find_first_of(" \n\t\r\0xb") != string::npos && !str_in_str)) { cur_string += temp_add; } if(css_input[i] == str_char && !escaped(css_input,i) && str_in_str == false) { status = from; if (cur_string.find_first_of(" \n\t\r\0xb") == string::npos && cur_property != "content") { if (str_char == '"' || str_char == '\'') { cur_string = cur_string.substr(1, cur_string.length() - 2); } else if (cur_string.length() > 3 && (cur_string[1] == '"' || cur_string[1] == '\'')) /* () */ { cur_string = cur_string[0] + cur_string.substr(2, cur_string.length() - 4) + cur_string[cur_string.length()-1]; } } if(from == iv) { cur_sub_value += cur_string; } else if(from == is) { cur_selector += cur_string; } } break; /* Case in-comment */ case ic: if(css_input[i] == '*' && s_at(css_input,i+1) == '/') { status = from; ++i; add_token(COMMENT, cur_comment); cur_comment = ""; } else { cur_comment += css_input[i]; } break; } } if(settings["merge_selectors"] > 1) { for(css_struct::iterator i = css.begin(); i != css.end(); i++ ) { merge_selectors(i->second); } } if(settings["optimise_shorthands"] > 0) { for(css_struct::iterator i = css.begin(); i != css.end(); ++i ) { for(sstore::iterator j = i->second.begin(); j != i->second.end();) { merge_4value_shorthands(i->first,j->first); if(settings["optimise_shorthands"] > 1) { merge_bg(j->second); } if(j->second.size() == 0) { i->second.erase(j); } else { ++j; } } } } } string csstidy::optimise_subvalue(string subvalue, const string property) { subvalue = trim(subvalue); string temp = compress_numbers(subvalue,property); if(temp != subvalue) { if(temp.length() > subvalue.length()) { log("Fixed invalid number: Changed \"" + subvalue + "\" to \"" + temp + "\"",Warning); } else { log("Optimised number: Changed \"" + subvalue + "\" to \"" + temp + "\"",Information); } subvalue = temp; } if(settings["compress_colors"]) { temp = cut_color(subvalue); if(temp != subvalue) { if(replace_colors.count(subvalue) > 0) { log("Fixed invalid color name: Changed \"" + subvalue + "\" to \"" + temp + "\"",Warning); } else { log("Optimised color: Changed \"" + subvalue + "\" to \"" + temp + "\"",Information); } subvalue = temp; } } return subvalue; } csstidy-1.4/csstidy/parse_css.hpp0000644000175000017500000000161710644712706016243 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HEADER_CSS_PARSE #define HEADER_CSS_PARSE // Parses CSS //css_manage parse_css(const string css_input); #endif // HEADER_CSS_PARSE csstidy-1.4/csstidy/prepare.cpp0000644000175000017500000004053310644712704015710 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "csspp_globals.hpp" map settings; map< string, vector > shorthands; map background_prop_default,replace_colors,all_properties; vector unit_values,color_values; map at_rules; void prepare() { unit_values.push_back("background"); unit_values.push_back("background-position"); unit_values.push_back("border"); unit_values.push_back("border-top"); unit_values.push_back("border-right"); unit_values.push_back("border-bottom"); unit_values.push_back("border-left"); unit_values.push_back("border-width"); unit_values.push_back("border-top-width"); unit_values.push_back("border-right-width"); unit_values.push_back("border-left-width"); unit_values.push_back("border-bottom-width"); unit_values.push_back("bottom"); unit_values.push_back("border-spacing"); unit_values.push_back("font-size"); unit_values.push_back("height"); unit_values.push_back("left"); unit_values.push_back("margin"); unit_values.push_back("margin-top"); unit_values.push_back("margin-right"); unit_values.push_back("margin-bottom"); unit_values.push_back("margin-left"); unit_values.push_back("max-height"); unit_values.push_back("max-width"); unit_values.push_back("min-height"); unit_values.push_back("min-width"); unit_values.push_back("outline-width"); unit_values.push_back("padding"); unit_values.push_back("padding-top"); unit_values.push_back("padding-right"); unit_values.push_back("padding-bottom"); unit_values.push_back("padding-left"); unit_values.push_back("position"); unit_values.push_back("right"); unit_values.push_back("top"); unit_values.push_back("text-indent"); unit_values.push_back("letter-spacing"); unit_values.push_back("word-spacing"); unit_values.push_back("width"); color_values.push_back("color"); color_values.push_back("background-color"); color_values.push_back("border-color"); color_values.push_back("border-top-color"); color_values.push_back("border-right-color"); color_values.push_back("border-bottom-color"); color_values.push_back("border-left-color"); color_values.push_back("border-color"); color_values.push_back("color"); color_values.push_back("outline-color"); replace_colors["aliceblue"] = "#F0F8FF"; replace_colors["antiquewhite"] = "#FAEBD7"; replace_colors["aquamarine"] = "#7FFFD4"; replace_colors["azure"] = "#F0FFFF"; replace_colors["beige"] = "#F5F5DC"; replace_colors["bisque"] = "#FFE4C4"; replace_colors["blanchedalmond"] = "#FFEBCD"; replace_colors["blueviolet"] = "#8A2BE2"; replace_colors["brown"] = "#A52A2A"; replace_colors["burlywood"] = "#DEB887"; replace_colors["cadetblue"] = "#5F9EA0"; replace_colors["chartreuse"] = "#7FFF00"; replace_colors["chocolate"] = "#D2691E"; replace_colors["coral"] = "#FF7F50"; replace_colors["cornflowerblue"] = "#6495ED"; replace_colors["cornsilk"] = "#FFF8DC"; replace_colors["crimson"] = "#DC143C"; replace_colors["cyan"] = "#00FFFF"; replace_colors["darkblue"] = "#00008B"; replace_colors["darkcyan"] = "#008B8B"; replace_colors["darkgoldenrod"] = "#B8860B"; replace_colors["darkgray"] = "#A9A9A9"; replace_colors["darkgreen"] = "#006400"; replace_colors["darkkhaki"] = "#BDB76B"; replace_colors["darkmagenta"] = "#8B008B"; replace_colors["darkolivegreen"] = "#556B2F"; replace_colors["darkorange"] = "#FF8C00"; replace_colors["darkorchid"] = "#9932CC"; replace_colors["darkred"] = "#8B0000"; replace_colors["darksalmon"] = "#E9967A"; replace_colors["darkseagreen"] = "#8FBC8F"; replace_colors["darkslateblue"] = "#483D8B"; replace_colors["darkslategray"] = "#2F4F4F"; replace_colors["darkturquoise"] = "#00CED1"; replace_colors["darkviolet"] = "#9400D3"; replace_colors["deeppink"] = "#FF1493"; replace_colors["deepskyblue"] = "#00BFFF"; replace_colors["dimgray"] = "#696969"; replace_colors["dodgerblue"] = "#1E90FF"; replace_colors["feldspar"] = "#D19275"; replace_colors["firebrick"] = "#B22222"; replace_colors["floralwhite"] = "#FFFAF0"; replace_colors["forestgreen"] = "#228B22"; replace_colors["gainsboro"] = "#DCDCDC"; replace_colors["ghostwhite"] = "#F8F8FF"; replace_colors["gold"] = "#FFD700"; replace_colors["goldenrod"] = "#DAA520"; replace_colors["greenyellow"] = "#ADFF2F"; replace_colors["honeydew"] = "#F0FFF0"; replace_colors["hotpink"] = "#FF69B4"; replace_colors["indianred"] = "#CD5C5C"; replace_colors["indigo"] = "#4B0082"; replace_colors["ivory"] = "#FFFFF0"; replace_colors["khaki"] = "#F0E68C"; replace_colors["lavender"] = "#E6E6FA"; replace_colors["lavenderblush"] = "#FFF0F5"; replace_colors["lawngreen"] = "#7CFC00"; replace_colors["lemonchiffon"] = "#FFFACD"; replace_colors["lightblue"] = "#ADD8E6"; replace_colors["lightcoral"] = "#F08080"; replace_colors["lightcyan"] = "#E0FFFF"; replace_colors["lightgoldenrodyellow"] = "#FAFAD2"; replace_colors["lightgrey"] = "#D3D3D3"; replace_colors["lightgreen"] = "#90EE90"; replace_colors["lightpink"] = "#FFB6C1"; replace_colors["lightsalmon"] = "#FFA07A"; replace_colors["lightseagreen"] = "#20B2AA"; replace_colors["lightskyblue"] = "#87CEFA"; replace_colors["lightslateblue"] = "#8470FF"; replace_colors["lightslategray"] = "#778899"; replace_colors["lightsteelblue"] = "#B0C4DE"; replace_colors["lightyellow"] = "#FFFFE0"; replace_colors["limegreen"] = "#32CD32"; replace_colors["linen"] = "#FAF0E6"; replace_colors["magenta"] = "#FF00FF"; replace_colors["mediumaquamarine"] = "#66CDAA"; replace_colors["mediumblue"] = "#0000CD"; replace_colors["mediumorchid"] = "#BA55D3"; replace_colors["mediumpurple"] = "#9370D8"; replace_colors["mediumseagreen"] = "#3CB371"; replace_colors["mediumslateblue"] = "#7B68EE"; replace_colors["mediumspringgreen"] = "#00FA9A"; replace_colors["mediumturquoise"] = "#48D1CC"; replace_colors["mediumvioletred"] = "#C71585"; replace_colors["midnightblue"] = "#191970"; replace_colors["mintcream"] = "#F5FFFA"; replace_colors["mistyrose"] = "#FFE4E1"; replace_colors["moccasin"] = "#FFE4B5"; replace_colors["navajowhite"] = "#FFDEAD"; replace_colors["oldlace"] = "#FDF5E6"; replace_colors["olivedrab"] = "#6B8E23"; replace_colors["orangered"] = "#FF4500"; replace_colors["orchid"] = "#DA70D6"; replace_colors["palegoldenrod"] = "#EEE8AA"; replace_colors["palegreen"] = "#98FB98"; replace_colors["paleturquoise"] = "#AFEEEE"; replace_colors["palevioletred"] = "#D87093"; replace_colors["papayawhip"] = "#FFEFD5"; replace_colors["peachpuff"] = "#FFDAB9"; replace_colors["peru"] = "#CD853F"; replace_colors["pink"] = "#FFC0CB"; replace_colors["plum"] = "#DDA0DD"; replace_colors["powderblue"] = "#B0E0E6"; replace_colors["rosybrown"] = "#BC8F8F"; replace_colors["royalblue"] = "#4169E1"; replace_colors["saddlebrown"] = "#8B4513"; replace_colors["salmon"] = "#FA8072"; replace_colors["sandybrown"] = "#F4A460"; replace_colors["seagreen"] = "#2E8B57"; replace_colors["seashell"] = "#FFF5EE"; replace_colors["sienna"] = "#A0522D"; replace_colors["skyblue"] = "#87CEEB"; replace_colors["slateblue"] = "#6A5ACD"; replace_colors["slategray"] = "#708090"; replace_colors["snow"] = "#FFFAFA"; replace_colors["springgreen"] = "#00FF7F"; replace_colors["steelblue"] = "#4682B4"; replace_colors["tan"] = "#D2B48C"; replace_colors["thistle"] = "#D8BFD8"; replace_colors["tomato"] = "#FF6347"; replace_colors["turquoise"] = "#40E0D0"; replace_colors["violet"] = "#EE82EE"; replace_colors["violetred"] = "#D02090"; replace_colors["wheat"] = "#F5DEB3"; replace_colors["whitesmoke"] = "#F5F5F5"; replace_colors["yellowgreen"] = "#9ACD32"; shorthands["border-color"].push_back("border-top-color"); shorthands["border-color"].push_back("border-right-color"); shorthands["border-color"].push_back("border-bottom-color"); shorthands["border-color"].push_back("border-left-color"); shorthands["border-style"].push_back("border-top-style"); shorthands["border-style"].push_back("border-right-style"); shorthands["border-style"].push_back("border-bottom-style"); shorthands["border-style"].push_back("border-left-style"); shorthands["border-width"].push_back("border-top-width"); shorthands["border-width"].push_back("border-right-width"); shorthands["border-width"].push_back("border-bottom-width"); shorthands["border-width"].push_back("border-left-width"); shorthands["margin"].push_back("margin-top"); shorthands["margin"].push_back("margin-right"); shorthands["margin"].push_back("margin-bottom"); shorthands["margin"].push_back("margin-left"); shorthands["padding"].push_back("padding-top"); shorthands["padding"].push_back("padding-right"); shorthands["padding"].push_back("padding-bottom"); shorthands["padding"].push_back("padding-left"); shorthands["-moz-border-radius"].push_back("0"); all_properties["background"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["background-color"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["background-image"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["background-repeat"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["background-attachment"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["background-position"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["border"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["border-top"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["border-right"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["border-bottom"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["border-left"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["border-color"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["border-top-color"] = "CSS2.0,CSS2.1"; all_properties["border-bottom-color"] = "CSS2.0,CSS2.1"; all_properties["border-left-color"] = "CSS2.0,CSS2.1"; all_properties["border-right-color"] = "CSS2.0,CSS2.1"; all_properties["border-style"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["border-top-style"] = "CSS2.0,CSS2.1"; all_properties["border-right-style"] = "CSS2.0,CSS2.1"; all_properties["border-left-style"] = "CSS2.0,CSS2.1"; all_properties["border-bottom-style"] = "CSS2.0,CSS2.1"; all_properties["border-width"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["border-top-width"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["border-right-width"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["border-left-width"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["border-bottom-width"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["border-collapse"] = "CSS2.0,CSS2.1"; all_properties["border-spacing"] = "CSS2.0,CSS2.1"; all_properties["bottom"] = "CSS2.0,CSS2.1"; all_properties["caption-side"] = "CSS2.0,CSS2.1"; all_properties["content"] = "CSS2.0,CSS2.1"; all_properties["clear"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["clip"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["color"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["counter-reset"] = "CSS2.0,CSS2.1"; all_properties["counter-increment"] = "CSS2.0,CSS2.1"; all_properties["cursor"] = "CSS2.0,CSS2.1"; all_properties["empty-cells"] = "CSS2.0,CSS2.1"; all_properties["display"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["direction"] = "CSS2.0,CSS2.1"; all_properties["float"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["font"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["font-family"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["font-style"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["font-variant"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["font-weight"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["font-stretch"] = "CSS2.0"; all_properties["font-size-adjust"] = "CSS2.0"; all_properties["font-size"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["height"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["left"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["line-height"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["list-style"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["list-style-type"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["list-style-image"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["list-style-position"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["margin"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["margin-top"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["margin-right"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["margin-bottom"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["margin-left"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["marks"] = "CSS1.0,CSS2.0"; all_properties["marker-offset"] = "CSS2.0"; all_properties["max-height"] = "CSS2.0,CSS2.1"; all_properties["max-width"] = "CSS2.0,CSS2.1"; all_properties["min-height"] = "CSS2.0,CSS2.1"; all_properties["min-width"] = "CSS2.0,CSS2.1"; all_properties["overflow"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["orphans"] = "CSS2.0,CSS2.1"; all_properties["outline"] = "CSS2.0,CSS2.1"; all_properties["outline-width"] = "CSS2.0,CSS2.1"; all_properties["outline-style"] = "CSS2.0,CSS2.1"; all_properties["outline-color"] = "CSS2.0,CSS2.1"; all_properties["padding"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["padding-top"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["padding-right"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["padding-bottom"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["padding-left"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["page-break-before"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["page-break-after"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["page-break-inside"] = "CSS2.0,CSS2.1"; all_properties["page"] = "CSS2.0"; all_properties["position"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["quotes"] = "CSS2.0,CSS2.1"; all_properties["right"] = "CSS2.0,CSS2.1"; all_properties["size"] = "CSS1.0,CSS2.0"; all_properties["speak-header"] = "CSS2.0,CSS2.1"; all_properties["table-layout"] = "CSS2.0,CSS2.1"; all_properties["top"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["text-indent"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["text-align"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["text-decoration"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["text-shadow"] = "CSS2.0"; all_properties["letter-spacing"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["word-spacing"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["text-transform"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["white-space"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["unicode-bidi"] = "CSS2.0,CSS2.1"; all_properties["vertical-align"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["visibility"] = "CSS1.0,CSS2.0,CSS2.1"; all_properties["width"] = "CSS2.0,CSS2.1"; all_properties["widows"] = "CSS2.0,CSS2.1"; all_properties["z-index"] = "CSS1.0,CSS2.0,CSS2.1"; /* Speech */ all_properties["volume"] = "CSS2.0,CSS2.1"; all_properties["speak"] = "CSS2.0,CSS2.1"; all_properties["pause"] = "CSS2.0,CSS2.1"; all_properties["pause-before"] = "CSS2.0,CSS2.1"; all_properties["pause-after"] = "CSS2.0,CSS2.1"; all_properties["cue"] = "CSS2.0,CSS2.1"; all_properties["cue-before"] = "CSS2.0,CSS2.1"; all_properties["cue-after"] = "CSS2.0,CSS2.1"; all_properties["play-during"] = "CSS2.0,CSS2.1"; all_properties["azimuth"] = "CSS2.0,CSS2.1"; all_properties["elevation"] = "CSS2.0,CSS2.1"; all_properties["speech-rate"] = "CSS2.0,CSS2.1"; all_properties["voice-family"] = "CSS2.0,CSS2.1"; all_properties["pitch"] = "CSS2.0,CSS2.1"; all_properties["pitch-range"] = "CSS2.0,CSS2.1"; all_properties["stress"] = "CSS2.0,CSS2.1"; all_properties["richness"] = "CSS2.0,CSS2.1"; all_properties["speak-punctuation"] = "CSS2.0,CSS2.1"; all_properties["speak-numeral"] = "CSS2.0,CSS2.1"; background_prop_default["background-image"] = "none"; background_prop_default["background-size"] = "auto"; background_prop_default["background-repeat"] = "repeat"; background_prop_default["background-position"] = "0 0"; background_prop_default["background-attachment"] = "scroll"; background_prop_default["background-clip"] = "border"; background_prop_default["background-origin"] = "padding"; background_prop_default["background-color"] = "transparent"; at_rules["page"] = is; at_rules["font-face"] = is; at_rules["charset"] = iv; at_rules["import"] = iv; at_rules["namespace"] = iv; at_rules["media"] = at; } csstidy-1.4/csstidy/prepare.hpp0000644000175000017500000000154610644712704015716 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HEADER_CSS_PREPARE #define HEADER_CSS_PREPARE void prepare(); #endif // HEADER_CSS_PREPARE csstidy-1.4/csstidy/print_css.cpp0000644000175000017500000001521010644712704016250 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "csspp_globals.hpp" using namespace std; string csstidy::_htmlsp(const string istring, const bool plain) { if (!plain) { return htmlspecialchars(istring); } return istring; } void csstidy::_convert_raw_css() { csstokens = vector(); for (css_struct::iterator i = css.begin(); i != css.end(); ++i) { if (settings["sort_selectors"]) i->second.sort(); if (i->first != "standard") { add_token(AT_START, i->first, true); } for(sstore::iterator j = i->second.begin(); j != i->second.end(); ++j) { if (settings["sort_properties"]) j->second.sort(); add_token(SEL_START, j->first, true); for(umap::iterator k = j->second.begin(); k != j->second.end(); ++k) { add_token(PROPERTY, k->first, true); add_token(VALUE, k->second, true); } add_token(SEL_END, j->first, true); } if (i->first != "standard") { add_token(AT_END, i->first, true); } } } int csstidy::_seeknocomment(const int key, int move) { int go = (move > 0) ? 1 : -1; for (int i = key + 1; abs(key-i)-1 < abs(move); i += go) { if (i < 0 || i > csstokens.size()) { return -1; } if (csstokens[i].type == COMMENT) { move += 1; continue; } return csstokens[i].type; } } void csstidy::print_css(string filename) { if(css.empty() && charset == "" && namesp == "" && import.empty() && csstokens.empty()) { if(!settings["silent"]) cout << "Invalid CSS!" << endl; return; } ofstream file_output; if(filename != "") { file_output.open(filename.c_str(),ios::binary); if(file_output.bad()) { if(!settings["silent"]) cout << "Error when trying to save the output file!" << endl; return; } } if(!settings["preserve_css"]) { _convert_raw_css(); } if(!settings["allow_html_in_templates"]) { for(int i = 0; i < csstemplate.size(); ++i) { csstemplate[i] = strip_tags(csstemplate[i]); } } stringstream output, in_at_out; if (settings["timestamp"]) { time_t rawtime; time(&rawtime); token temp; temp.data = " CSSTidy "; temp.data += CSSTIDY_VERSION; temp.data += ": " + rtrim(asctime (localtime ( &rawtime ))) + " "; temp.type = COMMENT; csstokens.insert(csstokens.begin(), temp); } if(charset != "") { output << csstemplate[0] << "@charset " << csstemplate[5] << charset << csstemplate[6]; } if(import.size() > 0) { for(int i = 0; i < import.size(); i ++) { output << csstemplate[0] << "@import " << csstemplate[5] << import[i] << csstemplate[6]; } } if(namesp != "") { output << csstemplate[0] << "@namespace " << csstemplate[5] << namesp << csstemplate[6]; } output << csstemplate[13]; stringstream* out =& output; bool plain = !settings["allow_html_in_templates"]; for (int i = 0; i < csstokens.size(); ++i) { switch (csstokens[i].type) { case AT_START: *out << csstemplate[0] << _htmlsp(csstokens[i].data, plain) + csstemplate[1]; out =& in_at_out; break; case SEL_START: if(settings["lowercase_s"]) csstokens[i].data = strtolower(csstokens[i].data); *out << ((csstokens[i].data[0] != '@') ? csstemplate[2] + _htmlsp(csstokens[i].data, plain) : csstemplate[0] + _htmlsp(csstokens[i].data, plain)); *out << csstemplate[3]; break; case PROPERTY: if(settings["case_properties"] == 2) csstokens[i].data = strtoupper(csstokens[i].data); if(settings["case_properties"] == 1) csstokens[i].data = strtolower(csstokens[i].data); *out << csstemplate[4] << _htmlsp(csstokens[i].data, plain) << ":" << csstemplate[5]; break; case VALUE: *out << _htmlsp(csstokens[i].data, plain); if(_seeknocomment(i, 1) == SEL_END && settings["remove_last_;"]) { *out << str_replace(";", "", csstemplate[6]); } else { *out << csstemplate[6]; } break; case SEL_END: *out << csstemplate[7]; if(_seeknocomment(i, 1) != AT_END) *out << csstemplate[8]; break; case AT_END: out =& output; *out << csstemplate[10] << str_replace("\n", "\n" + csstemplate[10], in_at_out.str()); in_at_out.str(""); *out << csstemplate[9]; break; case COMMENT: *out << csstemplate[11] << "/*" << _htmlsp(csstokens[i].data, plain) << "*/" << csstemplate[12]; break; } } string output_string = trim(output.str()); if(!settings["silent"]) { cout << endl << "Selectors: " << selectors << " | Properties: " << properties << endl; float ratio = round(((input_size - (float) output_string.length())/input_size)*100,2); float i_b = round(((float) input_size)/1024,3); float o_b = round(((float) output_string.length())/1024,3); cout << "Input size: " << i_b << "KiB Output size: " << o_b << "KiB Compression ratio: " << ratio << "%" << endl; } if(filename == "") { if(!settings["silent"]) cout << "-----------------------------------\n\n"; cout << output_string << "\n"; } else { file_output << output_string; } if(logs.size() > 0 && !settings["silent"]) { cout << "-----------------------------------\n\n"; for(map >::iterator j = logs.begin(); j != logs.end(); j++ ) { for(int i = 0; i < j->second.size(); ++i) { cout << j->first << ": " << j->second[i].m << "\n" ; } } } if(!settings["silent"]) { cout << "\n-----------------------------------" << endl << "CSSTidy " << CSSTIDY_VERSION << " by Florian Schmitz 2005, 2006" << endl; } file_output.close(); } csstidy-1.4/csstidy/SConscript0000644000175000017500000000205510644712704015555 0ustar kevinkevin#This file is adapted from http://www.scons.org/wiki/SconstructMultiple import glob #get all the build variables we need Import('env', 'project', 'mymode', 'debugcflags', 'releasecflags') localenv = env.Copy() buildroot = '../' + mymode #holds the root of the build directory tree builddir = buildroot + '/' + project #holds the build directory for this project targetpath = builddir + '/' + 'csstidy' #holds the path to the executable in the build directory #append the user's additional compile flags #assume debugcflags and releasecflags are defined if mymode == 'debug': localenv.Append(CCFLAGS=debugcflags) else: localenv.Append(CCFLAGS=releasecflags) #specify the build directory localenv.BuildDir(builddir, ".", duplicate=0) #Figure out all the source files srclst = map(lambda x: builddir + '/' + x, glob.glob('*.cpp')) #If running win32 get special version information from the .rc if localenv['PLATFORM'] == 'win32': resource = localenv.RES('win32_resource.rc') srclst.append(resource) localenv.Program(targetpath, source=srclst) csstidy-1.4/csstidy/trim.cpp0000644000175000017500000000410710644712704015222 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "csspp_globals.hpp" using namespace std; const string trim(const string istring) { std::string::size_type first = istring.find_first_not_of(" \n\t\r\0xb"); if (first == std::string::npos) { return std::string(); } else { std::string::size_type last = istring.find_last_not_of(" \n\t\r\0xb"); return istring.substr( first, last - first + 1); } } const string ltrim(const string istring) { std::string::size_type first = istring.find_first_not_of(" \n\t\r\0xb"); if (first == std::string::npos) { return std::string(); } else { return istring.substr( first ); } } const string rtrim(const string istring) { std::string::size_type last = istring.find_last_not_of(" \n\t\r\0xb"); /// must succeed return istring.substr( 0, last + 1); } const string rtrim(const string istring, const string chars) { std::string::size_type last = istring.find_last_not_of(chars); /// must succeed return istring.substr( 0, last + 1); } string strip_tags(string istring) { bool intag = false; string new_string; for(int i = 0; i < istring.length(); i++) { if(istring[i] != '<' && !intag) { new_string += istring[i]; } if(istring[i] == '<' && !intag) { intag = true; } if(istring[i] == '>' && intag) { intag = false; } } return new_string; } csstidy-1.4/csstidy/trim.hpp0000644000175000017500000000235110644712706015230 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HEADER_CSS_TRIM #define HEADER_CSS_TRIM // Removes whitespace at the end and beginning of a string const string trim(const string istring); // Removes whitespace at the beginning of a string const string ltrim(const string istring); // Removes whitespace at the end of a string const string rtrim(const string istring); const string rtrim(const string istring, const string chars); // Removes HTML tags string strip_tags(string istring); #endif // HEADER_CSS_TRIM csstidy-1.4/csstidy/umap.cpp0000644000175000017500000000000210644712704015177 0ustar kevinkevin csstidy-1.4/csstidy/umap.hpp0000644000175000017500000001031610644712704015215 0ustar kevinkevin/* * This file is part of CSSTidy. * * CSSTidy is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CSSTidy 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 CSSTidy; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include #include #include #include #include using namespace std; template class umap { typedef map StoreT; typedef std::vector FifoT; private: FifoT sortv; StoreT content; public: // Functions, same as map<> (simplified) void erase(const keyT& key) { for (typename FifoT::iterator i = sortv.begin(), e = sortv.end(); i != e; ++i) { if( (*i)->first == key) { content.erase(*i); sortv.erase(i); return; } } } int size() { return content.size(); } bool empty() { return content.empty(); } void sort() { sortv.clear(); for(typename StoreT::iterator i = content.begin(), e = content.end(); i != e; ++i) { sortv.push_back(i); } } // Checks if the map has the key bool has(const keyT key) { return (content.find(key) != content.end()); } void operator=(umap& set) { sortv.clear(); content = set.content; for(typename map::iterator i = content.begin(); i != content.end(); ++i) { sortv.push_back(i); } } bool operator==(umap& comp) const { if(sortv.size() != comp.sortv.size()) { return false; } for(int i = 0; i < sortv.size(); ++i) { if(sortv[i]->first != comp.sortv[i]->first) { return false; } } return (content == comp.content); } // Access the map per [] or at() valT& operator[](keyT const& key ) { typename StoreT::iterator mIt = content.find(key); if (mIt == content.end()) { mIt = content.insert(typename StoreT::value_type(key, valT())).first; sortv.push_back(mIt); } return mIt->second; } valT& at(int index) { if(index < size() && index >= 0) { return sortv[index]->second; } } // Iterator class iterator { friend typename umap::iterator umap::begin(); friend typename umap::iterator umap::end(); friend void umap::erase(const typename umap::iterator& it); private: typename FifoT::iterator pos; int num; int size; public: iterator() { num = 0; } typename umap::iterator& operator= (const typename umap::iterator& iter) { pos = iter.pos; num = 0; size = 0; return *this; } bool islast() { return (num == size-1); } void operator++() { ++pos; ++num; } void operator++(int) { ++pos; ++num; } bool operator!= (typename umap::iterator iter) { return (iter.pos != pos); } typename StoreT::iterator& operator->() { return *pos; } }; void erase(const typename umap::iterator& it) { content.erase(*it.pos); sortv.erase(it.pos); } typename umap::iterator begin() { typename umap::iterator test; test.pos = sortv.begin(); test.size = size(); return test; } typename umap::iterator end() { typename umap::iterator test; test.pos = sortv.end(); test.size = size(); return test; } }; csstidy-1.4/csstidy/win32_resource.rc0000644000175000017500000000211010644712706016734 0ustar kevinkevin///////////////////////////////////////////////////////////////////////////// // // Version Information // VS_VERSION_INFO VERSIONINFO FILEVERSION 1,0,0,1 PRODUCTVERSION 1,0,0,1 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L #else FILEFLAGS 0x0L #endif FILEOS 0x4L FILETYPE 0x1L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "080004b0" BEGIN VALUE "Comments", "See http://csstidy.sf.net for more information" VALUE "CompanyName", "test" VALUE "FileDescription", "CSSTidy command line executable" VALUE "FileVersion", "1, 0, 0, 1" VALUE "InternalName", "csstidy.exe" VALUE "LegalCopyright", "Copyright (C) 2005-2006 by Florian Schmitz under the GPL" VALUE "OriginalFilename", "csstidy.exe" VALUE "ProductName", " CSSTidy" VALUE "ProductVersion", "1, 0, 0, 1" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x0, 1200 END END /////////////////////////////////////////////////////////////////////////////