Skip to content

refactor: code block & math block syntax highlighting#2873

Open
nperez0111 wants to merge 4 commits into
code-block-previewsfrom
syntax-highlighting
Open

refactor: code block & math block syntax highlighting#2873
nperez0111 wants to merge 4 commits into
code-block-previewsfrom
syntax-highlighting

Conversation

@nperez0111

Copy link
Copy Markdown
Contributor

Summary

The goal of this refactor was to use #2872 which allows for "sub extensions" (a blocknote extension within a blocknote extension) to be de-duped. And, leverage that to allow both the code-block & math block to operate with the syntax highlighting extension.

Now, the math block & code block declares how to highlight their contents & the syntax highlighting extension will pickup on them as being the nodes they should try to syntax highlight upon.

I've made the code block accept the syntax highlighter like it was accepting before. And, now the math block can accept a syntax highlighter (if for some reason you only care to configure the math block highlighting but not the code block one).

The trouble is how to handle both code block & the math extension wanting to configure the highlighter in different ways. Well, extensions can now only be registered once per key with #2872 so it will just silently drop one of the configurations and use one of the highlight instances to try to highlight both the math & code blocks.

I think this is a fine tradeoff for now, since you can really just leave the code block syntax highlighting on & get both code blocks & math blocks "for free". There is a larger question on how to do this in the more general case for extensions which depend on each other, but that is just a hard problem in programming in general.

Rationale

Changes

Impact

Testing

Screenshots/Video

Checklist

  • Code follows the project's coding standards.
  • Unit tests covering the new feature have been added.
  • All existing tests pass.
  • The documentation has been updated to reflect the new feature

Additional Notes

YousefED and others added 4 commits June 25, 2026 08:47
Logged-out buyers now go straight to Polar checkout instead of being
sent to /signup first.
De-duplication: when an extension with a given key is already registered,
skip registering another one with the same key (the first registration
wins). This lets an extension declare a dependency on another via
`blockNoteExtensions` without conflicting when that same extension is also
registered directly by the user.

Ordering: a sub-extension declared via `blockNoteExtensions` is a dependency
of the extension that declares it, so it now runs before its parent. The
dependency is recorded as the sub is resolved (before the de-duplication
check), so it holds even when multiple parents declare the same sub-extension
and when a parent has a higher base priority via `runsBefore`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… & math block can configure a highlighter for
@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
blocknote Ready Ready Preview Jun 29, 2026 1:40pm
blocknote-website Error Error Jun 29, 2026 1:40pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 13eee8ba-25e2-4f56-8e64-f9e7b44d5e89

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch syntax-highlighting

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants