Skip to content

Commit c0df377

Browse files
committed
chore: update version references and consolidate agent documentation
1 parent 61c1f0e commit c0df377

3 files changed

Lines changed: 30 additions & 17 deletions

File tree

AGENTS.md

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# AGENTS.md
22

3-
WordPress plugin extending the native Gutenberg `core/code` block with syntax highlighting via JS block filters and a `render_block_core/code` PHP filter. Does not replace the block — existing posts stay valid.
3+
**WebberZone Code Block Highlighting** v1.1.0. WordPress plugin extending the native Gutenberg `core/code` block with syntax highlighting via JS block filters and a `render_block_core/code` PHP filter. Does not replace the block — existing posts stay valid. Namespace: `WebberZone\Code_Block_Highlighting`. Requires WordPress 6.6+, PHP 7.4+. No Freemius.
44

55
Two highlighting modes:
66
- **Client-side** (default): Prism.js runs in the browser. Loads the Prism JS bundle + theme CSS.
@@ -24,11 +24,6 @@ npm run start # Watch mode for block/editor/frontend bundles
2424
npm run zip # Plugin zip
2525
```
2626

27-
## Source of truth
28-
29-
- Active implementation plan: `PLAN.md`
30-
- Backlog/reference only: `OLD-FEATURE-PLAN.md` — do not assume features exist unless implemented in code.
31-
3227
## Architecture
3328

3429
**Namespace:** `WebberZone\Code_Block_Highlighting`
@@ -37,9 +32,9 @@ Bootstrap: `wzcbh()` singleton on `plugins_loaded` → instantiates `Frontend\Bl
3732

3833
Key files:
3934
- `includes/class-main.php` — bootstrap and object wiring
40-
- `includes/frontend/class-blocks.php` — editor assets, REST route, `render_block_core/code`
41-
- `includes/frontend/class-styles-handler.php` — conditional Prism asset loading
42-
- `includes/admin/class-settings.php` — settings registration, theme resolution
35+
- `includes/frontend/class-blocks.php` — editor assets, REST route, `render_block_core/code` filter; `render_code_block_server()` for server mode; `remap_token_classes()` for hljs→Prism class mapping
36+
- `includes/frontend/class-styles-handler.php` — conditional asset loading for both modes: client (Prism JS + theme CSS) and server (theme CSS + `hljs-server-mode.css`, no JS)
37+
- `includes/admin/class-settings.php` — settings registration; `get_color_scheme_css()` always returns Prism CSS URL (no per-mode branch)
4338
- `includes/blocks/src/js/index.js` — block filter, Inspector Controls
4439
- `includes/blocks/src/js/frontend.js` — Prism grammars + plugins
4540

@@ -61,9 +56,32 @@ Always `require` the generated `.asset.php` manifest before enqueueing block scr
6156

6257
**If you change block attributes in JS**, update `render_code_block()` in `class-blocks.php` and the defaults flow as well.
6358

59+
## Non-obvious implementation details
60+
61+
**`_legacyTitle` attribute** — read-only migration attribute; copies `title` from old `code-syntax-block` format on first load, then clears itself.
62+
63+
**`maxHeight`** — CSS-only: serialized as inline `style` by the block save function, not touched by the PHP render filter.
64+
65+
**`wzcbh_languages` filter** — controls the editor UI dropdown only. Does not affect which Prism grammars are bundled. Adding a slug without a matching grammar import in `frontend.js` results in plain-text output.
66+
67+
**Editor canvas styling**`enqueue_editor_canvas_styles()` extracts only `background` and `color` from the active Prism theme CSS and re-injects them with `.block-editor-block-list__layout` prepended to win the specificity race against the editor's own `pre` styles.
68+
69+
**Server-mode token remapping**`remap_token_classes()` in `class-blocks.php` uses `strtr()` to convert every `class="hljs-*"` span emitted by highlight.php into the equivalent Prism `class="token *"` span. Keys are ordered longest-first to prevent prefix collisions.
70+
71+
**highlight.php autoloader**`\Highlight\Autoloader::register()` does not exist. Use `spl_autoload_register(static function(string $class_name): void { \Highlight\Autoloader::load($class_name); })`.
72+
73+
**`hljs-server-mode.css`** — only handles `.wzcbh-highlighted-line` line highlighting. Font-size, line-numbers gutter, and word-wrap are all in `frontend.css` (webpack build), which loads in both modes.
74+
75+
**Both modes use the same Prism theme CSS**`Settings::get_color_scheme_css()` always returns the Prism CSS URL. There is no per-mode branch.
76+
77+
**Default color scheme:** `prism-onedark`
78+
6479
## Asset loading
6580

66-
Prism assets load only on pages containing at least one `core/code` block (`Styles_Handler::enqueue_assets()`). Use `wzcbh_force_load_assets` to override.
81+
Assets load only on pages containing at least one `core/code` block (`Styles_Handler::enqueue_assets()`). Use `wzcbh_force_load_assets` to override.
82+
83+
- **Client mode**: `frontend.css` + Prism theme CSS + `wzcbh-prism-js` script bundle
84+
- **Server mode**: `frontend.css` + Prism theme CSS + `hljs-server-mode.css` (no JS; syntax already pre-rendered in HTML)
6785

6886
## Filters and routes
6987

CLAUDE.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44

55
## Plugin Overview
66

7-
**WebberZone Code Block Highlighting** (plugin slug: `webberzone-code-block-highlighting`) extends the native Gutenberg `core/code` block with syntax highlighting via JS block filters and a `render_block_core/code` PHP filter. Does not replace the block — existing posts stay valid. Namespace: `WebberZone\Code_Block_Highlighting`. Requires WordPress 6.6+, PHP 7.4+. No Freemius.
7+
**WebberZone Code Block Highlighting** v1.1.0 (plugin slug: `webberzone-code-block-highlighting`) extends the native Gutenberg `core/code` block with syntax highlighting via JS block filters and a `render_block_core/code` PHP filter. Does not replace the block — existing posts stay valid. Namespace: `WebberZone\Code_Block_Highlighting`. Requires WordPress 6.6+, PHP 7.4+. No Freemius.
88

99
Two highlighting modes:
1010
- **Client-side** (default): Prism.js runs in the browser. Loads the Prism JS bundle + theme CSS.
@@ -31,11 +31,6 @@ npm run start # Watch mode for block/editor/frontend bundles
3131
npm run zip # Plugin zip
3232
```
3333

34-
## Source of truth
35-
36-
- Active implementation plan: `PLAN.md`
37-
- Backlog/reference only: `OLD-FEATURE-PLAN.md` — do not assume features exist unless implemented in code.
38-
3934
## Architecture
4035

4136
**Namespace:** `WebberZone\Code_Block_Highlighting`

includes/frontend/class-blocks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ static function () use ( $new_code ): string {
618618
* server mode reuse the Prism theme CSS directly, giving exact theme parity
619619
* across all 21 themes with no per-theme hljs CSS files needed.
620620
*
621-
* @since 1.3.0
621+
* @since 1.1.0
622622
*
623623
* @param string $html Highlighted HTML from highlight.php.
624624
* @return string HTML with hljs class names replaced by Prism token class names.

0 commit comments

Comments
 (0)