Metadata-Version: 2.4
Name: bear-export
Version: 0.1.1
Summary: Export Bear blog CSV data to organized markdown files
Requires-Python: >=3.13
Description-Content-Type: text/markdown
Requires-Dist: pandas>=2.0.0
Requires-Dist: click>=8.0.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: python-dateutil>=2.8.0

# Bear Export CLI Tool

A command-line tool to export Bear blog CSV data to organized markdown files.

## Installation

### Install with uvx (recommended)

```bash
uvx bear-export
```

## Usage

### Using uvx (recommended)

```bash
uvx bear-export [OPTIONS]
```

### Options

- `-c, --csv-file TEXT`: Path to Bear blog CSV export file (default: post_export.csv)
- `-o, --output-dir TEXT`: Output directory name (default: Blog)
- `--include-drafts`: Include unpublished draft posts
- `--organize-by [date|tags|none]`: Organize files by date, tags, or no organization (default: none)
- `--front-matter [yaml|toml|none]`: Front matter format for static site generators (default: yaml)

### Examples

Basic export (published posts only, flat structure):
```bash
python main.py
```

Include drafts and organize by date:
```bash
python main.py --include-drafts --organize-by date
```

Organize by tags with TOML front matter:
```bash
python main.py --organize-by tags --front-matter toml
```

Custom CSV file and output directory:
```bash
python main.py --csv-file my_export.csv --output-dir MyBlog
```

## Output Structure

### Flat Organization (default)
```
Blog/
├── post1.md
├── post2.md
├── post3.md
└── README.md
```

### Date Organization
```
Blog/
├── 2023/
│   ├── 01/
│   │   ├── january-post.md
│   │   └── another-january-post.md
│   └── 12/
│       └── december-post.md
├── 2024/
│   └── 03/
│       └── march-post.md
└── README.md
```

### Tags Organization
```
Blog/
├── personal/
│   ├── my-life.md
│   └── thoughts.md
├── coding/
│   ├── python-tips.md
│   └── vim-guide.md
├── uncategorized-post.md
└── README.md
```

## Front Matter

The tool generates front matter compatible with static site generators like Hugo, Jekyll, and others.

### YAML Front Matter (default)
```yaml
---
title: My Blog Post
slug: my-blog-post
date: 2024-03-15T10:30:00
tags:
  - personal
  - coding
lang: en
published: true
type: post
uid: abc123
---
```

### TOML Front Matter
```toml
+++
title = 'My Blog Post'
slug = 'my-blog-post'
date = '2024-03-15T10:30:00'
tags = ['personal', 'coding']
lang = 'en'
published = true
type = 'post'
uid = 'abc123'
+++
```

## Features

- Parse Bear blog CSV exports with proper encoding
- Generate clean markdown files with front matter
- Support for YAML and TOML front matter formats
- Multiple organization strategies (flat, by date, by tags)
- Filter published/draft posts
- Generate index/README file with post listings
- Handle special characters and filenames safely
- Preserve post metadata (tags, dates, language, etc.)

## Requirements

- Python 3.7+
- pandas
- click
- pyyaml
- python-dateutil
