• Stars
    star
    185
  • Rank 208,271 (Top 5 %)
  • Language
    Haskell
  • Created almost 8 years ago
  • Updated 8 months ago

Reviews

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

Repository Details

A Haskell syntax highlighting library with tokenizers derived from KDE syntax highlighting descriptions

skylighting

license CI tests

A Haskell syntax highlighting library with tokenizers derived from KDE XML syntax highlighting descriptions.

A command-line highlighter program, skylighting, is also provided.

This project is divided up into five packages:

  • skylighting-core: this provides KDE XML parsing, data types, and a tokenizer. This includes the core functionality of the skylighting project licensed under the BSD3 license, along with the KDE XML files, some of which are licensed under the LGPL or GPL. This package does not provide any built-in parsers corresponding to the XML descriptions, however. For that, use skylighting.
  • skylighting-format-ansi: this provides formatters for rendering skylighting tokens as colored ANSI text.
  • skylighting-format-blaze-html: this provides formatters for rendering skylighting tokens as HTML, using the blaze-html library.
  • skylighting-format-context: this provides formatters for rendering skylighting tokens as ConTeXt.
  • skylighting-format-latex: this provides formatters for rendering skylighting tokens as LaTeX.
  • skylighting: this exposes the skylighting-core API and ANSI, HTML, ConTeXt, and LaTeX formatters, and also provides bundled Haskell parser modules derived from the XML descriptions in the core package. This package is entirely licensed under the GPL.

Motivation

This library is the successor to highlighting-kate, which had some problems that were difficult to resolve given its architecture.

In highlighting-kate, the XML syntax descriptions were converted into individual parsec parsers, which were then compiled. This made it difficult to handle IncludeRules properly without circular imports. There was also no way to load a syntax description dynamically.

Skylighting, by contrast, parses the XML syntax descriptions into Haskell data structures, which are then interpreted by a "tokenize" function. IncludeRules can now be handled properly, and users can add new syntax descriptions dynamically. It is also now possible to convert .theme files directly into styles.

Skylighting is also faster than highlighting-kate, by a factor of 3 in some cases.

Installing

To install the latest release from Hackage, do

stack install skylighting

or

cabal install skylighting

If you want the command-line tool, set the executable flag using --flag "skylighting:executable" in stack or -fexecutable in cabal.

The release tarball for the skylighting package includes generated files not present in this repository. Building from this repository is a two-step process. In the first step we build the skylighting-core package, which provides a program, skylighting-extract, which reads XML syntax highlighting definitions from the xml directory and writes Haskell source files. In the second we actually build the skylighting package.

Using cabal:

# First, build skylighting-extract
cabal build -fexecutable skylighting-core
# This will print the path of the built executable.
# Replace $EXE with this path in the following steps
# Now, generate the syntax files
cd ../skylighting
$EXE ../skylighting-core/xml
cabal install -fexecutable

Using stack:

stack build --flag skylighting-core:executable skylighting-core
cd skylighting
stack exec skylighting-extract -- ../skylighting-core/xml
cd ..
stack install --flag skylighting:executable

Command-line tool

A command-line executable, skylighting, is installed if the executable cabal flag is set in building.

For help, skylighting --help.

Adding new syntaxes

To compile with additional syntaxes, simply add the syntax definition (XML) file to the xml directory of the skylighting-core package and repeat the bootstrap build described above.

Note that both the library and the executable can dynamically load syntax definitions, so you may not need to compile them in. If you prefer this approach, you can use the skylighting-core package directly which provides the XML files without the generated code produced by the bootstrap process described above.

If the syntax definition you are adding is not already in the KDE repository, please submit it upstream so it can be included there. You can do that here, providing the file (or changes) and a test: https://invent.kde.org/frameworks/syntax-highlighting/-/merge_requests. Here is a sample merge request: https://invent.kde.org/frameworks/syntax-highlighting/-/merge_requests/20/diffs. If creating a proper merge request is too much work, at least submit an issue to https://invent.kde.org/frameworks/syntax-highlighting/-/issues alerting the KDE developers of the availability of a new or changed syntax definition; they can then decide whether to integrate it.

We normally pull changes in syntax definitions from upstream before each release.

License

The skylighting package is licensed under the GPL because some of the XML syntax descriptions from which its tokenizers are generated are GPL-licensed. However, the skylighting-core package, which provides the core types and functions of this project is licensed under the BSD3 license and bundles the GPL-licensed XML files separately.

The KDE project now recommends that new syntax highlighting files be MIT licensed.

References

Kate syntax highlighting documentation: https://docs.kde.org/stable5/en/kate/katepart/highlight.html

Kate highlighting definitions: KDE repository

More Repositories

1

pandoc

Universal markup converter
Haskell
34,313
star
2

gitit

A wiki using HAppS, pandoc, and git
Haskell
2,126
star
3

djot

A light markup language
HTML
1,557
star
4

peg-markdown

An implementation of markdown in C, using a PEG grammar
C
686
star
5

pandocfilters

A python module for writing pandoc filters, with a collection of examples
Python
511
star
6

pandoc-templates

Templates for pandoc, tagged to release
HTML
418
star
7

yst

create static websites from YAML data and string templates
Haskell
373
star
8

texmath

A Haskell library for converting LaTeX math to MathML.
Haskell
291
star
9

pandoc-citeproc

Library and executable for using citeproc with pandoc
Haskell
288
star
10

lunamark

Lua library for conversion between markup formats
C
192
star
11

citeproc

CSL citation processing library in Haskell
Haskell
138
star
12

commonmark-hs

Pure Haskell commonmark parsing library, designed to be flexible and extensible
Haskell
130
star
13

djot.js

JavaScript implementation of djot
TypeScript
120
star
14

highlighting-kate

A syntax highlighting library in Haskell, based on Kate syntax definitions
HTML
109
star
15

cheapskate

Experimental markdown processor in Haskell
HTML
105
star
16

pandoc-types

types for representing structured documents
Haskell
105
star
17

gitit2

A reimplementation of gitit in Yesod
Haskell
94
star
18

lcmark

Flexible CommonMark converter
Lua
54
star
19

doctemplates

Pandoc-compatible templating system
Haskell
49
star
20

zip-archive

Native Haskell library for working with zip archives
Haskell
44
star
21

cmark-hs

Haskell bindings to libcmark commonmark parser
C
43
star
22

djot.lua

Lua parser for the djot light markup language
Lua
39
star
23

typst-hs

Haskell library for parsing and evaluating typst
Haskell
32
star
24

dotvim

My vim configuration
Vim Script
30
star
25

scripts

A collection of small scripts to do various things
Shell
28
star
26

filestore

A versioning file store backed by git, darcs, or mercurial
Haskell
28
star
27

pandoc-website

Source files for pandoc's website
Lua
28
star
28

illuminate

An efficient syntax highlighting library in Haskell, using alex-generated lexers
Haskell
26
star
29

emojis

Haskell library for emojis
Haskell
25
star
30

markdown-peg

A Haskell implementation of markdown using a PEG grammar
Haskell
24
star
31

pandoc-server

Simple server app for pandoc conversions.
Haskell
20
star
32

doclayout

A prettyprinting library designed for laying out plain text documents
Haskell
20
star
33

standalone-html

Incorporates external dependencies into HTML file using data: URI scheme
Haskell
19
star
34

pandoc-tex2svg

Pandoc filter to convert math to SVG using MathJax-node's tex2svg
HTML
19
star
35

cloudlib

tools for keeping a library of books and articles on Amazon's S3 and SimpleDB
Ruby
19
star
36

cmark-lua

Lua bindings to libcmark CommonMark parser
C
17
star
37

HeX

a flexible text macro system
Haskell
17
star
38

djoths

Haskell parser for the djot light markup language
Haskell
17
star
39

unicode-collation

Haskell implementation of the Unicode Collation Algorithm
Haskell
16
star
40

sep-offprint

Creates formatted "offprints" of Stanford Encyclopedia of Philosophy entries.
15
star
41

BayHac2014

Slides for my presentation on pandoc at BayHac2014
TeX
14
star
42

cmarkpdf

Steps towards a PDF renderer for cmark using libharu
C
14
star
43

lunamark-standalone

Standalone version of lunamark (compiled with no library dependencies)
C
12
star
44

commonmarker

Ruby wrapper for libcmark (CommonMark parser)
Ruby
12
star
45

ipynb

Data structures and JSON serializer/deserializer for Jupyter notebooks (.ipynb) format.
Jupyter Notebook
11
star
46

hsb2hs

Preprocessor for inserting literals with binary blobs into Haskell programs.
Haskell
11
star
47

gogar

Computer implementation of Robert Brandom's "game of giving and asking for reasons," from Making It Explicit, chapter 3.
Ruby
10
star
48

emacsd

emacs configuration
Emacs Lisp
9
star
49

hscommonmark

pure Haskell CommonMark parser
Haskell
9
star
50

recaptcha

Haskell library for using the reCAPTCHA service
Haskell
8
star
51

select-meta

Pandoc lua filter for constructing metadata from YAML data sources using queries
Lua
8
star
52

html2cmark

Lua library to convert HTML5 to commonmark
Lua
8
star
53

citeproc-hs-bin

Command-line interface to the citeproc-hs CSL citation processing library
Haskell
8
star
54

grammata

Well-typed system for generating documents in multiple formats
Haskell
7
star
55

hw2gitit

Script to convert haskellwiki pages to a gitit wiki
Haskell
7
star
56

ecstatic

Static website management using tenjin templates and YAML data files
Ruby
7
star
57

hsgit

A higher-level interface to libgit2 functions than hlibgit2
Haskell
6
star
58

trypandoc

Live demo of pandoc
JavaScript
6
star
59

pandoc-highlight

Filter and library for using pandoc with highlighting-kate
Haskell
6
star
60

commonmark-lua

Lua binding to libcmark commonmark parser
Lua
5
star
61

rfc5051

Haskell implementation of RFC5051, simple unicode collation.
Haskell
5
star
62

jgm.github.com

jgm's web pages on github
4
star
63

rocks

luarocks repository
4
star
64

cmark-fuzz-data

A minimal fuzz test suite for cmark created by american fuzzy lop and afl-cmin
3
star
65

GHCUnicodeAlt

Improved version of GHC.Unicode, with benchmarks
Haskell
3
star
66

luacmark

Lua binding to CommonMark
C
2
star
67

typst-symbols

Defines symbols and emoji used in typst
Haskell
2
star