Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS/JSX: Add support for recursive expressions #2163

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

RunDevelopment
Copy link
Member

@RunDevelopment RunDevelopment commented Jan 6, 2020

So after #2159 I wanted to add support for arbitrary JS spread expressions and kinda overdid it. I also added support for deeply nested expressions in JS template string interpolations.

Because I need very similar patterns in #2139, I decided that JS is going to share its patterns and added a way for languages to share internal patterns. It's done via a non-enumerable property $. Because the property is non-enumerable, it won't be cloned (e.g. for extend) but it will be kept by insertBefore.
Btw. I'm not very attached to this version by variable sharing, so better ideas are very welcome.

Edit: Maybe we could do a Prism.patterns for globally shared patterns (RegExp or string)?

This PR is a 3 in 1: JS Template strings, JSX spread expressions, and the $ property.

@mAAdhaTTah
Copy link
Member

Another one worth refreshing for bundle size impacts.

@github-actions
Copy link

JS File Size Changes (gzipped)

A total of 4 files have changed, with a combined diff of +261 B (+4.5%).

file master pull size diff % diff
components/prism-core.min.js 3.01 KB 3.03 KB +18 B +0.6%
components/prism-javascript.min.js 1.29 KB 1.63 KB +339 B +26.2%
components/prism-jsx.min.js 850 B 888 B +38 B +4.5%
components/prism-qml.min.js 595 B 461 B -134 B -22.5%

Generated by 🚫 dangerJS against b905f40

@JaKXz
Copy link
Collaborator

JaKXz commented Jul 18, 2021

@RunDevelopment this looks really interesting, but I'm not sure how to help since a lot of it seems to be* out of date at this point. Do you think this is worth picking back up again?

@RunDevelopment
Copy link
Member Author

Do you think this is worth picking back up again?

Not in its current form, no. This PR relies on a sorta hack to share regexes across languages. I'd rather wait for v2 where we can just directly import/export regexes via ESM.

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

Successfully merging this pull request may close these issues.

None yet

3 participants