Skip to content

Commit

Permalink
Merge pull request #275 from pragdave/i259-remove-sanitize
Browse files Browse the repository at this point in the history
Fixes: #259;
  • Loading branch information
RobertDober authored Sep 4, 2019
2 parents f829528 + a145b35 commit b325e71
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 42 deletions.
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.

0 comments on commit b325e71

Please sign in to comment.