From 3ec60ea8ae51fda6b544c4b9a40bedf990a0167f Mon Sep 17 00:00:00 2001 From: Austin Ziegler Date: Sat, 24 Jan 2026 11:17:14 -0500 Subject: [PATCH] feat: update to MDEx 0.11 This is a partial revert from #169 because the custom handling of `:plugins` is no longer necessary with MDEx 0.11 which has "native" plugin handling (and with 0.11.1 or later has the same handling applied to `to_*` functions). Signed-off-by: Austin Ziegler --- lib/tableau.ex | 9 ++++-- lib/tableau/converters/mdex_converter.ex | 37 ++---------------------- mix.exs | 2 +- mix.lock | 4 +-- 4 files changed, 11 insertions(+), 41 deletions(-) diff --git a/lib/tableau.ex b/lib/tableau.ex index 7fa393d..49c2ff4 100644 --- a/lib/tableau.ex +++ b/lib/tableau.ex @@ -9,8 +9,7 @@ defmodule Tableau do * `:url` - string (required) - The URL of your website. * `:converters` - mapping of file extensions to converter module. Defaults to `[md: Tableau.MDExConverter]` * `:markdown` - keyword - * `:mdex` - keyword - Options to pass to `MDEx.to_html/2`. See `MDEx` documentation for list of options, as options listed here are non-standard and specific to Tableau. - * `:plugins` - module list - MDEx plugin modules to attach to the processing pipeline + * `:mdex` - keyword - Options to pass to `MDEx.to_html/2` * `:slug` - keyword - Options to pass to `Slug.slugify/2` ### Example @@ -63,5 +62,9 @@ defmodule Tableau do Will use the globally configured options, but you can also pass it overrides. """ - defdelegate markdown(content, overrides \\ []), to: Tableau.MDExConverter + def markdown(content, overrides \\ []) do + {:ok, config} = Tableau.Config.get() + + MDEx.to_html!(content, Keyword.merge(config.markdown[:mdex], overrides)) + end end diff --git a/lib/tableau/converters/mdex_converter.ex b/lib/tableau/converters/mdex_converter.ex index 28cca7b..597e773 100644 --- a/lib/tableau/converters/mdex_converter.ex +++ b/lib/tableau/converters/mdex_converter.ex @@ -1,41 +1,8 @@ defmodule Tableau.MDExConverter do @moduledoc """ - Converter to parse markdown content with `MDEx` with support for MDEx plugins. + Converter to parse markdown content with `MDEx` """ - - @doc """ - Convert markdown content to HTML using `MDEx.to_html!/2`. - - Will use the globally configured options, but you can also pass it overrides. - """ - def markdown(content, overrides \\ []) do - {:ok, config} = Tableau.Config.get() - - {plugins, mdex_config} = - config.markdown[:mdex] - |> Keyword.merge(overrides) - |> Keyword.pop(:plugins, []) - - render!(content, mdex_config, plugins) - end - def convert(_filepath, _front_matter, body, %{site: %{config: config}}) do - {plugins, mdex_config} = Keyword.pop(config.markdown[:mdex], :plugins, []) - render!(body, mdex_config, plugins) - end - - defp render!(content, mdex_config, plugins) do - mdex_config - |> Keyword.put(:markdown, content) - |> MDEx.new() - |> attach_plugins(plugins) - |> MDEx.to_html!() - end - - defp attach_plugins(mdex, plugins) do - Enum.reduce(plugins, mdex, fn mod, mdex -> - Code.ensure_loaded!(mod) - mod.attach(mdex) - end) + MDEx.to_html!(body, config.markdown[:mdex]) end end diff --git a/mix.exs b/mix.exs index 692d37d..fed4878 100644 --- a/mix.exs +++ b/mix.exs @@ -37,7 +37,7 @@ defmodule Tableau.MixProject do {:date_time_parser, "~> 1.2"}, {:html_entities, "~> 0.5.2"}, {:libgraph, "~> 0.16.0"}, - {:mdex, "~> 0.10.0"}, + {:mdex, "~> 0.11.1"}, {:schematic, "~> 0.5.1"}, {:slugify, "~> 1.3"}, {:tz, "~> 0.28.1"}, diff --git a/mix.lock b/mix.lock index 8477d74..da039e4 100644 --- a/mix.lock +++ b/mix.lock @@ -1,5 +1,5 @@ %{ - "autumn": {:hex, :autumn, "0.5.7", "f6bfdc30d3f8d5e82ba5648489db7a7b6b7479d7be07a8288d4db2437434e26d", [:mix], [{:nimble_options, "~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:rustler, "~> 0.29", [hex: :rustler, repo: "hexpm", optional: true]}, {:rustler_precompiled, "~> 0.6", [hex: :rustler_precompiled, repo: "hexpm", optional: false]}], "hexpm", "d272bfddeeea863420a8eb994d42af219ca5391191dd765bf045fbacf56a28d1"}, + "autumn": {:hex, :autumn, "0.6.0", "56cba6145da885262ef705e6e7a83d981e1f756d629a6d0e10b79a79243b702b", [:mix], [{:nimble_options, "~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:rustler, "~> 0.29", [hex: :rustler, repo: "hexpm", optional: false]}, {:rustler_precompiled, "~> 0.6", [hex: :rustler_precompiled, repo: "hexpm", optional: false]}], "hexpm", "d9f7bad90b462e2e3ae3ce3a6d0dcd128230fec2a276cba0af18ce26165b54ce"}, "bandit": {:hex, :bandit, "1.5.7", "6856b1e1df4f2b0cb3df1377eab7891bec2da6a7fd69dc78594ad3e152363a50", [:mix], [{:hpax, "~> 1.0.0", [hex: :hpax, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:thousand_island, "~> 1.0", [hex: :thousand_island, repo: "hexpm", optional: false]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "f2dd92ae87d2cbea2fa9aa1652db157b6cba6c405cb44d4f6dd87abba41371cd"}, "castore": {:hex, :castore, "1.0.17", "4f9770d2d45fbd91dcf6bd404cf64e7e58fed04fadda0923dc32acca0badffa2", [:mix], [], "hexpm", "12d24b9d80b910dd3953e165636d68f147a31db945d2dcb9365e441f8b5351e5"}, "date_time_parser": {:hex, :date_time_parser, "1.2.0", "3d5a816b91967f51e0f94dcb16a34b2cb780f22cd48931779e81d72f7d3eadb1", [:mix], [{:kday, "~> 1.0", [hex: :kday, repo: "hexpm", optional: false]}], "hexpm", "0cf09ada9f42c0b3bfba02dc0ea2e4b4d2f543d9d2bf99b831a29e6b4a4160e5"}, @@ -15,7 +15,7 @@ "makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"}, "makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [: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", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"}, "makeup_erlang": {:hex, :makeup_erlang, "1.0.2", "03e1804074b3aa64d5fad7aa64601ed0fb395337b982d9bcf04029d68d51b6a7", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "af33ff7ef368d5893e4a267933e7744e46ce3cf1f61e2dccf53a111ed3aa3727"}, - "mdex": {:hex, :mdex, "0.10.0", "eae4d3bd4c0b77d6d959146a2d6faaec045686548ad1468630130095dbd93def", [:mix], [{:autumn, ">= 0.5.4", [hex: :autumn, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:nimble_options, "~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}, {:rustler, "~> 0.32", [hex: :rustler, repo: "hexpm", optional: false]}, {:rustler_precompiled, "~> 0.7", [hex: :rustler_precompiled, repo: "hexpm", optional: false]}], "hexpm", "6ad76e32056c44027fe985da7da506e033b07037896d1f130f7d5c332b0d0ac0"}, + "mdex": {:hex, :mdex, "0.11.2", "7b01f784f38b0dfea92af164b8d1dae6f31f77e344da821b852be7bd8cd67484", [:mix], [{:autumn, ">= 0.6.0", [hex: :autumn, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:nimble_options, "~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 1.0", [hex: :phoenix_live_view, repo: "hexpm", optional: true]}, {:rustler, "~> 0.32", [hex: :rustler, repo: "hexpm", optional: true]}, {:rustler_precompiled, "~> 0.7", [hex: :rustler_precompiled, repo: "hexpm", optional: false]}], "hexpm", "3a9d3f7049be6e37793cbe533bc6eea2e4df572aca32a67a857a2e8921964c00"}, "mime": {:hex, :mime, "2.0.6", "8f18486773d9b15f95f4f4f1e39b710045fa1de891fada4516559967276e4dc2", [:mix], [], "hexpm", "c9945363a6b26d747389aac3643f8e0e09d30499a138ad64fe8fd1d13d9b153e"}, "nimble_options": {:hex, :nimble_options, "1.1.1", "e3a492d54d85fc3fd7c5baf411d9d2852922f66e69476317787a7b2bb000a61b", [:mix], [], "hexpm", "821b2470ca9442c4b6984882fe9bb0389371b8ddec4d45a9504f00a66f650b44"}, "nimble_parsec": {:hex, :nimble_parsec, "1.4.2", "8efba0122db06df95bfaa78f791344a89352ba04baedd3849593bfce4d0dc1c6", [:mix], [], "hexpm", "4b21398942dda052b403bbe1da991ccd03a053668d147d53fb8c4e0efe09c973"},