Skip to content

Commit 8f9d9d1

Browse files
committed
Update AGENTS.md: add standard header, plugin URLs, Themes list, Docs section
1 parent 8442735 commit 8f9d9d1

1 file changed

Lines changed: 28 additions & 11 deletions

File tree

AGENTS.md

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

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.
3+
This file provides guidance to Codex (Codex.ai/code) when working with code in this repository.
44

5-
Two highlighting modes:
5+
## Plugin Overview
6+
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.
68

9+
Two highlighting modes:
710
- **Client-side** (default): Prism.js runs in the browser. Loads the Prism JS bundle + theme CSS.
8-
- **Server-side**: highlight.php pre-renders token spans on the server. Loads only `hljs-clipboard.js` for the copy-to-clipboard and expand/collapse toolbar buttons (no Prism JS). Uses the same Prism theme CSS — token class remapping (`remap_token_classes()` in `class-blocks.php`) converts hljs-* span classes to Prism `token *` classes via `strtr`, giving exact visual parity across all 21 themes.
11+
- **Server-side**: highlight.php pre-renders token spans on the server. No Prism.js loaded. Loads Prism theme CSS + `hljs-server-mode.css` + `hljs-clipboard.js` (copy-to-clipboard + expand/collapse). Token class remapping (`remap_token_classes()` in `class-blocks.php`) converts hljs-* span classes to Prism `token *` classes via `strtr`, giving exact visual parity across all 21 themes.
12+
13+
WordPress.org: https://wordpress.org/plugins/webberzone-code-block-highlighting/
14+
webberzone.com: https://webberzone.com/plugins/webberzone-code-block-highlighting/
915

1016
## Commands
1117

@@ -32,7 +38,6 @@ npm run zip # Plugin zip
3238
Bootstrap: `wzcbh()` singleton on `plugins_loaded` → instantiates `Frontend\Blocks`, `Frontend\Styles_Handler``Admin\Admin` on `init` (admin only).
3339

3440
Key files:
35-
3641
- `includes/class-main.php` — bootstrap and object wiring
3742
- `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
3843
- `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` + `hljs-clipboard.js`)
@@ -50,24 +55,28 @@ Always `require` the generated `.asset.php` manifest before enqueueing block scr
5055

5156
**`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.
5257

53-
**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.
58+
**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. Layout properties are intentionally excluded.
59+
60+
**Themes (21):** A11y Dark, Coldark Cold, Coldark Dark, Dracula, Duotone Dark, Duotone Light, GitHub Light, Gruvbox Dark, Gruvbox Light, Lucario, Material Dark, Material Light, Night Owl, Nord, One Dark, One Light, Shades of Purple, Solarized Dark, Synthwave '84, VS Code Dark+, Xonokai (Monokai).
61+
62+
**Default color scheme:** `prism-onedark`
63+
64+
**If you change block attributes in JS**, update `render_code_block()` in `class-blocks.php` and the defaults flow as well.
5465

55-
**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.
66+
**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. `strtr()` is safe here because highlight.php emits single-class spans only (no compound classes). Keys are ordered longest-first to prevent prefix collisions (e.g. `hljs-selector-tag` before a hypothetical `hljs-selector`).
5667

5768
**highlight.php autoloader**`\Highlight\Autoloader::register()` does not exist. Use `spl_autoload_register(static function(string $class_name): void { \Highlight\Autoloader::load($class_name); })`.
5869

5970
**`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.
6071

61-
**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.
62-
63-
**Default color scheme:** `prism-onedark`
72+
**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 or hljs-specific theme mapping table.
6473

6574
## Asset loading
6675

6776
Assets load only on pages containing at least one `core/code` block (`Styles_Handler::enqueue_assets()`). Use `wzcbh_force_load_assets` to override.
6877

69-
- **Client mode**: `frontend.css` + Prism theme CSS + `wzcbh-prism-js` script bundle
70-
- **Server mode**: `frontend.css` + Prism theme CSS + `hljs-server-mode.css` + `hljs-clipboard.js` (syntax pre-rendered in HTML; `hljs-clipboard.js` provides copy-to-clipboard and expand/collapse only, no Prism)
78+
- **Client mode**: `frontend.css` + Prism theme CSS + `wzcbh-prism-js` script bundle (includes all grammars and plugins)
79+
- **Server mode**: `frontend.css` + Prism theme CSS + `hljs-server-mode.css` + `hljs-clipboard.js` (copy-to-clipboard + expand/collapse)
7180

7281
## Filters and routes
7382

@@ -94,6 +103,14 @@ Assets load only on pages containing at least one `core/code` block (`Styles_Han
94103

95104
Toolbar language labels are `aria-hidden`. Expand/collapse button uses `aria-expanded`. When extending toolbar behaviour, preserve keyboard access and screen reader support.
96105

106+
## Docs
107+
108+
KB articles live in `docs/` using the standard WebberZone structure. Frontmatter values:
109+
- `products: [code-block-highlighting]`
110+
- Section prefixes: `01-wzcbh-getting-started`, `02-wzcbh-advanced`, `03-wzcbh-developer-docs`
111+
112+
Run `/docs-style --audit webberzone-code-block-highlighting` to check style compliance before committing docs.
113+
97114
## Before adding new per-block controls
98115

99116
Verify: JS attribute schema → save output → `render_code_block()` in PHP → frontend Prism plugin support.

0 commit comments

Comments
 (0)