pbek / QOwnNotes

QOwnNotes is a plain-text file notepad and todo-list manager with Markdown support and Nextcloud / ownCloud integration.
https://www.qownnotes.org/
GNU General Public License v2.0
4.6k stars 409 forks source link

[FEATURE] KSyntaxHighlighting #3078

Open pa-0 opened 1 month ago

pa-0 commented 1 month ago

Is your feature request related to a problem? Please describe.

As far as I know, currently QownNotes syntax highlighting support is hard-coded and not extensible (albeit supporting more than just a few languages). Still, I see a few issues/requests for syntax highlighting support for other languages...

So, I have been thinking about possible solutions or workarounds. This is less of a feature request, and more an attempt to pick the maintainers' brains and get the general temperature of the room:

Describe the solution you'd like

What are your thoughts on KSyntaxHighlighter?


... a stand-alone implementation of the cross-platform Kate editor syntax highlighting engine. It's meant as a building block for text editors as well as for simple highlighted text rendering (e.g. as HTML), supporting both integration with a custom editor as well as a ready-to-use QSyntaxHighlighter sub-class.[^1]


KSyntaxHighlighter overview

Featureful:

Natively supports syntax highlighting for 300+ already defined syntaxes...!!.

Easy integration with apps built on QT framework:

Both C++ and QML API's are already exposed / provided

Actively maintained:

As a standalone (separate from Kate editor) library here

User-Customizable and Extensible:

[^1]: KSyntaxHighlighter's README.md

pbek commented 1 month ago

The main questions that come to mind are:

Edit:

Edit2:

pa-0 commented 1 month ago

Valid points.

The main questions that come to mind are:

pbek commented 1 month ago

What has been the approach up until now for enhancements / new features? Have you been pushing major changes there first and then integrating into QownNotes that way?

Everything that is for general use goes into qmarkdowntextedit (that's why I extracted it as a component from the get-go). Everything that is specific to QOwnNotes goes into QOwnNotes.

And of course I forgot one other point:

pa-0 commented 1 month ago

Still at work, but FYI just came across this so it might be informative/educational at least

vnote implements KSyntaxHighlighter:

pbek commented 1 month ago

Hah, nice. 😉

Btw. @Waqar144, surely has opinions, since he works on kate.

pa-0 commented 1 month ago

I know! When I was researching yesterday, I noticed a shoutout/thank you to him. From what I read on the homepage for kate, I got the distinct impression that they were able to port it to qt6 thanks to him. Pretty awesome how much he contributes to the community.

Waqar144 commented 1 month ago

It is possible but it will be a lot of work. Firstly KSyntaxHighlighting doesnot support qmake so that will need to be figured out first. Also, KSyntaxHighlighting themes are much bigger than the ones in QOwnNotes (which is essentially 5 colors). So QOwnNotes will need to somehow extend its UI to allow modifying those themes. Integerating KSH in the code would be simple I think.

Alternatively, QOwnNotes can be extended so that it takes a list of keywords from a file which allow the users to add more languages without having to modify the code.

Waqar144 commented 1 month ago

Another big blocker would be that KSyntaxHighlighting doesn't support Qt5 at all.

pbek commented 1 month ago

I know! When I was researching yesterday, I noticed a shoutout/thank you to him. From what I read on the homepage for kate, I got the distinct impression that they were able to port it to qt6 thanks to him. Pretty awesome how much he contributes to the community.

Yes, he is pretty awesome! 😉

pbek commented 1 month ago

Another big blocker would be that KSyntaxHighlighting doesn't support Qt5 at all.

Ah, I didn't even think about that on my list!

pa-0 commented 1 month ago

Ahh

Another big blocker would be that KSyntaxHighlighting doesn't support Qt5 at all.

Ah, I didn't even think about that on my list!

AHH, ok. I don't doubt that, @Waqar144, you are the expert here given your involvement on kate. I missed that lack of compatibility when looking at the repo -- Actually, my assumption was that, even if the current build of the syntax highlighting engine doesn't support qt5, the commit history / issues seem to indicate that the syntax highlighting engine has been used in kate for a few years now (before the port to qt6) so getting qt5 compatibility was just a matter of using an earlier release of the engine.

Regardless, taking a step back, what are your personal views on syntax highlighting? In other words, does your vision for the future of QownNotes include syntax highlighting for several languages? many languages? Is it something you care about / would like to see?

If the answer is yes, I think that's something to consider. If its really not at all important to either of you, then maybe best to leave it be for now (at least until some easier approach to implementation is developed or found in the future)?

Personally, I think the user-defined keywords @Waqar144 mentioned sounds like a good solution.

github-actions[bot] commented 6 days ago

This issue is stale because it has been open for 30 days with no activity.