Skip to content

bengal 0.2.0

Choose a tag to compare

@lbliii lbliii released this 14 Feb 22:48
· 777 commits to main since this release
ee66cf9

Bengal 0.2.0

Key additions: Block-level code block caching via Rosettes HighlightCache, Pounce ASGI backend for the dev server (SSE live reload, fragment-based partial updates), Kida/Patitas 0.2.0 integration with AST-based block recompilation and structured error handling, and native Jupyter notebook rendering with download and Colab links.

Highlights

Rosettes Highlight Caching

Code block highlighting is now cached across pages to avoid re-highlighting identical blocks:

  • HighlightCache: Cache keyed on rosettes.content_hash(code, language) with extended key for hl_lines/show_linenos
  • Batch flow: Uncached blocks are highlighted in batch, then merged with cached results
  • Dependency: Requires rosettes>=0.2.0 (content_hash, HighlightItem, unified highlight_many)

Dev Server: Pounce ASGI Backend

The development server now uses Pounce instead of ThreadingTCPServer:

  • ASGI app: Static serving and HTML injection in a single ASGI application
  • SSE live reload: Real-time updates when content changes
  • Fragment-based partial updates: Efficient partial page updates instead of full reloads
  • Request logging: Clear visibility into served requests
  • Dependency: Requires bengal-pounce>=0.2.0

Kida & Patitas 0.2.0

Template and parser stack updated to 0.2.0:

  • Kida structured errors: Bengal consumes structured error attributes instead of string parsing
  • AST-based block recompilation: Kida fragment fast path and partial evaluation
  • Dependencies: kida-templates>=0.2.0, patitas>=0.2.0

Native Notebook Rendering

Jupyter notebooks (.ipynb) are now rendered natively as doc pages—no conversion tools or extra dependencies. Drop notebooks into any content directory and build.

  • Download link: The .ipynb file is copied to output; a download button links readers to the source notebook
  • Colab link: Add repo_url to [params] in bengal.toml for auto-generated "Open in Colab" buttons on every notebook page
  • Binder: Add binder_url in section cascade or notebook frontmatter for "Run in Binder"

Configuration (in bengal.toml or config/_default/params.yaml):

[params]
repo_url = "https://github.com/your-org/your-repo"
colab_branch = "main"        # optional, default: main
colab_path_prefix = "site"   # when site lives in repo subdirectory

Override per-page with colab_url or download_url in frontmatter. See [[docs/content/authoring/notebooks/setup|Notebook Setup Guide]] for details.

Breaking Changes

None. This is a fully backward-compatible release.

Dependency Updates

Package Version Change
rosettes ≥0.2.0 content_hash, HighlightItem, unified highlight_many
kida-templates ≥0.2.0 Structured errors, AST block recompilation
patitas ≥0.2.0 Parser improvements
bengal-pounce ≥0.2.0 ASGI server for dev server

Upgrading

uv pip install --upgrade bengal
# or
pip install --upgrade bengal
# or use the self-update command
bengal upgrade