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

feature request - code formatting #43

Closed
glinkot opened this issue Apr 11, 2024 · 8 comments
Closed

feature request - code formatting #43

glinkot opened this issue Apr 11, 2024 · 8 comments

Comments

@glinkot
Copy link

glinkot commented Apr 11, 2024

Would be nice to have two features on code (see screenshot from heyGPT, which has been abandoned but has been my go-to until I found pyGPT):

  • Code highlighting
  • The convenience feature where the code appears in a code box, with a 'copy' button at the top.

image

@glinkot
Copy link
Author

glinkot commented Apr 11, 2024

I notice this project which could help with the syntax highlighting:

https://pygments.org/

@szczyglis-dev
Copy link
Owner

Copy to clipboard button added in 2.1.45. Thanks!

Code highlighting coming soon.

@glinkot
Copy link
Author

glinkot commented Apr 11, 2024

Another notable thing - the one I use applies the code highlighting in real time as the text comes through, rather than just once at the end. That's really useful as you watch it spool out.

@glinkot
Copy link
Author

glinkot commented Apr 12, 2024

I downloaded 2.1.46 that mentioned improved code formatting, but I didn't notice differences yet. Thanks so much for looking into it though!

@szczyglis-dev
Copy link
Owner

szczyglis-dev commented Apr 21, 2024

Syntax highlighting added in 2.1.59:

2.1.59 (2024-04-20)

  • Added output renderer: WebEngine/Chromium – with full HTML/CSS/JS support. (Experimental)
  • Added a new option to choose a render engine in Settings -> General -> Rendering engine to select between WebEngine / Chromium mode and the Legacy mode (old, with simple markdown CSS support only - for compatibility reasons and troubleshooting).
  • Added syntax highlighting to code blocks – issue feature request - code formatting #43.
  • Added a new option in Settings -> Layout -> Code syntax highlight to select a highlight theme.
  • Added a new option in Settings -> Context -> Convert lists to paragraphs to enable/disable converting ul and li into p for better copying.
  • Copy to clipboard and regenerate response icons are now visible by default.

@glinkot
Copy link
Author

glinkot commented Apr 21, 2024

This is awesome! Do you think it runs quickly enough that we could apply the highlight after each word or few words as it streams out of the API, rather than once at the end?

@glinkot
Copy link
Author

glinkot commented Apr 21, 2024

Also it would be good to put any unrecognised syntaxes into a monospaced code box rather than leaving the backticks (example of each shown)

image

image

@szczyglis-dev
Copy link
Owner

szczyglis-dev commented Apr 21, 2024

This is awesome! Do you think it runs quickly enough that we could apply the highlight after each word or few words as it streams out of the API, rather than once at the end?

Thanks ;) And yes, real-time formatting in stream mode has just been added in version 2.1.61 (it also works for syntax highlighting).

2.1.61 (2024-04-21)

  • Added real-time HTML formatting of text chunks in stream mode.

Also added default syntax highlighting if no language is provided:

2.1.62 (2024-04-22)

  • Added default lexer for code syntax highlighting if no language provided.

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

No branches or pull requests

2 participants