# `Makeup.Registry`
[🔗](https://github.com/elixir-makeup/makeup/blob/v1.2.3/lib/makeup/registry.ex#L1)

A registry that allows users to dynamically register new makeup lexers.

Lexers should register themselves on application start.
That way, you can add support for new programming languages by depending on the relevant lexers.
This is useful for projects such as ExDoc, which might contain code
in a number of different programming languages.

# `fetch_lexer_by_extension`

Fetches a lexer from Makeup's registry with the given file `extension`.

Returns either `{:ok, {lexer, options}}` or `:error`.
This behaviour is based on `Map.fetch/2`.

# `fetch_lexer_by_extension!`

Fetches the lexer from Makeup's registry with the given file `extension`.

Returns either `{:ok, {lexer, options}}` or raises a `KeyError`.
This behaviour is based on `Map.fetch/2`.

# `fetch_lexer_by_name`

Fetches the lexer from Makeup's registry with the given `name`.

Returns either `{:ok, {lexer, options}}` or `:error`.
This behaviour is based on `Map.fetch/2`.

# `fetch_lexer_by_name!`

Fetches the lexer from Makeup's registry with the given `name`.

Returns either `{lexer, options}` or raises a `KeyError`.
This behaviour is based on `Map.fetch!/2`.

# `get_lexer_by_extension`

Gets the lexer from Makeup's registry with the given file `extension`.

Returns either `{lexer, options}` or the `default` value
(which by default is `nil`).
This behaviour is based on `Map.get/3`.

# `get_lexer_by_name`

Gets the lexer from Makeup's registry with the given `name`.

Returns either `{lexer, options}` or the `default` value
(which by default is `nil`).
This behaviour is based on `Map.get/3`.

# `register_lexer`

Add a new lexer to Makeup's registry under the given names and extensions.

Expects a lexer `lexer` and a number of options:

  * `:options` (default: `[]`) - the lexer options.
    If your lexer doesn't take any options, you'll want the default value of `[]`.

  * `:names` (default: `[]`) - a list of strings with the language names for the lexer.
    Language names are strings, not atoms.
    Even if there is only one valid name, you must supply a list with that name.
    To avoid filling the registry unnecessarily, you should normalize your language names
    to lowercase strings.
    If the caller wants to support upper case language names for some reason,
    they can normalize the language names themselves.

  * `:extensions` (default: `[]`) - the list of file extensions for the languages supported by the lexer.
    For example, the elixir lexer should support the `"ex"` and `"exs"` file extensions.
    The extensions should not include the dot.
    That is, you should register `"ex"` and not `".ex"`.
    Even if there is only a supported extension, you must supply a list.

## Example

    alias Makeup.Registry
    alias Makeup.Lexers.ElixirLexer
    # The `:options` key is not required
    Registry.register_lexer(ElixirLexer, names: ["elixir", "iex"], extensions: ["ex", "exs"])

# `register_lexer_with_extension`

Adds a new lexer to Makeup's registry under the given `extension`.

This function expects a file extension (e.g. `"ex"`) and a pair containing
a `lexer` and a list of `options`.

You might want to use the `Makeup.Registry.register_lexer/2` function instead.

## Examples

    alias Makeup.Lexers.ElixirLexer
    alias Makeup.Registry

    Registry.register_lexer_with_extension("ex"), {ElixirLexer, []})
    Registry.register_lexer_with_extension("exs"), {ElixirLexer, []})

# `register_lexer_with_name`

Adds a new lexer to Makeup's registry under the given `name`.

This function expects a language name (e.g. `"elixir"`) and a pair containing
a `lexer` and a list of `options`.

You might want to use the `Makeup.Registry.register_lexer/2` function instead.

## Examples

    alias Makeup.Lexers.ElixirLexer
    alias Makeup.Registry

    Registry.register_lexer_with_name("elixir", {ElixirLexer, []})
    Registry.register_lexer_with_name("iex", {ElixirLexer, []})

# `supported_file_extensions`

Gets the list of supported language extensions.

# `supported_language_names`

Gets the list of supported language names.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
