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 syntax highlighting support for ruby and erb #203

Merged
merged 9 commits into from Feb 22, 2021
Merged

Conversation

colebemis
Copy link
Contributor

@colebemis colebemis commented Oct 23, 2020

This PR adds support for ruby and erb syntax highlighting in code examples:

Example

```erb
<h1 class="hi">foo</h1>
<%= render(Primer::SpinnerComponent.new) %>
```

Before

image

After

image

Closes #200

@changeset-bot
Copy link

changeset-bot bot commented Oct 23, 2020

🦋 Changeset detected

Latest commit: 5709e7a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@primer/gatsby-theme-doctocat Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Oct 23, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

doctocat – ./

🔍 Inspect: https://vercel.com/primer/doctocat/7amR94d5iunr2ETZqBits1n8ND37
✅ Preview: https://doctocat-git-erb-syntax-primer.vercel.app

gatsby-theme-primer-example – ./

🔍 Inspect: https://vercel.com/primer/gatsby-theme-primer-example/4QGkwF2EbYdxkexZynaQ8EQkUd9a
✅ Preview: https://gatsby-theme-primer-example-git-erb-syntax-primer.vercel.app

@colebemis
Copy link
Contributor Author

Looks like this is working in the Primer ViewComponents docs for one-line examples:

image

...but it has a hard time with multi-line examples:

image

@colebemis
Copy link
Contributor Author

I filed an issue in the prism repo to report the bug described in my previous comment: PrismJS/prism#2602

@manuelpuyol
Copy link
Contributor

@colebemis any updates here?

@colebemis
Copy link
Contributor Author

@manuelpuyol Sorry, I haven't had time to follow up on this. If you feel comfortable, feel free to take over this PR. Otherwise, I'll revisit this when I have more time.

@manuelpuyol
Copy link
Contributor

manuelpuyol commented Feb 12, 2021

Dug some more and I think I found the problem FormidableLabs/prism-react-renderer#104

@manuelpuyol
Copy link
Contributor

manuelpuyol commented Feb 19, 2021

As an update, my PR FormidableLabs/prism-react-renderer#105 was merged! I'm waiting for prism-react-renderer to publish a new version with the fix.

For it to work properly we have to set up our custom PrismJS, which I did in theme/src/prism.js, but that means that we need to manually setup the languages we want to support. @colebemis mind helping me here how to proceed?

@@ -0,0 +1,74 @@
export default {
Copy link
Contributor

Choose a reason for hiding this comment

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

prism-react-rendered changed the github theme on v1.2.0 and it does not look right:

Before After
image image

So I decided to extract the previous version of the theme into this project to keep the docs consistent (keeping the Before style)

@manuelpuyol manuelpuyol marked this pull request as ready for review February 22, 2021 15:57
@manuelpuyol manuelpuyol self-assigned this Feb 22, 2021
Copy link
Contributor Author

@colebemis colebemis left a comment

Choose a reason for hiding this comment

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

Wow, nice work, @manuelpuyol! Very impressed with your debugging abilities. Thanks for pushing this over the finish line ❤️

Approved ✅ (I can't officially approve because I started the PR 😅)

@colebemis colebemis merged commit afb67b4 into master Feb 22, 2021
@github-actions github-actions bot mentioned this pull request Feb 22, 2021
@manuelpuyol manuelpuyol deleted the erb-syntax branch February 22, 2021 16:39
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.

Add support for ERB syntax highlighting
2 participants