Packages

Earmark is a pure-Elixir Markdown converter. It is intended to be used as a library (just call Earmark.as_html), but can also be used as a command-line tool (run mix escript.build first). Output generation is pluggable.

Retired package: Deprecated - Earmark is no longer maintained. Migrate to a replacement, for example MDEx (https://hex.pm/packages/mdex).
Security advisory: This version has known vulnerabilities. View advisories

Current section

Files

Jump to
earmark lib earmark earmark_parser_proxy.ex
Raw

lib/earmark/earmark_parser_proxy.ex

defmodule Earmark.EarmarkParserProxy do
@moduledoc ~S"""
This acts as a proxy to adapt to changes in `EarmarkParser`'s API
If no changes are needed it can delegate `as_ast` to `EarmarkParser`
If changes are needed they will be realised in this modules `as_ast`
function.
For that reason `EarmarkParser.as_ast/*` **SHALL NOT** be invoked
anywhere else in this code base
"""
@doc ~S"""
An adapter to `EarmarkParser.as_ast/*`
"""
def as_ast(input, options)
def as_ast(input, options) when is_list(options) do
EarmarkParser.as_ast(input, options |> Keyword.delete(:smartypants) |> Keyword.delete(:messages))
end
def as_ast(input, options) when is_map(options) do
EarmarkParser.as_ast(input, options |> Map.delete(:smartypants) |> Map.delete(:messages))
end
end
# SPDX-License-Identifier: Apache-2.0