Liking cljdoc? Tell your friends :D

Clojars Project GitHub issues License

Reagent wrapper for Highlight.js

A simple Reagent wrapper around the Highlight.js library, with no dependencies except Highlight.js itself via npm (for shadow-cljs) or via cljsjs.

Quick Start

Step 1. Add Dependency

Add the following project dependency: Clojars Project

Requires that you have reagent as a dependency of your project: Clojars Project

If you use shadow-cljs, the highlight.js npm library dependency will be pulled automatically via src/deps.cljs :npm-deps.

If you use another build system, you will probably need to add the following cljsjs dependency to your project: Clojars Project

Cljsjs is not included as a transitive dependency because it lags behind the npm release, so including it here would mean that this project depended on two different versions of Highlight.js. Cljsjs support is not a priority since shadow-cljs is the way to go these days, so code-wise it is compatible but consumers who want it have the cljsjs support need to add the dependency themselves.

Step 2. Add Highlight.js Theme

Add a Highlight.js stylesheet to your index.html or equivalent; e.g.:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/styles/default.min.css">

Step 3. Use

(ns my-app
  (:require
    [re-highlight.core :refer [highlight]]))
(defn panel
  []
  [highlight
    {:language "clojure"}
    "(defn fibo-recursive [n]\n         (if (or (= n 0) (= n 1))\n           n\n           (+ (fibo-recursive (- n 1)) (fibo-recursive (- n 2)))))"]]])

License

The MIT License (MIT)

Copyright (c) 2019-2021 Isaac Johnston

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close