Skip to content

Commit ad82438

Browse files
authored
Update README.md
1 parent 4b67d4b commit ad82438

1 file changed

Lines changed: 43 additions & 1 deletion

File tree

README.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,32 @@
1-
# CSS2PHP
1+
# CSS2PHP Converter
2+
3+
A powerful Python tool for converting CSS files and URLs into PHP arrays with advanced parsing and merging capabilities.
4+
5+
![Version](https://img.shields.io/badge/version-1.0.1-blue)
6+
![License](https://img.shields.io/badge/license-MIT-green)
7+
8+
## Key Features
9+
10+
- 🎯 **New: Split Selectors Mode** - Optional splitting of combined CSS selectors
11+
- 🔄 Convert CSS files/URLs to PHP arrays
12+
- 📱 Handle media queries & pseudo-classes
13+
- 🛠️ Auto-fix PHP syntax issues
14+
- 📊 Detailed statistics & reporting
15+
- 🔄 Advanced file merging with priority
16+
- 💾 Customizable output paths
17+
18+
## Installation
19+
20+
```bash
21+
# Clone repository
22+
git clone https://github.com/sakibweb/css2php
23+
24+
# Navigate to directory
25+
cd css2php
26+
27+
# Install dependencies
28+
pip install -r requirements.txt
29+
```
230

331
**Convert CSS files/URLs to PHP arrays**
432

@@ -19,6 +47,7 @@
1947
* **Merge Functionality:** Capable of merging multiple PHP array files (generated by CSS2PHP) into a single, consolidated file, useful for combining styles from different sources.
2048
* **Output Customization:** Allows setting a custom output directory and filename prefix for generated PHP files.
2149
* **PHP Syntax Validation & Auto-Fix:** Validates the generated PHP array for syntax errors and attempts to automatically fix common issues, ensuring code correctness.
50+
* **Split Selectors Mode:** Option to split combined CSS selectors into individual keys in the PHP array. This might be useful in some scenarios but could lead to loss of CSS specificity. Controlled by the `--split-selectors` flag.
2251
* **Statistics (Detailed):** Generates in-depth processing statistics, including class counts, compression ratio, media query and pseudo-class detection, and syntax validation status.
2352
* **Tailwind CSS Compatibility:** Handles common Tailwind CSS escape patterns in class names for cleaner PHP output.
2453
* **Timeout Control:** Sets a timeout for fetching remote CSS files, preventing indefinite hangs.
@@ -85,6 +114,14 @@ css2php -m -md ./php_output -mn combined_styles
85114

86115
This will merge all PHP files found in the `./php_output` directory and create a merged file named `combined_styles.php` in the `./output` directory.
87116

117+
**Splitting CSS Selectors:**
118+
119+
To split combined CSS selectors (like `.class1.class2`) into individual keys:
120+
121+
```bash
122+
css2php styles.css --split-selectors
123+
```
124+
88125
## Command-Line Arguments
89126

90127
Here is a list of all available command-line arguments, sorted alphabetically:
@@ -129,6 +166,10 @@ Here is a list of all available command-line arguments, sorted alphabetically:
129166
* **Description:** Instructs CSS2PHP to skip errors encountered during CSS fetching or parsing and continue processing other sources. Warnings will be printed for skipped errors.
130167
* **Example:** `css2php styles.css -s`
131168

169+
* `--split-selectors`:
170+
* **Description:** Splits combined CSS selectors into individual keys in the PHP array.
171+
* **Example:** `css2php styles.css --split-selectors`
172+
132173
* `-sources` `[SOURCES ...]`:
133174
* **Description:** One or more CSS file paths or URLs to convert. This is the primary input for the tool.
134175
* **Example:** `css2php styles.css https://example.com/theme.css`
@@ -176,6 +217,7 @@ CSS2PHP provides detailed reports and statistics for each conversion and merge o
176217
* Skip errors (Yes/No)
177218
* Timeout (seconds)
178219
* Overwrite enabled (Yes/No)
220+
* Split Selectors (Yes/No)
179221
* **File Structure Explanation:** Describes the structure of the generated PHP array.
180222
181223
**For merge operations, the report includes:**

0 commit comments

Comments
 (0)