View Source Makeup (Makeup v1.2.1)

Syntax highlighting library for code, inspired by Pygments.

By default, it doesn't include any lexers. You must import them separately (even the Elixir lexer).

Summary

Functions

Highlights the given string using the given lexer and formatter.

Convenience for formatting as the inner bits of HTML.

Generates a CSS stylesheet for highlighted code for the given style.

Functions

Link to this function

highlight(source, options \\ [])

View Source

Highlights the given string using the given lexer and formatter.

By default it highlight the Elixir language using Makeup.Formatters.HTML.HTMLFormatter.

Options:

  • :lexer - module name of the lexer to use (default: Makeup.Lexers.ElixirLexer)
  • :lexer_options - list of options for the lexer
  • :formatter - module name of the formatter to use (defult: Makeup.Formatters.HTML.HTMLFormatter)
  • :formatter_options - list of options for the formatter. For the included HTMLFormatter, that's:
    • :css_class - css class(es) of the main <pre> element (default: "highlight")
    • :highlight_tag - tag that wraps every token (default: "span")
Link to this function

highlight_inner_html(source, options \\ [])

View Source

Convenience for formatting as the inner bits of HTML.

Link to this function

stylesheet(style \\ :default_style, css_class \\ "highlight")

View Source

Generates a CSS stylesheet for highlighted code for the given style.

It expects a style, either as an atom name or as "style map", and the css_class as the top level class for highlighted code.

For example, if the css_class is "highlight" (the default), the stylesheet has the form:

.highlight .someclass {...}
.highlight .anotherclass {...}

See Makeup.Styles.HTML.StyleMap for all style maps.