aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-02-21 17:13:59 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-02-21 17:13:59 +0100
commit7af3d90ae1ca43eb8354876c7dc2e8e2245f2274 (patch)
tree9ccd76a69de42265809b69126cb000ee26d107bb /src/Text
parent612f1238aafc169f220d63611442a550c3ed0b83 (diff)
downloadpandoc-7af3d90ae1ca43eb8354876c7dc2e8e2245f2274.tar.gz
MediaWiki writer: Updated list of syntax highlighting languages.
Now 'r' gets you `<source>` rather than `<code>` (among others). Closes #3461.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/MediaWiki.hs658
1 files changed, 641 insertions, 17 deletions
diff --git a/src/Text/Pandoc/Writers/MediaWiki.hs b/src/Text/Pandoc/Writers/MediaWiki.hs
index dc6206e6c..c554812fd 100644
--- a/src/Text/Pandoc/Writers/MediaWiki.hs
+++ b/src/Text/Pandoc/Writers/MediaWiki.hs
@@ -38,7 +38,8 @@ import Text.Pandoc.Pretty (render)
import Text.Pandoc.ImageSize
import Text.Pandoc.Templates (renderTemplate')
import Text.Pandoc.XML ( escapeStringForXML )
-import Data.List ( intersect, intercalate )
+import Data.List ( intercalate )
+import qualified Data.Set as Set
import Network.URI ( isURI )
import Control.Monad.Reader
import Control.Monad.State
@@ -137,23 +138,15 @@ blockToMediaWiki (Header level _ inlines) = do
return $ eqs ++ " " ++ contents ++ " " ++ eqs ++ "\n"
blockToMediaWiki (CodeBlock (_,classes,_) str) = do
- let at = classes `intersect` ["actionscript", "ada", "apache", "applescript", "asm", "asp",
- "autoit", "bash", "blitzbasic", "bnf", "c", "c_mac", "caddcl", "cadlisp", "cfdg", "cfm",
- "cpp", "cpp-qt", "csharp", "css", "d", "delphi", "diff", "div", "dos", "eiffel", "fortran",
- "freebasic", "gml", "groovy", "html4strict", "idl", "ini", "inno", "io", "java", "java5",
- "javascript", "latex", "lisp", "lua", "matlab", "mirc", "mpasm", "mysql", "nsis", "objc",
- "ocaml", "ocaml-brief", "oobas", "oracle8", "pascal", "perl", "php", "php-brief", "plsql",
- "python", "qbasic", "rails", "reg", "robots", "ruby", "sas", "scheme", "sdlbasic",
- "smalltalk", "smarty", "sql", "tcl", "", "thinbasic", "tsql", "vb", "vbnet", "vhdl",
- "visualfoxpro", "winbatch", "xml", "xpp", "z80"]
+ let at = Set.fromList classes `Set.intersection` highlightingLangs
return $
- if null at
- then "<pre" ++ (if null classes
- then ">"
- else " class=\"" ++ unwords classes ++ "\">") ++
- escapeString str ++ "</pre>"
- else "<source lang=\"" ++ head at ++ "\">" ++ str ++ "</source>"
- -- note: no escape!
+ case Set.toList at of
+ [] -> "<pre" ++ (if null classes
+ then ">"
+ else " class=\"" ++ unwords classes ++ "\">") ++
+ escapeString str ++ "</pre>"
+ (l:_) -> "<source lang=\"" ++ l ++ "\">" ++ str ++ "</source>"
+ -- note: no escape! even for <!
blockToMediaWiki (BlockQuote blocks) = do
contents <- blockListToMediaWiki blocks
@@ -440,3 +433,634 @@ inlineToMediaWiki (Note contents) = do
modify (\s -> s { stNotes = True })
return $ "<ref>" ++ contents' ++ "</ref>"
-- note - may not work for notes with multiple blocks
+
+highlightingLangs :: Set.Set String
+highlightingLangs = Set.fromList [
+ "abap",
+ "abl",
+ "abnf",
+ "aconf",
+ "actionscript",
+ "actionscript3",
+ "ada",
+ "ada2005",
+ "ada95",
+ "adl",
+ "agda",
+ "ahk",
+ "alloy",
+ "ambienttalk",
+ "ambienttalk/2",
+ "antlr",
+ "antlr-actionscript",
+ "antlr-as",
+ "antlr-c#",
+ "antlr-cpp",
+ "antlr-csharp",
+ "antlr-java",
+ "antlr-objc",
+ "antlr-perl",
+ "antlr-python",
+ "antlr-rb",
+ "antlr-ruby",
+ "apache",
+ "apacheconf",
+ "apl",
+ "applescript",
+ "arduino",
+ "arexx",
+ "as",
+ "as3",
+ "asm",
+ "aspectj",
+ "aspx-cs",
+ "aspx-vb",
+ "asy",
+ "asymptote",
+ "at",
+ "autohotkey",
+ "autoit",
+ "awk",
+ "b3d",
+ "basemake",
+ "bash",
+ "basic",
+ "bat",
+ "batch",
+ "bbcode",
+ "because",
+ "befunge",
+ "bf",
+ "blitzbasic",
+ "blitzmax",
+ "bmax",
+ "bnf",
+ "boo",
+ "boogie",
+ "bplus",
+ "brainfuck",
+ "bro",
+ "bsdmake",
+ "bugs",
+ "c",
+ "c#",
+ "c++",
+ "c++-objdumb",
+ "c-objdump",
+ "ca65",
+ "cadl",
+ "camkes",
+ "cbmbas",
+ "ceylon",
+ "cf3",
+ "cfc",
+ "cfengine3",
+ "cfg",
+ "cfm",
+ "cfs",
+ "chai",
+ "chaiscript",
+ "chapel",
+ "cheetah",
+ "chpl",
+ "cirru",
+ "cl",
+ "clay",
+ "clipper",
+ "clj",
+ "cljs",
+ "clojure",
+ "clojurescript",
+ "cmake",
+ "cobol",
+ "cobolfree",
+ "coffee",
+ "coffee-script",
+ "coffeescript",
+ "common-lisp",
+ "componentpascal",
+ "console",
+ "control",
+ "coq",
+ "cp",
+ "cpp",
+ "cpp-objdump",
+ "cpsa",
+ "crmsh",
+ "croc",
+ "cry",
+ "cryptol",
+ "csh",
+ "csharp",
+ "csound",
+ "csound-csd",
+ "csound-document",
+ "csound-orc",
+ "csound-sco",
+ "csound-score",
+ "css",
+ "css+django",
+ "css+erb",
+ "css+genshi",
+ "css+genshitext",
+ "css+jinja",
+ "css+lasso",
+ "css+mako",
+ "css+mozpreproc",
+ "css+myghty",
+ "css+php",
+ "css+ruby",
+ "css+smarty",
+ "cu",
+ "cucumber",
+ "cuda",
+ "cxx-objdump",
+ "cypher",
+ "cython",
+ "d",
+ "d-objdump",
+ "dart",
+ "debcontrol",
+ "debsources",
+ "delphi",
+ "dg",
+ "diff",
+ "django",
+ "docker",
+ "dockerfile",
+ "dosbatch",
+ "doscon",
+ "dosini",
+ "dpatch",
+ "dtd",
+ "duby",
+ "duel",
+ "dylan",
+ "dylan-console",
+ "dylan-lid",
+ "dylan-repl",
+ "earl-grey",
+ "earlgrey",
+ "easytrieve",
+ "ebnf",
+ "ec",
+ "ecl",
+ "eg",
+ "eiffel",
+ "elisp",
+ "elixir",
+ "elm",
+ "emacs",
+ "erb",
+ "erl",
+ "erlang",
+ "evoque",
+ "ex",
+ "exs",
+ "ezhil",
+ "factor",
+ "fan",
+ "fancy",
+ "felix",
+ "fish",
+ "fishshell",
+ "flx",
+ "fortran",
+ "fortranfixed",
+ "foxpro",
+ "fsharp",
+ "fy",
+ "gap",
+ "gas",
+ "gawk",
+ "genshi",
+ "genshitext",
+ "gherkin",
+ "glsl",
+ "gnuplot",
+ "go",
+ "golo",
+ "gooddata-cl",
+ "gosu",
+ "groff",
+ "groovy",
+ "gst",
+ "haml",
+ "handlebars",
+ "haskell",
+ "haxe",
+ "haxeml",
+ "hexdump",
+ "hs",
+ "html",
+ "html+cheetah",
+ "html+django",
+ "html+erb",
+ "html+evoque",
+ "html+genshi",
+ "html+handlebars",
+ "html+jinja",
+ "html+kid",
+ "html+lasso",
+ "html+mako",
+ "html+myghty",
+ "html+php",
+ "html+ruby",
+ "html+smarty",
+ "html+spitfire",
+ "html+twig",
+ "html+velocity",
+ "htmlcheetah",
+ "htmldjango",
+ "http",
+ "hx",
+ "hxml",
+ "hxsl",
+ "hy",
+ "hybris",
+ "hylang",
+ "i6",
+ "i6t",
+ "i7",
+ "idl",
+ "idl4",
+ "idr",
+ "idris",
+ "iex",
+ "igor",
+ "igorpro",
+ "ik",
+ "inform6",
+ "inform7",
+ "ini",
+ "io",
+ "ioke",
+ "irb",
+ "irc",
+ "isabelle",
+ "j",
+ "jade",
+ "jags",
+ "jasmin",
+ "jasminxt",
+ "java",
+ "javascript",
+ "javascript+cheetah",
+ "javascript+django",
+ "javascript+erb",
+ "javascript+genshi",
+ "javascript+genshitext",
+ "javascript+jinja",
+ "javascript+lasso",
+ "javascript+mako",
+ "javascript+mozpreproc",
+ "javascript+myghty",
+ "javascript+php",
+ "javascript+ruby",
+ "javascript+smarty",
+ "javascript+spitfire",
+ "jbst",
+ "jcl",
+ "jinja",
+ "jl",
+ "jlcon",
+ "jproperties",
+ "js",
+ "js+cheetah",
+ "js+django",
+ "js+erb",
+ "js+genshi",
+ "js+genshitext",
+ "js+jinja",
+ "js+lasso",
+ "js+mako",
+ "js+myghty",
+ "js+php",
+ "js+ruby",
+ "js+smarty",
+ "js+spitfire",
+ "json",
+ "json-ld",
+ "jsonld",
+ "jsonml+bst",
+ "jsp",
+ "julia",
+ "kal",
+ "kconfig",
+ "kernel-config",
+ "kid",
+ "koka",
+ "kotlin",
+ "ksh",
+ "lagda",
+ "lasso",
+ "lassoscript",
+ "latex",
+ "lcry",
+ "lcryptol",
+ "lean",
+ "less",
+ "lhaskell",
+ "lhs",
+ "lid",
+ "lidr",
+ "lidris",
+ "lighttpd",
+ "lighty",
+ "limbo",
+ "linux-config",
+ "liquid",
+ "lisp",
+ "literate-agda",
+ "literate-cryptol",
+ "literate-haskell",
+ "literate-idris",
+ "live-script",
+ "livescript",
+ "llvm",
+ "logos",
+ "logtalk",
+ "lsl",
+ "lua",
+ "m2",
+ "make",
+ "makefile",
+ "mako",
+ "man",
+ "maql",
+ "mask",
+ "mason",
+ "mathematica",
+ "matlab",
+ "matlabsession",
+ "mawk",
+ "menuconfig",
+ "mf",
+ "minid",
+ "mma",
+ "modelica",
+ "modula2",
+ "moin",
+ "monkey",
+ "moo",
+ "moocode",
+ "moon",
+ "moonscript",
+ "mozhashpreproc",
+ "mozpercentpreproc",
+ "mq4",
+ "mq5",
+ "mql",
+ "mql4",
+ "mql5",
+ "msc",
+ "mscgen",
+ "mupad",
+ "mxml",
+ "myghty",
+ "mysql",
+ "nasm",
+ "nawk",
+ "nb",
+ "nemerle",
+ "nesc",
+ "newlisp",
+ "newspeak",
+ "nginx",
+ "nim",
+ "nimrod",
+ "nit",
+ "nix",
+ "nixos",
+ "nroff",
+ "nsh",
+ "nsi",
+ "nsis",
+ "numpy",
+ "obj-c",
+ "obj-c++",
+ "obj-j",
+ "objc",
+ "objc++",
+ "objdump",
+ "objdump-nasm",
+ "objective-c",
+ "objective-c++",
+ "objective-j",
+ "objectivec",
+ "objectivec++",
+ "objectivej",
+ "objectpascal",
+ "objj",
+ "ocaml",
+ "octave",
+ "odin",
+ "ooc",
+ "opa",
+ "openbugs",
+ "openedge",
+ "pacmanconf",
+ "pan",
+ "parasail",
+ "pas",
+ "pascal",
+ "pawn",
+ "pcmk",
+ "perl",
+ "perl6",
+ "php",
+ "php3",
+ "php4",
+ "php5",
+ "pig",
+ "pike",
+ "pkgconfig",
+ "pl",
+ "pl6",
+ "plpgsql",
+ "po",
+ "posh",
+ "postgres",
+ "postgres-console",
+ "postgresql",
+ "postgresql-console",
+ "postscr",
+ "postscript",
+ "pot",
+ "pov",
+ "powershell",
+ "praat",
+ "progress",
+ "prolog",
+ "properties",
+ "proto",
+ "protobuf",
+ "ps1",
+ "ps1con",
+ "psm1",
+ "psql",
+ "puppet",
+ "py",
+ "py3",
+ "py3tb",
+ "pycon",
+ "pypy",
+ "pypylog",
+ "pyrex",
+ "pytb",
+ "python",
+ "python3",
+ "pyx",
+ "qbasic",
+ "qbs",
+ "qml",
+ "qvt",
+ "qvto",
+ "r",
+ "racket",
+ "ragel",
+ "ragel-c",
+ "ragel-cpp",
+ "ragel-d",
+ "ragel-em",
+ "ragel-java",
+ "ragel-objc",
+ "ragel-rb",
+ "ragel-ruby",
+ "raw",
+ "rb",
+ "rbcon",
+ "rconsole",
+ "rd",
+ "rebol",
+ "red",
+ "red/system",
+ "redcode",
+ "registry",
+ "resource",
+ "resourcebundle",
+ "rest",
+ "restructuredtext",
+ "rexx",
+ "rhtml",
+ "rkt",
+ "roboconf-graph",
+ "roboconf-instances",
+ "robotframework",
+ "rout",
+ "rql",
+ "rsl",
+ "rst",
+ "rts",
+ "ruby",
+ "rust",
+ "s",
+ "sage",
+ "salt",
+ "sass",
+ "sc",
+ "scala",
+ "scaml",
+ "scheme",
+ "scilab",
+ "scm",
+ "scss",
+ "sh",
+ "shell",
+ "shell-session",
+ "shen",
+ "slim",
+ "sls",
+ "smali",
+ "smalltalk",
+ "smarty",
+ "sml",
+ "snobol",
+ "sources.list",
+ "sourceslist",
+ "sp",
+ "sparql",
+ "spec",
+ "spitfire",
+ "splus",
+ "sql",
+ "sqlite3",
+ "squeak",
+ "squid",
+ "squid.conf",
+ "squidconf",
+ "ssp",
+ "st",
+ "stan",
+ "supercollider",
+ "sv",
+ "swift",
+ "swig",
+ "systemverilog",
+ "tads3",
+ "tap",
+ "tcl",
+ "tcsh",
+ "tcshcon",
+ "tea",
+ "termcap",
+ "terminfo",
+ "terraform",
+ "tex",
+ "text",
+ "tf",
+ "thrift",
+ "todotxt",
+ "trac-wiki",
+ "trafficscript",
+ "treetop",
+ "ts",
+ "turtle",
+ "twig",
+ "typescript",
+ "udiff",
+ "urbiscript",
+ "v",
+ "vala",
+ "vapi",
+ "vb.net",
+ "vbnet",
+ "vctreestatus",
+ "velocity",
+ "verilog",
+ "vfp",
+ "vgl",
+ "vhdl",
+ "vim",
+ "winbatch",
+ "winbugs",
+ "x10",
+ "xbase",
+ "xml",
+ "xml+cheetah",
+ "xml+django",
+ "xml+erb",
+ "xml+evoque",
+ "xml+genshi",
+ "xml+jinja",
+ "xml+kid",
+ "xml+lasso",
+ "xml+mako",
+ "xml+myghty",
+ "xml+php",
+ "xml+ruby",
+ "xml+smarty",
+ "xml+spitfire",
+ "xml+velocity",
+ "xq",
+ "xql",
+ "xqm",
+ "xquery",
+ "xqy",
+ "xslt",
+ "xten",
+ "xtend",
+ "xul+mozpreproc",
+ "yaml",
+ "yaml+jinja",
+ "zephir" ]