English | [中文](README.zh-CN.md) # Auto Spacer Obsidian plugin for mixed CJK–English typography. Inserts spaces at CJK–Latin boundaries and wraps English segments in inline code. ## Features - Detects mixed Chinese (including Japanese kana and kanji) and English text - Inserts spaces between CJK and Latin characters - Wraps English segments in `` `inline code` `` - Skips existing backticks, links, tags, and other Markdown structures - Formats the current selection, or the entire current line when nothing is selected - Optional toolbar button in the editor header ## Usage ### Command Open the command palette and run **「中英混排:反引号包裹并补空格」** (Mixed CJK–English: wrap in backticks and add spaces). Default shortcut: `Cmd + Shift + S` (macOS) / `Ctrl + Shift + S` (Windows / Linux). ### Settings Configure under **Settings → Community plugins → Auto Spacer**: - **显示顶部按钮** (Show header button): show the “中英混排格式化” action in the editor toolbar ## Installation ### Manual install from GitHub Release 1. Download `main.js`, `manifest.json`, and `styles.css` from [Releases](https://github.com/fanthus/obsidian-auto-spacer/releases) 2. Copy them into your vault: ``` YourVault/.obsidian/plugins/auto-spacer/ ``` 3. Enable the plugin in Obsidian: **Settings → Community plugins** > Source files alone are not enough—you must build `main.js` or download the compiled artifacts from a Release. ## Development ### Requirements - [Node.js](https://nodejs.org/) 16 or later (18+ recommended) ### Local development ```bash git clone https://github.com/fanthus/obsidian-auto-spacer.git cd obsidian-auto-spacer npm install npm run dev ``` `npm run dev` watches and compiles `src/main.ts` to `main.js`. Reload Obsidian after code changes to test. Production build: ```bash npm run build ``` ### Linting ESLint is configured. Run: ```bash npm run lint ``` You can also use the Obsidian rules package [eslint-plugin-obsidianmd](https://github.com/obsidianmd/eslint-plugin). A GitHub Action runs lint on pushes to all branches. ## Releasing This project uses `release.mjs` to build and create GitHub Releases. Obsidian downloads `main.js`, `manifest.json`, and `styles.css` from the release. Repository: [https://github.com/fanthus/obsidian-auto-spacer](https://github.com/fanthus/obsidian-auto-spacer) ### Prerequisites 1. Install [Node.js](https://nodejs.org/) (18+ recommended) 2. Install [GitHub CLI](https://cli.github.com/) and sign in: ```bash gh auth login ``` 3. Install dependencies: ```bash npm install ``` ### First release Set the target version in `manifest.json` (e.g. `1.0.0`), then run: ```bash npm run release -- --push ``` The script will: 1. Run `npm run build` to produce `main.js` 2. Create a git tag matching the version (e.g. `1.0.0`—no `v` prefix) 3. Push the branch and tag to GitHub 4. Create a GitHub Release and upload `main.js`, `manifest.json`, and `styles.css` ### Subsequent releases Pick a bump type for your changes: | Command | Version change | When to use | |---------|----------------|-------------| | `npm run release:patch` | `1.0.0` → `1.0.1` | Bug fixes, small changes | | `npm run release:minor` | `1.0.0` → `1.1.0` | New features, backward compatible | | `npm run release:major` | `1.0.0` → `2.0.0` | Breaking changes | These commands bump the version, sync `manifest.json` and `versions.json`, build, publish, and push. Update `minAppVersion` in `manifest.json` before releasing if you require a newer Obsidian version. ### Common options Preview steps without publishing: ```bash npm run release -- --dry-run ``` Custom release notes: ```bash npm run release -- --bump patch --push --notes "Fix spacing around punctuation." ``` Read notes from a file: ```bash npm run release -- --bump patch --push --notes-file CHANGELOG.md ``` Replace an existing release (e.g. after a failed publish): ```bash npm run release -- --push --force ``` Full help: ```bash node release.mjs --help ``` ### Manual release (optional) Without the script: 1. Update `version` in `manifest.json` 2. Add `"newVersion": "minObsidianVersion"` to `versions.json` 3. Run `npm run build` 4. Create a GitHub Release whose tag exactly matches `version` (e.g. `1.0.0`) 5. Attach `main.js`, `manifest.json`, and `styles.css` ### Submit to the Obsidian community catalog After a GitHub Release, submit your plugin on [community.obsidian.md](https://community.obsidian.md) with the repository URL. See [Submit your plugin](https://docs.obsidian.md/Plugins/Releasing/Submit+your+plugin). ## Funding links Set `fundingUrl` in `manifest.json` to show sponsorship options: ```json { "fundingUrl": "https://buymeacoffee.com" } ``` Multiple links as an object: ```json { "fundingUrl": { "Buy Me a Coffee": "https://buymeacoffee.com", "GitHub Sponsor": "https://github.com/sponsors", "Patreon": "https://www.patreon.com/" } } ``` ## API documentation Obsidian plugin development: