module Prettyprinter.Lucid (renderHtml) where import qualified Data.Text as T import Lucid (Html, ToHtml (toHtml), br_, pre_) import Prettyprinter.Render.Util.SimpleDocTree (SimpleDocTree (..)) renderHtml :: SimpleDocTree (Html () -> Html ()) -> Html () renderHtml :: SimpleDocTree (Html () -> Html ()) -> Html () renderHtml = let go :: SimpleDocTree (Html () -> Html ()) -> Html () go = \case SimpleDocTree (Html () -> Html ()) STEmpty -> () -> Html () forall (f :: * -> *) a. Applicative f => a -> f a pure () STChar Char c -> Text -> Html () forall a (m :: * -> *). (ToHtml a, Monad m) => a -> HtmlT m () toHtml (Text -> Html ()) -> Text -> Html () forall a b. (a -> b) -> a -> b $ Char -> Text T.singleton Char c STText Int _ Text t -> Text -> Html () forall a (m :: * -> *). (ToHtml a, Monad m) => a -> HtmlT m () toHtml Text t STLine Int i -> [Attribute] -> Html () forall (m :: * -> *). Applicative m => [Attribute] -> HtmlT m () br_ [] Html () -> Html () -> Html () forall (m :: * -> *) a b. Monad m => m a -> m b -> m b >> Text -> Html () forall a (m :: * -> *). (ToHtml a, Monad m) => a -> HtmlT m () toHtml (Int -> Text -> Text T.replicate Int i (Text -> Text) -> Text -> Text forall a b. (a -> b) -> a -> b $ Char -> Text T.singleton Char ' ') STAnn Html () -> Html () ann SimpleDocTree (Html () -> Html ()) content -> Html () -> Html () ann (Html () -> Html ()) -> Html () -> Html () forall a b. (a -> b) -> a -> b $ SimpleDocTree (Html () -> Html ()) -> Html () go SimpleDocTree (Html () -> Html ()) content STConcat [SimpleDocTree (Html () -> Html ())] contents -> (SimpleDocTree (Html () -> Html ()) -> Html ()) -> [SimpleDocTree (Html () -> Html ())] -> Html () forall (t :: * -> *) m a. (Foldable t, Monoid m) => (a -> m) -> t a -> m foldMap SimpleDocTree (Html () -> Html ()) -> Html () go [SimpleDocTree (Html () -> Html ())] contents in Html () -> Html () forall arg result. Term arg result => arg -> result pre_ (Html () -> Html ()) -> (SimpleDocTree (Html () -> Html ()) -> Html ()) -> SimpleDocTree (Html () -> Html ()) -> Html () forall b c a. (b -> c) -> (a -> b) -> a -> c . SimpleDocTree (Html () -> Html ()) -> Html () go