From 7e4decd07e6f4ad2617aad053c7009e0fa7ae473 Mon Sep 17 00:00:00 2001 From: Aleksei Matiushkin Date: Thu, 23 May 2024 19:04:32 +0200 Subject: [PATCH] ready for `1.17/27` --- lib/md/parser/engine.ex | 26 +++++++++++++------------- mix.lock | 12 ++++++------ test/md/engine_test.exs | 8 ++++---- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/md/parser/engine.ex b/lib/md/parser/engine.ex index c3bfbca..c35a0f5 100644 --- a/lib/md/parser/engine.ex +++ b/lib/md/parser/engine.ex @@ -1,9 +1,9 @@ defmodule Md.Engine do @moduledoc false - @spec closing_match(Md.Listener.branch()) :: Macro.t() - def closing_match(tags) do - us = Macro.var(:_, %Macro.Env{}.context) + @spec closing_match(Md.Listener.branch(), module()) :: Macro.t() + def closing_match(tags, context) do + us = Macro.var(:_, context) Enum.reduce(tags, [], &[{:{}, [], [&1, us, us]} | &2]) end @@ -543,7 +543,7 @@ defmodule Md.Engine do defmacro block(blocks) do quote generated: true, location: :keep, - bind_quoted: [blocks: blocks], + bind_quoted: [blocks: blocks, ctx: __CALLER__.module], context: __CALLER__.module do Enum.each(blocks, fn {md, properties} -> [tag | _] = tags = List.wrap(properties[:tag]) @@ -551,7 +551,7 @@ defmodule Md.Engine do attrs = Macro.escape(properties[:attributes]) pop = Macro.escape(properties[:pop]) - closing_match = Md.Engine.closing_match(tags) + closing_match = Md.Engine.closing_match(tags, ctx) defp do_parse(<>, state_linefeed()) do state = @@ -600,14 +600,14 @@ defmodule Md.Engine do defmacro shift(shifts) do quote generated: true, location: :keep, - bind_quoted: [shifts: shifts], + bind_quoted: [shifts: shifts, ctx: __CALLER__.module], context: __CALLER__.module do Enum.each(shifts, fn {md, properties} -> [tag | _] = tags = List.wrap(properties[:tag]) mode = Map.get(properties, :mode, {:inner, :raw}) attrs = Macro.escape(properties[:attributes]) - closing_match = Md.Engine.closing_match(tags) + closing_match = Md.Engine.closing_match(tags, ctx) defp do_parse( <>, @@ -999,7 +999,7 @@ defmodule Md.Engine do defmacro paragraph(paragraphs) do quote generated: true, location: :keep, - bind_quoted: [paragraphs: paragraphs], + bind_quoted: [paragraphs: paragraphs, ctx: __CALLER__.module], context: __CALLER__.module do Enum.each(paragraphs, fn {md, properties} -> [tag | _] = tags = List.wrap(properties[:tag]) @@ -1007,7 +1007,7 @@ defmodule Md.Engine do attrs = Macro.escape(properties[:attributes]) rewind_until = List.last(tags) - closing_match = Md.Engine.closing_match(tags) + closing_match = Md.Engine.closing_match(tags, ctx) defp do_parse(<>, empty({:linefeed, _pos})) do state = @@ -1277,7 +1277,7 @@ defmodule Md.Engine do defmacro tag(tags) do quote generated: true, location: :keep, - bind_quoted: [tags: tags], + bind_quoted: [tags: tags, ctx: __CALLER__.module], context: __CALLER__.module do Enum.each(tags, fn {md, properties} -> [tag] = @@ -1286,7 +1286,7 @@ defmodule Md.Engine do mode = Map.get(properties, :mode, :md) attrs = Macro.escape(properties[:attributes]) closing = Map.get(properties, :closing, "") - closing_match = Md.Engine.closing_match(tags) + closing_match = Md.Engine.closing_match(tags, ctx) defp do_parse( <>, @@ -1320,14 +1320,14 @@ defmodule Md.Engine do defmacro brace(braces) do quote generated: true, location: :keep, - bind_quoted: [braces: braces], + bind_quoted: [braces: braces, ctx: __CALLER__.module], context: __CALLER__.module do Enum.each(braces, fn {md, properties} -> [tag | _] = tags = List.wrap(properties[:tag]) mode = Map.get(properties, :mode) attrs = Macro.escape(properties[:attributes]) closing = Map.get(properties, :closing, md) - closing_match = Md.Engine.closing_match(tags) + closing_match = Md.Engine.closing_match(tags, ctx) defp do_parse( <>, diff --git a/mix.lock b/mix.lock index 98fcc68..156499e 100644 --- a/mix.lock +++ b/mix.lock @@ -2,12 +2,12 @@ "benchfella": {:hex, :benchfella, "0.3.5", "b2122c234117b3f91ed7b43b6e915e19e1ab216971154acd0a80ce0e9b8c05f5", [:mix], [], "hexpm", "23f27cbc482cbac03fc8926441eb60a5e111759c17642bac005c3225f5eb809d"}, "bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"}, "certifi": {:hex, :certifi, "2.9.0", "6f2a475689dd47f19fb74334859d460a2dc4e3252a3324bd2111b8f0429e7e21", [:rebar3], [], "hexpm", "266da46bdb06d6c6d35fde799bcb28d36d985d424ad7c08b5bb48f5b5cdd4641"}, - "credo": {:hex, :credo, "1.7.5", "643213503b1c766ec0496d828c90c424471ea54da77c8a168c725686377b9545", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "f799e9b5cd1891577d8c773d245668aa74a2fcd15eb277f51a0131690ebfb3fd"}, + "credo": {:hex, :credo, "1.7.6", "b8f14011a5443f2839b04def0b252300842ce7388f3af177157c86da18dfbeea", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "146f347fb9f8cbc5f7e39e3f22f70acbef51d441baa6d10169dd604bfbc55296"}, "dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"}, "earmark": {:hex, :earmark, "1.4.46", "8c7287bd3137e99d26ae4643e5b7ef2129a260e3dcf41f251750cb4563c8fb81", [:mix], [], "hexpm", "798d86db3d79964e759ddc0c077d5eb254968ed426399fbf5a62de2b5ff8910a"}, "earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"}, "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, - "ex_doc": {:hex, :ex_doc, "0.32.1", "21e40f939515373bcdc9cffe65f3b3543f05015ac6c3d01d991874129d173420", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.1", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "5142c9db521f106d61ff33250f779807ed2a88620e472ac95dc7d59c380113da"}, + "ex_doc": {:hex, :ex_doc, "0.33.0", "690562b153153c7e4d455dc21dab86e445f66ceba718defe64b0ef6f0bd83ba0", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "3f69adc28274cb51be37d09b03e4565232862a4b10288a3894587b0131412124"}, "excoveralls": {:hex, :excoveralls, "0.18.1", "a6f547570c6b24ec13f122a5634833a063aec49218f6fff27de9df693a15588c", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "d65f79db146bb20399f23046015974de0079668b9abb2f5aac074d078da60b8d"}, "file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"}, "floki": {:hex, :floki, "0.36.2", "a7da0193538c93f937714a6704369711998a51a6164a222d710ebd54020aa7a3", [:mix], [], "hexpm", "a8766c0bc92f074e5cb36c4f9961982eda84c5d2b8e979ca67f5c268ec8ed580"}, @@ -16,18 +16,18 @@ "html_entities": {:hex, :html_entities, "0.5.2", "9e47e70598da7de2a9ff6af8758399251db6dbb7eebe2b013f2bbd2515895c3c", [:mix], [], "hexpm", "c53ba390403485615623b9531e97696f076ed415e8d8058b1dbaa28181f4fdcc"}, "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, "jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"}, - "makeup": {:hex, :makeup, "1.1.1", "fa0bc768698053b2b3869fa8a62616501ff9d11a562f3ce39580d60860c3a55e", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "5dc62fbdd0de44de194898b6710692490be74baa02d9d108bc29f007783b0b48"}, + "makeup": {:hex, :makeup, "1.1.2", "9ba8837913bdf757787e71c1581c21f9d2455f4dd04cfca785c70bbfff1a76a3", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cce1566b81fbcbd21eca8ffe808f33b221f9eee2cbc7a1706fc3da9ff18e6cac"}, "makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"}, - "makeup_erlang": {:hex, :makeup_erlang, "0.1.5", "e0ff5a7c708dda34311f7522a8758e23bfcd7d8d8068dc312b5eb41c6fd76eba", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "94d2e986428585a21516d7d7149781480013c56e30c6a233534bedf38867a59a"}, + "makeup_erlang": {:hex, :makeup_erlang, "1.0.0", "6f0eff9c9c489f26b69b61440bf1b238d95badae49adac77973cbacae87e3c2e", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "ea7a9307de9d1548d2a72d299058d1fd2339e3d398560a0e46c27dab4891e4d2"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, - "mneme": {:hex, :mneme, "0.6.0", "b2e0536305cadd5e546a87a518a776559f2207bb0a1f8712889d240600e58657", [:mix], [{:nimble_options, "~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:owl, "~> 0.9", [hex: :owl, repo: "hexpm", optional: false]}, {:rewrite, "~> 0.10.1", [hex: :rewrite, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.0", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "ee9bfbf0d9def1e8748dc81f312046da15203c0af8e6b39c5490244274ad6039"}, + "mneme": {:hex, :mneme, "0.6.1", "94339ebb09be2edeeece9fa9ffca011c710da607fe704346c148739316107252", [:mix], [{:nimble_options, "~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:owl, "~> 0.9", [hex: :owl, repo: "hexpm", optional: false]}, {:rewrite, "~> 0.10.1", [hex: :rewrite, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.0", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "bad5f9836079f0d25710b15ce2c87194f47d36bbe77b0f78fe1f726013ef2142"}, "nimble_options": {:hex, :nimble_options, "1.1.0", "3b31a57ede9cb1502071fade751ab0c7b8dbe75a9a4c2b5bbb0943a690b63172", [:mix], [], "hexpm", "8bbbb3941af3ca9acc7835f5655ea062111c9c27bcac53e004460dfd19008a99"}, "nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"}, "owl": {:hex, :owl, "0.9.0", "9b33d64734bd51d3fc1d6ed01b12f8c2ed23e1fbf8c43658a6dfbff62578bd03", [:mix], [{:ucwidth, "~> 0.2", [hex: :ucwidth, repo: "hexpm", optional: true]}], "hexpm", "cd70b55327985f8f24d38cb7de5bf8a8d24040e1b49cca2345508f8119ce81fd"}, "parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"}, "rewrite": {:hex, :rewrite, "0.10.1", "238073297d122dad6b5501d761cb3bc0ce5bb4ab86e34c826c395f5f44b2f562", [:mix], [{:glob_ex, "~> 0.1", [hex: :glob_ex, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.0", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "91f8d6fe363033e8ff60097bb5e0b76867667df0b4d67e79c2850444c02d8b19"}, - "sourceror": {:hex, :sourceror, "1.0.3", "111711c147f4f1414c07a67b45ad0064a7a41569037355407eda635649507f1d", [:mix], [], "hexpm", "56c21ef146c00b51bc3bb78d1f047cb732d193256a7c4ba91eaf828d3ae826af"}, + "sourceror": {:hex, :sourceror, "1.2.0", "471232b2eb9ab930b90673d37cf005bbaec0ef02dadf5bf4c8c00c3d75a6c131", [:mix], [], "hexpm", "f01796ce1b87016573ce7b66073d6b48297c4d233982340340834269b8c95e51"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"}, "string_naming": {:hex, :string_naming, "0.7.3", "bc187567ea2b2d0b83a9df8f105ec34b22ea0b738d96a4c32ed18c756fd2b5dc", [:mix], [], "hexpm", "63150a7420deed0e93040b606da16750ce902116855e326f51b4d5bc5ac7e92a"}, "unicode": {:hex, :unicode, "1.19.0", "264191eacb1d44039d0dbb9fd936c557431825373b6e7b18d77e80cb0cc344bd", [:mix], [], "hexpm", "ae83bbf54429a67bc6fa9c941a6e9f0ec38dd9c2a32b21583ad511d3b6555631"}, diff --git a/test/md/engine_test.exs b/test/md/engine_test.exs index 2dfc35a..5fe1a0f 100644 --- a/test/md/engine_test.exs +++ b/test/md/engine_test.exs @@ -4,10 +4,10 @@ defmodule Md.Engine.Test do test "closing_match/1" do assert [ - {:{}, [], [:c, {:_, [], nil}, {:_, [], nil}]}, - {:{}, [], [:b, {:_, [], nil}, {:_, [], nil}]}, - {:{}, [], [:a, {:_, [], nil}, {:_, [], nil}]} - ] = Md.Engine.closing_match([:a, :b, :c]) + {:{}, [], [:c, {:_, [], Md.Engine.Test}, {:_, [], Md.Engine.Test}]}, + {:{}, [], [:b, {:_, [], Md.Engine.Test}, {:_, [], Md.Engine.Test}]}, + {:{}, [], [:a, {:_, [], Md.Engine.Test}, {:_, [], Md.Engine.Test}]} + ] = Md.Engine.closing_match([:a, :b, :c], __MODULE__) end test "raises when no @syntax defined" do