How to enable Mathematica syntax highlighting for

2019-04-11 22:37发布

问题:

I'd like to syntax highlight Mathematica code on a MediaWiki site. I've already installed the MediaWiki extension SyntaxHighlight GeSHi and verified that it works for other languages.

I tried simply putting a Mathematica langauge data file mathematica.php into MediaWiki's extension path wiki/extensions/SyntaxHighlight_GeSHi/geshi, however it didn't correctly highlight a Mathematica code block such as:

<syntaxhighlight lang="Mathematica">
(* this is a comment *)
List[Sin[x], Cos[x], Tan[x]];
</syntaxhighlight>

Any ideas?

回答1:

I do not see Mathematica listed as a supported language at http://qbnz.com/highlighter/, so I suppose GeSHi simply doesn't know it. I suppose you could contribute the respective highlighting code to the geshi project, if you like.



回答2:

you need modify geshi.php, function get_language_name_from_extension to be specific, for added language definition to be recognized.