From 25bba0cc62dae54b5b5a4a9ba540fa7b1ec54530 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 18 Nov 2021 20:03:06 -0800 Subject: MediaWiki writer: use HTML spans for anchors when header has id. Closes #7697. --- src/Text/Pandoc/Writers/MediaWiki.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/Text') 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 " ident <> "\">\n") + <> eqs <> " " <> contents <> " " <> eqs <> "\n" blockToMediaWiki (CodeBlock (_,classes,keyvals) str) = do let at = Set.fromList classes `Set.intersection` highlightingLangs -- cgit v1.2.3