diff --git a/lib/earmark_parser/ast/inline.ex b/lib/earmark_parser/ast/inline.ex index 439a79ad..000759a8 100644 --- a/lib/earmark_parser/ast/inline.ex +++ b/lib/earmark_parser/ast/inline.ex @@ -255,7 +255,7 @@ defmodule Earmark.Parser.Ast.Inline do if match = Regex.run(@inline_ial, src) do [match, ial] = match {context1, ial_attrs} = parse_attrs(context, ial, lnb) - new_tags = augment_tag_with_ial(context.value, ial_attrs) + new_tags = augment_tag_with_ial(context.value, ial_attrs, match) {behead(src, match), lnb, set_value(context1, new_tags), use_linky?} end end diff --git a/lib/earmark_parser/helpers/ast_helpers.ex b/lib/earmark_parser/helpers/ast_helpers.ex index 7c17a4d2..d2b6eaa2 100644 --- a/lib/earmark_parser/helpers/ast_helpers.ex +++ b/lib/earmark_parser/helpers/ast_helpers.ex @@ -28,15 +28,16 @@ defmodule Earmark.Parser.Helpers.AstHelpers do end @doc false - def augment_tag_with_ial(tags, ial) - - def augment_tag_with_ial([{t, a, c, m} | tags], atts) do - [{t, merge_attrs(a, atts), c, m} | tags] + def augment_tag_with_ial(tags, ial, src) + def augment_tag_with_ial([{t, a, c, m}|tags], atts, _src) do + [{t, merge_attrs(a, atts), c, m}|tags] end - - def augment_tag_with_ial([], _atts) do + def augment_tag_with_ial([], _atts, _src) do [] end + def augment_tag_with_ial([any], _atts, src) do + [any <> src] + end @doc false def code_classes(language, prefix) do diff --git a/test/regressions/i154_crash_on_symbolic_input_test.exs b/test/regressions/i154_crash_on_symbolic_input_test.exs new file mode 100644 index 00000000..f8bf773d --- /dev/null +++ b/test/regressions/i154_crash_on_symbolic_input_test.exs @@ -0,0 +1,11 @@ +defmodule Test.Regressions.I154CrashOnSymbolicInputTest do + use ExUnit.Case + + test "do not crash here" do + md = "\\[{:}" + html = "

\n[{:}

\n" + assert Earmark.as_html(md) == {:ok, html, []} + end + +end +# SPDX-License-Identifier: Apache-2.0