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] KSyntaxHighlighting #3078

Open
pa-0 opened this issue Aug 7, 2024 · 12 comments
Open

[FEATURE] KSyntaxHighlighting #3078

pa-0 opened this issue Aug 7, 2024 · 12 comments
Labels
Stale No activity for a while Type: Support

Comments

@pa-0
Copy link

pa-0 commented Aug 7, 2024

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:

  • Syntax Definition files in XML format and stored in user's home/profile directory so new language support can be added simply by dropping new definition files in that same folder.
  • Color themes also customizable via user-defined config files stored in the JSON format.

Footnotes

  1. KSyntaxHighlighter's README.md

@pbek
Copy link
Owner

pbek commented Aug 7, 2024

The main questions that come to mind are:

Edit:

  • The old highlighting schemes need to work

Edit2:

  • Qt5 and Qt6 support

@pa-0
Copy link
Author

pa-0 commented Aug 7, 2024

Valid points.

The main questions that come to mind are:

  • Does it build with qmake and CMake?
    Cmake: definitely - qmake: I'll take a look at the logs and find out.

  • Does it also build on Windows, macOS, FreeBSD, ...?
    Yes to all 3 (in addiiton to android apparently)

  • How can all the features of the highlighter of https://github.com/pbek/qmarkdowntextedit/ and the quirks added by QOwnNotes be integrated?
    Kate's implementation could be revealing, at least for the editor implementation. After work today, I will see if I can find any qt-based apps that have implemented it in markdown preview pane - though I believe kate has an extension that does that as well. It couldn't hurt to review the source of those apps at least as a starting point to get some idea of best approach. As far as quirks, that will also require a follow-up.

  • Should it be integrated into https://github.com/pbek/qmarkdowntextedit/ (which would be a major external dependency) or QOwnNotes directly (which also would be a major external dependency)?

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?

@pbek
Copy link
Owner

pbek commented Aug 7, 2024

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:

  • The old highlighting schemes need to work

@pa-0
Copy link
Author

pa-0 commented Aug 7, 2024

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

vnote implements KSyntaxHighlighter:

  • looks like it builds with cmake primarily though I did see some references to qmake during a very cursory review while on my lunch break
  • cross-platform: mac (dmg) / linux (appimage) /windows (exe/zip)
  • Built on qt5/c++ (for Win7 compatibility) and qt6 /c++ note-taking application
  • main editor components are hosted at vtextedit (including - i believe - the plain-text editor, wysiwyg markdown editor and markdown preview)
  • .gitmodules for vtextedit:
    [submodule "src/libs/syntax-highlighting"]
      path = libs/syntax-highlighting
      url = https://github.com/vnotex/syntax-highlighting.git
    [submodule "src/libs/hunspell"]
      path = libs/hunspell
      url = https://github.com/vnotex/hunspell.git
    [submodule "src/libs/sonnet"]
      path = libs/sonnet
      url = https://github.com/vnotex/sonnet.git
    ...

@pbek
Copy link
Owner

pbek commented Aug 8, 2024

Hah, nice. 😉

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

@pa-0
Copy link
Author

pa-0 commented Aug 8, 2024

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
Copy link
Contributor

Waqar144 commented Aug 8, 2024

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
Copy link
Contributor

Waqar144 commented Aug 8, 2024

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

@pbek
Copy link
Owner

pbek commented Aug 8, 2024

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
Copy link
Owner

pbek commented Aug 8, 2024

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
Copy link
Author

pa-0 commented Aug 8, 2024

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.

Copy link

github-actions bot commented Sep 8, 2024

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

@github-actions github-actions bot added the Stale No activity for a while label Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale No activity for a while Type: Support
Projects
None yet
Development

No branches or pull requests

3 participants