Packages
earmark_parser
1.4.19
1.4.46
1.4.45
1.4.44
1.4.43
1.4.42
1.4.41
1.4.40
1.4.39
1.4.38
1.4.37
1.4.36
1.4.35
1.4.34
1.4.33
1.4.32
1.4.31
1.4.30
1.4.29
1.4.28
1.4.27
1.4.26
1.4.25
1.4.24
1.4.23
1.4.22
1.4.21
1.4.20
1.4.20-pre
1.4.19
1.4.18
1.4.17
1.4.16
1.4.16-pre2
1.4.16-pre1
1.4.16-pre
1.4.15
1.4.13
1.4.12
1.4.11
1.4.10
1.4.9
1.4.8
AST parser and generator for Markdown
Current section
Files
Jump to
Current section
Files
lib/earmark_parser/options.ex
defmodule EarmarkParser.Options do
use EarmarkParser.Types
# What we use to render
defstruct renderer: EarmarkParser.HtmlRenderer,
# Inline style options
gfm: true,
gfm_tables: false,
breaks: false,
footnotes: false,
footnote_offset: 1,
wikilinks: false,
parse_inline: true,
# allow for annotations
annotations: nil,
# additional prefies for class of code blocks
code_class_prefix: nil,
# Filename and initial line number of the markdown block passed in
# for meaningful error messages
file: "<no file>",
line: 1,
# [{:error|:warning, lnb, text},...]
messages: MapSet.new([]),
pure_links: true,
# deprecated
pedantic: false,
smartypants: false,
timeout: nil
@type t :: %__MODULE__{
breaks: boolean,
code_class_prefix: maybe(String.t),
footnotes: boolean,
footnote_offset: number,
gfm: boolean,
messages: MapSet.t,
pedantic: boolean,
pure_links: boolean,
smartypants: boolean,
wikilinks: boolean,
parse_inline: boolean
}
@doc false
def add_deprecations(options, messages)
def add_deprecations(%__MODULE__{smartypants: true}=options, messages) do
add_deprecations(%{options|smartypants: false},
[{:deprecated, 0, "The smartypants option has no effect anymore and will be removed in EarmarkParser 1.5"}|messages])
end
def add_deprecations(%__MODULE__{timeout: timeout}=options, messages) when timeout != nil do
add_deprecations(%{options|timeout: nil},
[{:deprecated, 0, "The timeout option has no effect anymore and will be removed in EarmarkParser 1.5"}|messages])
end
def add_deprecations(%__MODULE__{pedantic: true}=options, messages) do
add_deprecations(%{options|pedantic: false},
[{:deprecated, 0, "The pedantic option has no effect anymore and will be removed in EarmarkParser 1.5"}|messages])
end
def add_deprecations(_options, messages), do: messages
@doc ~S"""
Use normalize before passing it into any API function
iex(1)> options = normalize(annotations: "%%")
...(1)> options.annotations
~r{\A(.*)(%%.*)}
"""
def normalize(options)
def normalize(%__MODULE__{}=options) do
case options.annotations do
%Regex{} -> options
nil -> options
_ -> %{options | annotations: Regex.compile!("\\A(.*)(#{Regex.escape(options.annotations)}.*)")}
end
end
def normalize(options), do: struct(__MODULE__, options) |> normalize()
@doc false
def plugin_for_prefix(options, plugin_name) do
Map.get(options.plugins, plugin_name, false)
end
end
# SPDX-License-Identifier: Apache-2.0