Skip to content

Conversation

@DmitrySharabin
Copy link
Member

@DmitrySharabin DmitrySharabin commented Oct 10, 2025

Summary

  • Add utils authored by @LeaVerou: isObject(), isPlainObject(), deepMerge(), deepClone(), betterAssign(),insert(), and insertAfter(). Update insertBefore() accordingly.
  • Update extend() to support new special properties ($insertBefore, $insertAfter, $insert, $delete, and $merge) that allow defining grammars more declaratively and adding a new grammarPatch() util (all authored by @LeaVerou). See [v2] Language combinations / extensions / embeddings / ... #3927 for details.
  • Adjust TS types and config to support the new API.
  • Fix TS errors.

Those are non-breaking changes. Corresponding changes to language definitions are in a separate PR.


This is part 2 of 3 in a stack made with GitButler:

@github-actions
Copy link

github-actions bot commented Oct 10, 2025

No JS Changes

Generated by 🚫 dangerJS against f1faac8

@netlify
Copy link

netlify bot commented Oct 10, 2025

Deploy Preview for dev-prismjs-com ready!

Name Link
🔨 Latest commit f1faac8
🔍 Latest deploy log https://app.netlify.com/projects/dev-prismjs-com/deploys/68ed4d45a82c3d0008c75174
😎 Deploy Preview https://deploy-preview-4019--dev-prismjs-com.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@DmitrySharabin DmitrySharabin force-pushed the grammar-patch branch 2 times, most recently from 538eaec to 3328581 Compare October 10, 2025 15:47
return source;
}

return source ?? target;
Copy link
Member Author

@DmitrySharabin DmitrySharabin Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated this part to handle the $merge special property correctly. Before, it was target ?? source, and we couldn't merge numbers, strings, regexes, etc.


/** @typedef {import('../../src/types.d.ts').GrammarOptions} GrammarOptions */
/**
* @typedef {import('../../src/types.d.ts').GrammarOptions} GrammarOptions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw this might be useful here too: color-js/color.js#685

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, it's on my list. 😊

Copy link
Member

@LeaVerou LeaVerou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@DmitrySharabin DmitrySharabin merged commit b93e36c into v2 Oct 29, 2025
13 of 14 checks passed
@DmitrySharabin DmitrySharabin deleted the grammar-patch branch October 29, 2025 13:27
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.

3 participants