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

feat(gatsby-remark-embed-snippet): apply gatsby-remark-prismjs configuration to embedded snippets #13973

Merged
merged 8 commits into from
Jun 14, 2019
Merged

feat(gatsby-remark-embed-snippet): apply gatsby-remark-prismjs configuration to embedded snippets #13973

merged 8 commits into from
Jun 14, 2019

Conversation

timhagn
Copy link
Contributor

@timhagn timhagn commented May 11, 2019

Description

This is the continuation of PR #13841, which I sadly botched % ).
Added my changes here again on a clean fork.

While writing a documentation page for gbi, I noticed that line numbering and some other options of gatsby-remark-prismjs weren't working here. Stepping through it with Intellij Idea's Debugger confirmed that the visit(markdownAST, code, node => {...} branch of it was of course never reached, as this plugin already had processed it to HTML.
So I changed the constructed node.type to code, just gave the read in file as node.value and added node.lang to the returned node, which are needed for further processing down the line.
It just seemed unnecessary to duplicate gatsby-remark-prismjs's code-highlighting functionality by creating nearly the same output (and it should prevent any future deviations).

Related Issues

Fixes the issue I would have opened otherwise ; ).

@pieh
Copy link
Contributor

pieh commented May 13, 2019

It looks good 👍

I think this change warrant doing major version bump for gatsby-remark-embed-snippet as there is potential for changed behaviour when using it with same configuration (i.e added line numbering).

@timhagn
Copy link
Contributor Author

timhagn commented May 13, 2019

Hi @pieh, thanks for the thumbs up : )!

Though as I already tested it in reactjs.org (see this comment from the first PR #13841) and it doesn't seem to break anything in combination with the current gatsby-remark-prismjs - and -embed-snippets now just follows its default node creation / transformation process - I don't think a major version bump would really be necessary.
But that's up to you people, of course ; ).

@pieh
Copy link
Contributor

pieh commented May 13, 2019

What I meant by changed behaviour, is that if you specify line numbering option (right now), it won't be used for embedded snippets. If I understand changes here correctly - this will fix it, so fixing this, also changes behaviour (different output for same plugin options) ;)

@timhagn
Copy link
Contributor Author

timhagn commented May 13, 2019

*hmmz* But it fixes behavior in a backwards compatible manner, or doesn't it? Just thinking according to SemVer that'd be a minor version update. But what's semver more than "semantics" - so let's not dive into them ; ). In the end it's up to you and the other maintainers anyway ^^.

@timhagn
Copy link
Contributor Author

timhagn commented May 21, 2019

Anyone willing to give this a review, please : )?

@timhagn
Copy link
Contributor Author

timhagn commented Jun 12, 2019

@marcysutton @KyleAMathews @DSchau
Is this still wanted and would anyone of you be willing to give it a review, please : )?
What do you think about @pieh's objection? Would be willing to add an option for old vs. "new" behavior in the meantime... *thinks*

@pieh pieh self-assigned this Jun 12, 2019
Copy link
Contributor

@DSchau DSchau left a comment

Choose a reason for hiding this comment

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

This seems pretty reasonable to me.

I think @pieh's reservation about a major bump (which is reasonable) is more that we can't guarantee this doesn't break something. While testing with reactjs.org is great (and thank you for doing it!), it doesn't guarantee nothing is broken. Since this is a possibly breaking change, I'd be fine releasing this as a major bump to just be on the safe side.

packages/gatsby-remark-embed-snippet/README.md Outdated Show resolved Hide resolved
Co-Authored-By: Dustin Schau <DSchau@users.noreply.github.com>
@timhagn timhagn requested a review from a team as a code owner June 14, 2019 11:40
@timhagn
Copy link
Contributor Author

timhagn commented Jun 14, 2019

Thanks for reviewing it, @DSchau!
As written, I've committed your suggested change to the README, hope it doesn't break the overall tests now - as you and the team seem to have made quite some progress while I re-opened this PR : ).
In case it would (at 15 successful ones now, fingers crossed ; ) and before I accidentally break the PR again, what's the preferred way of updating a PR to gatsbyjs from upstream? Merging changes into my local repo?
What do you think about me adding a switch in the meantime? And no prob about testing it with reactjs.org, was an interesting insight for me : ).
Thanks again!

@pieh
Copy link
Contributor

pieh commented Jun 14, 2019

what's the preferred way of updating a PR to gatsbyjs from upstream?

We do squash commits from PR, so merging gatsbyjs/gatsby master branch into is ok. Rebasing would work too. You can chose whatever workflow you are comfortable with. I'll update branch and do some local testing and hopefully merge this today.

I will do major version bump - this was never a blocker, just a note. We can bump plugins major versions when needed and this is not tied to Gatsby core package major versions bump which are far less frequent.

@pieh pieh added the breaking change If implemented, this proposed work would break functionality for older versions of Gatsby label Jun 14, 2019
@pieh pieh changed the title feat(gatsby-remark-embed-snippet): let gatsby-remark-prismjs do the heavy lifting feat(gatsby-remark-embed-snippet): apply gatsby-remark-prismjs configuration to embedded snippets Jun 14, 2019
Copy link
Contributor

@pieh pieh left a comment

Choose a reason for hiding this comment

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

Thanks for patience on this. Changes looks good!

@pieh pieh merged commit c43c4c8 into gatsbyjs:master Jun 14, 2019
@gatsbot
Copy link

gatsbot bot commented Jun 14, 2019

Holy buckets, @timhagn — we just merged your PR to Gatsby! 💪💜

Gatsby is built by awesome people like you. Let us say “thanks” in two ways:

  1. We’d like to send you some Gatsby swag. As a token of our appreciation, you can go to the Gatsby Swag Store and log in with your GitHub account to get a coupon code good for one free piece of swag. We’ve got Gatsby t-shirts, stickers, hats, scrunchies, and much more. (You can also unlock even more free swag with 5 contributions — wink wink nudge nudge.) See gatsby.dev/swag for details.
  2. We just invited you to join the Gatsby organization on GitHub. This will add you to our team of maintainers. Accept the invite by visiting https://github.com/orgs/gatsbyjs/invitation. By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests.

If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’.

Thanks again!

@pieh
Copy link
Contributor

pieh commented Jun 14, 2019

Published gatsby-remark-embed-snippet@4.0.0

Also added some BREAKING CHANGES note in changelog - https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-remark-embed-snippet/CHANGELOG.md#400-2019-06-14

@timhagn
Copy link
Contributor Author

timhagn commented Jun 14, 2019

Thanks a lot @pieh, was worth the wait ; ). And to you, too, of course, @DSchau! Let's just say the whole Gatsby team : )!

mxxk pushed a commit to mxxk/gatsby that referenced this pull request Jun 21, 2019
…uration to embedded snippets (gatsbyjs#13973)

BREAKING CHANGE: Configuration of `gatsby-remark-prismjs` is used to generate markup for code snippets. `classPrefix` option has been removed from `gatsby-remark-embed-snippet` (same option in `gatsby-remark-prismjs` will be used instead).
johno pushed a commit to johno/gatsby that referenced this pull request Jul 17, 2019
…uration to embedded snippets (gatsbyjs#13973)

BREAKING CHANGE: Configuration of `gatsby-remark-prismjs` is used to generate markup for code snippets. `classPrefix` option has been removed from `gatsby-remark-embed-snippet` (same option in `gatsby-remark-prismjs` will be used instead).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change If implemented, this proposed work would break functionality for older versions of Gatsby
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants