Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide means of rendering pretty HTML #2

Open
bitemyapp opened this issue Oct 13, 2016 · 6 comments
Open

Provide means of rendering pretty HTML #2

bitemyapp opened this issue Oct 13, 2016 · 6 comments

Comments

@bitemyapp
Copy link

https://hackage.haskell.org/package/blaze-markup-0.7.0.2/docs/Text-Blaze-Renderer-Pretty.html

@bitemyapp
Copy link
Author

Also wow is that being String unfortunate.

@bitemyapp
Copy link
Author

screenshot from 2016-10-12 21-24-25

low whistle

Pretty bad.

@bitemyapp
Copy link
Author

HTML it returns isn't even correct :\

@alpmestan
Copy link
Contributor

Do you get the same issue with this one ?

A PrettyHTML content type could be defined as follows, assuming the rendering function I pointed to doesn't have the problem you've mentionned.

{-# LANGUAGE DeriveDataTypeable    #-}
{-# LANGUAGE FlexibleInstances     #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}

import           Data.Typeable                 (Typeable)
import qualified Network.HTTP.Media            as M
import           Servant.API                   (Accept (..), MimeRender (..))
import           Text.Blaze.Html               (Html, ToMarkup, toHtml)
import           Text.Blaze.Html.Renderer.Pretty (renderHtml)

data PrettyHTML deriving Typeable

-- | @text/html;charset=utf-8@
instance Accept PrettyHTML where
    contentType _ = "text" M.// "html" M./: ("charset", "utf-8")

instance OVERLAPPABLE_ ToMarkup a => MimeRender PrettyHTML a where
    mimeRender _ = renderHtml . toHtml

instance OVERLAPPING_ MimeRender PrettyHTML Html where
mimeRender _ = renderHtml

@bitemyapp
Copy link
Author

@alpmestan that is the same renderer that's broken, look: https://hackage.haskell.org/package/blaze-html-0.8.1.2/docs/src/Text-Blaze-Html-Renderer-Pretty.html#renderHtml

The method of furnishing pretty HTML (changing type) seems fine to me, but I'm a bit galled that there isn't a working pretty HTML renderer.

@alpmestan
Copy link
Contributor

Oh, it just calls out to the other. Well, if you fix it or find another one, we can put together a PR for a pretty HTML combinator :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants