Ledger Viewer

approvedunreviewed

by qnosuke

Open and edit Ledger CLI files (.ledger) with VSCode-style syntax highlighting.

★ 1 stars↓ 28 downloadsUpdated 23d agoMIT

Ledger Viewer for Obsidian

Open and edit Ledger CLI plain-text accounting files (.ledger) directly inside Obsidian, with VSCode-style syntax highlighting.

Syntax rules are ported from the VSCode extension vscode-ledger (MIT License), and the color palette follows VSCode's default Dark+ / Light+ themes. Highlighting automatically follows Obsidian's dark/light theme.

Features

  • Open .ledger / .ldg / .ldgr / .journal / .hledger files with a click
  • CodeMirror 6 based editing (undo/redo, line numbers, multiple cursors, line wrapping)
  • Same color rules as the VSCode ledger extension (see the table below)
  • Auto save (0.8s after typing stops / on focus loss / Cmd/Ctrl+S)
  • Read-only toggle (button in the header)
  • Automatic reload on external changes (e.g. sync tools) when there are no unsaved edits
  • Works on desktop and mobile

Install

Once approved, install from Obsidian's Community Plugins browser ("Ledger Viewer").

Manual install (before approval / from source):

  1. Copy main.js, manifest.json, and styles.css into .obsidian/plugins/ledger-view/ inside your vault
  2. Disable Restricted Mode in Settings → Community Plugins (if you haven't)
  3. Enable "Ledger Viewer"

Highlighting reference

ElementExampleTextMate scopeDark+Light+
Date2024/04/01string.other.date#CE9178#A31515
Effective date=2024/05/02samesamesame
Amount3,480 -100,000constant.numeric.amount#B5CEA8#098658
CurrencyJPY USD ¥constant.other.currencydefaultdefault
Account (posting)Assets:Cashmarkup.bold.accountboldbold
Virtual posting(Assets:Cash)markup.italic.accountitalicitalic
Directiveaccount commodity include Y Pkeyword#569CD6#0000FF
payee directivepayee storekeyword.control#C586C0#AF00DB
Identifier argsvalue of alias, path of includevariable.other#9CDCFE#001080
Expression= Expenses:Food > 10000, assert/check/evalstring.regexp#D16969#811F3F
Cleared description* descriptionmarkup.italic.descitalicitalic
Pending description! descriptionmarkup.underline.descunderlineunderline
Comment; # % | * at line start / comment blockcomment#6A9955#008000

Note: one deliberate improvement over VSCode — for lines like account X ; comment, VSCode drops the whole line's coloring, while this plugin keeps the keyword and account colors and only colors the trailing comment green.

Development

npm install
npm run build   # type-check + build main.js
npm test        # tokenizer tests (sample.ledger)

Credits


Ledger Viewer for Obsidian(日本語)

Ledger CLI のファイル(.ledger など)を Obsidian 内で開けるようにするプラグインです。 シンタックスハイライトは VSCode 拡張 vscode-ledger (MIT) の TextMate 文法を移植し、配色は VSCode 標準テーマ (Dark+ / Light+) に合わせています。Obsidian のテーマ(ダーク/ライト)に応じて自動で切り替わります。

機能

  • .ledger / .ldg / .ldgr / .journal / .hledger ファイルをクリックで開く
  • CodeMirror 6 ベースの編集(元に戻す/やり直し、行番号、複数選択、行折り返し)
  • VSCode ledger 拡張と同じ色分け規則(上記英語セクションの対応表参照)
  • 自動保存(入力停止後 0.8 秒 / フォーカス喪失時 / Cmd/Ctrl+S)
  • 読み取り専用トグル(ヘッダーのボタン)
  • 外部変更(同期ツールなど)を自動で再読み込み(未保存変更がない場合)

開発

npm install
npm run build   # 型チェック + main.js ビルド
npm test        # トークナイザーのテスト(sample.ledger)

クレジット

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.