Tutorial on adding improvised Syntax Highlighter

  1. 5 years ago
    Edited 5 years ago by Cv3

    I've noticed there are a lot of folks here looking for working syntax highlighter. Unfortunately all I've tried from the Plugins channel was bogus or not working or pretty damn hard to get working.

    Since I don't have the time to get familiar with the plugins here and to make new one, here is simple tutorial how to get a syntax highlighter working along your BBCode plugin.

    Remember to follow instructions carefully and keep a running backup.

    1 >_: Download jquery-syntaxhighlighter.zip
    2 >_: Extract it as following into

    addons/plugins/BBCode/resources/*

    so that path should look like

    addons/plugins/BBCode/resources/jquery-syntaxhighlighter

    3 >_: Open your bbcode.js . It's in directory addons/plugins/BBCode/resources/bbcode.js and add the following after the existing code:

    $(document).ready(function() {
    	$.SyntaxHighlighter.init({
    		'debug': false,
    		'alternateLines': true,
    		'prettifyBaseUrl': ET.webPath + '/addons/plugins/BBCode/resources/jquery-syntaxhighlighter/prettify',
    		'baseUrl': ET.webPath + '/addons/plugins/BBCode/resources/jquery-syntaxhighlighter'
    	});
    });

    4 >_: Open plugin.php . It's in directory addons/plugins/BBCode/plugin.php
    Find the row:

    $sender->addJSFile($this->resource("bbcode.js"));

    Add before:

    $sender->addJSFile($this->resource("jquery-syntaxhighlighter/scripts/jquery.syntaxhighlighter.min.js"));

    Find the row:

    $sender->content = preg_replace("/<pre><\/pre>/ie", "'<pre>' . array_pop(\$this->blockFixedContents) . '</pre>'", $sender->content);

    In the row find: '<pre>' and replace it with '<pre class=\"highlight\">'

    Delete cache and refresh

    It's just a fix thanks to samsong just made few edits to get the code working on the latest version.

    Hope it will help someone.

    Best wishes,
    Cv3

  2. You might want to fix this, as getResource should be resource.

  3. Yeah , sorry I copied the wrong file..

 

or Sign Up to reply!