hakyll-std/TableOfContents: build ordered list in markupHeaders directly
				
					
				
			This commit is contained in:
		
							parent
							
								
									00d1944a27
								
							
						
					
					
						commit
						91fab7dd48
					
				| @ -61,20 +61,20 @@ markupLink (headerId, _, headerProperties) headerText | ||||
| markupHeader :: Tree Block -> H.Html | ||||
| markupHeader n@(Node (Header _ hAttr hText) headers) | ||||
|   | headers == [] = H.li $ link | ||||
|   | otherwise     = H.li $ link <> (H.ol $ markupHeaders headers) | ||||
|   | otherwise     = H.li $ link <> markupHeaders headers | ||||
|   where link = fromRight mempty . runPure . writeHtml5 def $ Pandoc nullMeta [Plain [markupLink hAttr hText]] | ||||
| markupHeader n = error $    "'markupHeader' should only be passed a 'Node $ Header'\n" | ||||
|                          ++ "    saw: " ++ show n | ||||
| 
 | ||||
| markupHeaders :: Forest Block -> H.Html | ||||
| markupHeaders = mconcat . map markupHeader | ||||
| markupHeaders = H.ol . mconcat . map markupHeader | ||||
| 
 | ||||
| createTable :: TOCAlignment -> Forest Block -> Block | ||||
| createTable _ [] = Null | ||||
| createTable alignment headers | ||||
|     = render $ (H.nav ! (A.id "toc" <> alignmentAttr)) $ do | ||||
|             H.p "Contents" | ||||
|             H.ol $ markupHeaders headers | ||||
|             markupHeaders headers | ||||
|   where render = (RawBlock "html") . renderHtml | ||||
|         alignmentAttr = case alignment of | ||||
|                            TOCRight -> A.class_ "right-toc" | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user