Skip to content

Improve PlaintextSyntaxHighlighter #2560

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

guanglinn
Copy link
Contributor

@guanglinn guanglinn commented Apr 13, 2025

Make PlaintextSyntaxHighlighter have versatile languages syntax highlight function based on configuration files (JSON), and add several popular language (C, C++, Java, Python) syntax highlight. Which language to be highlighted depends on the plain text file extension.

@guanglinn
Copy link
Contributor Author

guanglinn commented Apr 13, 2025

Screenshot ↓

Screenshot_20250418_073016_net.gsantner.markor_test.jpg

@gsantner
Copy link
Owner

Thank you! Is that json format of some other tool / something generic where other languages can be fetched from?
Or where did you get those from?

@guanglinn
Copy link
Contributor Author

guanglinn commented Apr 14, 2025

I referred to these projects for Markor's current JSON syntax highlighting configuration files.

Their syntax highlighting definitions are advanced and sophisticated, I don't know how to directly use these files, so I just reused some basic regex from these files, such as keywords, variable, string, number, function and comment ...

By the way, I found many text editors use TextMate grammars to highlight. Maybe we can use TextMate grammars for Markor, and if use it, we can directly use these syntax highlighting configuration files.

1. PrismJS

PrismJS syntax highlighting configuration files

2. sora-editor

sora-editor

Using TextMate grammars.

3. Xed-Editor

Xed-Editor syntax highlighting configuration files

Using TextMate grammars.

4. Visual Studio Code

Syntax Highlight Guide

Using TextMate grammars.

@gsantner
Copy link
Owner

gsantner commented Apr 14, 2025

If you feel any is somewhat similar to whats feasible for Markor, feel free to rearrange the json/definition structure.

I asked also because saw the keyword list and what came to my mind were Geany filedefs (https://github.com/geany/geany/blob/master/data/filedefs/filetypes.java)

@guanglinn guanglinn changed the title Add common syntax highlighter Add syntax highlight support for PlaintextSyntaxHighlighter Apr 26, 2025
@guanglinn guanglinn changed the title Add syntax highlight support for PlaintextSyntaxHighlighter Improve PlaintextSyntaxHighlighter Apr 30, 2025
@gsantner gsantner added this to the Markor v2.15 milestone May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants