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

Vendor GitHub css #469

Closed
wants to merge 6 commits into from
Closed

Vendor GitHub css #469

wants to merge 6 commits into from

Conversation

jennybc
Copy link
Member

@jennybc jennybc commented Sep 4, 2024

Fixes #468

The basic approach is to get GitHub's CSS from a more definitive source than the rmarkdown package. Then I have to fix it up a bit to play well with an html template, which we also bring into reprex now.

If you really wanted a faithful preview, there's a GitHub API endpoint that will take markdown and render HTML as GitHub would. But that seems like overkill.

Skimming through the individual commits is probably the easiest way to see what I've tweaked in the files I'm getting from elsewhere.

@jennybc
Copy link
Member Author

jennybc commented Sep 4, 2024

Some before and afters in RStudio

CRAN reprex (so before this PR), RStudio, dark mode

Screenshot 2024-09-03 at 9 49 56 PM

With this PR, RStudio, dark mode

Screenshot 2024-09-03 at 9 52 16 PM

@jennybc
Copy link
Member Author

jennybc commented Sep 4, 2024

Some before and afters in RStudio

CRAN reprex (so before this PR), RStudio, light mode

Screenshot 2024-09-03 at 10 14 59 PM

With this PR, RStudio, light mode

Screenshot 2024-09-03 at 9 51 53 PM

@jennybc
Copy link
Member Author

jennybc commented Sep 4, 2024

Some before and afters in Positron, light mode (dark mode is shown elsewhere)

CRAN reprex (so before this PR), Positron, light mode

Screenshot 2024-09-03 at 9 48 29 PM

With this PR, Positron, light mode

Screenshot 2024-09-03 at 9 42 52 PM

@jennybc jennybc marked this pull request as ready for review September 4, 2024 05:09
@jennybc jennybc requested a review from hadley September 4, 2024 05:09
@@ -63,3 +63,12 @@ newline <- function(x) paste0(x, "\n")
is_testing <- function() {
identical(Sys.getenv("TESTTHAT"), "true")
}

is_dark_mode <- function() {
if (rstudioapi::isAvailable() && rstudioapi::hasFun("getThemeInfo")) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Once posit-dev/positron#2986 is handled, the full glory of this PR will apply in Positron.

theme_info <- rstudioapi::getThemeInfo()
theme_info$dark
} else {
FALSE
Copy link
Member Author

Choose a reason for hiding this comment

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

Until posit-dev/positron#2986 happens, Positron will always get reprex previews in light mode, but this is still an improvement over what's happening now.

Before this PR:

Screenshot 2024-09-03 at 9 47 59 PM

After this PR:

Screenshot 2024-09-03 at 9 46 47 PM

Comment on lines +3 to +5
:root {
--bg-color: #0d1117;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I added this. (Ditto in github-light.css.)

-webkit-text-size-adjust: 100%;
margin: 0;
color: #e6edf3;
background-color: var(--bg-color);
Copy link
Member Author

Choose a reason for hiding this comment

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

Changed this to a variable. (Ditto in github-dark.css.)

max-width: 980px;
margin: 0 auto;
padding: 45px;
padding-top: 15px;
Copy link
Member Author

Choose a reason for hiding this comment

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

Some new padding at the top.


<body>

<div class="markdown-body">
Copy link
Member Author

Choose a reason for hiding this comment

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

New div because markdown-body that is the main class that GitHub's CSS deals with.

@hadley
Copy link
Member

hadley commented Sep 4, 2024

In your examples e.g. "With this PR, Positron, light mode", it looks like syntax highlighting is missing?

@jennybc
Copy link
Member Author

jennybc commented Sep 4, 2024

In your examples e.g. "With this PR, Positron, light mode", it looks like syntax highlighting is missing?

Yeah, I had noticed that as well. Working on it. So far without much success, but presumably solvable.

@jennybc
Copy link
Member Author

jennybc commented Sep 9, 2024

I have (more than) solved the syntax highlighting problem, but lordy was it a journey. I'm closing this PR and will make a new one with a clean history that actually helps tell the story.

@jennybc jennybc closed this Sep 9, 2024
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.

Ensure white background when rendering via reprex:::preview()
2 participants