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

code highlight

Open yesmeck opened this issue 2 years ago • 5 comments

It appears that ChatGPT returns a markdown format. Using a markdown rendering library would make the results more readable.

yesmeck avatar Dec 04 '22 16:12 yesmeck

That's definitely in the TODO

wong2 avatar Dec 05 '22 02:12 wong2

Hi there, I managed to get the CSS code highlighted but not the other languages : (

CSS code highlight

Here is the response from the API, as you can see it includes CSS after ```

CSS code response

It turns out the chatgpt API only response ``` without the language identifier for language like js, python, java and etc. The following screenshot shows part of the response when asking "blinking effect in javascript" jscode response

Shall I create a PR or shall we wait and see if anyone else has a better idea on code highlights? Cheers : )

jameszu avatar Dec 09 '22 09:12 jameszu

I'm curious about your current approach

wong2 avatar Dec 09 '22 09:12 wong2

Added the highlightjs css file and used the code from markdown-it documentation as the following https://markdown-it.github.io/markdown-it/ highlightjs code

jameszu avatar Dec 09 '22 09:12 jameszu

You could tryhljs.highlightAuto()

jjroley avatar Dec 13 '22 19:12 jjroley