diff --git a/lib/textile/parser.ex b/lib/textile/parser.ex index f5e6ff87..67c59b86 100644 --- a/lib/textile/parser.ex +++ b/lib/textile/parser.ex @@ -1,6 +1,5 @@ defmodule Textile.Parser do import Textile.ParserHelpers - import Phoenix.HTML alias Textile.{ Lexer, @@ -9,7 +8,6 @@ defmodule Textile.Parser do } defstruct [ - reductions: [], image_transform: nil ] @@ -129,7 +127,7 @@ defmodule Textile.Parser do {:ok, [markup: ~s|
|] ++ tree ++ [markup: ~s||], r2_tokens} else _ -> - {:ok, [text: ~s|[bq="#{author}"]|], r_tokens} + {:ok, [text: escape_nl2br(~s|[bq="#{author}"]|)], r_tokens} end end @@ -138,7 +136,7 @@ defmodule Textile.Parser do {:ok, [markup: ~s|
|] ++ tree ++ [markup: ~s||], r2_tokens} else _ -> - {:ok, [text: escape_html(open)], r_tokens} + {:ok, [text: escape_nl2br(open)], r_tokens} end end @@ -155,7 +153,7 @@ defmodule Textile.Parser do {:ok, [markup: ~s||] ++ tree ++ [markup: ~s||], r2_tokens} else _ -> - {:ok, [text: escape_html(open)], r_tokens} + {:ok, [text: escape_nl2br(open)], r_tokens} end end @@ -172,7 +170,7 @@ defmodule Textile.Parser do {:ok, [markup: ~s||] ++ tree ++ [markup: ~s||], r2_tokens} else _ -> - {:ok, [text: escape_html(start)], r_tokens} + {:ok, [text: escape_nl2br(start)], r_tokens} end end @@ -305,16 +303,4 @@ defmodule Textile.Parser do defp text(_parser, _tokens), do: {:error, "Expected text"} - - - defp escape_nl2br(text) do - text - |> String.split("\n", trim: true) - |> Enum.map(&escape_html(&1)) - |> Enum.join("