oae / gnome-shell-pano

Next-gen Clipboard Manager for Gnome Shell
https://extensions.gnome.org/extension/5278/pano/
GNU General Public License v2.0
978 stars 52 forks source link

Overhaul code highlighting #278

Open Totto16 opened 2 months ago

Totto16 commented 2 months ago

Overhaul code highlighting

Description

As described in #271 code highlighting should become optional, so that user need to install an additional package or something similar to make it work.

There are a few options, I'll test all of them and list benefits from them and shortcomings

Overview

We need an option that can do these things:

Our options are:

1. Option

Pros:

Cons:

Feature Table

package name detection many languages markdown output styleable
source-highlight ✔️ ⚠️ ⚠️
pygments ⚠️ ✔️ ✔️ ✔️

Notes

source-highlight:

It can not detect languages without filename or shebang, it also can't tell you, how confident it was (there is a option to infer the language, but it only works on file extensions / shebangs or similar metadata) It can't output to markdown, but to simple html, which would be styleable in some way You can specify custom css or similar things, but it's not that easy, but maybe doable.

pygments(python3-pygments)

It is good at detecting creating languages (like python) but when I tried JS, or HTML or some other ones it failed ... i didn't test 100 files, but it wasn't that good, the one good thing was, that it's better than highlight.js in many cases and the detected languages all seem to look similar, when highlighted. It has support for many many languages, it is easy styleable and can output pango markdown out of the box.

update: after some modification to the detection logic, it seems really stable and robust when working with more than ~ +- 200 characters. The shortcoming of it is, that it has no real relevance value, but we can emulate that, by using that charaacter length. After that it is really good.

2. Option

Pros:

Cons:

3. Option

Pros:

Cons:

Current state

I would focus on option 1, since it's the best choice atm. I tested source-highlight but it's quite bad. So I'll be using pygments(python3-pygments) for now.

TODOs:

optional:

Type of change

Checklist

Totto16 commented 2 months ago

@oae Do you have an auto branch protection rule in some way, if the branch isn't named feat/ (is that even possible) Since I am currently unable to push (it fails with the reason, that this is a protected branch ❓) grafik

oae commented 2 months ago

The first option with pygments sounds good to me too

oae commented 2 months ago

@oae Do you have an auto branch protection rule in some way, if the branch isn't named feat/ (is that even possible) Since I am currently unable to push (it fails with the reason, that this is a protected branch ❓) grafik

I have changed some settings now. Can you try again?

Totto16 commented 2 months ago

The first option with pygments sounds good to me too

@oae Do you have an auto branch protection rule in some way, if the branch isn't named feat/ (is that even possible) Since I am currently unable to push (it fails with the reason, that this is a protected branch ❓) grafik

I have changed some settings now. Can you try again?

Same error, strange, it seems, that I can't push to any branch on this repo, but I could earlier this day 🤔

Edit: indeed, it is fixed ❤️

oae commented 2 months ago

I think it should be fixed now

HearseDev commented 1 month ago

Not really experienced with anything gnome, but was wondering if this would be a viable and much cleaner solution. It could be an optional lib install and also has bindings for js. Or it could be required and could be used as a default text view?(think it might be preinstalled with gnome, not too sure) I am just throwing out an idea, never really worked with anything remotely close to this. https://wiki.gnome.org/Projects/GtkSourceView https://gnome.pages.gitlab.gnome.org/gtksourceview/gtksourceview5/class.PrintCompositor.html

Totto16 commented 1 month ago

Not really experienced with anything gnome, but was wondering if this would be a viable and much cleaner solution. It could be an optional lib install and also has bindings for js. Or it could be required and could be used as a default text view?(think it might be preinstalled with gnome, not too sure) I am just throwing out an idea, never really worked with anything remotely close to this. https://wiki.gnome.org/Projects/GtkSourceView https://gnome.pages.gitlab.gnome.org/gtksourceview/gtksourceview5/class.PrintCompositor.html

I think I saw this in my research, but It isn't half as good as pygments in autodetecting languages and it's ballpark is nearly the same as source-highlight.

It has integrated GTK support, but it's not themeable (at least easily) and it has no "real" autodetection feature, you have to create a widget to get the language, which is not suitable for our purpose 😓

PiotrGrobelak commented 2 weeks ago

Hi @oae and @Totto16, what can I pick up to help you with for the full release of GNOME 46?