aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2020-11-04 21:20:41 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2020-11-04 21:20:41 -0800
commit08134388ad94a9652050f416287dbcaaf2962114 (patch)
treeb46a3b7bb84e9655b987a6839b925f1871004c3d /src/Text
parentb5e9c2a7a644409c4ba9fb6bb429e9c9524cfb01 (diff)
downloadpandoc-08134388ad94a9652050f416287dbcaaf2962114.tar.gz
MediaWiki writer: use syntaxhighlight tag...
instead of deprecated source, for highlighted code. Also support `startFrom` attribute and `numberLines`. Closes #6810.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/MediaWiki.hs11
1 files changed, 9 insertions, 2 deletions
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
[] -> "<pre" <> (if null classes
then ">"
else " class=\"" <> T.unwords classes <> "\">") <>
escapeText str <> "</pre>"
- (l:_) -> "<source lang=\"" <> l <> "\">" <> str <> "</source>"
+ (l:_) -> "<syntaxhighlight lang=\"" <> l <> "\"" <>
+ (if numberLines then " line" else "") <>
+ maybe "" (\x -> " start=\"" <> x <> "\"") start <>
+ ">" <> str <>
+ "</syntaxhighlight>"
-- note: no escape! even for <!
blockToMediaWiki (BlockQuote blocks) = do