From 19d9482fc400cf486547b6a670c946d3634401cf Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Mon, 26 Jun 2017 16:46:56 +0200
Subject: [PATCH] OpenDocument/ODT writer: Added support for table of contents.

Closes #2836.

Thanks to @anayrat.
---
 MANUAL.txt                              | 3 ++-
 src/Text/Pandoc/Writers/OpenDocument.hs | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/MANUAL.txt b/MANUAL.txt
index 6499426e1..b5cea779e 100644
--- a/MANUAL.txt
+++ b/MANUAL.txt
@@ -1228,7 +1228,8 @@ as the following:
 :   non-null value if `--toc/--table-of-contents` was specified
 
 `toc-title`
-:   title of table of contents (works only with EPUB and docx)
+:   title of table of contents (works only with EPUB,
+    opendocument, odt, docx)
 
 `include-before`
 :   contents specified by `-B/--include-before-body` (may have
diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs
index 6c53ab4ab..ed3dabb87 100644
--- a/src/Text/Pandoc/Writers/OpenDocument.hs
+++ b/src/Text/Pandoc/Writers/OpenDocument.hs
@@ -220,6 +220,7 @@ writeOpenDocument opts (Pandoc meta blocks) = do
   let listStyles  = map listStyle (stListStyles s)
   let automaticStyles = vcat $ reverse $ styles ++ listStyles
   let context = defField "body" body
+              $ defField "toc" (writerTableOfContents opts)
               $ defField "automatic-styles" (render' automaticStyles)
               $ metadata
   case writerTemplate opts of