Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Implemented toc-depth for html writer.

  • Loading branch information...
commit 08efc7db605d26877483c029ed3841e76d5a2f59 1 parent c45ae57
@jgm authored
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/Text/Pandoc/Writers/HTML.hs
View
5 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
Please sign in to comment.
Something went wrong with that request. Please try again.