How to add custom language

markus ferringer March 22, 2016

This question is in reference to Atlassian Documentation: Code Block Macro

I created a JavaScript file accoriding to the documentation and added it as a custom language to the Code Block Macro. While I can now actually select this new language for code formatting, an error message pops up when I do so (SyntaxHighligher: Can't find brush for: vhdl). What am I doing wrong here? Below you find my JavaScript file. Thanks a lot!

;(function()
{
    SyntaxHighlighter = SyntaxHighlighter || (typeof(require) != 'undefined' ? SyntaxHighlighter = require('shCore').SyntaxHighlighter : null);
    
    function Brush()
    {
      var funcs       = 'to_integer to_string';
      var types       = 'std_logic std_logic_vector';
      var keywords    = 'abs access after ';
     
      this.regexList = [
          { regex: /--(.*)$/gm, css: 'comments' },
          { regex: regexLib.multiLineCComments, css: 'comments' },
          { regex: new RegExp(this.getKeywords(funcs), 'gmi'), css: 'functions' },
          { regex: new RegExp(this.getKeywords(types), 'gmi'), css: 'color1' },
          { regex: new RegExp(this.getKeywords(keywords), 'gmi'),css: 'keyword' }
          ];
    };
    
    Brush.prototype  = new SyntaxHighlighter.Highlighter();
    Brush.aliases  = ['vhdl', 'Vhdl', 'VHDL'];
    SyntaxHighlighter.brushes.vhdl = Brush;
    typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
})();

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
wrenoud August 12, 2019

I did the same as you, and it didn't work. But following the example from http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/custom.html linked from the docs made it work.

Following that example, your highlighter would be:

SyntaxHighlighter.brushes.Custom = function()
{
var funcs = 'to_integer to_string';
var types = 'std_logic std_logic_vector';
var keywords = 'abs access after ';

this.regexList = [
{ regex: /--(.*)$/gm, css: 'comments' },
{ regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' },
{ regex: new RegExp(this.getKeywords(funcs), 'gmi'), css: 'functions' },
{ regex: new RegExp(this.getKeywords(types), 'gmi'), css: 'color1' },
{ regex: new RegExp(this.getKeywords(keywords), 'gmi'),css: 'keyword' }
];
};
SyntaxHighlighter.brushes.Custom.prototype = new SyntaxHighlighter.Highlighter();
SyntaxHighlighter.brushes.Custom.aliases = ['vhdl', 'Vhdl', 'VHDL'];
0 votes
markus ferringer May 12, 2016

Thanks for the hint. I followed your description - downloaded the source of the plugin, made the changes, compiled & packaged everything, and installed the macro using the confluence web-interface. However, the error still remains - "can't find brush for: vhdl".

Any ideas? I don't understand why the brush cannot be found. It's the same code as for all other supported languages, I double and triple checked.

0 votes
Paul Chung May 6, 2016

I believe this is a bug with Confluence: https://jira.atlassian.com/browse/CONF-40838.

I ran into this and had to resort to downloading the source at https://bitbucket.org/atlassian/confluence-newcode-macro-plugin. After placing the brush script in resources/sh/scripts/, adding the script as a resource in atlassian-plugin.xml, inserting an entry in the friendlyNameMap in the BuiltInLanguageInstaller class, packaging and installing the jar as a plugin, it finally worked. It was a lot more effort than it should have been and I hope the bug is fixed soon.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events