You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+28-10Lines changed: 28 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# AGENTS.md
2
2
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.
4
4
5
5
Two highlighting modes:
6
6
-**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
24
24
npm run zip # Plugin zip
25
25
```
26
26
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.
-`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)
@@ -61,9 +56,32 @@ Always `require` the generated `.asset.php` manifest before enqueueing block scr
61
56
62
57
**If you change block attributes in JS**, update `render_code_block()` in `class-blocks.php` and the defaults flow as well.
63
58
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
+
64
79
## Asset loading
65
80
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.
Copy file name to clipboardExpand all lines: CLAUDE.md
+1-6Lines changed: 1 addition & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
4
4
5
5
## Plugin Overview
6
6
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.
8
8
9
9
Two highlighting modes:
10
10
-**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
31
31
npm run zip # Plugin zip
32
32
```
33
33
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.
0 commit comments