text-formater


Nametext-formater JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryA CLI tool for polishing text with Chinese typography rules
upload_time2025-10-09 04:02:05
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords text formatter chinese typography cjk cli
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Text Formater

A Python CLI tool for polishing text with Chinese typography rules. Automatically formats mixed Chinese-English text, fixes em-dash spacing, normalizes ellipsis, and more.

## Features

### Universal Rules (All Languages)
- **Ellipsis normalization**: Converts `. . .` or `. . . .` to `...` with proper spacing

### Chinese-Specific Rules
- **Em-dash spacing**: Converts `--` to `——` with smart spacing around Chinese quotes `《》` and parentheses `()`
- **Quote spacing**: Adds spaces around Chinese quotation marks `""`
- **CJK-English spacing**: Automatically adds spaces between Chinese characters and English letters/numbers
- **Multiple space collapsing**: Reduces consecutive spaces to single space

### File Type Support
- **Plain Text** (`.txt`): Direct formatting
- **Markdown** (`.md`): Preserves code blocks (fenced, indented, inline)
- **HTML** (`.html`, `.htm`): Formats text content while preserving tags and `<code>`/`<pre>` elements

## Installation

### Requirements

- Python 3.8 or higher

### Install from PyPI

```bash
# Basic installation
pip install text-formater

# With HTML support (optional)
pip install text-formater[html]
```

### Install from Source

```bash
git clone https://github.com/xiaolai/text-formater.git
cd text-formater
pip install -e .

# Or with HTML support
pip install -e ".[html]"
```

### Verify Installation

```bash
# Check version
textformat --version

# Show help
textformat --help

# Quick test
textformat "文本English混合"
# Expected output: 文本 English 混合
```

## Usage

### Command Line

```bash
# Format text directly
textformat "文本English混合"
# Output: 文本 English 混合

# Format with em-dash
textformat "《书名》--作者"
# Output: 《书名》—— 作者

# Read from stdin
echo "文本English混合" | textformat

# Format a single file
textformat input.txt
textformat input.md --output formatted.md

# Format in-place
textformat document.txt --inplace

# Preview changes without writing (dry-run)
textformat document.txt --dry-run

# Format all files in a directory
textformat ./docs/ --inplace
textformat ./docs/ --recursive --inplace

# Format specific file types only
textformat ./docs/ --inplace -e .md -e .txt
```

### Python API

```python
from textformater.polish import polish_text

# Format text
text = "文本English混合,数字123也包含。"
result = polish_text(text)
print(result)
# Output: 文本 English 混合,数字 123 也包含。

# Format with em-dash
text = "《Python编程》--一本好书"
result = polish_text(text)
print(result)
# Output: 《Python 编程》—— 一本好书
```

```python
from textformater.processors import process_file, find_files

# Process a single file
result = process_file(Path("document.md"))

# Find and process multiple files
files = find_files(Path("./docs"), recursive=True, extensions=['.md', '.txt'])
for file in files:
    result = process_file(file)
    # Do something with result
```

## Configuration

**Requires Python 3.11+** (uses built-in `tomllib`). On Python <3.11, all rules are enabled by default.

### Config File Locations

Configuration is loaded with the following priority (highest to lowest):

1. **Custom path**: `textformat --config /path/to/config.toml`
2. **Project root**: `./textformat.toml`
3. **User config**: `~/.config/textformat.toml`
4. **Defaults**: All rules enabled

### Quick Start

```bash
# Copy example config to your project
cp textformat.toml.example textformat.toml

# Or to user config
cp textformat.toml.example ~/.config/textformat.toml

# Edit and customize rules
```

### Configuration Format

```toml
# textformat.toml

[rules]
# Toggle built-in rules on/off
ellipsis_normalization = true
dash_conversion = true
emdash_spacing = true
quote_spacing = true
cjk_english_spacing = true
space_collapsing = true

# Define custom regex rules
[[custom_rules]]
name = "arrow_unicode"
pattern = '->'
replacement = '→'
description = "Use Unicode arrows"

[[custom_rules]]
name = "multiply_sign"
pattern = '(\d+)\s*x\s*(\d+)'
replacement = '\1×\2'
description = "Use proper multiplication sign"
```

### Built-in Rules

| Rule | Default | Description |
|------|---------|-------------|
| `ellipsis_normalization` | ✅ | Convert `. . .` to `...` |
| `dash_conversion` | ✅ | Convert `--` to `——` |
| `emdash_spacing` | ✅ | Fix spacing around `——` |
| `quote_spacing` | ✅ | Add spaces around `""` |
| `cjk_english_spacing` | ✅ | Space between Chinese & English |
| `space_collapsing` | ✅ | Collapse multiple spaces |

### Custom Rules

Add your own regex-based transformations:

```toml
[[custom_rules]]
name = "rule_name"              # Identifier (required)
pattern = 'regex pattern'       # Regex to match (required)
replacement = 'replacement'     # Replacement text (required)
description = "What it does"    # Optional description
```

**Examples:**

```toml
# Unicode fractions
[[custom_rules]]
name = "fraction_half"
pattern = '\b1/2\b'
replacement = '½'

# Temperature symbols
[[custom_rules]]
name = "celsius"
pattern = '(\d+)\s*C\b'
replacement = '\1°C'

# Smart quotes
[[custom_rules]]
name = "double_quotes"
pattern = '"([^"]+)"'
replacement = '"\1"'
```

### Usage with Config

```bash
# Use project config (auto-detected)
textformat input.txt

# Use specific config file
textformat input.txt --config my-rules.toml

# Show what changed (verbose mode)
textformat input.txt --verbose

# Disable a rule temporarily (edit config file)
# Set: dash_conversion = false
```

### Validating Config Files

```bash
# Validate a config file
textformat --validate-config textformat.toml

# Example output for valid config:
# Validating: textformat.toml
# ✓ Configuration is valid

# Example output for invalid config:
# Validating: textformat.toml
# Errors:
#   ✗ Unknown rule name: 'unknown_rule'. Valid rules: ...
#   ✗ custom_rules[0] (bad_regex): Invalid regex pattern: ...
```

**What gets validated:**
- ✅ File exists and is readable
- ✅ Valid TOML syntax
- ✅ Rule names match known built-in rules
- ✅ Custom rules have required fields (`name`, `pattern`, `replacement`)
- ✅ Regex patterns compile successfully

### Showing Effective Config

```bash
# Show which config is active and what rules are enabled
textformat --show-config

# With custom config
textformat --show-config --config my-rules.toml

# Example output:
# Effective Configuration:
#
# Config Source:
#   Project: ./textformat.toml
#
# Built-in Rules:
#   ✓ cjk_english_spacing: True
#   ✗ dash_conversion: False
#   ...
#
# Custom Rules:
#   [1] unicode_arrows
#       pattern: ->
#       replacement: →
#       description: Use Unicode right arrow
```

## Typography Rules

### Em-Dash Spacing

| Before | After | Rule |
|--------|-------|------|
| `text--more` | `text —— more` | Regular text: spaces on both sides |
| `《书名》--作者` | `《书名》—— 作者` | After `》`: no space before `——`, space after |
| `作者--《书名》` | `作者 ——《书名》` | Before `《`: space before `——`, no space after |
| `(注释)--内容` | `(注释)—— 内容` | After `)`: no space before `——`, space after |
| `内容--(注释)` | `内容 ——(注释)` | Before `(`: space before `——`, no space after |

### CJK-English Spacing

| Before | After |
|--------|-------|
| `中文English` | `中文 English` |
| `数字123` | `数字 123` |
| `100个item` | `100 个 item` |

### Ellipsis Normalization

| Before | After |
|--------|-------|
| `. . .` | `...` |
| `wait . . . more` | `wait... more` |
| `end . . . .` | `end...` |

## Development

### Running Tests

```bash
# Run all tests
pytest

# Run with coverage
pytest --cov=textformater

# Run specific test file
pytest tests/test_polish.py -v
```

### Project Structure

```
text-formater/
├── src/
│   └── textformater/
│       ├── __init__.py
│       ├── polish.py        # Core polishing logic
│       ├── processors.py    # File type processors
│       └── cli.py           # Command-line interface
├── tests/
│   ├── test_polish.py       # Polish function tests
│   └── test_processors.py  # File processor tests
├── pyproject.toml           # Package configuration
└── README.md
```

### Adding New Rules

To add a new typography rule:

1. **Add tests** in `tests/test_polish.py`:
   ```python
   def test_new_rule(self):
       assert polish_text("input") == "expected_output"
   ```

2. **Implement the rule** in `src/textformater/polish.py`:
   ```python
   def _new_rule(text: str) -> str:
       # Implementation
       return text
   ```

3. **Add to pipeline** in `polish_text()`:
   ```python
   def polish_text(text: str) -> str:
       text = _normalize_ellipsis(text)
       text = _new_rule(text)  # Add your rule
       # ... rest of pipeline
       return text.strip()
   ```

## Options

| Option | Short | Description |
|--------|-------|-------------|
| `--output PATH` | `-o` | Output file path |
| `--inplace` | `-i` | Modify files in place |
| `--recursive` | `-r` | Process directories recursively |
| `--dry-run` | `-n` | Preview changes without writing |
| `--extensions EXT` | `-e` | File extensions to process (e.g., `-e .txt -e .md`) |
| `--verbose` | `-v` | Show summary of changes made |
| `--config PATH` | `-c` | Path to custom config file |
| `--validate-config PATH` | | Validate config file and exit |
| `--show-config` | | Show effective configuration and exit |
| `--version` | | Show version and exit |

## Examples

### Format Chinese-English Mixed Content

```bash
$ textformat "Python是一门编程语言,有3.11版本。"
Python 是一门编程语言,有 3.11 版本。
```

### Format Book Titles with Em-Dash

```bash
$ textformat "《人生》--路遥著"
《人生》—— 路遥著
```

### Batch Process Markdown Files

```bash
# Format all markdown files in docs/ and subdirectories
textformat ./docs/ --recursive --inplace -e .md

# Preview changes first
textformat ./docs/ --recursive --dry-run -e .md
```

### Process with Preserved Code Blocks

Markdown code blocks are automatically preserved:

```bash
$ cat document.md
# 标题Title

文本English混合

\`\`\`python
# This code won't be formatted
text--more
\`\`\`

$ textformat document.md --inplace
$ cat document.md
# 标题 Title

文本 English 混合

\`\`\`python
# This code won't be formatted
text--more
\`\`\`
```

## License

MIT License

## Contributing

Contributions are welcome! Please:

1. Fork the repository
2. Create a feature branch
3. Add tests for new functionality
4. Ensure all tests pass: `pytest`
5. Submit a pull request

## Author

Created by Xiaolai for the TEPUB project.

Originally developed as part of [TEPUB](https://github.com/xiaolai/tepub), a tool for EPUB translation and audiobook generation.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "text-formater",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "text, formatter, chinese, typography, cjk, cli",
    "author": null,
    "author_email": "lixiaolai <xiaolaidev@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/81/a5/89a5a5b4ed6d9e8b95e4c0f5c0c5a2c7dd24d59847b3f5121d7aac505ab7/text_formater-0.1.1.tar.gz",
    "platform": null,
    "description": "# Text Formater\n\nA Python CLI tool for polishing text with Chinese typography rules. Automatically formats mixed Chinese-English text, fixes em-dash spacing, normalizes ellipsis, and more.\n\n## Features\n\n### Universal Rules (All Languages)\n- **Ellipsis normalization**: Converts `. . .` or `. . . .` to `...` with proper spacing\n\n### Chinese-Specific Rules\n- **Em-dash spacing**: Converts `--` to `\u2014\u2014` with smart spacing around Chinese quotes `\u300a\u300b` and parentheses `\uff08\uff09`\n- **Quote spacing**: Adds spaces around Chinese quotation marks `\"\"`\n- **CJK-English spacing**: Automatically adds spaces between Chinese characters and English letters/numbers\n- **Multiple space collapsing**: Reduces consecutive spaces to single space\n\n### File Type Support\n- **Plain Text** (`.txt`): Direct formatting\n- **Markdown** (`.md`): Preserves code blocks (fenced, indented, inline)\n- **HTML** (`.html`, `.htm`): Formats text content while preserving tags and `<code>`/`<pre>` elements\n\n## Installation\n\n### Requirements\n\n- Python 3.8 or higher\n\n### Install from PyPI\n\n```bash\n# Basic installation\npip install text-formater\n\n# With HTML support (optional)\npip install text-formater[html]\n```\n\n### Install from Source\n\n```bash\ngit clone https://github.com/xiaolai/text-formater.git\ncd text-formater\npip install -e .\n\n# Or with HTML support\npip install -e \".[html]\"\n```\n\n### Verify Installation\n\n```bash\n# Check version\ntextformat --version\n\n# Show help\ntextformat --help\n\n# Quick test\ntextformat \"\u6587\u672cEnglish\u6df7\u5408\"\n# Expected output: \u6587\u672c English \u6df7\u5408\n```\n\n## Usage\n\n### Command Line\n\n```bash\n# Format text directly\ntextformat \"\u6587\u672cEnglish\u6df7\u5408\"\n# Output: \u6587\u672c English \u6df7\u5408\n\n# Format with em-dash\ntextformat \"\u300a\u4e66\u540d\u300b--\u4f5c\u8005\"\n# Output: \u300a\u4e66\u540d\u300b\u2014\u2014 \u4f5c\u8005\n\n# Read from stdin\necho \"\u6587\u672cEnglish\u6df7\u5408\" | textformat\n\n# Format a single file\ntextformat input.txt\ntextformat input.md --output formatted.md\n\n# Format in-place\ntextformat document.txt --inplace\n\n# Preview changes without writing (dry-run)\ntextformat document.txt --dry-run\n\n# Format all files in a directory\ntextformat ./docs/ --inplace\ntextformat ./docs/ --recursive --inplace\n\n# Format specific file types only\ntextformat ./docs/ --inplace -e .md -e .txt\n```\n\n### Python API\n\n```python\nfrom textformater.polish import polish_text\n\n# Format text\ntext = \"\u6587\u672cEnglish\u6df7\u5408\uff0c\u6570\u5b57123\u4e5f\u5305\u542b\u3002\"\nresult = polish_text(text)\nprint(result)\n# Output: \u6587\u672c English \u6df7\u5408\uff0c\u6570\u5b57 123 \u4e5f\u5305\u542b\u3002\n\n# Format with em-dash\ntext = \"\u300aPython\u7f16\u7a0b\u300b--\u4e00\u672c\u597d\u4e66\"\nresult = polish_text(text)\nprint(result)\n# Output: \u300aPython \u7f16\u7a0b\u300b\u2014\u2014 \u4e00\u672c\u597d\u4e66\n```\n\n```python\nfrom textformater.processors import process_file, find_files\n\n# Process a single file\nresult = process_file(Path(\"document.md\"))\n\n# Find and process multiple files\nfiles = find_files(Path(\"./docs\"), recursive=True, extensions=['.md', '.txt'])\nfor file in files:\n    result = process_file(file)\n    # Do something with result\n```\n\n## Configuration\n\n**Requires Python 3.11+** (uses built-in `tomllib`). On Python <3.11, all rules are enabled by default.\n\n### Config File Locations\n\nConfiguration is loaded with the following priority (highest to lowest):\n\n1. **Custom path**: `textformat --config /path/to/config.toml`\n2. **Project root**: `./textformat.toml`\n3. **User config**: `~/.config/textformat.toml`\n4. **Defaults**: All rules enabled\n\n### Quick Start\n\n```bash\n# Copy example config to your project\ncp textformat.toml.example textformat.toml\n\n# Or to user config\ncp textformat.toml.example ~/.config/textformat.toml\n\n# Edit and customize rules\n```\n\n### Configuration Format\n\n```toml\n# textformat.toml\n\n[rules]\n# Toggle built-in rules on/off\nellipsis_normalization = true\ndash_conversion = true\nemdash_spacing = true\nquote_spacing = true\ncjk_english_spacing = true\nspace_collapsing = true\n\n# Define custom regex rules\n[[custom_rules]]\nname = \"arrow_unicode\"\npattern = '->'\nreplacement = '\u2192'\ndescription = \"Use Unicode arrows\"\n\n[[custom_rules]]\nname = \"multiply_sign\"\npattern = '(\\d+)\\s*x\\s*(\\d+)'\nreplacement = '\\1\u00d7\\2'\ndescription = \"Use proper multiplication sign\"\n```\n\n### Built-in Rules\n\n| Rule | Default | Description |\n|------|---------|-------------|\n| `ellipsis_normalization` | \u2705 | Convert `. . .` to `...` |\n| `dash_conversion` | \u2705 | Convert `--` to `\u2014\u2014` |\n| `emdash_spacing` | \u2705 | Fix spacing around `\u2014\u2014` |\n| `quote_spacing` | \u2705 | Add spaces around `\"\"` |\n| `cjk_english_spacing` | \u2705 | Space between Chinese & English |\n| `space_collapsing` | \u2705 | Collapse multiple spaces |\n\n### Custom Rules\n\nAdd your own regex-based transformations:\n\n```toml\n[[custom_rules]]\nname = \"rule_name\"              # Identifier (required)\npattern = 'regex pattern'       # Regex to match (required)\nreplacement = 'replacement'     # Replacement text (required)\ndescription = \"What it does\"    # Optional description\n```\n\n**Examples:**\n\n```toml\n# Unicode fractions\n[[custom_rules]]\nname = \"fraction_half\"\npattern = '\\b1/2\\b'\nreplacement = '\u00bd'\n\n# Temperature symbols\n[[custom_rules]]\nname = \"celsius\"\npattern = '(\\d+)\\s*C\\b'\nreplacement = '\\1\u00b0C'\n\n# Smart quotes\n[[custom_rules]]\nname = \"double_quotes\"\npattern = '\"([^\"]+)\"'\nreplacement = '\"\\1\"'\n```\n\n### Usage with Config\n\n```bash\n# Use project config (auto-detected)\ntextformat input.txt\n\n# Use specific config file\ntextformat input.txt --config my-rules.toml\n\n# Show what changed (verbose mode)\ntextformat input.txt --verbose\n\n# Disable a rule temporarily (edit config file)\n# Set: dash_conversion = false\n```\n\n### Validating Config Files\n\n```bash\n# Validate a config file\ntextformat --validate-config textformat.toml\n\n# Example output for valid config:\n# Validating: textformat.toml\n# \u2713 Configuration is valid\n\n# Example output for invalid config:\n# Validating: textformat.toml\n# Errors:\n#   \u2717 Unknown rule name: 'unknown_rule'. Valid rules: ...\n#   \u2717 custom_rules[0] (bad_regex): Invalid regex pattern: ...\n```\n\n**What gets validated:**\n- \u2705 File exists and is readable\n- \u2705 Valid TOML syntax\n- \u2705 Rule names match known built-in rules\n- \u2705 Custom rules have required fields (`name`, `pattern`, `replacement`)\n- \u2705 Regex patterns compile successfully\n\n### Showing Effective Config\n\n```bash\n# Show which config is active and what rules are enabled\ntextformat --show-config\n\n# With custom config\ntextformat --show-config --config my-rules.toml\n\n# Example output:\n# Effective Configuration:\n#\n# Config Source:\n#   Project: ./textformat.toml\n#\n# Built-in Rules:\n#   \u2713 cjk_english_spacing: True\n#   \u2717 dash_conversion: False\n#   ...\n#\n# Custom Rules:\n#   [1] unicode_arrows\n#       pattern: ->\n#       replacement: \u2192\n#       description: Use Unicode right arrow\n```\n\n## Typography Rules\n\n### Em-Dash Spacing\n\n| Before | After | Rule |\n|--------|-------|------|\n| `text--more` | `text \u2014\u2014 more` | Regular text: spaces on both sides |\n| `\u300a\u4e66\u540d\u300b--\u4f5c\u8005` | `\u300a\u4e66\u540d\u300b\u2014\u2014 \u4f5c\u8005` | After `\u300b`: no space before `\u2014\u2014`, space after |\n| `\u4f5c\u8005--\u300a\u4e66\u540d\u300b` | `\u4f5c\u8005 \u2014\u2014\u300a\u4e66\u540d\u300b` | Before `\u300a`: space before `\u2014\u2014`, no space after |\n| `\uff08\u6ce8\u91ca\uff09--\u5185\u5bb9` | `\uff08\u6ce8\u91ca\uff09\u2014\u2014 \u5185\u5bb9` | After `\uff09`: no space before `\u2014\u2014`, space after |\n| `\u5185\u5bb9--\uff08\u6ce8\u91ca\uff09` | `\u5185\u5bb9 \u2014\u2014\uff08\u6ce8\u91ca\uff09` | Before `\uff08`: space before `\u2014\u2014`, no space after |\n\n### CJK-English Spacing\n\n| Before | After |\n|--------|-------|\n| `\u4e2d\u6587English` | `\u4e2d\u6587 English` |\n| `\u6570\u5b57123` | `\u6570\u5b57 123` |\n| `100\u4e2aitem` | `100 \u4e2a item` |\n\n### Ellipsis Normalization\n\n| Before | After |\n|--------|-------|\n| `. . .` | `...` |\n| `wait . . . more` | `wait... more` |\n| `end . . . .` | `end...` |\n\n## Development\n\n### Running Tests\n\n```bash\n# Run all tests\npytest\n\n# Run with coverage\npytest --cov=textformater\n\n# Run specific test file\npytest tests/test_polish.py -v\n```\n\n### Project Structure\n\n```\ntext-formater/\n\u251c\u2500\u2500 src/\n\u2502   \u2514\u2500\u2500 textformater/\n\u2502       \u251c\u2500\u2500 __init__.py\n\u2502       \u251c\u2500\u2500 polish.py        # Core polishing logic\n\u2502       \u251c\u2500\u2500 processors.py    # File type processors\n\u2502       \u2514\u2500\u2500 cli.py           # Command-line interface\n\u251c\u2500\u2500 tests/\n\u2502   \u251c\u2500\u2500 test_polish.py       # Polish function tests\n\u2502   \u2514\u2500\u2500 test_processors.py  # File processor tests\n\u251c\u2500\u2500 pyproject.toml           # Package configuration\n\u2514\u2500\u2500 README.md\n```\n\n### Adding New Rules\n\nTo add a new typography rule:\n\n1. **Add tests** in `tests/test_polish.py`:\n   ```python\n   def test_new_rule(self):\n       assert polish_text(\"input\") == \"expected_output\"\n   ```\n\n2. **Implement the rule** in `src/textformater/polish.py`:\n   ```python\n   def _new_rule(text: str) -> str:\n       # Implementation\n       return text\n   ```\n\n3. **Add to pipeline** in `polish_text()`:\n   ```python\n   def polish_text(text: str) -> str:\n       text = _normalize_ellipsis(text)\n       text = _new_rule(text)  # Add your rule\n       # ... rest of pipeline\n       return text.strip()\n   ```\n\n## Options\n\n| Option | Short | Description |\n|--------|-------|-------------|\n| `--output PATH` | `-o` | Output file path |\n| `--inplace` | `-i` | Modify files in place |\n| `--recursive` | `-r` | Process directories recursively |\n| `--dry-run` | `-n` | Preview changes without writing |\n| `--extensions EXT` | `-e` | File extensions to process (e.g., `-e .txt -e .md`) |\n| `--verbose` | `-v` | Show summary of changes made |\n| `--config PATH` | `-c` | Path to custom config file |\n| `--validate-config PATH` | | Validate config file and exit |\n| `--show-config` | | Show effective configuration and exit |\n| `--version` | | Show version and exit |\n\n## Examples\n\n### Format Chinese-English Mixed Content\n\n```bash\n$ textformat \"Python\u662f\u4e00\u95e8\u7f16\u7a0b\u8bed\u8a00\uff0c\u67093.11\u7248\u672c\u3002\"\nPython \u662f\u4e00\u95e8\u7f16\u7a0b\u8bed\u8a00\uff0c\u6709 3.11 \u7248\u672c\u3002\n```\n\n### Format Book Titles with Em-Dash\n\n```bash\n$ textformat \"\u300a\u4eba\u751f\u300b--\u8def\u9065\u8457\"\n\u300a\u4eba\u751f\u300b\u2014\u2014 \u8def\u9065\u8457\n```\n\n### Batch Process Markdown Files\n\n```bash\n# Format all markdown files in docs/ and subdirectories\ntextformat ./docs/ --recursive --inplace -e .md\n\n# Preview changes first\ntextformat ./docs/ --recursive --dry-run -e .md\n```\n\n### Process with Preserved Code Blocks\n\nMarkdown code blocks are automatically preserved:\n\n```bash\n$ cat document.md\n# \u6807\u9898Title\n\n\u6587\u672cEnglish\u6df7\u5408\n\n\\`\\`\\`python\n# This code won't be formatted\ntext--more\n\\`\\`\\`\n\n$ textformat document.md --inplace\n$ cat document.md\n# \u6807\u9898 Title\n\n\u6587\u672c English \u6df7\u5408\n\n\\`\\`\\`python\n# This code won't be formatted\ntext--more\n\\`\\`\\`\n```\n\n## License\n\nMIT License\n\n## Contributing\n\nContributions are welcome! Please:\n\n1. Fork the repository\n2. Create a feature branch\n3. Add tests for new functionality\n4. Ensure all tests pass: `pytest`\n5. Submit a pull request\n\n## Author\n\nCreated by Xiaolai for the TEPUB project.\n\nOriginally developed as part of [TEPUB](https://github.com/xiaolai/tepub), a tool for EPUB translation and audiobook generation.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A CLI tool for polishing text with Chinese typography rules",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/xiaolai/text-formater",
        "Issues": "https://github.com/xiaolai/text-formater/issues",
        "Repository": "https://github.com/xiaolai/text-formater"
    },
    "split_keywords": [
        "text",
        " formatter",
        " chinese",
        " typography",
        " cjk",
        " cli"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a4ac8f6de90281aa0dc4d6e07317693a06f7e2264eae85edb9f014352929c20a",
                "md5": "3bdd8cab7013f4ed1eddcb6ed3a19112",
                "sha256": "f9032aaf5a1eaadb2fcaa880669a13a629667fc0aea3adc71b70bbfd98aca863"
            },
            "downloads": -1,
            "filename": "text_formater-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3bdd8cab7013f4ed1eddcb6ed3a19112",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 18443,
            "upload_time": "2025-10-09T04:02:03",
            "upload_time_iso_8601": "2025-10-09T04:02:03.789745Z",
            "url": "https://files.pythonhosted.org/packages/a4/ac/8f6de90281aa0dc4d6e07317693a06f7e2264eae85edb9f014352929c20a/text_formater-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "81a589a5a5b4ed6d9e8b95e4c0f5c0c5a2c7dd24d59847b3f5121d7aac505ab7",
                "md5": "90915ec36367b978d7ba295c9e802221",
                "sha256": "1a3f1fdd47093c93c73ffbc95fd875d5d9e8a1d656c416e5b5cd4e37ae58b3af"
            },
            "downloads": -1,
            "filename": "text_formater-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "90915ec36367b978d7ba295c9e802221",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 24886,
            "upload_time": "2025-10-09T04:02:05",
            "upload_time_iso_8601": "2025-10-09T04:02:05.331136Z",
            "url": "https://files.pythonhosted.org/packages/81/a5/89a5a5b4ed6d9e8b95e4c0f5c0c5a2c7dd24d59847b3f5121d7aac505ab7/text_formater-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-09 04:02:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "xiaolai",
    "github_project": "text-formater",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "text-formater"
}
        
Elapsed time: 2.03957s