Skip to content

Commit

Permalink
Allow passing theme to Markdown converter
Browse files Browse the repository at this point in the history
Use on code blocks
  • Loading branch information
leandrocp committed Oct 2, 2023
1 parent 8de6a05 commit 884fbf7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/beacon/template/markdown.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -26,7 +36,7 @@ defmodule Beacon.Template.Markdown do
unsafe_: true
],
features: [
syntax_highlight_theme: "onedark"
syntax_highlight_theme: syntax_highlight_theme
]
)

Expand Down

0 comments on commit 884fbf7

Please sign in to comment.