@@ -727,7 +727,7 @@ getNumId = (((baseListId - 1) +) . length) `fmap` gets stLists
727727
728728
729729makeTOC :: (PandocMonad m) => WriterOptions -> WS m [Element]
730−makeTOC opts | writerTableOfContents opts = do
730+makeTOC opts = do
731731 let depth = "1-"++show (writerTOCDepth opts)
732732 let tocCmd = "TOC \\o \""++depth++"\" \\h \\z \\u"
733733 tocTitle <- gets stTocTitle
@@ -751,8 +751,6 @@ makeTOC opts | writerTableOfContents opts = do
751751 ) -- w:p
752752 ])
753753 ])] -- w:sdt
754−makeTOC _ = return []
755−
756754
757755-- | Convert Pandoc document to two lists of
758756-- OpenXML elements (the main document and footnotes).
@@ -770,6 +768,13 @@ writeOpenXML opts (Pandoc meta blocks) = do
770768 Just (MetaBlocks [Para xs]) -> xs
771769 Just (MetaInlines xs) -> xs
772770 _ -> []
771+ let includeTOC = writerTableOfContents opts ||
772+ case lookupMeta "toc" meta of
773+ Just (MetaBlocks _) -> True
774+ Just (MetaInlines _) -> True
775+ Just (MetaString (_:_)) -> True
776+ Just (MetaBool True) -> True
777+ _ -> False
773778 title <- withParaPropM (pStyleM "Title") $ blocksToOpenXML opts [Para tit | not (null tit)]
774779 subtitle <- withParaPropM (pStyleM "Subtitle") $ blocksToOpenXML opts [Para subtitle' | not (null subtitle')]
775780 authors <- withParaProp (pCustomStyle "Author") $ blocksToOpenXML opts $
@@ -801,7 +806,9 @@ writeOpenXML opts (Pandoc meta blocks) = do
801806 ] ++ annotation
802807 ]
803808 comments' <- mapM toComment comments
804− toc <- makeTOC opts
809+ toc <- if includeTOC
810+ then makeTOC opts
811+ else return []
805812 let meta' = title ++ subtitle ++ authors ++ date ++ abstract ++ toc
806813 return (meta' ++ doc', notes', comments')
807814