-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add markdown support to challenge description (#490)
- Loading branch information
1 parent
418716b
commit 0114391
Showing
6 changed files
with
36 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
defmodule SafiraWeb.Components.Markdown do | ||
@moduledoc """ | ||
Markdown component. | ||
""" | ||
use SafiraWeb, :component | ||
|
||
attr :content, :string, default: "" | ||
attr :class, :string, default: "" | ||
|
||
def markdown(assigns) do | ||
html = | ||
assigns.content | ||
|> String.trim() | ||
|> Earmark.as_html!() | ||
|> raw() | ||
|
||
assigns = assign(assigns, :html, html) | ||
|
||
~H""" | ||
<section class={@class}> | ||
<%= @html %> | ||
</section> | ||
""" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters