hakyll-std/TableOfContents: Blaze dependency removed from generateTOC
This commit is contained in:
parent
40934fa72e
commit
c19c62fd2b
@ -66,21 +66,20 @@ markupHeader n = error $ "'markupHeader' should only be passed a 'Node $ Head
|
|||||||
markupHeaders :: Forest Block -> H.Html
|
markupHeaders :: Forest Block -> H.Html
|
||||||
markupHeaders = mconcat . map markupHeader
|
markupHeaders = mconcat . map markupHeader
|
||||||
|
|
||||||
createTable :: Forest Block -> H.Html
|
createTable :: TOCAlignment -> Forest Block -> Block
|
||||||
createTable headers =
|
createTable _ [] = Null
|
||||||
(H.nav ! A.id "toc") $ do
|
createTable alignment headers
|
||||||
H.p "Contents"
|
= render $ (H.nav ! (A.id "toc" <> alignmentAttr)) $ do
|
||||||
H.ol $ markupHeaders headers
|
H.p "Contents"
|
||||||
|
H.ol $ markupHeaders headers
|
||||||
|
where render = (RawBlock "html") . renderHtml
|
||||||
|
alignmentAttr = case alignment of
|
||||||
|
TOCRight -> A.class_ "right-toc"
|
||||||
|
_ -> mempty
|
||||||
|
|
||||||
generateTOC :: [Block] -> TOCAlignment -> Block -> Block
|
generateTOC :: [Block] -> TOCAlignment -> Block -> Block
|
||||||
generateTOC [] _ x = x
|
|
||||||
generateTOC headers alignment x@(BulletList (( (( Plain ((Str "toc"):_)):_)):_))
|
generateTOC headers alignment x@(BulletList (( (( Plain ((Str "toc"):_)):_)):_))
|
||||||
= case alignment of
|
= createTable alignment . groupByHierarchy $ headers
|
||||||
TOCRight -> render . (! A.class_ "right-toc") . table $ headers
|
|
||||||
TOCLeft -> render . table $ headers
|
|
||||||
_ -> x
|
|
||||||
where render = (RawBlock "html") . renderHtml
|
|
||||||
table = createTable . groupByHierarchy
|
|
||||||
generateTOC _ _ x = x
|
generateTOC _ _ x = x
|
||||||
|
|
||||||
tableOfContents :: TOCAlignment -> Pandoc -> Pandoc
|
tableOfContents :: TOCAlignment -> Pandoc -> Pandoc
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user