From 6ca97c245713ea6ba83a3cd1d3c9873bac6bcd99 Mon Sep 17 00:00:00 2001 From: defanor Date: Wed, 8 Nov 2017 13:05:35 +0300 Subject: Denote headings --- Pancake/Printing.hs | 1 + Pancake/Rendering.hs | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'Pancake') diff --git a/Pancake/Printing.hs b/Pancake/Printing.hs index 9bc6c81..04d9de6 100644 --- a/Pancake/Printing.hs +++ b/Pancake/Printing.hs @@ -93,6 +93,7 @@ showSexps uri ro = showDenotation :: Denotation -> String showDenotation (Link u) = list ["link", ".", encodeStr $ show u] showDenotation (Math m) = list ["math", ".", encodeStr m] + showDenotation (Heading l) = list ["heading", ".", show l] mergeStyled :: [Styled] -> [Styled] mergeStyled = foldr mergeStyled' [] diff --git a/Pancake/Rendering.hs b/Pancake/Rendering.hs index e88a9ad..0794616 100644 --- a/Pancake/Rendering.hs +++ b/Pancake/Rendering.hs @@ -37,6 +37,7 @@ data Listing = Bulleted data Denotation = Link URI | Math String + | Heading Int deriving (Show, Eq) -- | A styled string. @@ -339,11 +340,10 @@ renderBlock (P.DefinitionList dl) = in mapM_ renderDefinition dl renderBlock (P.Header level attr i) = do storeAttr attr - strings <- readInlines i - storeLines [[""]] - indented $ map (map (Fg Green) . ([fromString (replicate level '#'), " "] ++) - . map (Bold . Underline)) strings - storeLines [[""]] + indented =<< map (map (Denote (Heading level) . Fg Green) + . ([fromString (replicate level '#'), " "] ++) + . map (Bold . Underline)) + <$> readInlines i renderBlock P.HorizontalRule = do st <- get indented [[Fg Black $ -- cgit v1.2.3