Code Block Char Count

by wbl
5
4
3
2
1
Score: 50/100

Description

Obsidian plugin: display a character count badge at the bottom-right of every code block / 在代码块右下角显示字符数量统计

Reviews

No reviews yet.

Stats

0
stars
48
downloads
0
forks
43
days
43
days
43
days
0
total PRs
0
open PRs
0
closed PRs
0
merged PRs
0
total issues
0
open issues
0
closed issues
2
commits

Latest Version

a month ago

Changelog

Code Block Char Count 1.0.0

在代码块右下角显示字符数量统计(不含空格、换行),支持阅读视图与实时预览。

Displays a character count badge (whitespace excluded) at the bottom-right corner of every code block, in both reading view and live preview.

安装 / Install

  • 手动:下载 main.js、manifest.json、styles.css 放到 <vault>/.obsidian/plugins/code-block-char-count/,重启 Obsidian 后在 设置 → 第三方插件 中启用
  • BRAT:添加 power-ioi/code-block-char-count

README file from

Github

Code Block Char Count

Obsidian

Display a character count badge at the bottom-right corner of every code block in Obsidian.

在 Obsidian 中每个代码块的右下角显示字符数量统计。

Features / 功能

  • Live update / 实时更新 — the badge updates as you type / 输入时数字实时刷新
  • Works everywhere / 全场景支持 — reading view, live preview, and embedded renders (embeds, canvas) / 阅读视图、实时预览、嵌入渲染均支持
  • Visible characters only / 只统计可见字符 — spaces, tabs and newlines are excluded / 空格、制表符与换行不计入
  • Zero config / 零配置 — no settings, just enable and go / 无需任何设置,启用即用

Install / 安装

  1. Install and enable BRAT
  2. Run BRAT: Add a beta plugin for testing
  3. Enter power-ioi/code-block-char-count

Manual / 手动安装

  1. Download main.js, manifest.json, styles.css from the latest release
  2. Put them into <vault>/.obsidian/plugins/code-block-char-count/
  3. Restart Obsidian, then enable Code Block Char Count in Settings → Community plugins

Usage / 使用

No configuration needed. Open any note with a code block and you will see a small badge like 32 字符 at its bottom-right corner.

无需配置。打开任意包含代码块的笔记,右下角即可看到如 32 字符 的小角标。

How it works / 实现原理

  • Live preview: a CodeMirror 6 ViewPlugin scans the editor syntax tree (HyperMD-codeblock line groups) and attaches a line decoration to the last line of each code block.
  • Reading view: a registerMarkdownPostProcessor hook appends the badge to each rendered <pre> element.

License / 许可

MIT