• Stars
    star
    128
  • Rank 281,044 (Top 6 %)
  • Language
    HTML
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Syntax highlighting Engine for Structured Text and Code.

Syntax Highlighting

Syntax highlighting engine for Kate syntax definitions

Table of contents

  1. Introduction
  2. Out of scope
  3. Syntax definition files
  4. Color theme files
  5. Build it
  6. How to contribute
  7. Report bug or help to fix them
  8. Updating the syntax & themes pages of the kate-editor.org website

Introduction

This is a stand-alone implementation of the Kate 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.

Besides a C++ API, a [QML API](@ref qml_api) is also provided.

Out of scope

To not turn this into yet another text editor, the following things are considered out of scope:

  • code folding, beyond providing folding range information
  • auto completion
  • spell checking
  • user interface for configuration
  • management of text buffers or documents

If you need any of this, check out KTextEditor.

Syntax definition files

This library uses Kate syntax definition files for the actual highlighting, the file format is documented here.

More than 300 syntax definition files are included, that are located in data/syntax/ and have the .xml extension. Additional ones are picked up from the file system if present, so you can easily extend this by application-specific syntax definitions for example.

To install or test a syntax definition file locally, place it in org.kde.syntax-highlighting/syntax/, which is located in your user directory. Usually it is:

For local user $HOME/.local/share/org.kde.syntax-highlighting/syntax/
For Flatpak packages $HOME/.var/app/package-name/data/org.kde.syntax-highlighting/syntax/
For Snap packages $HOME/snap/package-name/current/.local/share/org.kde.syntax-highlighting/syntax/
On Windows® %USERPROFILE%\AppData\Local\org.kde.syntax-highlighting\syntax\
On macOS® $HOME/Library/Application Support/org.kde.syntax-highlighting/syntax/

For more details, see "The Highlight Definition XML Format" (Working with Syntax Highlighting, KDE Documentation).

Also, in data/schema/ there is a script to validate the syntax definition XML files. Use the command validatehl.sh mySyntax.xml.

Color theme files

This library includes the color themes, which are documented here.

The color theme files use the JSON format and are located in data/themes/ with the .theme extension. Additional ones are also picked up from the file system if present, in the org.kde.syntax-highlighting/themes/ folder of your user directory, allowing you to easily add custom color theme files. This location is the same as shown in the table of the previous section, replacing the syntax folder with themes. For more details, see "The Color Themes JSON Format" (Working with Color Themes, KDE Documentation).

The KTextEditor library (used by Kate, Kile and KDevelop, for example) provides a user interface for editing and creating KSyntaxHighlighting color themes, including a tool for exporting and importing the JSON theme files.

Note that in KDE text editors, the KSyntaxHighlighting color themes are used since KDE Frameworks 5.75, released on October 10, 2020. Previously, Kate's color schemes (KConfig based schema config) were used and are now deprecated. The tool utils/schema-converter/ and the script utils/kateschema_to_theme_converter.py convert the old Kate schemas to KSyntaxHighlighting themes.

Also see "Submit a KSyntaxHighlighting Color Theme" (Kate Editor Website).

Build it

  1. Create and change into a build directory. Usually, a folder called build is created inside the syntax-highlighting source directory.

    mkdir <build-directory>
    cd <build-directory>
  2. Run the configure process with cmake and compile:

    cmake <source-directory>
    make

    For example:

    git clone [email protected]:frameworks/syntax-highlighting.git
    mkdir ./syntax-highlighting/build
    cd ./syntax-highlighting/build
    cmake ../
    make

    For more details see "Building Kate from Sources on Linux" (Kate Editor Website).

    NOTE: If running cmake shows an error related to your version of KDE Frameworks, you edit the CMakeLists.txt file in the line find_package(ECM 5.XX.X ...).

  3. To run tests:

    make test

    The tests are located in the autotests directory. This command can be used to check changes to units test after modifying some syntax definition file. To add a unit test or update the references, see the section "Adding unit tests for a syntax definition".

How to contribute

KDE uses a GitLab instance at invent.kde.org for code review. The official repository of the KSyntaxHighlighting framework is here.

All the necessary information to send contributions is here.

Licensing

Contributions to KSyntaxHighlighting shall be licensed under MIT.

All files shall contain a proper "SPDX-License-Identifier: MIT" identifier inside a header like:

/*
    SPDX-FileCopyrightText: 2020 Christoph Cullmann <[email protected]>

    SPDX-License-Identifier: MIT
*/

Tips for contributing to syntax definition files

Adding unit tests for a syntax definition

  1. Add an input file into the autotests/input/ folder, lets call it test.<language-extension>.

  2. If the file extension is not sufficient to trigger the right syntax definition, you can add an second file testname.<language-extension>.syntax that contains the syntax definition name to enforce the use of the right extension.

  3. Do make && make test.

    Note that after adding or modifying something in <source-directory>/autotests/input/, an error will be showed when running make test, because the references in the source directory do not match the ones now generated.

  4. Inspect the outputs found in your binary directory autotests/folding.out/, autotests/html.output/ and autotests/output/.

  5. If OK, run in the binary folder ./autotests/update-reference-data.sh to copy the results to the right location. That script updates the references in the source directory in autotest/folding/, autotest/html/ and autotest/reference/.

  6. Add the result references after the copying to the git.

Report bug or help to fix them

KDE uses Bugzilla to management of bugs at bugs.kde.org. You can see the bugs reported of frameworks-syntax-highlighting here.

Also, you can report a bug here.

However, some users often report bugs related to syntax highlighting in kate/syntax and kile/editor.

Updating the syntax & themes pages of the kate-editor.org website

To update the kate-editor.org/syntax and kate-editor.org/themes websites including the update site & all linked examples/files, please run after successful build & test the following make target:

make update_kate_editor_org

This will clone the kate-editor.org git from invent.kde.org into kate-editor-org inside the build directory and update the needed things.

You can afterwards step into kate-editor-org and commit & push the change after review.

The kate-editor.org webserver will update itself periodically from the repository on invent.kde.org.

More Repositories

1

krita

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
5,850
star
2

ghostwriter

Text editor for Markdown
C++
4,121
star
3

heaptrack

A heap memory profiler for Linux
C++
3,212
star
4

kdenlive

Free and open source video editor, based on MLT Framework and KDE Frameworks 5
C++
2,439
star
5

kdeconnect-kde

Multi-platform app that allows your devices to communicate
C++
2,171
star
6

latte-dock

Replacement dock for Plasma desktops, providing an elegant and intuitive experience for your tasks and plasmoids
C++
1,474
star
7

rust-qt-binding-generator

Generate bindings to use Rust code in Qt and QML
Rust
788
star
8

kdeconnect-android

Native Android port of the KDE Connect Qt app
Java
774
star
9

plasma-desktop

Plasma for the Desktop
C++
692
star
10

okular

KDE document viewer
C++
632
star
11

clazy

Qt-oriented static code analyzer based on the Clang framework
C++
609
star
12

kate

Modern text editor built on the KDE Frameworks and Qt
C++
558
star
13

digikam

digiKam is an advanced open-source digital photo management application that runs on Linux, Windows, and MacOS. The application provides a comprehensive set of tools for importing, managing, editing, and sharing photos and raw files.
C++
507
star
14

kdevelop

Cross-platform IDE for C, C++, Python, QML/JavaScript and PHP
C++
434
star
15

kwin

Easy to use, but flexible, X Window Manager and Wayland Compositor
C++
427
star
16

konsole

Terminal emulator by KDE
C++
418
star
17

dolphin

File manager by KDE
C++
400
star
18

kdiff3

Utility for comparing and merging files and directories
C++
332
star
19

yakuake

Drop-down terminal emulator based on Konsole technologies
C++
330
star
20

kcachegrind

GUI to profilers such as Valgrind
C++
326
star
21

falkon

Cross-platform Qt-based web browser
C++
324
star
22

kdeconnect-ios

Native iOS port of KDE Connect
Swift
313
star
23

snoretoast

Command-line application capable of creating Windows Toast notifications
C++
280
star
24

massif-visualizer

Visualizer for Valgrind Massif data files
C++
267
star
25

elisa

Simple music player aiming to provide a nice experience for its users
C++
238
star
26

breeze-icons

Breeze icon theme.
C++
217
star
27

kirigami

A QtQuick based components set
QML
208
star
28

breeze

Artwork, styles and assets for the Breeze visual style for the Plasma Desktop
C++
192
star
29

plasma-workspace

Various components needed to run a Plasma-based environment
C++
191
star
30

kstars

Desktop Planetarium
C++
191
star
31

spectacle

Screenshot capture utility
C++
179
star
32

labplot

LabPlot is a FREE, open source and cross-platform Data Visualization and Analysis software accessible to everyone.
C++
177
star
33

amarok

Powerful music player that lets you rediscover your music
C++
153
star
34

kube

Modern groupware client based on QtQuick and Sink
C++
152
star
35

calligra

Office and graphic art suite by KDE
C++
144
star
36

khtml

KHtml
136
star
37

plasma-mobile

Plasma shell for mobile devices
QML
132
star
38

plasma-framework

Plasma library and runtime components
C++
130
star
39

snorenotify

Multi-platform Qt notification framework
C++
128
star
40

krusader

Advanced twin panel (commander style) file manager
C++
123
star
41

k3b

Full-featured CD/DVD/Blu-ray burning and ripping application
C++
118
star
42

marble

Virtual Globe and World Atlas that you can use to learn more about the Earth
C++
117
star
43

kmymoney

Personal finance manager
C++
114
star
44

neochat

A client for matrix, the decentralized communication protocol
C
113
star
45

extra-cmake-modules

Extra modules and scripts for CMake.
CMake
113
star
46

umbrello

GUI for diagramming Unified Modelling Language (UML)
C++
105
star
47

plasma-workspace-wallpapers

Wallpapers for Plasma Workspaces
CMake
103
star
48

plasma-browser-integration

Components necessary to integrate browsers into the Plasma Desktop
JavaScript
100
star
49

gwenview

Image viewer by KDE
C++
93
star
50

kdeplasma-addons

All kind of add-ons to improve your Plasma experience
C++
85
star
51

okteta

Hex editor for viewing and editing the raw data of files
C++
85
star
52

plasma-bigscreen

Plasma shell for TVs
QML
84
star
53

kalendar

A calendar application using Akonadi to sync with external services (Nextcloud, GMail, ...)
C++
81
star
54

kio-gdrive

KIO Slave to access Google Drive
C++
80
star
55

wacomtablet

GUI for Wacom Linux drivers that supports different button/pen layout profiles
C++
79
star
56

kleopatra

Certificate manager and GUI for OpenPGP and CMS cryptography
C++
79
star
57

kolourpaint

Easy-to-use paint program
C++
78
star
58

qca

Qt Cryptographic Architecture — straightforward cross-platform crypto API
C++
76
star
59

discover

KDE and Plasma resources management GUI
C++
75
star
60

ark

File archiver by KDE
C++
72
star
61

qqc2-desktop-style

Qt Quick Controls 2: Desktop Style
QML
71
star
62

krunner

Framework for providing different actions given a string query.
C++
69
star
63

kile

Integrated LaTeX Editing Environment
HTML
69
star
64

breeze-gtk

Breeze widget theme for GTK 2 and 3
SCSS
66
star
65

liquidshell

Basic desktop shell using QtWidgets
C++
65
star
66

ring-kde

Qt-based Ring communication framework (www.ring.cx) client
QML
64
star
67

ktexteditor

KTextEditor Framework
C++
64
star
68

ktorrent

Powerful BitTorrent client
C++
64
star
69

konqueror

Web browser and Swiss Army knife for any kind of file management and previewing
C++
63
star
70

ktouch

Touch Typing Tutor
C++
61
star
71

kio

KIO
C++
60
star
72

kmail

State-of-the-art feature-rich email client that supports many protocols
C++
60
star
73

vvave

Multi-platform media player
C++
58
star
74

baloo

Baloo is a framework for searching and managing metadata.
C++
56
star
75

craft

Open source meta build system and package manager
Python
55
star
76

haruna

Open source video player built with Qt/QML and libmpv.
QML
53
star
77

kid3

Efficient audio tagger that supports a large variety of file formats
C++
52
star
78

partitionmanager

Manage the disk devices, partitions and file systems on your computer
C++
51
star
79

cantor

Front end to powerful mathematics and statistics packages
Jupyter Notebook
48
star
80

kscreen

KDE's screen management software
C++
46
star
81

plasma-vault

Plasma applet and services for creating encrypted vaults
C++
46
star
82

xdg-desktop-portal-kde

A backend implementation for xdg-desktop-portal that is using Qt/KDE
C++
44
star
83

ksshaskpass

ssh-add helper that uses KWallet and KPasswordDialog
C++
44
star
84

kbibtex

An editor for bibliographies used with LaTeX
C++
43
star
85

kwayland

KWayland provides a Qt-style Client and Server library wrapper for the Wayland libraries.
C++
43
star
86

krdc

Remote Desktop Client
C++
42
star
87

konversation

User-friendly and fully-featured IRC client
C++
42
star
88

qtcurve

Style engine for Qt and other toolkits
C++
42
star
89

systemsettings

Control center to configure your Plasma Desktop
C++
42
star
90

akregator

RSS Feed Reader
C++
40
star
91

plasma-nm

Plasma applet written in QML for managing network connections
C++
40
star
92

ksysguard

Resource usage monitor for your computer
C
40
star
93

kdev-rust

KDevelop plugin which provides Rust language support.
C++
39
star
94

plasma-systemmonitor

An interface for monitoring system sensors, process information and other system resources
QML
39
star
95

kjs

KJS
39
star
96

minuet

Free and open-source software for music education
C++
39
star
97

docker-neon

Docker packaging environment for KDE Neon
Ruby
38
star
98

elf-dissector

Tools for inspecting, analyzing and optimizing ELF files
C++
38
star
99

ruqola

KDE client for Rocket Chat
C++
38
star
100

libqgit2

Qt wrapper library around the libgit2 git access library
C++
37
star