mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-26 20:02:27 +03:00
tools/pandoc-site: pass in generated toc from top-level filter
This commit is contained in:
parent
e2a322283a
commit
ae987b236b
@ -64,18 +64,17 @@ createTable alignment headers
|
||||
tocString = unpack . fromRight mempty . runPure . writeHtml5String def $ tocDoc
|
||||
in RawBlock "html" (navBegin ++ "\n" ++ tocString ++ "\n" ++ navEnd)
|
||||
|
||||
generateTOC :: [Block] -> TOCAlignment -> Block -> Block
|
||||
generateTOC headers alignment x@(BulletList (( (( Plain ((Str "toc"):_)):_)):_))
|
||||
= createTable alignment . groupByHierarchy $ headers
|
||||
generateTOC _ _ x = x
|
||||
generateTOC :: Block -> Block -> Block
|
||||
generateTOC toc (BulletList (( (( Plain ((Str "toc"):_)):_)):_))
|
||||
= toc
|
||||
generateTOC _ x = x
|
||||
|
||||
tableOfContents :: TOCAlignment -> Pandoc -> Pandoc
|
||||
tableOfContents TOCOff ast = walk ignoreTOC ast
|
||||
tableOfContents alignment ast
|
||||
= let headers = query collectHeaders ast
|
||||
tocGen = case alignment of
|
||||
TOCOff -> walk ignoreTOC
|
||||
_ -> walk (generateTOC headers alignment)
|
||||
in tocGen $ ast
|
||||
= let headers = query collectHeaders ast
|
||||
toc = createTable alignment . groupByHierarchy $ headers
|
||||
in walk (generateTOC toc) ast
|
||||
|
||||
main :: IO ()
|
||||
main = toJSONFilter (tableOfContents TOCRight)
|
||||
|
Loading…
Reference in New Issue
Block a user