Summary
When no language is set on a block, use highlight.php's highlightAuto() in server mode to detect and highlight it, with an optional detected-language badge.
Details
- In
render_code_block_server() (class-blocks.php), fall back to highlightAuto() when language is empty; constrain the candidate set to the plugin's supported language list for accuracy/performance.
- Map the detected language through
remap_token_classes() as usual; optionally show the detected slug in the toolbar label with a "(detected)" hint.
- Global setting to enable/disable (off by default to avoid surprises); cache detection results with the existing render caching if any.
- Client mode could later get parity via Prism's autoloader/heuristics, but server mode is the quick win.
Why
Many existing posts have untagged core/code blocks; auto-detection upgrades them to highlighted output with zero editing.
Speed to implement: Fast · Usefulness: Medium · Rank: 8
Summary
When no language is set on a block, use highlight.php's
highlightAuto()in server mode to detect and highlight it, with an optional detected-language badge.Details
render_code_block_server()(class-blocks.php), fall back tohighlightAuto()whenlanguageis empty; constrain the candidate set to the plugin's supported language list for accuracy/performance.remap_token_classes()as usual; optionally show the detected slug in the toolbar label with a "(detected)" hint.Why
Many existing posts have untagged
core/codeblocks; auto-detection upgrades them to highlighted output with zero editing.Speed to implement: Fast · Usefulness: Medium · Rank: 8