aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-11-18 20:03:06 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2021-11-18 21:15:51 -0800
commit25bba0cc62dae54b5b5a4a9ba540fa7b1ec54530 (patch)
treefaa55b1e74a6b4324b42c0d37354c46755f0a6e3 /src
parent005dc7ce56a4a165fa9af239cc28a2589f7b169d (diff)
downloadpandoc-25bba0cc62dae54b5b5a4a9ba540fa7b1ec54530.tar.gz
MediaWiki writer: use HTML spans for anchors when header has id.
Closes #7697.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/MediaWiki.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/MediaWiki.hs b/src/Text/Pandoc/Writers/MediaWiki.hs
index c7c53943a..e5e2dfde2 100644
--- a/src/Text/Pandoc/Writers/MediaWiki.hs
+++ b/src/Text/Pandoc/Writers/MediaWiki.hs
@@ -128,10 +128,16 @@ blockToMediaWiki b@(RawBlock f str)
blockToMediaWiki HorizontalRule = return "\n-----\n"
-blockToMediaWiki (Header level _ inlines) = do
+blockToMediaWiki (Header level (ident,_,_) inlines) = do
+ opts <- gets stOptions
+ let autoId = uniqueIdent (writerExtensions opts) inlines mempty
contents <- inlineListToMediaWiki inlines
let eqs = T.replicate level "="
- return $ eqs <> " " <> contents <> " " <> eqs <> "\n"
+ return $
+ (if T.null ident || autoId == ident
+ then ""
+ else "<span id=\"" <> ident <> "\"></span>\n")
+ <> eqs <> " " <> contents <> " " <> eqs <> "\n"
blockToMediaWiki (CodeBlock (_,classes,keyvals) str) = do
let at = Set.fromList classes `Set.intersection` highlightingLangs