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
- Host: GitHub
- URL: https://github.com/superstructor/re-highlight
- Owner: superstructor
- License: mit
- Created: 2021-03-22T10:24:57.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-02-23T22:42:11.000Z (over 2 years ago)
- Last Synced: 2025-05-16T13:52:54.327Z (about 2 months ago)
- Topics: clojurescript, react, reagent, reagent-components, ui-components
- Language: CSS
- Homepage:
- Size: 369 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.adoc
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
:source-highlighter: coderay
:source-language: clojure
:toc:
:toc-placement: preamble
:sectlinks:
:sectanchors:
:toc:
:icons: fontimage: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.