Ticket #203 (closed defect: fixed)

Opened 2 years ago

Last modified 10 months ago

very difficult to list pragmas in haddock code blocks

Reported by: JeremyShaw Owned by:
Priority: minor Milestone:
Version: 2.9.4 Keywords:
Cc:

Description

I would like to embed this as a code block in haddock:

> {-# LANGUAGE QuasiQuotes #-}
> import Data.Char        (toUpper)
> import HSX.QQ           (hsx)
> import HSX.XMLGenerator
>
> html :: (XMLGenerator m) => XMLGenT m (XMLType m)
> html = [hsx| <p><% map toUpper "hello, world!"  %></p> |]

But, the LANGUAGE pragma gets stripped out. I can do this inside the normal part of the haddock comment:

{&#45;\# LANGUAGE QuasiQuotes? \#&#45;}

And it renders as desired. However, if I put that inside the code block, it does not get stripped out, but it also does not get unescaped. So, it shows up exactly like that.

As far as I can tell, there is no way to actually show the pragma in the code block.

Change History

Changed 2 years ago by SimonHengel

That's weird, it seems to me that this only happens if you use {- ... -}-style comments.

I think the following can be used to work around this (for now).

-- |
-- > {-# LANGUAGE QuasiQuotes #-}
-- > import Data.Char        (toUpper)
-- > import HSX.QQ           (hsx)
-- > import HSX.XMLGenerator
-- >
-- > html :: (XMLGenerator m) => XMLGenT m (XMLType m)
-- > html = [hsx| <p><% map toUpper "hello, world!"  %></p> |]

Changed 2 years ago by anonymous

  • milestone 2.10.0 deleted

Milestone 2.10.0 deleted

Changed 10 months ago by Fūzetsu

  • status changed from new to closed
  • resolution set to fixed

With HEAD, you can now also use the ‘@’ style code block which now fixes the problem with the HTML code being unescaped (although you'll have to escape some ‘<’s now). This now does what you wanted so I'm closing the issue as fixed.

http://fuuzetsu.co.uk/images/1389578747.png

Note: See TracTickets for help on using tickets.