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] Syntax Highlighting #16

Open
mattbisme opened this issue Nov 20, 2023 · 5 comments
Open

[Feature Request] Syntax Highlighting #16

mattbisme opened this issue Nov 20, 2023 · 5 comments

Comments

@mattbisme
Copy link

Just tried out Ollamac for the first time. Wow, is it smooth! I'll never use a browser UI again! Having said that, it would be great to see some syntax highlighting for code blocks, if that's possible.

@kevinhermawan
Copy link
Owner

Hi @mattbisme, thanks! Super glad to hear you're finding it smooth.


About the syntax highlighting, I've been wanting to add that feature since day one. Right now, there isn't a native solution that fits perfectly. There's a workaround using JS, but I'm a bit cautious about how it might affect performance. But, I'm up for experimenting to see how it goes 😃

@mattbisme
Copy link
Author

Right now, there isn't a native solution that fits perfectly.

Is this a Swift issue, or an Ollama issue? I'm surprised that there isn't a Swift native solution. I did notice that Ollama doesn't specify named code blocks when generating in the CLI. That is, instead of starting a code block with something like

```python

it just has the lone tick marks without python. I found that to be a bit strange.

For what it's worth, Safari has hardware accelerated JS. Does that apply to JS used in a Swift app as well? I can't imagine that it's as performant as native Swift, but, if there is really no other option… I assume it be possible to only activate the syntax highlighting when a code block is generated?

@kevinhermawan
Copy link
Owner

I'm surprised that there isn't a Swift native solution

Most Swift code highlighters I've found are JavaScript-based, like Highlight.js. And yes, Ollama also doesn't specify the language in code blocks, likely due to a model limitation.

Does that apply to JS used in a Swift app as well?

Yes, the performance benefits of Apple's JavaScriptCore do apply to JavaScript used within a Swift app.

I assume it be possible to only activate the syntax highlighting when a code block is generated?

Yes, it is indeed possible to activate syntax highlighting only when a code block is generated.


I'm still experimenting with this and also keeping an eye on the performance metrics. It's an ongoing process, but I'm making progress! 😃

@mattbisme
Copy link
Author

And yes, Ollama also doesn't specify the language in code blocks, likely due to a model limitation.

I noticed that when using phind-codellama with Ollama that it does properly specify the language. I'm not sure if that's helpful at this point, since I see that you are already planning for syntax highlighting in v2… but just thought I'd point that out anyway!

@Akeuuh
Copy link

Akeuuh commented Feb 16, 2024

I did tryto add the syntax highlighting, it worked fine but only for swift code since I was using a swift method to do it..

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

3 participants