Chess PGN Viewer is an Obsidian plugin that renders interactive chess games inside ```chess code blocks. It turns PGN into a clickable board, supports move navigation, and displays comments, variations, board annotations, and move glyphs.
See CHANGELOG.md for release history.


%csl square highlights%cal arrows!, ?, !!, ??, !?, ?!npm install.npm run build.main.js and styles.css into your vault plugin folder at .obsidian/plugins/chess-pgn-viewer/.cp main.js .obsidian/plugins/chess-pgn-viewer/main.js && cp styles.css .obsidian/plugins/chess-pgn-viewer/styles.cssCreate a fenced code block with the chess language:
orientation: white
showMoves: true
showComments: true
showVariations: true
[Event "Training Game"]
[White "Kasparov"]
[Black "Karpov"]
1. e4 {King pawn opening [%csl Ge4][%cal Ge2e4]}
e5
2. Nf3 (2. Bc4 {Italian-style line}) Nc6
3. Bb5 a6
orientation: white | blackshowMoves: true | falseshowComments: true | falseshowVariations: true | falseIf a block option is omitted, the plugin uses its default value.
npm install
npm run dev
npm test
npm run build
npm run dev builds in watch mode.npm test runs the Vitest suite.npm run build creates the production main.js bundle.npm run build, refresh the installed vault copy before manual testing:cp main.js .obsidian/plugins/chess-pgn-viewer/main.js
cp styles.css .obsidian/plugins/chess-pgn-viewer/styles.css
git diff --no-index -- main.js .obsidian/plugins/chess-pgn-viewer/main.js
git diff --no-index -- styles.css .obsidian/plugins/chess-pgn-viewer/styles.css
No output means the local Obsidian plugin copy is in sync.
src/main.ts - Obsidian plugin entry pointsrc/chess/block.ts - PGN parsing and game-state modelsrc/chess/viewer.ts - board rendering, navigation, and notation UItests/ - Vitest coverage for parsing and viewer behaviordocs/assets/ - screenshot assets used in this READMEstyles.css - plugin stylesmain.js - built plugin bundleTests use vitest with jsdom. The most important coverage is around PGN parsing, notation layout, navigation, geometry, and annotation rendering. Run the full suite before publishing changes.
When fixing notation layout bugs, add a focused regression in tests/chess-viewer.test.ts first and cover both the CSS contract and the rendered DOM behavior.
main.js is generated; do not edit it by hand..obsidian/plugins/chess-pgn-viewer/ is for testing only and is not part of the Git repository.1..., and variation rows in a narrow notation panel to ensure text wraps instead of clipping.