Skip to content

Improve PlaintextSyntaxHighlighter#2560

Merged
gsantner merged 22 commits into
gsantner:masterfrom
guanglinn:common_highlight
Jun 12, 2025
Merged

Improve PlaintextSyntaxHighlighter#2560
gsantner merged 22 commits into
gsantner:masterfrom
guanglinn:common_highlight

Conversation

@guanglinn
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

guanglinn commented Apr 13, 2025

Screenshot ↓

Screenshot_20250418_073016_net.gsantner.markor_test.jpg

@gsantner
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@gsantner
Copy link
Copy Markdown
Owner

Thanks, I did further improvements and fixes (i.e. it was crashing for files that are not one of those py/java/..).

Good enough for getting it in use as first. Good also that its fully app internal for now (no external loading), this allows to further improve (i.e. change the language definition syntax).

@gsantner gsantner merged commit df93f72 into gsantner:master Jun 12, 2025
1 check passed
@guanglinn guanglinn deleted the common_highlight branch September 3, 2025 23:19
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