Skip to content

Improve syntax highlighting #651

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

Merged
merged 3 commits into from
Feb 7, 2025
Merged

Conversation

RealOrangeOne
Copy link
Member

Fixes #530

This PR makes 2 main changes:

  • Dynamically generate the syntax highlighting styles, so it's clear where they came from.
  • Use a better theme with better contrast
  • Add a background to inline highlight elements so they're more distinct from the rest of the text
Images

image

image

@RealOrangeOne RealOrangeOne requested review from WillB97 and a team December 10, 2024 23:05
Copy link
Member

@PeterJCLaw PeterJCLaw left a comment

Choose a reason for hiding this comment

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

Some thoughts with an infra-y hat on. (Note also this appears to be broken in CI)

Comment on lines +37 to +40
task :styles => [:dependencies] do
highlight_css = `bundle exec rougify style github`.strip()
File.write("_sass/_syntax-highlighting.scss", highlight_css)
end
Copy link
Member

Choose a reason for hiding this comment

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

Dynamically generate the syntax highlighting styles, so it's clear where they came from.

I'm not sure this makes it any clearer where the styles come from? Having a comment in the file or something might be an alternative (and would avoid additional compile-time overhead). Even if we also provide the command which generates the file and validate in CI that the file matches that command (the validate-generated-files action can help with the latter)

Copy link
Member Author

Choose a reason for hiding this comment

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

The question is, where did the current file come from? It's hard to tell. No need for that if it's generated.

Copy link
Member

@PeterJCLaw PeterJCLaw Dec 12, 2024

Choose a reason for hiding this comment

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

Somewhat, though a comment at the top of the file like:

/* This file was generated by running .... */

Feels like it'd be at least as good?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, for the sake of source attribution alone, that's functionally the same. But this way, there's no longer a generated file committed into the repository, since it can be easily generated automatically at build time.

Copy link
Contributor

@WillB97 WillB97 left a comment

Choose a reason for hiding this comment

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

Great improvement, could you what colour is used for comment lines.

@RealOrangeOne
Copy link
Member Author

@WillB97 contrast looks pretty good for comments:

image

It's included in the main bundle

This comment was marked as off-topic.

@RealOrangeOne RealOrangeOne merged commit dbdc08c into main Feb 7, 2025
6 checks passed
@RealOrangeOne RealOrangeOne deleted the improve-syntax-highlighting branch February 7, 2025 17:52
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.

Update theme for inline code and code blocks
4 participants