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

Add jssyntax as Prism alias for syntax boxes #6682

Merged
merged 2 commits into from
Aug 8, 2022
Merged

Conversation

teoli2003
Copy link
Contributor

See mdn/mdn-community#149.

This adds an alias in Prism for js: jssyntax.

The plan is to use it with syntax boxes (Web APIs and JS) that have pseudo-JS. We want them to be highlighted as JavaScript by Prism, but distinct so that tools like Prettier and ESLint can skip them.

@OnkarRuikar
Copy link
Contributor

We may also need alias jsonc for json. [ref]

@teoli2003 teoli2003 marked this pull request as ready for review July 14, 2022 17:04
@teoli2003
Copy link
Contributor Author

I'll prefer to wait a bit for jsonc and see how it turns out with this one first, even if it is easy to reverse.

We can use Prettier/ESLint on js blocks first, then extend to json.

@lionralfs
Copy link

Prism already supports comments in JSON: PrismJS/prism#1595
For a live example see https://developer.mozilla.org/en-US/docs/MDN/Structures/Compatibility_tables#basic_compat_data_structure

It seems that the only reason this PR is not merged yet is to make sure Prettier/ESLint can handle jsonc. With JSON not currently being linted anyways, wouldn't it make sense to merge this to address issues in https://github.com/orgs/mdn/discussions/158 first

@teoli2003
Copy link
Contributor Author

I would prefer for this to land, and to keep the json/jsonc discussion separated from this PR.

@teoli2003
Copy link
Contributor Author

To @OnkarRuikar and @lionsralf: once this lands, let's test it on 20-30 pages and only when we are sure that this is working as expected, without any surprise or side-effect, we will be updating the many pages with a syntax.

Let's be cautious. I'm very confident, but let's be cautious.

@OnkarRuikar
Copy link
Contributor

I've tried it in my local and it works as expected:

before

before

after

after

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.

4 participants