Support highlighting Haskell code in code fences in markdown pages

This commit is contained in:
Chris Done 2014-05-29 00:59:22 +02:00
parent baab9896eb
commit 66aa649bfa

View file

@ -1,3 +1,4 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-} {-# LANGUAGE BangPatterns #-}
-- | Markdown files. -- | Markdown files.
@ -6,6 +7,8 @@ module HL.M.Markdown where
import HL.C import HL.C
import HL.Types import HL.Types
import HL.V.Code
import Control.Exception import Control.Exception
import qualified Data.Text.IO as ST import qualified Data.Text.IO as ST
@ -20,7 +23,11 @@ getMarkdown name =
do exists <- doesFileExist fp do exists <- doesFileExist fp
if exists if exists
then do text <- fmap L.fromStrict (ST.readFile fp) then do text <- fmap L.fromStrict (ST.readFile fp)
let !html = markdown def text let !html = markdown def { msBlockCodeRenderer = renderer } text
return html return html
else throw (MarkdownFileUnavailable name) else throw (MarkdownFileUnavailable name)
where fp = "static" </> "markdown" </> name where fp = "static" </> "markdown" </> name
renderer lang (src,_) =
if lang == Just "haskell"
then haskellPre src
else toHtml src