Bengal 0.1.6
Kida template engine, Patitas parser, Rosettes syntax highlighter, and comprehensive error system
Key additions: Kida template engine (now default), Patitas markdown parser, Rosettes syntax highlighter, structured error codes across all packages, and 2-13x algorithm speedups.
Highlights
Kida Template Engine
Bengal now ships with Kida, a pure-Python template engine designed for Python 3.14's free-threading. It's Jinja2-compatible with additional features:
{% match page.layout %}
{% case "post" %}
{% include "layouts/post.html" %}
{% case "doc" | "reference" %}
{% include "layouts/doc.html" %}
{% default %}
{% include "layouts/default.html" %}
{% endmatch %}
{# Pipeline operators #}
{{ pages |> where("draft", false) |> sort_by("date") |> first }}
{# Optional chaining #}
{{ page.author?.avatar ?? "/images/default-avatar.png" }}
Features:
{% match %}pattern matching with guards- Pipeline operators
|>for filter chaining - Optional chaining
??for nil-resilient access {% while %}loops,{% cache %},{% slot %},{% embed %}- Bytecode caching with site-wide
BlockCache - Compile-time filter validation with suggestions
Jinja2 remains fully supported. Settemplate_engine: jinja2in your config to use it.
Patitas Markdown Parser
Patitas is a new markdown parser with a typed AST and O(n) lexer:
# Enable in config
markdown:
parser: patitas # default, or "mistune" (legacy)
- 54 directive handlers with full Bengal directive support
- Zero-Copy Lexer Handoff (ZCLH) for Rosettes integration
- Directive and role systems for custom markup
Rosettes Syntax Highlighter
Rosettes provides pure-Python syntax highlighting that works with Python 3.14's free-threading without re-enabling the GIL. Now available as a standalone package!
- 📦 Package:
pip install rosettes - 📚 Docs: Rosettes documentation
# Enable in config
highlighting:
backend: rosettes # default, or "pygments" (optional)
- 55 languages with hand-written state machine lexers
- O(n) guaranteed performance, zero ReDoS vulnerability
- Semantic token system with CSS theming
- Automatic fallback to Pygments when needed
Structured Error Codes
All packages now use structured error codes:
| Series | Package | Example |
|---|---|---|
| A | Cache | A001: Cache version mismatch |
| B | Orchestration | B003: Build phase failed |
| C | Config | C002: Invalid configuration key |
| D | Discovery | D008: Content fetch failed |
| N | Collections | N011: Collection not found |
| O | Autodoc | O003: Extraction failed |
| V | Health | V001: Validation error |
| X | Assets | X007: Asset not found |
Each error includes actionable suggestions. Session tracking viarecord_error()captures silent failures for debugging.
Performance
Algorithm Optimizations
| Area | Before | After | Method |
|---|---|---|---|
| Cache affected pages | O(n) scan | O(1) lookup | Reverse dependency graph |
| Taxonomy lookups | O(n) | O(1) | Reverse index |
| DirectiveAnalyzer | O(L²) | O(L) | Index-based checks |
| AutoFixer | O(D²) | O(D) | Dict lookup |
| LLM streaming | O(n×c) memory | O(c) | Streaming writes |
Content Sources
| Source | Improvement | Method |
|---|---|---|
| LocalSource (2K files) | 2.5x faster | Regex pre-compilation, O(n) default |
| GitHubSource | 10x faster | Parallel fetching with semaphores |
| NotionSource | 3x faster | Block caching with TTL |
Build Time
- Health validators: 312ms saved per build (redundant checks removed)
- Directive rendering check: 1s saved per build (H207 removed)
- Docs nav: 13x faster rendering (macro instead of recursive include)
- Cache size: 40% smaller (~2.8MB savings via compression)
Thread Safety
Full support for Python 3.14's free-threading (PEP 703):
DirectiveCache._lockfor concurrent directive access_icon_lockfor thread-safe icon resolution- Double-check locking in rendering context
- GIL-safe syntax highlighting via Rosettes
Autodoc
- OpenAPI layouts: Three-panel scroll-sync REST API reference pages
- View filters:
PostView,ReleaseView,AuthorView,TagView - Theme helpers:
MemberView,CommandView,OptionView - Kida migration: All autodoc templates now use Kida
Other Improvements
Health Check
- Error codes with H-prefix schema (H0xx-H9xx)
--ignoreCLI option for selective validation- O(1) dict lookup for fence fixes in AutoFixer
Template Functions
- 13 new filters for dates, collections, sharing, and archive helpers
page._sourceandpage.word_countproperties
Type System
Anyreplaced with typed protocols across 4 phases- TypedDict and Protocol definitions for type refinement
- Fixed cache inheritance bug in
DirectiveOptions.from_raw()
Documentation
- 15+ accuracy fixes across versioning, i18n, authoring, filtering
- Kida Template Engine Concepts crash course
- 62 code blocks with language designators
Removed
- Component preview: Removed from dev server
- Module shadowing: Backward-compat shims removed
- Autodoc aliases: Legacy compatibility code removed
Upgrading
uv pip install --upgrade bengal
# or
pip install --upgrade bengal
All changes are backward compatible. Kida is now the default template engine, but Jinja2 templates continue to work. Caches auto-migrate to the new format.
To explicitly use Jinja2:
template_engine: jinja2