From 08efc7db605d26877483c029ed3841e76d5a2f59 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 5 Jan 2013 12:07:09 -0800 Subject: Implemented toc-depth for html writer. --- src/Text/Pandoc/Writers/HTML.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 6222bd810..2345243d2 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -247,8 +247,8 @@ showSecNum = concat . intersperse "." . map show -- | Converts an Element to a list item for a table of contents, -- retrieving the appropriate identifier from state. elementToListItem :: WriterOptions -> Element -> State WriterState (Maybe Html) -elementToListItem _ (Blk _) = return Nothing -elementToListItem opts (Sec _ num id' headerText subsecs) = do +elementToListItem opts (Sec lev num id' headerText subsecs) + | lev <= writerTOCDepth opts = do let sectnum = if writerNumberSections opts then (H.span ! A.class_ "toc-section-number" $ toHtml $ showSecNum num) >> preEscapedString " " @@ -260,6 +260,7 @@ elementToListItem opts (Sec _ num id' headerText subsecs) = do else unordList opts subHeads return $ Just $ (H.a ! A.href (toValue $ "#" ++ writerIdentifierPrefix opts ++ id') $ toHtml txt) >> subList +elementToListItem _ _ = return Nothing -- | Convert an Element to Html. elementToHtml :: Int -> WriterOptions -> Element -> State WriterState Html -- cgit v1.2.3