Skip to content

Diff highlighting (added/removed line markers) #3

Description

@ajaydsouza

Summary

Support diff-style highlighting: +/- prefixed lines get green/red backgrounds, combinable with a base language (e.g. diff-php).

Details

  • Client mode: bundle prism-diff grammar plus the diff-highlight Prism plugin in frontend.js; expose a "Show as diff" toggle or diff-{language} handling in the language logic.
  • Server mode: highlight.php supports diff as a language; combined diff+language rendering needs a custom pass in render_code_block_server() (split lines by +/-, highlight the remainder with the base language, then wrap).
  • Extend remap_token_classes() for diff token classes; add styling to hljs-server-mode.css/frontend.css.
  • Follow the standard flow: JS attribute schema → save output → render_code_block() → frontend Prism plugin support.

Why

Extremely common in tutorials and changelogs ("change this line to that"). Prism's diff-highlight is well-proven; few WP block plugins expose it.

Speed to implement: Medium · Usefulness: High · Rank: 3

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions