Page MenuHomePhabricator

Allow showing code in an unsupported language with a warning
Closed, ResolvedPublic

Description

I participate in writing the Wikibook about the Haskell programming language.

GeSHi doesn't support Haskell yet, but it might in the near future (see the feature request - http://sourceforge.net/tracker/index.php?func=detail&aid=1720310&group_id=114997&atid=670234 ).

In the meantime, if i try to write <source lang="haskell">SOME CODE</source>, it is rendered as a Big Red Error that doesn't show any code. I think that it would be better to display the source in the default (black) color with a small warning saying that the language is not supported. This way, when support for that language is added, the warning will go away and the coloring will just start working.


Version: unspecified
Severity: enhancement
URL: http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi

Details

Reference
bz10201

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:54 PM
bzimport added a project: SyntaxHighlight.
bzimport set Reference to bz10201.

I am not a PHP expert and i don't have an environment to test it, but it looks like it's really easy to change.

Just change the line

return syntaxHighlightHelp( wfMsgHtml( 'syntaxhighlight-err-language' ) );

into

return $text . syntaxHighlightHelp( wfMsgHtml( 'syntaxhighlight-err-language' ) );

And make syntaxHighlightHelp() and syntaxHighlightError() return more modest error messages.

I hope it helps.

robchur wrote:

Not a viable patch, includes cross-site scripting injection vector.

It probably wouldn't be a bad idea to go ahead and show the input (properly escaped and <pre>d of course), but I'm not sure about making the warning smaller... listing the supported languages is probably the only way to figure out wtf is going on. :)

[Though in theory that could be moved to a special help page or something and that could be linked.... shrug]

ayg wrote:

Why not pass the list of supported languages and escaped properly formatted code as $1 and $2 to the error message so this can be decided on a site-by-site basis? I'd say the default should be to display it, yes, that's a much better failure mode, but with a list of supported languages too.

So how about this ?

<source lang="something">
Code
</source>
still only shows an error message.

Or was something else meant (which may or may not be fixed in the mean time)

No, this isn't fixed. Haskell seems to be supported now, but for unsupported language only an error message is shown.