Skip to content

Bishop-Fox/cssquery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSSQuery Tool

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.

Features

  • 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.

Usage

Command-Line Tool

    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.

Examples

Query a Selector:

Extract all instances of a selector's content:

cssquery ../base16-dispatch/theme.css.theme-dark

Query a Property:

To retrieve a specific property's value within a selector:

cssquery ../base16-dispatch/theme.css.theme-dark.--blue

Verbose Output:

To enable verbose output for debugging:

cssquery -v ../base16-dispatch/theme.css.theme-dark.--blue

As a Module

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.")

Requirements

  • Python 3.x

Installation

  • Clone the repository or download the cssquery.qmd script.
  • Ensure you have Python 3.x installed on your system.

Contributing

Contributions are welcome! If you find a bug or have a feature request, please open an issue or submit a pull request.

License

  • This project is licensed under the MIT License.

About

Pull contents of css selectors

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages