-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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 line numbers to prismjs plugin #5821
Add line numbers to prismjs plugin #5821
Conversation
4baa2ef
to
905f7bc
Compare
Deploy preview for using-drupal ready! Built with commit ba1aa0f0a2333902fbec38b071df5e85145ba5f8 |
Deploy preview for using-drupal ready! Built with commit ece4d0d |
Deploy preview for gatsbygram ready! Built with commit ece4d0d |
Deploy preview for gatsbygram ready! Built with commit ba1aa0f0a2333902fbec38b071df5e85145ba5f8 |
Deploy preview for using-drupal ready! Built with commit 4baa2ef621a6e665f33747d18c2077d7c966dc80 |
Deploy preview for gatsbygram ready! Built with commit 4baa2ef621a6e665f33747d18c2077d7c966dc80 |
8a780a5
to
92d361c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh good stuff @phacks, thanks. I tried this on the using-remark
example and the code blocks were overlapping the line numbers.
Is that something that can be fixed?
Another thought.. This PR enables or disables line numbering for a whole site. It might be useful to specify line number for individual blocks, and also the starting line number for a block. I'm not sure what the best way to do that, maybe similarly to the line highlighting syntax? Number lines, starting from 1:
Number lines, starting from 5:
Thoughts? |
Hi @m-allanson! Thanks for the feedback. I’ll be looking into the layout issues and the possible enhancements, hopefully in the next few days 😊 |
53d8452
to
a2a308e
Compare
I fixed the issue on The issue was caused by this padding overwriting the a2a308e#diff-2e101cb7175492ace9066869ab398490L135 Removing it didn’t impact the code block style, so I went with it — what do you think? |
a2a308e
to
fe303b4
Compare
@phacks this is something I introduced and need to fix! Sorry for disturbance |
fe303b4
to
cea7660
Compare
@pieh It’s fixed! Many thanks 😊 |
Just tried to rebase to master and it broke the code blocks layout again… Back to the drawing board! |
cea7660
to
44d8463
Compare
1c905f5
to
1512bbd
Compare
ae322e4
to
beff9ea
Compare
@m-allanson Fixed, thanks! I think I made a mistake somewhere while migrating the branch to |
@m-allanson @KyleAMathews Hi! Small reminder that I updated my PR and it should be ready to go! Thanks 😊 |
@m-allanson @KyleAMathews Hi! This PR should be ready for you to review and merge, many thanks! |
Thanks for the reminders @phacks, sorry you had to wait so long on another review for this. I ran through another check, and generally things look good 👍 However, I noticed one issue that will need fixing. It seems that this change adds extra padding around all code blocks, which it shouldn't do. Here's a couple of screenshots with this PR on the left, and the currently live example site on the right: It seems there's extra padding on all sides of the code blocks. Could you fix that up to match the padding on the live example site? Apologies in advance if this is an annoying CSS specificity thing! Hopefully fixing this will remove some of that large gap to the left of the line-numbers which should look a bit neater too. Please drop any questions here if you have them, I'll endeavor to get to them more quickly this time 😅 |
@m-allanson @KyleAMathews How did I miss that 😅Should be better now, as you can see: |
Deploy preview for using-postcss-sass failed. Built with commit ece4d0d https://app.netlify.com/sites/using-postcss-sass/deploys/5b72ce87c6aed62d422b61f3 |
53eae6e
to
a5cc869
Compare
Deploy preview for gatsbyjs failed. Built with commit 53eae6e1667ed48cdb5160dce6520f5a491b24f1 https://app.netlify.com/sites/gatsbyjs/deploys/5b61d3eac9659221ab5dfd3e |
Deploy preview for gatsbyjs failed. Built with commit ece4d0d https://app.netlify.com/sites/gatsbyjs/deploys/5b72ce86c6aed62d422b61e7 |
@m-allanson @KyleAMathews Sorry if I come off as a little bit pushy — do you think you can have another look (and hopefully the last one!) at this PR, now that I fixed the CSS padding problem? Many thanks! 😊 |
Hey @phacks, don't worry that's not pushy, it's good to get reminders sometimes! I want to get back to this as soon as I can, but it's looking like that'll be early next week. Sorry for the delay and thanks again for your patience. |
* master: (597 commits) Add a site(https://mojaave.com) to showcase list (gatsbyjs#7275) feat: create a doc for open source pair programming sessions (gatsbyjs#7266) [docs] Add video lesson to the StaticQuery docs (gatsbyjs#7249) [v2] docs - update page query docs (gatsbyjs#7285) [v2] docs "Styling" overview (gatsbyjs#7288) Remove delay (gatsbyjs#7273) add site (gatsbyjs#7291) Adding new site to the showcase. (gatsbyjs#7281) chore(release): Publish initial webpack externals support (gatsbyjs#7245) add missing package dependencies (gatsbyjs#7259) add: custom configuration overview (gatsbyjs#7231): tutorial part four updates (gatsbyjs#7240) [www] Fix showcase search, checkbox styles (gatsbyjs#7014) (gatsbyjs#6584): Restructure plugin overview and plugin authoring pages (gatsbyjs#7229) Use Hubspot form for email subscription (gatsbyjs#7233) Adding bootstrap CV starter (gatsbyjs#7207) Stub Articles and new names (gatsbyjs#7200) Improve readability of verbose logging code in wordpress source plugin (gatsbyjs#7146) Update hash link to scroll to right section of page (gatsbyjs#7161) ...
Deploy preview for using-contentful failed. Built with commit ece4d0d https://app.netlify.com/sites/using-contentful/deploys/5b72ce89c6aed62d422b6202 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good to go 🎉 thanks @phacks!
I merged the latest changes from master in, broke something, fixed it, added a few more tests and an extra example. Can you check my changes look good to you? If so we can get this merged in :)
@m-allanson Awesome, thanks! Looked through your commits and they are fine by me. You can go ahead and merge the PR |
Holy buckets, @phacks — we just merged your PR to Gatsby! 💪💜 Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
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! |
This has been published as |
* Add line numbers to prismjs plugin * Fix line numbers with line highlighting layout problems * Scope line numbering by code block, add start index * Fix line numbering problem in using-remark example * Add <gatsby-remark-prismjs>/add-line-numbers.js to gitignore * Fix oversized padding around code blocks * Run missed tests and add a few more * Make it easier to read generated code string * Use plain old string concatenation instead * Add one more snapshot test * Add another example * Skip formatting for this block
Hi! First time contributor, please feel free to tell me how I can improve the PR 😊
This PR adds the ability to show line numbers for code blocs using the PrismJS line number plugin.
See example:
This relates to the issue #5775.
Oops, just realized that it didn’t work well with highlighted lines, I’ll try to take another look at this soon!Edit: fixed! 🎉