---
title: Bengal 0.1.6
description: Kida template engine, Patitas parser, Rosettes syntax highlighter, and comprehensive error system
type: changelog
date: 2026-01-01
draft: false
lang: en
tags: [release, changelog, kida, patitas, rosettes, templates, performance, errors]
keywords: [release, 0.1.6, kida, template engine, patitas, markdown parser, rosettes, syntax highlighting, error codes]
category: changelog
---

# Bengal 0.1.6

**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:

```kida
{% 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. Set `template_engine: jinja2` in your config to use it.

### Patitas Markdown Parser

**Patitas** is a new markdown parser with a typed AST and O(n) lexer:

```yaml
# 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

**[[ext:rosettes:docs/get-started|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`](https://pypi.org/project/rosettes/)
- 📚 **Docs**: [[ext:rosettes:docs/get-started|Rosettes documentation]]

```yaml
# 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 via `record_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._lock` for concurrent directive access
- `_icon_lock` for 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)
- `--ignore` CLI 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._source` and `page.word_count` properties

### Type System

- `Any` replaced 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

```bash
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:

```yaml
template_engine: jinja2
```

---

## Links

- [Documentation](https://github.com/lbliii/bengal)
- [Issue Tracker](https://github.com/lbliii/bengal/issues)
- [Full Changelog](https://github.com/lbliii/bengal/blob/main/changelog.md)
