Haddock reader: add the "haskell" attribute to code blocks so they are

highlighted. We reasonably assume that code blocks in Haddock markup
wont be used for anything but Haskell code.
This commit is contained in:
David Lazar 2013-03-29 10:35:06 -07:00
parent 7424454ace
commit d2704c2af1

View file

@ -76,7 +76,7 @@ defpara :: { (Inlines, [Blocks]) }
para :: { Blocks }
: seq { para' $1 }
| codepara { codeBlock $1 }
| codepara { codeBlockWith ([], ["haskell"], []) $1 }
| property { $1 }
| examples { $1 }
@ -118,8 +118,8 @@ elem1 :: { Inlines }
| URL { makeHyperlink $1 }
| PIC { image $1 $1 mempty }
| ANAME { mempty } -- TODO
| IDENT { code $1 }
| DQUO strings DQUO { code $2 }
| IDENT { codeWith ([], ["haskell"], []) $1 }
| DQUO strings DQUO { codeWith ([], ["haskell"], []) $2 }
strings :: { String }
: STRING { $1 }
@ -162,7 +162,7 @@ makeProperty s = case strip s of
-- | Create an 'Example', stripping superfluous characters as appropriate
makeExample :: String -> String -> [String] -> Blocks
makeExample prompt expression result =
para $ codeWith ([], ["expr"], []) (strip expression ++ "\n")
para $ codeWith ([], ["haskell", "expr"], []) (strip expression ++ "\n")
<> codeWith ([], ["result"], []) (unlines result')
where
-- 1. drop trailing whitespace from the prompt, remember the prefix