@@ -11,6 +11,7 @@ import Agda.Syntax.Common.Pretty
1111
1212import Agda.Utils.Impossible (__IMPOSSIBLE__ )
1313import Agda.Utils.Function
14+ import Agda.Utils.DocTree
1415
1516import Control.DeepSeq
1617import Control.Monad
@@ -38,41 +39,15 @@ import qualified Text.Blaze.Html5.Attributes as Attr
3839import Text.Blaze.Html.Renderer.Text ( renderHtml )
3940import Text.Blaze.Html5 as Html hiding (map )
4041
41- data DocTree = Node Aspects [DocTree ] | Text Text. Text | Mark (Maybe Aspects )
42-
4342renderToHtml :: Doc -> Text
44- renderToHtml = finish . Ppr. fullRenderAnn Ppr. PageMode 100 1.5 cont [] where
45- consText (Ppr. Chr c) (Text t: ts) = Text (c `Text.cons` t): ts
46- consText (Ppr. Str c) (Text t: ts) = Text (Text. pack c <> t): ts
47- consText (Ppr. PStr c) (Text t: ts) = Text (Text. pack c <> t): ts
48- consText (Ppr. Chr c) ts = Text (Text. singleton c): ts
49- consText (Ppr. Str c) ts = Text (Text. pack c): ts
50- consText (Ppr. PStr c) ts = Text (Text. pack c): ts
51-
52- annotate acc (Mark (Just t): ts) = Node t (reverse acc): ts
53- annotate acc (Mark Nothing : ts) = reverse acc <> ts
54- annotate acc (t: ts) = annotate (t: acc) ts
55- annotate acc [] = __IMPOSSIBLE__
56-
57- cont :: Ppr. AnnotDetails Aspects -> [DocTree ] -> [DocTree ]
58- cont ann acc = case ann of
59- Ppr. AnnotStart -> annotate [] acc
60- Ppr. NoAnnot d _ -> consText d acc
61- Ppr. AnnotEnd a
62- | _: _ <- toAtoms a -> Mark (Just a): acc
63- | otherwise -> Mark Nothing : acc -- uncurry (<>) (break acc)
64-
65- toBlaze :: DocTree -> Html
66- toBlaze (Mark _) = __IMPOSSIBLE__
67- toBlaze (Text t) = Html. text t
68- toBlaze (Node a t) = Html. span do
69- aspectsToHtml Nothing mempty Nothing a $
70- traverse_ toBlaze t
43+ renderToHtml = finish . renderTree' Html. text toblaze . renderToTree where
44+ toblaze a t = Html. span do
45+ aspectsToHtml Nothing mempty Nothing a t
7146 unless (null (note a)) do
7247 Html. span (string (note a)) !! [Attr. class_ " Note" ]
7348
7449 finish = Tl. toStrict . renderHtml . wrapper
75- wrapper = (!! [Attr. class_ " Agda" ]) . Html. pre . traverse_ toBlaze
50+ wrapper = (!! [Attr. class_ " Agda" ]) . Html. pre
7651
7752-- | Data about an identifier
7853data Identifier = Identifier
0 commit comments