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

Code higlight for the response code blocks #113

Closed
wants to merge 8 commits into from

Conversation

jameszu
Copy link
Contributor

@jameszu jameszu commented Dec 14, 2022

Related #2

The code blocks from chatGPT responses can now be automatically highlighted in the corresponding language.
codeHighlightExample

Thx to @jjroley for the awesome tip : )

Cheers,
James

@wong2
Copy link
Owner

wong2 commented Dec 14, 2022

Hi, is your branch behind the main branch? The project does not use markdown-it anymore

@jameszu
Copy link
Contributor Author

jameszu commented Dec 14, 2022

Ah yes you are right I did not update it. I will see if there are other ways

@wong2
Copy link
Owner

wong2 commented Dec 14, 2022

Does rehype-highlight work for you?

@jameszu
Copy link
Contributor Author

jameszu commented Dec 14, 2022

Almost there, right now it doesn't have that auto detection thing like previous hightlight.js, but it should have one, I will let you know once I got it working : )

@jameszu
Copy link
Contributor Author

jameszu commented Dec 14, 2022

Hi @wong2

It should be all good for now.
A minor issue is that the hightlight.js CSS file has a default padding of 1em, which makes the code blocks look like this.
image
Hope that is not a big issue. I can look into it if you want the code blocks to have the same padding as before .

Cheers

@wong2
Copy link
Owner

wong2 commented Dec 14, 2022

I'd like to remove the padding, you can overwrite it in styles.css

@wong2
Copy link
Owner

wong2 commented Dec 14, 2022

Does the default theme work in dark mode?


.hljs {
padding: 0 !important;
}
Copy link
Owner

Choose a reason for hiding this comment

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

Don't do this, this might affect other elements using this class in the page. Put it inside .chat-gpt-container

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image
Does this looks better?

Copy link
Owner

Choose a reason for hiding this comment

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

that's right

@jameszu
Copy link
Contributor Author

jameszu commented Dec 14, 2022

  1. Padding is now working
  2. Unfortunately, the default CSS does not work well in dark mode.
    I tried to include the dark theme CSS file through an import in the style.css file at @ media (prefers-color-scheme: dark), but esbuild does not support conditional CSS import as for this issue.

One way would be adding all the dark CSS code into the media query for dark mode, but that would include lots of lines of code. 60 lines after prettier formatting.
image
Another way might require change of CSS files as the following:

I'm open to more ideas : )

@wong2
Copy link
Owner

wong2 commented Dec 15, 2022

Hi, I solved the theme problem here: cc92f92

@wong2 wong2 closed this Dec 15, 2022
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.

2 participants