mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-12-04 08:37:59 +01:00
23 lines
492 B
Elixir
23 lines
492 B
Elixir
|
defmodule PhilomenaWeb.TextileMarkdownRenderer do
|
||
|
alias Philomena.Textile.ParserMarkdown
|
||
|
|
||
|
def render_one(post, conn) do
|
||
|
hd(render_collection([post], conn))
|
||
|
end
|
||
|
|
||
|
def render_collection(posts, conn) do
|
||
|
opts = %{image_transform: &Camo.Image.image_url/1}
|
||
|
parsed = Enum.map(posts, &ParserMarkdown.parse(opts, &1.body))
|
||
|
|
||
|
parsed
|
||
|
|> Enum.map(fn tree ->
|
||
|
tree
|
||
|
|> Enum.map(fn
|
||
|
{_k, text} ->
|
||
|
text
|
||
|
end)
|
||
|
|> Enum.join()
|
||
|
end)
|
||
|
end
|
||
|
end
|