diff --git a/src/Rib/Markup.hs b/src/Rib/Markup.hs index 0f47475..97900b7 100644 --- a/src/Rib/Markup.hs +++ b/src/Rib/Markup.hs @@ -72,10 +72,5 @@ class Markup repr where "path" :! Path b File -> IO (Either (MarkupError repr) (Document repr)) - -- | Render the document as Lucid HTML - renderDoc :: - Document repr -> - Either (MarkupError repr) (Html ()) - -- | Convert `MarkupError` to string showMarkupError :: MarkupError repr -> Text diff --git a/src/Rib/Markup/MMark.hs b/src/Rib/Markup/MMark.hs index 2d4b4bd..693e13a 100644 --- a/src/Rib/Markup/MMark.hs +++ b/src/Rib/Markup/MMark.hs @@ -49,15 +49,13 @@ instance Markup MMark where content <- readFileText (toFilePath f) pure $ parseDoc k content - renderDoc = Right . MMark.render . _document_val - showMarkupError = toText . M.errorBundlePretty -- | Parse and render the markup directly to HTML renderMarkdown :: Text -> Html () renderMarkdown s = either (error . showMarkupError @MMark) id $ runExcept $ do doc <- liftEither $ parseDoc @MMark [relfile|.md|] s - liftEither $ renderDoc doc + pure $ MMark.render $ _document_val doc -- | Get the first image in the document if one exists getFirstImg :: MMark -> Maybe URI diff --git a/src/Rib/Markup/Pandoc.hs b/src/Rib/Markup/Pandoc.hs index 126aef9..88cf0e7 100644 --- a/src/Rib/Markup/Pandoc.hs +++ b/src/Rib/Markup/Pandoc.hs @@ -73,20 +73,16 @@ instance Markup Pandoc where mkDoc k <$> parse r content - renderDoc = - fmap toHtmlRaw - . first RibPandocError_PandocError - . liftEither - . render' - . _document_val - showMarkupError = toText @String . show -- | Parse and render the markup directly to HTML renderPandoc :: Path Rel File -> Text -> Html () renderPandoc f s = either (error . showMarkupError @Pandoc) id $ runExcept $ do doc <- liftEither $ parseDoc @Pandoc f s - liftEither $ renderDoc doc + liftEither + $ first RibPandocError_PandocError + $ render' + $ _document_val doc -- | Pure version of `parse` parsePure ::