Earmark.Options (Earmark v1.4.16-pre) View Source

This is a superset of the options that need to be passed into EarmarkParser.as_ast/2

The following options are proper to Earmark only and therefore explained in detail

  • compact_output: boolean indicating to avoid indentation and minimize whitespace
  • eex: Allows usage of an EEx template to be expanded to markdown before conversion
  • file: Name of file passed in from the CLI
  • line: 1 but might be set to an offset for better error messages in some integration cases
  • ignore_strings, postprocessor and registered_processors: processors that modify the AST returned from EarmarkParser.as_ast/2 before rendering (post because preprocessing is done on the markdown, e.g. eex) Refer to the moduledoc of Earmark.Transform for details

All other options are passed onto EarmarkParser.as_ast/2

Link to this section Summary

Functions

Make a legal and normalized Option struct from, maps or keyword lists

A convenience constructor

Link to this section Functions

Link to this function

make_options(options \\ [])

View Source

Make a legal and normalized Option struct from, maps or keyword lists

Without a param or an empty input we just get a new Option struct

iex(0)> { make_options(), make_options(%{}) }
{ {:ok, %Earmark.Options{}}, {:ok, %Earmark.Options{}} }

The same holds for the bang version of course

iex(1)> { make_options!(), make_options!(%{}) }
{ %Earmark.Options{}, %Earmark.Options{} }

We check for unallowed keys

iex(2)> make_options(no_such_option: true)
{:error, [{:warning, 0, "Unrecognized option no_such_option: true"}]}

Of course we do not let our users discover one error after another

iex(3)> make_options(no_such_option: true, gfm: false, still_not_an_option: 42)
{:error, [{:warning, 0, "Unrecognized option no_such_option: true"}, {:warning, 0, "Unrecognized option still_not_an_option: 42"}]}

And the bang version will raise an Earmark.Error as excepted (sic)

iex(3)> make_options!(no_such_option: true, gfm: false, still_not_an_option: 42)
** (Earmark.Error) [{:warning, 0, "Unrecognized option no_such_option: true"}, {:warning, 0, "Unrecognized option still_not_an_option: 42"}]
Link to this function

make_options!(options \\ [])

View Source
Link to this function

with_postprocessor(pp, rps \\ [])

View Source

A convenience constructor