cssquery
is a versatile tool for extracting CSS selector contents or specific property values from a CSS file. It can be used both as a command-line tool and as a module in other Python scripts.
- Extracts all instances of a CSS selector's content.
- Retrieves specific property values within a CSS selector.
- Supports verbose output for detailed debugging information.
- Can be used as a standalone command-line tool or imported as a module.
cssquery[-v] /path/to/file.css.selector[.property]
- v: Optional flag to enable verbose output, providing detailed information about the file path, CSS query, selector, property, and matches during execution.
/path/to/file.css.selector[.property]
: The path to the CSS file followed by the selector and optional property you want to query.
Extract all instances of a selector's content:
cssquery ../base16-dispatch/theme.css.theme-dark
To retrieve a specific property's value within a selector:
cssquery ../base16-dispatch/theme.css.theme-dark.--blue
To enable verbose output for debugging:
cssquery -v ../base16-dispatch/theme.css.theme-dark.--blue
You can also import the cssquery
function into another QMarkdown script:
# another_script.qmd
from cssquery import cssquery
file_path = '../base16-dispatch/theme.css'
css_query = 'theme-dark.--blue'
result = cssquery(file_path, css_query, verbose=True)
if result:
print("Result:", result)
else:
print("No match found.")
- Python 3.x
- Clone the repository or download the
cssquery.qmd
script. - Ensure you have Python 3.x installed on your system.
Contributions are welcome! If you find a bug or have a feature request, please open an issue or submit a pull request.
- This project is licensed under the MIT License.