Xarigami

projects

xarigami dphighlight

display
news
resources
dev notes
tracker
discuss
Project phase:
Iteration - stable
Latest release [all releases]:
Xarigami dpHighlight V1.2.0 Xarigami dpHighlight V1.2.0 Sep 12, 2008
Development: [Issues since release]
Xarigami dpHighlight V1.2.0 Latest snapshot build
Issue tracker:
Review or add issue

registered by

Jo on Jan 2, 2007 09:39:39 AM

summary

syntax highlighting without bbcode

details

The dpHighlight module is a utility module that provides syntax highlighting in any content (module itemtype) that supports Xaraya transform hooks (eg articles pubtype, comments).  It provides syntax highlighting support for a number of syntax highlighters, and allows individual configurations for each module itemtype it is enabled in.

The module was originally based on the Javascript based Gorbatchev's dpHighlight module also used in the bbcode module. It provided a means to have syntax highlighting using (x)html in content, rather than bbcode and without enabling bbcode.

The module now also incorporates PHP based Geshi syntax highlighting. The original Xaraya Geshi transform function was provided by Curtis Farnham in his Xaraya Highlight hook module. This has been enhanced in this version to provide additional options for syntax highlighting output.

This dpHighlighter module now provides:

  • Ability to use dpHighlight or Geshi syntax highlighting, or both, in any  content module itemtypes on your site
  • Can be configured independently for each module itemtype if required and turned on or off (No real advantage in most cases but has its uses  - see Known limitations).
  • Provides additional output options to enable line numbering, or plain output, and a wide range of different language highlighters
  • Allows syntax highlighting without bbcode module installation, provides all highlighters in one module and with one transform hook

EXTRA! For those of you using xarTinyMCE, the latest version of xarTinyMCE incorporates the dpHighlight plugin to easily enable you to add highlighting to your documents.

Examples:

dpHighlight

Syntax: <pre name="code" class="php:firstline[5]"> ....</pre>

if (isset($extrainfo['itemtype'])) {
        $itemtype = $extrainfo['itemtype']; 
    }

    foreach ($settings as $k=>$v) {
        if ($modname =="dphighlight") {
            xarModSetVar('dphighlight', $k,  $settings[$k]);
        } else {
            xarModSetVar($modname, $k.'.' . $itemtype, $settings[$k]);
        }
    }

Geshi

Syntax: <pre highlight="php:fancy:firstline[5]"> ....</pre>

The 'fancy' keyword adds alternating line backgrounds to geshi.

if (isset($extrainfo['itemtype'])) {
        $itemtype = $extrainfo['itemtype']; 
    }

    foreach ($settings as $k=>$v) {
        if ($modname =="dphighlight") {
            xarModSetVar('dphighlight', $k,  $settings[$k]);
        } else {
            xarModSetVar($modname, $k.'.' . $itemtype, $settings[$k]);
        }
    }

Requirements:

Xarigami cumulus or Xaraya 1.1.x core

Note: If you are running xarTinymce and using the HTML module, ensure you have tags and attributes allowed so that the highlighting and formatting can be displayed on output.

Known limitations:

For most people, they will never want to use hook overrides for the dpHighlighter module. The normal configuration settings in the dpHighlighter module are sufficient. However, for those that do :

  • Modules must support transform hooks for individual itemtypes. Although the modify config hook will appear, it will only work in modules that support invididual itemtype transform hooks, with and without other hooked modules.
  • dpHighlight Syntax Highlighter is Javascript (Geshi is PHP) and will load in the head of the page. This means that if you have any cases where dpHighlighter syntax highlighter is loaded at some point in a module,  then it will also load and be used/be available in any other module loaded on that page, even if individual override settings have it turned OFF. This does not apply to Geshi which is php based.

    An example of this is Articles with coments in the page. If dpHighlighter is turned on in Articles, and off in Comments, it will still display in comments if the correct syntax is provided.

Current status:

Stable

 

file releases:

last updated 20 Sep 08 15:10