esteinmann / chatgpt-convdown

GNU General Public License v3.0
56 stars 7 forks source link

Add programming language to code fences #1

Closed amundo closed 1 year ago

amundo commented 1 year ago

Awesome plugin, very useful.

I wonder if it would be possible to add programming language annotations to the code fences, so:

function someJS(){ // …etc
```

Would become:

```html
    ```javascript
    function someJS(){ // …etc


This is supported in a lot of markdown libraries, like pandoc, and would result in automatic syntax highlighting. 

I have not looked very hard but it seems like ChatGPT is putting a language name in class somewhere in the code snippets (it must be, to get the highlighting.)

Happy to help with this idea if you think it’s interesting.
esteinmann commented 1 year ago

Thanks for the feedback! Yes that should be possible. Have to investigate an active ChatGPT conversation to find out which tag stores this information. In case you already have a fix in place you are welcome to create a PR

esteinmann commented 1 year ago

I applied your suggestion (with a little help of ChatGPT itself ;)). Only thing I noticed is that ChatGPT will sometimes mark a JavaScript block as "typescript" instead of "javascript". But they should be displayed with the same highlighting by any system knowing both languages as TypeScript is a superset of JavaScript AFAIK.

Will create a new release in a few minutes and submit it to Mozilla

esteinmann commented 1 year ago

This is included in version 3.1 now: https://addons.mozilla.org/nl/firefox/addon/chatgpt-convdown/