Skip to content

Add ayu-highlight.css #1226

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 1 commit into from
Dec 28, 2020
Merged

Conversation

Cldfire
Copy link
Contributor

@Cldfire Cldfire commented Dec 28, 2020

Follow-up to #1221.

I began putting a theme together and thought "hmm, I feel like I've done this before." Turns out... I did! https://github.com/rust-lang/mdBook/blob/master/src/theme/ayu-highlight.css

I copied that CSS into static/ayu-highlight.css and added an exception for it to the .gitignore; if there's a better way to include it, let me know.

Here's what it looks like:

image

Note that a nice, easy way to see what it looks like for a large variety of input is to go to https://highlightjs.org/static/demo/ and replace the default stylesheet with the contents of whatever theme you'd like to test:

Example

image

@jyn514
Copy link
Member

jyn514 commented Dec 28, 2020

I copied that CSS into static/ayu-highlight.css and added an exception for it to the .gitignore; if there's a better way to include it, let me know.

I think that's fine; ideally it would get upstreamed to highlight.js but since it's a single CSS file maintaining it in tree doesn't seem like a burden. Doing fancy git things with subtrees or submodules doesn't seem worth it (and you'd have to have a repo for a single file, which also seems silly).

This looks really good in source mode, which was pretty lacking before. Great job!

Before:
image

After: image

The one thing I would change is that I think you made /// dark green for rustdoc - could you add the same color here?

@jyn514 jyn514 added A-docs-rs-themes Area: CSS themes in docs.rs itself S-waiting-on-author Status: This PR is incomplete or needs to address review comments labels Dec 28, 2020
@Cldfire
Copy link
Contributor Author

Cldfire commented Dec 28, 2020

ideally it would get upstreamed to highlight.js

I agree, that would be neat to do someday. First the theme would need some cleanup and modernization; ayu has changed in the years since I made it for mdbook.

The one thing I would change is that I think you made /// dark green for rustdoc - could you add the same color here?

Unfortunately I don't believe I can. highlight.js doesn't differentiate between doc comments and normal comments when highlighting rust code; they both get the hljs-comment class. This means they have to share a style.

@jyn514
Copy link
Member

jyn514 commented Dec 28, 2020

Oh, that's unfortunate :( ok, this is still great then :)

@jyn514 jyn514 merged commit 9f78c53 into rust-lang:master Dec 28, 2020
@Cldfire Cldfire deleted the add-ayu-highlight-css branch December 28, 2020 16:48
@jyn514 jyn514 added S-waiting-on-deploy This PR is ready to be merged, but is waiting for an admin to have time to deploy it and removed S-waiting-on-author Status: This PR is incomplete or needs to address review comments S-waiting-on-deploy This PR is ready to be merged, but is waiting for an admin to have time to deploy it labels Dec 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs-rs-themes Area: CSS themes in docs.rs itself
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants