CrossClj

1.0.0 docs

SourceDocs



RECENT

    clygments

    Clojars

    May 21, 2017


    OWNER
    Baptiste Fontaine
    @oscaro
    Paris, France
    b@ptistefontaine.fr
    bfontaine.net

    Readme

    Index of all namespaces


    The README below is fetched from the published project artifact. Some relative links may be broken.

    clygments

    Build Status Coverage Status

    clygments is a Clojure wrapper for Pygments.

    Usage

    Add the dependency in your project.clj:

    [clygments "0.1.1"]
    

    Then:

    (ns your-project.core
      (:require [clygments.core :as clygments]))
    

    It exposes only one function, highlight. Give it your code as a string, its language and the desired output and it’ll do that for you :)

    It’ll return a string or nil if there was an error, like an unsupported language or output.

    Example

    (clygments/highlight "(def x (+ 20 22))" :clojure :html)
    ;; => <div class=\"highlight\"><pre><span class=\"p\">(</span><span class=\"k\">def </span><span class=\"nv\">x</span> <span class=\"mi\">42</span><span class=\"p\">)</span>\n</pre></div>
    

    Support

    Clygments 0.1.1 supports Java 6+ but Clygments 1.0.0 only supports Java 7+.

    Langages

    See Pygments’ list for a list of available languages.

    Output

    • :bbcode
    • :html
    • :latex
    • :null (no formatting, this leaves the code unchanged)
    • :raw
    • :rtf
    • :svg
    • :terminal256
    • :terminal

    Images outputs are not supported. See also Pygments docs for the full list.

    Options

    All lexers’ and formatters’ options are supported since version 0.1.1. They are given as a map to highlight and support hyphens for a better readability. See Pygments’ docs for more info.

    Example

    ;; expand tabs to 4 spaces
    (cligments/highlight "def foo():\n\tpass" :python :html {:tab-size 4})
    
    ;; generate a full standalone HTML document with a custom title
    (cligments/highlight "int i = 2+2;" :C :html {:full true, :title "This is my code"})
    

    License

    Copyright © 2014-2017 Baptiste Fontaine

    Distributed under the Eclipse Public License either version 1.0 or any later version.