Copyright | Copyright (C) 2024 Yoo Chung |
---|---|
License | All rights reserved |
Maintainer | web@chungyc.org |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
Support generation of table of contents in programmatically generated pages on this website. This is for pages where the HTML is directly generated using Haskell code.
For example, the following generates HTML for a table of contents:
>>>
import Text.Blaze.Html.Renderer.Pretty (renderHtml)
>>>
:{
putStr $ renderHtml$ toc $ [ Entry "First section" "#first" [ Entry "First sub-section" "#first-sub" [] , Entry "Second sub-section" "#second-sub" [] ] , Entry "Second section" "#second" [] ] :} <nav class="toc"> <h2> Contents </h2> <ul> <li> <a href="#first"> First section </a> <ul> <li> <a href="#first-sub"> First sub-section </a> </li> <li> <a href="#second-sub"> Second sub-section </a> </li> </ul> </li> <li> <a href="#second"> Second section </a> </li> </ul> </nav>