@lwlee2608/pi-code-blocks

Fence-free Pi code blocks with accent-colored plain text.

Packages

Package details

extension

Install @lwlee2608/pi-code-blocks from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@lwlee2608/pi-code-blocks
Package
@lwlee2608/pi-code-blocks
Version
0.1.0
Published
Oct 24, 2026
Downloads
440/mo · 440/wk
Author
lwlee2608
License
MIT
Types
extension
Size
7 KB
Dependencies
0 dependencies · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./src/index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

Pi code blocks

An experimental Pi extension that hides code-block fences and colors plain-text blocks with the current theme’s accent color. Recognized code languages keep Pi’s syntax highlighting. The accent is theme-dependent, not always blue.

Install

pi install npm:@lwlee2608/pi-code-blocks

Run /reload afterward, or start a new session. No command or settings are needed.

To try it from this repository without installing:

pi -e ./packages/code-blocks/src/index.ts

To remove it:

pi remove npm:@lwlee2608/pi-code-blocks

Restart Pi after removal so all cached output uses the default renderer.

Behavior and limits

  • Removes generated opening and closing fences, not fence characters inside the code.
  • Uses the accent color for unlabeled, text, txt, plaintext, and plain blocks, including indented code.
  • Keeps Pi’s formatting for other language labels, including unknown languages.
  • Preserves indentation, blank lines inside blocks, syntax highlighting, and wrapping.
  • Applies to all instances of Pi’s shared Markdown renderer: assistant and user messages, thinking, previews, and tools that use it.
  • Does not alter stored messages, model context, print/JSON/RPC output, or Pi’s installed files.

The extension patches the private Markdown.prototype.renderToken method in TUI sessions. It checks the expected rendering behavior before installation and leaves the default renderer in place with a warning if that check fails. It restores the original method on reload/shutdown, unless another extension has since replaced it.

This is not a public Pi API. Compatibility checks cannot catch every future change. Tested with Pi 1.0.0, including the installed bundled CLI; unit tests also pass against pi-tui 1.4.0. If an update breaks it, disable the extension and restart Pi. Other extensions that patch the same renderer may conflict.

Development

npm run check -w packages/code-blocks
npm test -w packages/code-blocks

License

MIT