Drupal 6 syntaxhighlighter module

in

This Drupal 6 module does program code list syntax highlighting like this:

class Person(ln : String, fn : String, s : Person)
{
    def lastName = ln;
    def firstName = fn;
    def spouse = s;
    
    def this(ln : String, fn : String) = { this(ln, fn, null); }

    def introduction() : String = 
        return "Hi, my name is " + firstName + " " + lastName +
            (if (spouse != null) " and this is my spouse, " + spouse.firstName + " " + spouse.lastName + "." 
             else ".");
}

It uses the Syntax Highlighter Javascript library to perform the highlighting on the client browser.

The module is at the Drupal Syntaxhighlighter module project page. Before installing the module, first download the latest Syntax Highlighter Javascript Library. Unzip the entire content into a sub-directory inside sites/all/libraries. You can use any directory name, in any level of nesting or even no directory. You can delete the 'src' directory from the extracted files if you want. It's not needed for normal usage. Then install the module. Refer to the module README.txt file for details.

Module configuration

Go to 'admin/settings/syntaxhighlighter' to make configuration change:

(The checkboxes and radio buttons are displayed in columns above with the Multi-column checkboxes radios module. Install and enable that module to get it display like it's here. Otherwise, the checkboxes and radio buttons are in single long column.)

The first set of checkboxes allow you to selectively enable languages. You may want to enable only the languages you need to avoid loading unnecessary Javascript files. However, choosing all should not be any problem in any case because browses cache Javascript files.

The theme radio buttons let you choose the stylesheet used by the Syntax highlighter display.

The "Tag name" setting lets you change the code markup tag to some other legal html tag if <pre> for some reason cannot be used. For example, you can use the <code> tag instead.

Enable "Legacy mode" to support old style markup format. For most users this should just be disabled. This is provided in case you have contents that use the old style Syntax highlighter markup.

Use the "Turn off Syntax Highlighter on these pages" setting to disable the Syntax highlighter to avoid compatibility problem.

The "Default expressions" setting let you enter Javascript statements to initialize the Syntax highlighter to some site wide defaults.

Visit the 'admin/help/syntaxhighlighter' page for module help.

Content markup

Markup your program listing like this:

{syntaxhighlighter OPTIONS}
// paste your code verbatim in between the markup
#include <iostream>
// etc etc etc
{/syntaxhighlighter}

where OPTIONS is a syntax highlighter options string. See the Syntax Highlighter Javascript library page for details. To highlight some C++ code:

{syntaxhighlighter brush: cpp}
// paste your code verbatim in between the markup
#include <iostream>
// etc etc etc
{/syntaxhighlighter}

and that becomes:

// paste your code verbatim in between the markup
#include <iostream>
// etc etc etc

Click to see a sample of all syntax highlighted languages.

TinyMCE Wysiwyg editor integration

This provides a Syntax Highlighter button:

that brings up the Syntax Highlighter dialog:

where you can insert code and configure the syntax highlighter property. You can see this in action on the comment form below.

See the bottom of this module's project page for detail on how to setup this.

The GeSHi Filter module also does syntax highlight. It is a server side filter, so processing is done using PHP inside Drupal on the web server. Whereas this module off loads the processing entirely to the client browser.

toggle line numbers missing ;(

elmuchacho의 이미지

works like described ...
ty ...
but the menu in the upper right corner on my site shows "view source","copy to clipboard","print" and "help" ...

"toggle line numbers" is missing ;(

actually i've installed version 2.1.364 of the SyntaxHighlighter ...

any ideas ?

I'm using a customized version

Alpha Epsilon Delta의 이미지

of syntax highlighter javascript library. The one from Alex doesn't have this feature.

Drupal Issue: wysiwyg

Visitor의 이미지

Hi I'm triying to install tinymce o fckeditor over Drupal 6 an d wysiwyg, the problem is that i cant see de toolbar in Chrome or IExplorer 8. I get a javascript error in wysiwyg.js.

So when I have arrive to your page I've seen that you have the same problem, i can't see the toobar in IExplorer and Chrome on your page. Do you know something about it?

Dan
(Sorry my disgusting English)

Please update to the latest version...

Alpha Epsilon Delta의 이미지

of syntaxhighlighter js lib  (2.1.364 as of today)

 

see http://drupal.org/node/652586

Thanks for that link, it

bed &amp; breakfast barcelona의 이미지

Thanks for that link, it helped me a lot.

Thank you very much for the

alışveriş의 이미지

Thank you very much for the excellent and useful subject.

i want add the syntaxhighlighter button to CKEditor.

song의 이미지

I want known , if i want add the syntaxhighlighter button to CKEditor. how can i do?

Using syntax highlighter?

Jonathan의 이미지

 

Hi!

Thank you for your post.

I am trying to use syntax highlighter with fckeditor.

First, I'm wondering why the configuration says that I can use the PRE tag, and then in your example you use the tag {syntaxhighlighter}.

Second, whenever I try to use {syntaxhighlighter}, I get the following message:

{syntaxhighlighter} tags are not balanced: open and close tags must
match.

This is for the code:

 

if ( this_is_working() ) { echo "Test" } 

Do you know why this is?

 

댓글 쓰기

이 필드의 내용은 비밀로 유지되며, 공개되지 않습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
  • 사용할 수 있는 HTML 태그: <a> <blockquote> <br> <cite> <code> <dd> <div> <dl> <dt> <em> <li> <ol> <p> <pre> <span> <strong> <ul>
  • Syntax highlight code surrounded by the {syntaxhighlighter OPTIONS}...{/syntaxhighlighter} tags.

포맷팅 옵션에 대한 추가 정보

Navigation

사용자 로그인