summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/HTML.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-01-05 12:07:09 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-01-05 12:07:09 -0800
commit08efc7db605d26877483c029ed3841e76d5a2f59 (patch)
tree8b1c1e564f4ff6dfe449bce4494e43f17516b526 /src/Text/Pandoc/Writers/HTML.hs
parentc45ae571ccee3cd0e6aa11b3b43e8eaf6315386b (diff)
Implemented toc-depth for html writer.
Diffstat (limited to 'src/Text/Pandoc/Writers/HTML.hs')
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs5
1 files changed, 3 insertions, 2 deletions
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