An open API service indexing awesome lists of open source software.

https://github.com/superstructor/re-highlight

Reagent wrapper for Highlight.js
https://github.com/superstructor/re-highlight

clojurescript react reagent reagent-components ui-components

Last synced: 7 days ago
JSON representation

Reagent wrapper for Highlight.js

Awesome Lists containing this project

README

        

:source-highlighter: coderay
:source-language: clojure
:toc:
:toc-placement: preamble
:sectlinks:
:sectanchors:
:toc:
:icons: font

image:https://img.shields.io/clojars/v/superstructor/re-highlight?style=for-the-badge&logo=clojure&logoColor=fff["Clojars Project", link="https://clojars.org/superstructor/re-highlight"]
image:https://img.shields.io/github/issues-raw/superstructor/re-highlight?style=for-the-badge&logo=github["GitHub issues", link="https://github.com/superstructor/re-highlight/issues"]
image:https://img.shields.io/github/license/superstructor/re-highlight?style=for-the-badge["License", link="https://github.com/superstructor/re-highlight/blob/master/LICENSE"]

= Reagent wrapper for Highlight.js

A simple Reagent wrapper around the link:https://highlightjs.org/[Highlight.js] library, with no dependencies except Highlight.js itself
link:https://www.npmjs.com/package/highlight.js[via npm (for shadow-cljs)].

== Quick Start

=== Step 1. Add Dependency

Add the following project dependency:
image:https://img.shields.io/clojars/v/superstructor/re-highlight?style=for-the-badge&logo=clojure&logoColor=fff["Clojars Project", link="https://clojars.org/superstructor/re-highlight"]

Requires that you have reagent as a dependency of your project: image:https://img.shields.io/clojars/v/reagent?style=for-the-badge&logo=clojure&logoColor=fff["Clojars Project", link="https://clojars.org/reagent"]

The `highlight.js` npm library dependency will be
pulled in automatically by shadow-cljs via `src/deps.cljs` `:npm-deps`.

=== Step 2. Add Highlight.js Theme

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

=== 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)))))"]]])

=== Step 4. Optional. Add non-Clojure Language Support

Only Clojure support is registered by default. If you are using any other language, you need to explicitly require
and register it! E.g.

(require ["highlight.js/lib/languages/rust" :as rust])
(re-highlight/register-language "rust" rust)

== License

The MIT License (MIT)

Copyright (c) 2019-2022 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.