• Stars
    star
    101
  • Rank 338,166 (Top 7 %)
  • Language
    Clojure
  • License
    Eclipse Public Li...
  • Created over 9 years ago
  • Updated over 3 years ago

Reviews

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

Repository Details

Syntax highlighting for Clojure source code.

Glow

Build Status

A Clojure library for generating syntax-highlighted strings of Clojure source code. Glow is capable of generating both ANSI-escaped strings for terminal applications, and HTML/CSS targets for server-side generation syntax-highlighted templates.

Installation

To use Glow in your project, just add the following to the :dependencies key of your project.clj:

[venantius/glow "0.1.6"]

Usage

Usage is fairly straightforward.

Let's say you've got a Clojure file with the following contents:

(ns sample)

(defn func
 [^Throwable x & y]
 (conj {} [:a (+ 1.1 x)]))

(def variable
  @(future
     (if-let [x 5]
       true
       "false")))

ANSI-escaped Syntax Highlighting

To generate an ANSI-escaped string of source code, all we have to do is slurp that file and pass the string to glow.core/highlight:

Nice.

Server-side HTML/CSS Syntax Highlighting

The two relevant functions you'll want are glow.core/highlight-html, and glow.core/generate-css. Glow's styling here is compatible with Pygment stylesheets.

The API is very similar to terminal highlighting, but you'll need to generate both the CSS and the HTML separately and link them appropriately within your site.

For an example, see glow.html-test/generate-demo-page, which generates the following:

Configuration

Don't like the default colorschemes? No problem!

Pass a map with whatever highlighting options you want as an optional secondary argument:

Take a look at the colorschemes in glow.colorschemes to see how this should be structured.

Contributing

In general, bug reports, fixes, and code cleanup are always appreciated. I'd also love PRs for additional colorschemes, particularly for HTML output.

Feature requests are liable to be subject to a bit more discussion.

When filing issues, please include the following:

  • The operating system
  • The JDK version
  • The Leiningen version
  • The Clojure version
  • Any plugins and dependencies in your project.clj and your ~/.lein/profiles.clj

Special Thanks

I owe a big debt of gratitude to the authors, contributors and maintainers of vim-clojure-static for their lists of keywords. I also owe thanks to Alex Engelberg and Kyle Kingsbury (@aphyr) - the former helped me work on an EBNF grammar for Clojure, and the latter for writing clj-antlr. Lastly, thanks to Reid Mckenzie, who authored the Clojure antlr v4 grammar upon which Glow's grammar is based.

License

Copyright © 2019 W. David Jarvis

Distributed under the Eclipse Public License 1.0, the same as Clojure. Parts of the ANTLR code are covered by the BSD license, and the original grammar used for the parser is MIT-licensed. Sorry for giving you three licenses in one go.

More Repositories

1

ultra

A Leiningen plugin for a superior development environment
Clojure
1,245
star
2

pyro

Light up your Clojure stacktraces
Clojure
318
star
3

accountant

ClojureScript navigation for single-page applications, made simple.
Clojure
250
star
4

yagni

A Leiningen plugin for finding dead code
Clojure
219
star
5

glojure

The Glojure programming language
Go
172
star
6

vim-cljfmt

A Vim plugin for cljfmt, the Clojure formatting tool.
Vim Script
152
star
7

vim-eastwood

A Vim plugin for Clojure's Eastwood linter
Vim Script
84
star
8

dotfiles

It's creepy that you want these
Shell
18
star
9

maze

Mazes for Programmers
Go
7
star
10

photon

Experiments in realtime web framework design. Like Meteor, but for Clojure(Script)
Clojure
7
star
11

droplet

Droplet is a Python library for sampling, sketching, and summarizing data from massive data streams.
Python
6
star
12

school

C
2
star
13

takehome

Various puzzles, homework assignments, and interview questions
Python
2
star
14

rethink

A Clojure driver for RethinkDB.
Clojure
1
star
15

yagni-test

Dummy app for testing Yagni
Clojure
1
star
16

spindle

Playing with Node.js and express. Don't take this seriously.
JavaScript
1
star
17

demo

A demo application that shows repeated 404s for a valid worker endpoint using Google App Engine push queues
Go
1
star
18

babel

Chat bots for yo' chat ops.
Clojure
1
star
19

etrade-statement-scraper

A Python script for scraping E*Trade monthly statements for data
Python
1
star
20

shrike

Hosted Code Quality for Clojure -- an abandoned CodeClimate competitor.
CSS
1
star
21

orcs-in-space

Orcs in space!!!
Haskell
1
star
22

darg

Kill the status meeting -- an abandoned IDoneThis competitor.
CSS
1
star