Working Markdown processing and rendering
This commit is contained in:
@@ -1,7 +1,20 @@
|
||||
module Core.Rendering where
|
||||
|
||||
import Lucid
|
||||
import Data.ByteString.Lazy (ByteString)
|
||||
import Commonmark
|
||||
import Data.ByteString.Lazy (ByteString)
|
||||
import qualified Data.ByteString as B
|
||||
import Data.Text
|
||||
import Data.Text.Encoding (decodeUtf8)
|
||||
import qualified Lucid as LU
|
||||
import System.IO ()
|
||||
|
||||
lucidToTwain :: Html () -> ByteString
|
||||
lucidToTwain = renderBS
|
||||
lucidToTwain :: LU.Html () -> ByteString
|
||||
lucidToTwain = LU.renderBS
|
||||
|
||||
mdToLucid :: Text -> LU.Html ()
|
||||
mdToLucid cmtextinput = case (commonmark "" cmtextinput) of
|
||||
Left _ -> LU.toHtmlRaw ("Failed to parse Markdown document" :: Text)
|
||||
Right (h :: Html ()) -> LU.toHtmlRaw (renderHtml h)
|
||||
|
||||
mdFileToLucid :: FilePath -> IO (LU.Html ())
|
||||
mdFileToLucid path = fmap (mdToLucid . decodeUtf8) (B.readFile path)
|
||||
|
||||
Reference in New Issue
Block a user