From 08134388ad94a9652050f416287dbcaaf2962114 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 4 Nov 2020 21:20:41 -0800 Subject: MediaWiki writer: use syntaxhighlight tag... instead of deprecated source, for highlighted code. Also support `startFrom` attribute and `numberLines`. Closes #6810. --- src/Text/Pandoc/Writers/MediaWiki.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Writers/MediaWiki.hs b/src/Text/Pandoc/Writers/MediaWiki.hs index 513693389..d1912caa6 100644 --- a/src/Text/Pandoc/Writers/MediaWiki.hs +++ b/src/Text/Pandoc/Writers/MediaWiki.hs @@ -135,15 +135,22 @@ blockToMediaWiki (Header level _ inlines) = do let eqs = T.replicate level "=" return $ eqs <> " " <> contents <> " " <> eqs <> "\n" -blockToMediaWiki (CodeBlock (_,classes,_) str) = do +blockToMediaWiki (CodeBlock (_,classes,keyvals) str) = do let at = Set.fromList classes `Set.intersection` highlightingLangs + let numberLines = any (`elem` ["number","numberLines", "number-lines"]) + classes + let start = lookup "startFrom" keyvals return $ case Set.toList at of [] -> " (if null classes then ">" else " class=\"" <> T.unwords classes <> "\">") <> escapeText str <> "" - (l:_) -> " l <> "\">" <> str <> "" + (l:_) -> " l <> "\"" <> + (if numberLines then " line" else "") <> + maybe "" (\x -> " start=\"" <> x <> "\"") start <> + ">" <> str <> + "" -- note: no escape! even for