Count Block

approved

by Jongwoo Lee

Add editable text blocks with a live count beneath them. Supports customizable metrics, including NEIS bytes! - This plugin has not been manually reviewed by Obsidian staff.

76 downloadsUpdated 1mo agoMIT

Count Block

GitHub last commit GitHub Release GitHub Actions Workflow Status

An Obsidian plugin for text-counting blocks. Add editable text blocks with a live counter beneath them.

The block lives with the rest of your Markdown content: it's really just a code block with its language set as count. This plugin displays a footer with its count (of whatever metric you get to choose) right below each block. No content is stored outside your vault.

count-block-screenshot

Metrics

Word count is the default metric, while more options are available. It can be changed globally in the plugin settings or per block with inline options.

  • words: whitespace-separated words
  • characters: Unicode code points, including whitespace
  • characters-no-spaces: Unicode code points, excluding Unicode whitespace
  • utf8-bytes: standard UTF-8 byte length
  • neis-bytes: NEIS-style byte counting (a custom standard followed by Korean schools)

Block options belong on the opening fence and are not included in the count:

  • metric=<metric-id>
  • limit=<positive-integer>

Example:

```count metric=words limit=500
Write plain text here.


Use the Count Block: Insert command to create a block or wrap selected text.

Invalid metrics, limits, or option names are shown in the footer. Top-level fenced blocks are supported in the initial release; nesting a count block inside a list or blockquote is not yet supported by the live editor footer.

NEIS bytes

Yes this is a niche option, but is really the reason I built this thing. Korean schools happen to follow a weird counting method that counts Korean letters as three bytes, English as one and such. This differs significantly from standard byte counting, so a separate metric is needed.

Behavior follows the NEIS counter: logical line breaks count as two bytes; its listed math, Greek, middle-dot, and curly-quote exceptions count as one byte; other characters use their UTF-8 byte length. CRLF and CR line endings are normalized to logical line breaks before counting.

Roadmap

  • User-friendly dropdown controls & more
  • i18n
  • Custom metrics support (w. regex?)

I'd love to add support for custom metrics and more, but being quite occupied at the moment I'm not able to work on it right now. Will have my hands on it once I'm free.

Feedback

If you happen to encounter any bugs or have feature requests, please file an issue on GitHub. Contributions are welcome as well.

Development

npm install
npm test
npm run build

And then copy main.js, manifest.json, and styles.css to a test vault's .obsidian/plugins/count-block/ directory. Reminder: never develop against your primary vault!

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.