File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
test/lib/code_corps/services Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,9 @@ defmodule CodeCorps.Services.MarkdownRendererService do
1616
1717 @ spec convert_into_html ( String . t ) :: String . t
1818 defp convert_into_html ( markdown ) do
19- Earmark . as_html! ( markdown )
19+ # Prism.js requires a `language-` prefix in code classes
20+ # See: https://github.com/pragdave/earmark#syntax-highlightning
21+ Earmark . as_html! ( markdown , % Earmark.Options { code_class_prefix: "language-" } )
2022 end
2123
2224 @ spec put_into ( String . t , Changeset . t , atom ) :: Changeset . t
Original file line number Diff line number Diff line change @@ -21,6 +21,16 @@ defmodule CodeCorps.Services.MarkdownRendererServiceTest do
2121 assert changeset |> Ecto.Changeset . get_change ( :body ) == "<p>A <strong>strong</strong> body</p>\n "
2222 end
2323
24+ test "adds the right css class prefixes" do
25+ attrs = @ valid_attrs |> Map . merge ( % { markdown: "```css\n span {}\n ```" } )
26+ changeset =
27+ % Task { }
28+ |> Task . changeset ( attrs )
29+ |> render_markdown_to_html ( :markdown , :body )
30+
31+ assert changeset |> Ecto.Changeset . get_change ( :body ) == "<pre><code class=\" css language-css\" >span {}</code></pre>\n "
32+ end
33+
2434 test "returns changeset when changeset is invalid" do
2535 changeset =
2636 % Task { }
You can’t perform that action at this time.
0 commit comments