aiwlgp26 downloadsStructural syntax highlighting for Chinese notes: book titles, quotes, heading levels, meta key-value pairs, ordinals and dates, layered with an innermost-wins palette.
English | 中文
Structured syntax highlighting for Chinese notes in Obsidian: chapter headings, 《book titles》, 「quotes」, meta key–value pairs, ordinals, dates and links each get their own color, layered by a "strict innermost wins" rule that overrides Obsidian's default Markdown coloring.
Built for Chinese-structured writing — novels, reading notes, and other long-form Chinese Markdown where default syntax highlighting is too coarse.
Two kinds of rules, colored by "innermost wins" + "attributes stack":
Line-level (whole line)
第X卷 / 第X回/章/节 lines (volume / chapter headings)1 引言) and fixed headings (简介, 序, 前言, 附录, …)key:value meta pairs (作者:aiwlgp; preview text is taken from the author's novel 《梦境四重奏》)# headings (color progresses by level), blockquotes (>), italic annotation lines (*设计原理:…)一、, (一))Inline (fragments)
《》, quotes 「」 『』 “”[1], circled numbers ①②, numeric parens (1961), Chinese bracket pairs ()1970s, 7.83Hz), Latin identifiers→, em-dashes ——**, strikethrough ~~, inline code ` (markers themselves are not colored)The plugin highlights both in Reading view (Markdown PostProcessor) and Editing / Live Preview (CodeMirror ViewPlugin).
Manual install
.obsidian/plugins/inknote-highlight/ of your vault.main.js, manifest.json and styles.css exist there (main.js is the npm run build artifact).Build from source
npm install
npm run build # bundles src/main.js -> main.js and creates dist/inknote-highlight/
npm test # 21 offline tests (node --test)
npm run build also produces a release folder dist/inknote-highlight/ containing exactly the three files Obsidian needs. Copy that folder into .obsidian/plugins/ to install.
Requires Obsidian 1.5.0+. Desktop only (
isDesktopOnly: true); mobile is not tested.
No configuration — enable the plugin and it works. Colors adapt to light/dark themes, and the editor re-colors immediately when you switch themes.
Colors live in the THEMES object (light / dark) at the top of src/main.js; the rule table is buildRules():
{
name: "book",
re: /《[^《》\n]{1,60}》/g, // regex
style: { color: t.book }, // style object, or (match, theme) => style
group: 0, // optional: capture group to color (default 0 = whole match)
atomic: true, // optional: atomic span, blocks nested coloring
priority: 0, // optional: tie-breaker for identical ranges (content > wrapper)
}
Rebuild with npm run build after changes.
!important inline stylesObsidian's default Markdown coloring wins over ordinary inline styles, so the plugin sets colors with !important (both in Reading view spans and in CodeMirror mark decorations). This is intentional — without it the custom palette would be invisible.
Settings → InkNote Highlight opens a panel with a live preview of both light and dark themes. Every color token (book titles, quotes, heading levels, meta pairs, numbers, links, list markers, …) can be overridden per theme with a color picker. Click ↺ to restore a single token's default, or use Reset all colors to go back to the built-in palette.
Changes apply immediately to open notes: editor decorations are rebuilt and reading views re-render. Overrides live in the plugin's data.json under colors.light / colors.dark — only the keys you changed are stored, so future updates to the default palette still reach you.
Line-level rules follow the template start char + number + unit char + rest:
第1卷, 第1章, 第1回, 第1节1 引言 (number + separator + title)In settings, click the ▸ arrow at the far left of each row to edit its rules in place:
| Row | Fields |
|---|---|
| 卷标题 (volume) | Start chars — default 第; e.g. 第序 so 序1卷 matches. Volume units — default 卷; add 幕集篇 so 第1幕 uses the volume style. |
| 章节标题 (chapter) | Start chars (shared); Chapter units — default 回章节. |
| 小节 (section) | Start char (optional, e.g. 第); Separators — default 空格, add 、 . :; Title words — optional, e.g. 引言/引子 restricts what counts as a section title. |
Multiple values are written with / (e.g. 我/章节/章/节; phrases are supported and longer ones match first). Empty values fall back to the defaults, and special characters are escaped before being used in the pattern. Section numbers may be Chinese numerals (一, 十二, …) as well as Arabic digits.
键:值 pairs are highlighted as meta. The value accepts Chinese, Latin and digits up to the next space (作者:aiwlgp 鲁迅 → only aiwlgp is tinted), and up to two spaces are allowed around the colon (作者 : aiwlgp). Inside a meta value, Latin/digit rules step aside so the value stays one color.
| Path | Purpose |
|---|---|
src/main.js |
Plugin source (rule table, container detection, token synthesizer, reading/editor entry points) |
main.js |
Build artifact (esbuild bundle of src/main.js) |
manifest.json |
Obsidian manifest (id / version / minimum app version) |
styles.css |
Fallback styles + reading-view table header colors |
build.mjs |
Build script (npm run build, emits the release folder dist/) |
test/tokens.test.js |
Offline tests (npm test) |
dist/inknote-highlight/ |
Release folder: manifest.json + main.js + styles.css |
README.md), Chinese translation moved to README.zh.md (same functionality as 2.0.6).InkNote Highlight) and an English description ending with a period, as required by the community directory (same functionality as 2.0.5).https://...) was wrongly tinted as a meta value (meta keys are now Chinese-only). Perf: container scanning (code fences / tables) is cached per document text, so scrolling and theme switches no longer rescan the whole note.x tinted as Latin text. Editor mode now processes only the visible viewport (much faster on large notes); light/dark switch re-colors immediately; reading-view styles use !important.ISC — see LICENSE.