git.iko.soy/typeable/pandoc
on master help sign in
HTML writer: put anchors around contents of headers, not around
4f3ad77fiddlosopher
src/Text/Pandoc/Writers/HTML.hs+11−11
@@ -274,17 +274,17 @@ blockToHtml opts (Header level lst) = do
274 let attribs = if writerStrictMarkdown opts && not (writerTableOfContents opts)
274 let attribs = if writerStrictMarkdown opts && not (writerTableOfContents opts)
275 then []
275 then []
276 else [identifier id]
276 else [identifier id]
277+ let contents' = if writerTableOfContents opts
278+ then anchor ! [href ("#TOC-" ++ id)] $ contents
279+ else contents
277− let headerHtml = case level of
280+ return $ case level of
278− 1 -> h1 contents ! attribs
281+ 1 -> h1 contents' ! attribs
279− 2 -> h2 contents ! attribs
282+ 2 -> h2 contents' ! attribs
280− 3 -> h3 contents ! attribs
283+ 3 -> h3 contents' ! attribs
281− 4 -> h4 contents ! attribs
284+ 4 -> h4 contents' ! attribs
282− 5 -> h5 contents ! attribs
285+ 5 -> h5 contents' ! attribs
283− 6 -> h6 contents ! attribs
286+ 6 -> h6 contents' ! attribs
284− _ -> paragraph contents ! attribs
287+ _ -> paragraph contents' ! attribs
285− return $ if writerTableOfContents opts
286− then anchor ! [href ("#TOC-" ++ id)] $ headerHtml
287− else headerHtml
288blockToHtml opts (BulletList lst) = do
288blockToHtml opts (BulletList lst) = do
289 contents <- mapM (blockListToHtml opts) lst
289 contents <- mapM (blockListToHtml opts) lst
290 let attribs = if writerIncremental opts
290 let attribs = if writerIncremental opts