chatgpt-google-extension icon indicating copy to clipboard operation
chatgpt-google-extension copied to clipboard

Code higlight for the response code blocks

Open jameszu opened this issue 2 years ago • 8 comments

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

jameszu avatar Dec 14 '22 04:12 jameszu

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

wong2 avatar Dec 14 '22 04:12 wong2

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

jameszu avatar Dec 14 '22 04:12 jameszu

Does rehype-highlight work for you?

wong2 avatar Dec 14 '22 06:12 wong2

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 avatar Dec 14 '22 06:12 jameszu

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

jameszu avatar Dec 14 '22 06:12 jameszu

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

wong2 avatar Dec 14 '22 07:12 wong2

Does the default theme work in dark mode?

wong2 avatar Dec 14 '22 07:12 wong2

  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 : )

jameszu avatar Dec 14 '22 10:12 jameszu

Hi, I solved the theme problem here: https://github.com/wong2/chat-gpt-google-extension/pull/117/commits/cc92f923771a27c227f5736fdcd6d9b7a08a526d

wong2 avatar Dec 15 '22 04:12 wong2