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:
parent
7424454ace
commit
d2704c2af1
1 changed files with 4 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue