package hilite

  1. Overview
  2. Docs

Module HiliteSource

Core

Sourcetype error = [
  1. | `Unknown_lang of string
]

Error type for catching code blocks with languages not supported by the provided collection of textmate grammars.

Sourcetype tm_lookup_method = [
  1. | `Name
  2. | `Scope_name
  3. | `Filetype
]

Methods for looking up grammars, see TmLanguage for the various functions.

Sourceval langs : string list

The list of supported languages for the default collection of textmate grammers used in src_code_to_html if no tm argument is provided. The grammars for these languages can be found in Grammars.

Sourceval src_code_to_pairs : ?escape:bool -> ?lookup_method:tm_lookup_method -> ?tm:TmLanguage.t -> lang:string -> string -> ((string * string) list list, [> `Unknown_lang of string ]) result

The same as src_code_to_html except it only returns (class, content) pairs -- so agnostic to HTML.

Sourceval src_code_to_html : ?escape:bool -> ?lookup_method:tm_lookup_method -> ?tm:TmLanguage.t -> lang:string -> string -> (string, error) result

src_code_to_html ~lang src will highlight the source code src in language lang and return a string of HTML using span's with keyword classes.

Predefined Grammars

The Grammars module contains some predefined grammars for OCaml-specific languages including OCaml itself and dune, opam and interface files.

Sourcemodule Grammars : sig ... end
OCaml

Innovation. Community. Security.