Metadata-Version: 2.4
Name: clipai
Version: 0.1.0
Summary: Add your description here
Requires-Python: >=3.13
Description-Content-Type: text/markdown
Requires-Dist: beautifulsoup4>=4.15.0
Requires-Dist: copykitten>=2.0.0
Requires-Dist: markdownify>=1.2.3
Requires-Dist: rich>=15.0.0

# ClipAI

ClipAI is a powerful CLI utility that helps you read, convert, clean, and format the macOS clipboard (paste buffer). It supports converting Rich Text (RTF) and HTML clipboard content into clean **HTML**, **Markdown**, or **Plain Text**, with strict presentational sanitization.

## Features

- **Format Conversion**: Convert clipboard data dynamically to HTML, Markdown, or Plain Text.
- **Interactive TUI Menu**: Run the command without arguments to see a live terminal preview of your clipboard content and navigate the target format menu using arrow keys (`Up`/`Down`) or direct keyboard number selections (`1-3`), and `Enter` to confirm.
- **Strict Presentational Sanitization**: Keeps HTML outputs extremely minimal by stripping out all CSS styles, font families, font sizes, classes, IDs, scripts, and metadata.
- **Automatic Marker Stripping**: Removes system-generated comment/text noise like `<!--TgQPHd||-->`, `TgQPHd||[]`, or `TgQPHd` injected by automated scrappers/indexers.
- **Citation Filtering**: Automatically strips out academic/resource numbered citation anchors and links (e.g., `[1]`, `[1, 2]`, `[[1]](url)`) by default.
- **Link Preservation Control**: Links are stripped by default to keep outputs minimal. Use the `--allow-links` flag to retain hyperlinks.
- **File Output**: Directly save the output of your formatting to a file while optionally updating the pasteboard.

---

## Installation

This project is built using Python (3.11+) and managed via `uv`.

To install dependencies and run:

```bash
# Clone the repository and navigate inside
cd clipai

# Run using uv
uv run python -m clipai [options]
```

---

## CLI Options Reference

To see all available CLI options, run:

```bash
uv run python -m clipai -h
```

### Options

| Short Flag | Long Flag | Required | Choice / Values | Description |
| :--- | :--- | :--- | :--- | :--- |
| `-h` | `--help` | No | - | Show the help message and exit. |
| `-f` | `--format` | No | `html`, `markdown`, `plaintext` | The target format to convert the clipboard content to. If not specified, ClipAI launches the interactive menu. |
| - | `--allow-links` | No | - | Allow hyperlinks to be preserved in the output. By default, links and citation anchors are stripped. |
| `-o` | `--output` | No | `<path_to_file>` | A file path where the converted clipboard content will be written. |

---

## Example Usages

### 1. Interactive Mode (Default)

Simply run the CLI without arguments. It will display a Markdown preview of your clipboard contents and present an interactive selection menu:

```bash
uv run python -m clipai
```

*Use the `Up`/`Down` arrow keys or press `1`, `2`, or `3` to choose your format, then press `Enter` to copy to clipboard.*

### 2. Immediate Clipboard Conversion to Markdown

Convert clipboard contents directly to Markdown, strip citation elements and links, and overwrite the clipboard immediately:

```bash
uv run python -m clipai -f markdown
```

### 3. Immediate HTML Conversion (Preserving Hyperlinks)

Convert clipboard contents to clean, minimal HTML (removing styles, classes, fonts, and citations) while keeping external hyperlinks:

```bash
uv run python -m clipai -f html --allow-links
```

### 4. Save Clipboard Conversion to a File

Convert clipboard contents to Plain Text (stripping all links/citations) and save it directly to `output.txt` while copying it to your clipboard:

```bash
uv run python -m clipai -f plaintext -o output.txt
```
