Skip to content

Commit 2a4ff2b

Browse files
committed
ensure that markdown renderer will allow raw html
1 parent ebdf894 commit 2a4ff2b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Lucid/Extended.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ module Lucid.Extended
1515
)
1616
where
1717

18-
import CMark (Node (..), NodeType (..), commonmarkToHtml, commonmarkToNode)
18+
import CMark (Node (..), NodeType (..), commonmarkToHtml, commonmarkToNode, optUnsafe)
1919
import qualified Data.Text as T
2020
import Lucid hiding (button_, col_)
2121
import Lucid.Base (makeAttribute)
2222
import Protolude
2323

2424
renderMarkdown :: Text -> Text
25-
renderMarkdown = commonmarkToHtml []
25+
renderMarkdown = commonmarkToHtml [optUnsafe]
2626

2727
nodeToText :: Node -> Text
2828
nodeToText (Node _ nodeType children) = case nodeType of

test/Spec/Markdown.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Spec.Markdown (markdownSpec) where
22

3-
import Lucid.Extended (extractMetaDescription)
3+
import Lucid.Extended (extractMetaDescription, renderMarkdown)
44
import Protolude
55
import Test.Tasty.Hspec (Spec, describe, it, shouldReturn)
66

@@ -27,3 +27,7 @@ markdownSpec = do
2727
describe "Meta Description Truncation" $ do
2828
it "returns without broken word" $
2929
pure (extractMetaDescription 6 "foo bar") `shouldReturn` "foo..."
30+
describe "Markdown to HTML" $ do
31+
let runRenderMarkdown = pure . renderMarkdown
32+
it "returns raw html" $
33+
runRenderMarkdown "<video></video>" `shouldReturn` "<p><video></video></p>\n"

0 commit comments

Comments
 (0)