|
| 1 | +# format |
| 2 | + |
| 3 | +Format documentation files by fixing common issues like irregular whitespace |
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +``` |
| 8 | +docs-builder format [options...] [-h|--help] [--version] |
| 9 | +``` |
| 10 | + |
| 11 | +## Options |
| 12 | + |
| 13 | +`-p|--path` `<string>` |
| 14 | +: Path to the documentation folder, defaults to pwd. (optional) |
| 15 | + |
| 16 | +`--dry-run` `<bool?>` |
| 17 | +: Preview changes without modifying files (optional) |
| 18 | + |
| 19 | +## Description |
| 20 | + |
| 21 | +The `format` command automatically detects and fixes formatting issues in your documentation files. Currently, it handles irregular whitespace characters that may impair Markdown rendering. |
| 22 | + |
| 23 | +### Irregular Whitespace Detection |
| 24 | + |
| 25 | +The format command detects and replaces 24 types of irregular whitespace characters with regular spaces, including: |
| 26 | + |
| 27 | +- No-Break Space (U+00A0) |
| 28 | +- En Space (U+2002) |
| 29 | +- Em Space (U+2003) |
| 30 | +- Zero Width Space (U+200B) |
| 31 | +- Line Separator (U+2028) |
| 32 | +- Paragraph Separator (U+2029) |
| 33 | +- And 18 other irregular whitespace variants |
| 34 | + |
| 35 | +These characters can cause unexpected rendering issues in Markdown and are often introduced accidentally through copy-paste operations from other applications. |
| 36 | + |
| 37 | +## Examples |
| 38 | + |
| 39 | +### Format current directory |
| 40 | + |
| 41 | +```bash |
| 42 | +docs-builder format |
| 43 | +``` |
| 44 | + |
| 45 | +### Preview changes without modifying files |
| 46 | + |
| 47 | +```bash |
| 48 | +docs-builder format --dry-run |
| 49 | +``` |
| 50 | + |
| 51 | +### Format specific documentation folder |
| 52 | + |
| 53 | +```bash |
| 54 | +docs-builder format --path /path/to/docs |
| 55 | +``` |
| 56 | + |
| 57 | +## Output |
| 58 | + |
| 59 | +The command provides detailed feedback about the formatting process: |
| 60 | + |
| 61 | +``` |
| 62 | +Formatting documentation in: /path/to/docs |
| 63 | +Fixed 2 irregular whitespace(s) in: guide/setup.md |
| 64 | +Fixed 1 irregular whitespace(s) in: api/endpoints.md |
| 65 | +
|
| 66 | +Formatting complete: |
| 67 | + Files processed: 155 |
| 68 | + Files modified: 2 |
| 69 | + Total replacements: 3 |
| 70 | +``` |
| 71 | + |
| 72 | +When using `--dry-run`, files are not modified and the command reminds you to run without the flag to apply changes. |
| 73 | + |
| 74 | +## Future Enhancements |
| 75 | + |
| 76 | +The format command is designed to be extended with additional formatting capabilities in the future, such as: |
| 77 | + |
| 78 | +- Line ending normalization |
| 79 | +- Trailing whitespace removal |
| 80 | +- Consistent heading spacing |
| 81 | +- And other formatting fixes |
0 commit comments