mirror of
https://github.com/srid/rib.git
synced 2024-11-26 13:50:31 +03:00
Remove renderDoc from type class
This commit is contained in:
parent
3d24954226
commit
7f9a25e0d6
@ -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
|
||||
|
@ -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|<memory>.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
|
||||
|
@ -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 ::
|
||||
|
Loading…
Reference in New Issue
Block a user