Thai Word Count
pendingby Jiraphat Jackmetha
Counts words in Thai text.
Thai Word Count
This is an Obsidian plugin that counts words in Thai text.
This project uses TypeScript to provide type checking and documentation. The repo depends on the latest plugin API (obsidian.d.ts) in TypeScript Definition format, which contains TSDoc comments describing what it does.
Features
- Thai Word Segmentation: Uses the native
Intl.SegmenterAPI with Thai language support to accurately count words in Thai text. - Status Bar Display: Shows real-time word count in the status bar as you type.
- Selection Awareness: Displays both selected word count and total word count when text is selected.
- Live Updates: Updates automatically as you edit, with a 300ms debounce to prevent excessive recalculations.
Getting Started
Prerequisites
- Node.js v18 or higher
- npm (comes with Node.js)
Development Setup
- Clone this repo.
- Run
npm installto install dependencies. - Run
npm run devto start compilation in watch mode. - In Obsidian, reload the plugin to see your changes.
Building for Release
- Run
npm run buildto create an optimized production build. - Copy
main.js,manifest.json, andstyles.css(if any) to<VaultFolder>/.obsidian/plugins/Thai-Word-Count/. - Reload Obsidian and enable the plugin in Settings → Community plugins.
Releasing a New Version
- Update
manifest.jsonwith the new version number (e.g.,1.1.0) and minimum Obsidian version if needed. - Update
versions.jsonto map the new version to the minimum Obsidian version. - Run
npm run buildto create the production build. - Commit and push changes.
- Create a GitHub release with a tag matching the version number (e.g.,
1.1.0, notv1.1.0). - Attach
manifest.jsonandmain.jsto the release.
Using npm Version Helper
You can simplify the version bump process:
npm version patch
npm version minor
npm version major
Update
minAppVersioninmanifest.jsonmanually before runningnpm versionif needed.
How to Use
- Install the Thai Word Count plugin from Obsidian's community plugins.
- Open any note with Thai text.
- The word count will appear in the status bar at the bottom of the window.
- Select any portion of Thai text to see the selected word count and total count.
Example Status Bar Output
- Without selection:
Thai Words: 150 - With selection:
Thai Words: 25 / 150(25 words selected out of 150 total)
Code Quality
ESLint
- ESLint analyzes your code to find common bugs and improvements.
- Run
npm run lintto check the code. - This project includes ESLint preconfigured with Obsidian-specific rules.
- GitHub Actions automatically lints every commit.
Funding URL
{
"fundingUrl": {
"ko-fi": "https://ko-fi.com/jjpull1708"
}
}
API Documentation
For plugin developers
Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.