Syntax highlighting Engine for Structured Text and Code.
aaronpuchert Improve R documentation highlighting
After trying out the highlighting on a larger set of files and reading
parts of the specification again, I've come to the conclusion that there
is room for improvement. The following changes are included:

* Some sections don't support markup, so we highlight them as "names":
  \name, \keyword, \docType and \encoding.
* The \email keyword nominally supports markup inside of it, but it's
  not clear how that actually works, so we highlight it as verbatim.
* We separate R and R-like contexts. The former are actual R code and
  might be executed as such, but the latter will not be executed, and
  might not even be syntactically correct R code. So we don't use R
  highlighting for R-like code, and rather print it as verbatim.
* We now support \verb and \figure which I forgot for some reason in the
  original version.
* We added some markup support inside of R code. Note that because we
  also use R highlighting, the markup only works on the top level.
* Error recovery wasn't any good. When expecting an argument and not
  getting it, we now back off after highlighting whatever comes before
  the next opening brace. Otherwise it's just to noisy when writing
  code.  We also highlight extra spaces before `{` as erroneous.
* Spell checking makes no sense for R source, item names and errors.

Reviewers: cullmann, dhaumann

Reviewed By: dhaumann

Subscribers: kwrite-devel, kde-frameworks-devel, #framework_syntax_highlighting

Tags: #kate, #frameworks

Differential Revision:
Latest commit 445a3e9 Oct 20, 2018

Syntax Highlighting

Syntax highlighting engine for Kate syntax definitions


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.

Syntax Definition Files

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

More than 250 syntax definition files are included, additional ones are picked up from the file system if present, so you can easily extend this by application-specific syntax definitions for example.

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.