Page MenuHomePhabricator

SyntaxHighlight should warn and hint if you specify an invalid lang
Open, LowPublic


A bad SyntaxHighlight invocation like <source lang=html9> used to display an ugly warning which you could expand to a huge list of supported languages, which was good for editors but bad for readers:

Now it displays the unhighlighted source code without any warning, unless you notice the page receiving Category:Pages with syntax highlighting errors. That's good for readers, but no help for editors. gerrit 221311 adds messages for the warning, but has a comment "The actual warning text is not outputted anywhere yet; deferring that for a follow-up patch". The extension should show the warning on wikitext preview, along with its expandable list of supported languages (see related T103756); if the user saves the bad source tag, maybe SyntaxHighlight could show an inconspicuous error indicator, perhaps a ≸ superscript.

Event Timeline

Spage raised the priority of this task from to Needs Triage.
Spage updated the task description. (Show Details)
Spage added a project: SyntaxHighlight.
Spage added a subscriber: Spage.
Krinkle added a subscriber: Krinkle.

When users specify an invalid language in wikitext, there is no warning. That is still the case.

However, when inserting a new (or editing an existing) code block in VisualEditor, the input field does validate the value in realtime and outlines it with a red color if the value is not recognised. I suppose a tracking class could be added or a preview-only error perhaps for wikitext.

I don't think adding errors directly to the page for this is desirable because, unlike logic errors like with Cite or ParserFunctions, the list of lexers can and does change with time and we shouldn't surface that as an error to users, graceful degradation is imho desirable here.