Syntax Highlighter: can't find brush for XML

3.3k Views Asked by At

I've been using SyntaxHighlighter for some time without any problems.

However, I recently restyled my blog and now when one page loads - a page which uses the XML brush - I get a popup saying

Can't find brush for: xml

I've checked and double-checked, and I'm absolutely certain that the shBrushXML.js file is being included in the downloaded JavaScript bundle (I can see SyntaxHighlighter.brushes.Xml in the minified JS).

I've also tested using other syntaxes on the same page and they're ok; it's just the XML brush.

Does anyone have any ideas why the XML brush is causing this problem?

2

There are 2 best solutions below

1
On BEST ANSWER

This was caused by a small bug in another brush script (i.e. another SyntaxHighlighter brush).

I was also referencing a third party Razor syntax brush from here. This script has the line

SyntaxHighlighter.brushes.Xml = Brush;

Which should obviously be

SyntaxHighlighter.brushes.Razor = Brush;

Presumably this has been caused by the author copying the contents of the XML brush and then modifying it for Razor. On its own the XML brush worked, and on its own the Razor brush worked. The XML brush also worked when it was referenced after the Razor brush, and the Razor brush worked when it was referenced after the XML brush.

And now it's clear why.

0
On

I had same issue. Then I found that I was using lang=XML. However file shBrushXml.js had brush alias as xml. I made 2 changes which fixed the issue for me.

  1. updated lang=xml in my file where I wanted syntax highlighting.

  2. Updated shBrushXml.js Changed SyntaxHighlighter.brushes.Xml = Brush; To SyntaxHighlighter.brushes.Razor = Brush;