actually allow closing markup to match

This commit is contained in:
byte[] 2019-12-28 13:13:50 -05:00
parent 92e7a8bf17
commit ed40f5a35a

View file

@ -82,16 +82,16 @@ defmodule FastTextile.Parser do
#
# open_token callback* close_token (?!lookahead_not)
#
defp simple_lookahead_not(open_token, _close_token, _open_tag, _close_tag, _lookahead_not, _callback, _state, _parser, [{open_token, open}, {forbidden_lookahead, t} | r_tokens])
when forbidden_lookahead in [:space, :newline]
do
{:ok, [{:text, escape(open)}], [{forbidden_lookahead, t} | r_tokens]}
end
defp simple_lookahead_not(open_token, close_token, open_tag, close_tag, lookahead_not, callback, state, parser, [{open_token, open} | r_tokens]) do
case parser.state do
%{^state => _} ->
{:error, "End of rule"}
_ ->
case r_tokens do
[{forbidden_lookahead, _la} | _] when forbidden_lookahead in [:space, :newline] ->
{:ok, [{:text, escape(open)}], r_tokens}
_ ->
case repeat(callback, put_state(parser, state), r_tokens) do
{:ok, tree, [{^close_token, close}, {^lookahead_not, ln} | r2_tokens]} ->
@ -105,6 +105,7 @@ defmodule FastTextile.Parser do
end
end
end
end
defp simple_lookahead_not(_open_token, _close_token, _open_tag, _close_tag, _lookahead_not, _callback, _state, _parser, _tokens) do
{:error, "Expected a simple lookahead not rule"}
end