diff --git a/lib/earmark/context.ex b/lib/earmark/context.ex index 7bb8662b..a2198a2c 100644 --- a/lib/earmark/context.ex +++ b/lib/earmark/context.ex @@ -3,6 +3,14 @@ defmodule Earmark.Context do use Earmark.Types import Earmark.Helpers + @type t :: %__MODULE__{ + options: Earmark.Options.t, + links: map(), + rules: Keyword.t() | nil, + footnotes: map(), + value: String.t | [String.t] + } + defstruct options: %Earmark.Options{}, links: Map.new, rules: nil, @@ -33,7 +41,7 @@ defmodule Earmark.Context do def clear(%__MODULE__{} = ctx) do ctx |> set_value([]) - put_in(ctx.options.messages, []) + |> put_in([:options, :messages], []) end @doc false diff --git a/lib/earmark/helpers/attr_parser.ex b/lib/earmark/helpers/attr_parser.ex index cf35b159..1d0e293b 100644 --- a/lib/earmark/helpers/attr_parser.ex +++ b/lib/earmark/helpers/attr_parser.ex @@ -7,7 +7,7 @@ defmodule Earmark.Helpers.AttrParser do @type errorlist :: list(String.t) - @spec parse_attrs(Context.t, String.t, number()) :: {Map.t, errorlist} + @spec parse_attrs(Context.t, String.t, number()) :: {map, errorlist} def parse_attrs(context, attrs, lnb) do { attrs, errors } = _parse_attrs(%{}, attrs, [], lnb) { add_errors(context, errors, lnb), attrs } @@ -55,5 +55,5 @@ defmodule Earmark.Helpers.AttrParser do defp add_errors(context, [], _lnb), do: context defp add_errors(context, errors, lnb), do: add_message(context, {:warning, lnb, "Illegal attributes #{inspect errors} ignored in IAL"}) - + end diff --git a/lib/earmark/options.ex b/lib/earmark/options.ex index 11813111..d0b61295 100644 --- a/lib/earmark/options.ex +++ b/lib/earmark/options.ex @@ -1,5 +1,7 @@ defmodule Earmark.Options do + @type t :: %__MODULE__{} + # What we use to render defstruct renderer: Earmark.HtmlRenderer, # Inline style options diff --git a/lib/earmark/types.ex b/lib/earmark/types.ex index 272da1df..b78005d4 100644 --- a/lib/earmark/types.ex +++ b/lib/earmark/types.ex @@ -4,7 +4,7 @@ defmodule Earmark.Types do quote do @type token :: {atom, String.t} @type tokens :: list(token) - @type numbered_line :: %{line: String.t, lnb: number} + @type numbered_line :: %{required(:line) => String.t, required(:lnb) => number, optional(:inside_code) => String.t} @type message_type :: :warning | :error @type message :: {message_type, number, String.t} @type maybe(t) :: t | nil