Recent Commits
Commit | Author | Details | Committed | ||||
---|---|---|---|---|---|---|---|
1b294c9db28d | l10n daemon script | GIT_SILENT Upgrade ECM and KF5 version requirements for 5.71.0 release. | Jun 6 2020 | ||||
ebb2a2da0486 | nibags/cullmann | Update Raku extensions in Markdown blocks | May 28 2020 | ||||
70014ab33b16 | nibags/cullmann | Raku: fix fenced code blocks in Markdown | May 28 2020 | ||||
960aaca0f3eb | D28235 | apol | Add a simpler example | May 22 2020 | |||
78d207f24e43 | nibags/cullmann | Add collaboration guide in README | May 20 2020 | ||||
67e15e0fda0d | Juan Francisco Cantero Hurtado/nibags | Fixes suggested by ngonzalez: - raku.xml: - Increase version to 2… | May 20 2020 | ||||
b3574c3117f9 | mlaurent | GIT_SILENT: we don't use phabricator anymore | May 19 2020 | ||||
f804af905ef3 | D29735 | cullmann | Assign "Identifier" attribute to opening double quote instead of "Comment" | May 15 2020 | |||
b07ba52465e5 | l10n daemon script | GIT_SILENT Upgrade KF5 version to 5.71.0. | May 9 2020 | ||||
1e8466029c82 | D29354 | nibags/cullmann | Bash: fix comments after escapes | May 9 2020 | |||
0b6c88cfc167 | D29521 | nibags/cullmann | LaTeX: fix folding in \end{...} and in regions markers BEGIN-END | May 9 2020 | |||
12bcfcb28f61 | l10n daemon script | GIT_SILENT Upgrade ECM and KF5 version requirements for 5.70.0 release. | May 2 2020 | ||||
ff67bbbeff62 | pino | debchangelog: add Groovy Gorilla | Apr 26 2020 | ||||
7f4a425340cb | cullmann | fix unit test refs | Apr 25 2020 | ||||
559cda73cf57 | D28870 | cullmann | Updated test file for Logtalk syntax highlighting | Apr 25 2020 |
README.md
Syntax Highlighting
Syntax highlighting engine for Kate syntax definitions
Table of contents
- [Introduction](#introduction)
- [Syntax Definition Files](#syntax-definition-files)
- [Out of scope](#out-of-scope)
- [Build it](#build-it)
- [How to contribute](#how-to-contribute)
- [Adding unit tests for a syntax definition](#adding-unit-tests-for-a-syntax-definition)
- [Report bug or help to fix them](#report-bug-or-help-to-fix-them)
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.
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 definiton 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 <a href="https://flathub.org/apps/details/org.kde.kate">Kate's Flatpak package</a> | $HOME/.var/app/org.kde.kate/data/org.kde.syntax-highlighting/syntax/ |
For <a href="https://snapcraft.io/kate">Kate's Snap package</a> | $HOME/snap/kate/current/.local/share/org.kde.syntax-highlighting/syntax/ |
On Windows® | %USERPROFILE%\AppData\Local\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 definiton XML files. Use the command validatehl.sh mySyntax.xml.
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.
Build it
- Create and change into a build directory. Usually, a folder called build is created inside the syntax-highlighting source directory.
`bash mkdir <build-directory> cd <build-directory> `
- Run the configure process with *cmake* and compile:
`bash cmake <source-directory> 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 ...).
- To run tests:
`bash 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"](#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.
What you should know before working with syntax definition files and sending a patch
- If you are modifying an existing syntax definition XML file, you must increase the version number of the language.
- The KSyntaxHighlighting framework is under MIT license. Ideally, use MIT license for your contributions, including new XML files.
- Do not use hard colors, as they may not look good or be illegible in some color themes. Prefer to use the default color styles.
For more information, see:
- Important: add test files, these are found in autotests/input/. If you are going to add a new syntax XML file, create a new test file; if you are going to modify a XML file, adds examples to existing test files.
Then, it is necessary to generate and update the files in autotests/folding/, autotests/html/ and autotests/reference/, which must be included in the patches. The instructions are in the [next section](#adding-unit-tests-for-a-syntax-definition).
Adding unit tests for a syntax definition
- Add an input file into the autotests/input/ folder, lets call it test.<language-extension>.
- 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.
- 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.
- Inspect the outputs found in your binary directory autotests/folding.out/, autotests/html.output/ and autotests/output/.
- 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/.
- 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.