Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes: #259; #275

Merged
merged 1 commit into from
Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions lib/earmark.ex
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ defmodule Earmark do

alias Earmark.Error
alias Earmark.Options
import Earmark.Message, only: [add_message: 2, emit_messages: 1, sort_messages: 1]
import Earmark.Message, only: [emit_messages: 1, sort_messages: 1]

@doc """
Given a markdown document (as either a list of lines or
Expand Down Expand Up @@ -451,11 +451,10 @@ defmodule Earmark do

defp _as_html(lines, options) do
{blocks, context} = Earmark.Parser.parse_markdown(lines, options)
context1 = _add_sanitize_deprecation(context)

case blocks do
[] -> {context, ""}
_ -> options.renderer.render(blocks, context1)
_ -> options.renderer.render(blocks, context)
end
end

Expand All @@ -481,19 +480,6 @@ defmodule Earmark do
|> Enum.map(&_join_pmap_results_or_raise(&1, timeout))
end

defp _add_sanitize_deprecation(
%Earmark.Context{options: %Options{sanitize: sanitize}} = context
) do
if sanitize do
add_message(
context,
{:deprecation, "DEPRECATED: The sanitize option will be removed in Earmark 1.4", 0}
)
else
context
end
end

defp _join_pmap_results_or_raise(yield_tuples, timeout)
defp _join_pmap_results_or_raise({_task, {:ok, result}}, _timeout), do: result

Expand Down
13 changes: 3 additions & 10 deletions lib/earmark/context.ex
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,10 @@ defmodule Earmark.Context do
def update_context(context = %Earmark.Context{options: options}) do
context = %{context | rules: rules_for(options)}

context =
if options.smartypants do
put_in(context.options.do_smartypants, &smartypants/1)
else
put_in(context.options.do_smartypants, &noop/1)
end

if options.sanitize do
put_in(context.options.do_sanitize, &escape/1)
if options.smartypants do
put_in(context.options.do_smartypants, &smartypants/1)
else
put_in(context.options.do_sanitize, &noop/1)
put_in(context.options.do_smartypants, &noop/1)
end
end

Expand Down
4 changes: 1 addition & 3 deletions lib/earmark/inline.ex
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ defmodule Earmark.Inline do
defp converter_for_tag({src, context, result, lnb}, _renderer) do
case Regex.run(context.rules.tag, src) do
[match] ->
out = context.options.do_sanitize.(match)
{behead(src, match), context, prepend(result, out), lnb}

{behead(src, match), context, prepend(result, match), lnb}
_ ->
nil
end
Expand Down
2 changes: 0 additions & 2 deletions lib/earmark/options.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ defmodule Earmark.Options do
breaks: false,
pedantic: false,
smartypants: true,
sanitize: false,
footnotes: false,
footnote_offset: 1,

Expand All @@ -21,7 +20,6 @@ defmodule Earmark.Options do

# Internal—only override if you're brave
do_smartypants: nil,
do_sanitize: nil,

# Very internal—the callback used to perform
# parallel rendering. Set to &Enum.map/2
Expand Down
11 changes: 0 additions & 11 deletions test/functional/render/sanitize_test.exs

This file was deleted.