Last modified: 2013-02-28 05:01:34 UTC
I am writing an extension that creates <source> tags and invokes SyntaxHighlight_GeSHi to highlight source code for various filenames with a range of file types. It needs to call the GeSHi::get_language_name_from_extension() function in order to create a source tag with the correct "lang" attribute given a filename. Currently I have to do some gyration, first calling SyntaxHighlight_GeSHi::hSpecialVersion_GeSHi() as a roundabout way to ensure that geshi/geshi.php is loaded in, then creating a GeSHi object to provide the member function. The php file is probably in $IP/extensions/SyntaxHighlight_GeSHi, it's true, but there's nothing requiring it to be located there. This function could be static, and if either it were moved to the SyntaxHighlight_GeSHi class, or a SyntaxHighlight_GeSHi class function were provided that calls it, it would allow me and others to get the job done without relying on undocumented implementation details. Or failing that, it would be helpful to add the GeSHi class to $wgAutoloadClasses.
Unassigning default assignments. http://article.gmane.org/gmane.science.linguistics.wikipedia.technical/54734
Bump.
Why not just include it in your own code? Are you actually using anything from the SyntaxHighlight_GeSHi class? As you can only have one thing handling one tag, having this loaded in aswell would be useless. What's the point of moving it to the SyntaxHighlight_GeSHi class? It will still exist in the source. In the same idea, you could "move" (well, copy) it to your own code.. And to top all that off, get_language_name_from_extension isn't even static (when it should probably be), so you're instantiating an instance of the class and anything else it loads in, for these 90 lines of code. You should probably just use SyntaxHighlight_GeSHi::prepare( 'foo', 'ext')->get_language_name_from_extension( 'ext' )
Though, I'm not sure why you didn't make this request upstream. https://sourceforge.net/p/geshi/code/2573/