Files
mdq/README.md
Charlie Crossley cac0876769 README
2025-08-19 14:33:44 +01:00

151 lines
3.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
mdq - Markdown Query
`mdq` is a command-line tool for searching, filtering, and highlighting content within Markdown files. It allows you to query markdown documents for specific terms and returns results with context, including headings and list items.
Features
- Search for keywords: Easily search for specific keywords within markdown files.
- Highlight results: Search results are highlighted for better visibility using ANSI color codes.
- Contextual results: Display surrounding context around matches, such as parent headings or list items.
- Support for multiple search terms: Search for more than one term at once.
- No dependencies: `mdq` is built using Python's standard libraries, so its easy to set up and use.
Installation
Option 1: Install via `pipx` (Recommended)
`pipx` is a great way to install Python applications globally while keeping them isolated from the system environment.
1. Install `pipx` if it's not already installed:
```bash
sudo apt install pipx
```
2. Install `mdq`:
```bash
pipx install git+https://github.com/yourusername/mdq.git
```
Option 2: Install in a Virtual Environment
1. Create a virtual environment:
```bash
python3 -m venv mdq-env
```
2. Activate the virtual environment:
```bash
source mdq-env/bin/activate
```
3. Install `mdq` locally:
In the root of the repository (where `setup.py` is):
```bash
pip install .
```
4. Run the `mdq` command:
```bash
mdq "search term"
```
Option 3: Install Globally (Not Recommended)
If you really want to install `mdq` globally on your system, you can override the restrictions by running:
```bash
sudo pip install . --break-system-packages
```
Note: This method is not recommended, as it may interfere with system-managed Python packages.
Usage
Once installed, you can use the `mdq` command to search through markdown files. You can pass one or more search terms, and the results will include the matched content with context.
Basic Search
```bash
mdq "search term" /path/to/your/markdown/files/*.md
```
This will search for the term `"search term"` in all `.md` files in the specified directory.
Multiple Search Terms
```bash
mdq "term1" "term2" /path/to/your/markdown/files/*.md
```
This will search for both `"term1"` and `"term2"` in the specified markdown files and show the results for both.
Search with Context
By default, the results will show the keyword matches with surrounding context (headings and list items). You can adjust the context size and highlighting options through various flags.
Flags
- `--raw`: Output results without any highlighting (for raw output).
Example:
```bash
mdq --raw "search term" /path/to/your/markdown/files/*.md
```
- `--help`: Display help message with available options.
Example:
```bash
mdq --help
```
Example
If you have a Markdown file like this:
```markdown
# Tasks
## Deployment
- Set up the production environment
- Set up the staging environment
## Testing
- Test the production system
- Test the staging system
```
Running the following command:
```bash
mdq "production" /path/to/your/file.md
```
Will output something like:
```markdown
## Deployment
- Set up the **production** environment
- Set up the staging environment
```
Contributing
Feel free to fork the repository, open issues, and submit pull requests. If you'd like to contribute to the development of `mdq`, please follow these steps:
1. Fork the repository
2. Create a new branch
3. Make your changes
4. Open a pull request
Code of Conduct
We expect all contributors to follow the project's code of conduct. Please be respectful and considerate when participating in discussions and submitting contributions.
License
`mdq` is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.