summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-11-01 23:44:10 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-11-01 23:44:10 +0100
commit836e3ffa5a5c028fd505d6139f8bc3738d680fd6 (patch)
treeebdc4f7cb35cbbaf7e84815e4bb2b85da9044bea
parentRemove fromJust. (diff)
downloadvimwiki-scripts-836e3ffa5a5c028fd505d6139f8bc3738d680fd6.tar.gz
vimwiki-scripts-836e3ffa5a5c028fd505d6139f8bc3738d680fd6.tar.xz
Only include sidebar if TOC is available.
-rw-r--r--hs/src/Html.hs23
1 files changed, 13 insertions, 10 deletions
diff --git a/hs/src/Html.hs b/hs/src/Html.hs
index f46974d..24eb395 100644
--- a/hs/src/Html.hs
+++ b/hs/src/Html.hs
@@ -169,8 +169,8 @@ buildBreadcrumbs links = f <$> links
$ H.string (takeBaseName link)
-htmlWrap :: Configuration -> String -> [FilePath] -> Html -> Html -> Html -> Html
-htmlWrap conf title parts backlinks toc main = docTypeHtml $ do
+htmlWrap :: Configuration -> String -> [FilePath] -> Html -> Maybe Html -> Html -> Html
+htmlWrap conf title parts backlinks mtoc main = docTypeHtml $ do
H.head $ do
H.meta ! charset "utf-8"
H.meta ! name "generator" ! content "pandoc"
@@ -197,12 +197,15 @@ htmlWrap conf title parts backlinks toc main = docTypeHtml $ do
H.input ! A.type_ "submit" ! A.value "Sök"
H.div ! A.id "with-resizer" $ do
H.main $ main
- H.div ! A.id "resizer" $ do
- H.div ! A.id "resize-handle" $ "<>"
- H.nav ! A.id "TOC" ! role "doc-toc" $ do
- H.div $ do
- H.h2 ! A.id "toc-title" $ "Table of Contents"
- toc
+ case mtoc of
+ Just toc -> do
+ H.div ! A.id "resizer" $ do
+ H.div ! A.id "resize-handle" $ "<>"
+ H.nav ! A.id "TOC" ! role "doc-toc" $ do
+ H.div $ do
+ H.h2 ! A.id "toc-title" $ "Table of Contents"
+ toc
+ Nothing -> return mempty
H.footer $ do
backlinks
@@ -240,9 +243,9 @@ handlePart conf outdir backlinks wiki_root parts = do
pandoc <- handleSourceText conf text
let Pandoc meta blocks = pandoc
#if MIN_VERSION_pandoc(2, 6, 0)
- toc <- writeHtml5 def $ Pandoc meta $ [toTableOfContents def blocks]
+ toc <- fmap Just <$> writeHtml5 def $ Pandoc meta $ [toTableOfContents def blocks]
#else
- let toc = mempty
+ let toc = Nothing
#endif
html <- writeHtml5 def pandoc