diff options
author | John MacFarlane <jgm@berkeley.edu> | 2021-11-18 20:03:06 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2021-11-18 21:15:51 -0800 |
commit | 25bba0cc62dae54b5b5a4a9ba540fa7b1ec54530 (patch) | |
tree | faa55b1e74a6b4324b42c0d37354c46755f0a6e3 /src | |
parent | 005dc7ce56a4a165fa9af239cc28a2589f7b169d (diff) | |
download | pandoc-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.hs | 10 |
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 |