The markup generated for highlighted syntax is different on my local build and my website running on Github Pages. I’m not very Ruby person, Jekyll is the only piece of software that I use Ruby for. I updated my local githug-pages gem to the latest version to make sure that all the dependencies are running on the same version.
Doesn’t look like you have a Gemfile so it’s entirely possible some of the gems you’re locally using are different versions from GitHub Pages. If you use a Gemfile as instructed here and run Jekyll with bundle exec jekyll serve you should replicate GitHub Pages environment exactly.
Specifically Rouge, which does the syntax highlighting was updated recently so that could explain the difference in markup.
I keep the versions of all the gh-pages dependencies in sync by updating a gem. I run exactly the same versions of all the component. Inconsistency still occurs.
When was the last time GitHub Pages built your site? If it’s been a bit, entirely possible what you’re seeing there is using older versions of Jekyll/Rouge which is why the syntax highlighted blocks have different markup.
I just cloned your repo, used the GitHub Pages gem to build the site and I’m seeing markup like:
For what it’s worth, all of my GitHub Pages built repos all show code blocks like above. I’m thinking if you force a rebuild of your site you’ll see the newer markup that omits the extra <div class="highlight">.
So for whatever reason Rouge 2 is being engaged for you when building locally, and on GitHub Pages it’s using Rouge 1… which makes sense since they haven’t updated yet.
What’s confusing is your Gemfile.lock specifies the older version of Rouge… so not really sure how it’s using 2.
Can’t than you enough for your help and support. I’m not a RUby developer and to be honest with you I installed bundler for a first time in my life yesterday. I need to figure it out why the dependency version is different than the one in my Gemfile. I’ll ask some pals at work for help.
GitHub Pages is now running Rouge 2.2.1, which includes this div. Using v165 or later of the github-pages gem should use this newer version. Definitely recommend a Gemfile. If not, run gem uninstall rouge and select the version that’s not 2.2.1.
Hi @parkr thanks for the info. How can we run gem uninstall rouge and select the version that is not 2.2.1 on github? I understand we can do this locally.
@pawelgrzybek looks like fixing the CSS is the fastest way. Took me about 1 hour of work.
Follow @mmistakes 's instruction to replicate GitHub’s environment and you will see that your local copy will also generate the extra DIV. Alter the CSS to suit your preferred outcome and move on.
As far as CSS changes, what I ended up doing is targeting pre.highlight instead of just .highlight to avoid doubling up on some styling that could be added to div.highlight and pre.highlight.
Of course this is completely dependent on how you’re styling code blocks, but looking at your screenshot above @pawelgrzybek, seems like you have a similar issue as I did… the newer version of Rouge with the duplicate .highlight doubles up the padding.
Using this should remove the extra padding around the border.