Menu

Code highlighting - extra languages?

2022-02-03
2022-03-08
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2022-02-03

    I'm wondering what the best way would be to add extra languages to the code formatting and make them available in the log entries.

    The one I'm personally missing the most, is by far PowerShell. Although there are a lot of other interesting ones available as well.

    Assuming there will be no changes soon: is the recommendation to use the setHighlighter() method on the CKEditor instances with basically a copy-paste of the current highlighter's settings but this time including PowerShell (and also pointing to an updated highlight.pack.js)?

    I'm also considering making a PR request at some point where you could simply specify in iTop's config file which languages you want and then only generate a custom highlight.pack.js file which gets cached.

     
  • Pierre Goiffon

    Pierre Goiffon - 2022-02-21

    Hello Jeffrey,

    I didn't have a proper look at this for now, but what I can see is we are using Highlight.js through a CKEditor plugin (the file is in /js/ckeditor/plugins/codesnippet/lib/highlight).
    The current directory weights 284KB on my disk, so very little. Does the powershell language is included in this package, or should we add it ? I searched for hljs.registerLanguage(" occurrences in /js/ckeditor/plugins/codesnippet/lib/highlight/highlight.pack.js and didn't find PowerShell :/

    I imagine we won't be able to update this lib solely, and we might be forced to update the CKEditor plugin, and maybe CKEditor itself ?

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2022-02-22

    Hi Pierre

    I took a look at it, you can apparently build custom versions to include/exclude certain languages ( https://highlightjs.org/download/ )

    I actually took a look if I could somehow just add a separate .JS file with the languages I personally wanted to add (wouldn't be too much of a problem), but I couldn't figure out a hook or point to override this before the CKEditor objects are initiated in iTop.

     
  • Pierre Goiffon

    Pierre Goiffon - 2022-03-03

    Well, furthemore we are not integrating Highlight.js directly : we are using CK editor, and a CK plugin that is embedding Highlight.js...

     
  • Pierre Goiffon

    Pierre Goiffon - 2022-03-03

    I've created an enhancement request in our iTop (N°4901)
    You are the only one to ask for it for now, so I fear it won't be planned soon.

     
  • Guillaume Lajarige

    IMHO, for that kind of enhancements which are of very low priority for Combodo, the best way to accelerate the process is to make a PR. That way the proposition will be reviewed and integrated if well coded.

    Cheers,
    Guillaume

     
    👍
    1

    Last edit: Guillaume Lajarige 2022-03-03
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2022-03-04

    Any suggestions what the preferred approach would be?

    A default setting in iTop's config file with the languages (of course makes it more complex); or simply adding them to the .JS file?

     
  • Pierre Goiffon

    Pierre Goiffon - 2022-03-08

    Hello,
    Considering the whole languages files in the existing package are quite small, I don't think this would matter to simply add a new language, so just start like this ?
    But beware of the hightlight lib version embedded in the plugin, there might be some compatibility issues ?

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.