diff --git a/lib/beacon/template/markdown.ex b/lib/beacon/template/markdown.ex index 1c106ee0..4da52ca3 100644 --- a/lib/beacon/template/markdown.ex +++ b/lib/beacon/template/markdown.ex @@ -7,8 +7,18 @@ defmodule Beacon.Template.Markdown do # TODO: implement a markdown format that is aware of Phoenix features like link attrs and assigns + @doc """ + Convert a markdown `template` into HTML using [mdex](https://hex.pm/packages/mdex) + + ## Options + + * `:syntax_highlight_theme` (default `"onedark"`) - see https://hexdocs.pm/mdex/MDEx.html#to_html/2 for more info. + + """ @spec convert_to_html(Beacon.Template.t(), Beacon.Template.LoadMetadata.t()) :: {:cont, Beacon.Template.t()} | {:halt, Exception.t()} - def convert_to_html(template, _metadata) do + def convert_to_html(template, _metadata, opts \\ []) do + syntax_highlight_theme = Keyword.get(opts, :syntax_highlight_theme, "onedark") + template = MDEx.to_html(template, extension: [ @@ -26,7 +36,7 @@ defmodule Beacon.Template.Markdown do unsafe_: true ], features: [ - syntax_highlight_theme: "onedark" + syntax_highlight_theme: syntax_highlight_theme ] )