Xarigami

projects

xarigami dphighlight

display
news
resources
dev notes
tracker
discuss
Project phase:
Iteration - stable
Latest release [all releases]:
xarigami dpHighlight V1.3.0 xarigami dpHighlight V1.3.0 Sep 15, 2010
Development:
Latest snapshot build 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 enables text, wrapped in pre tags with special attributes, to display with syntax highlighting. A variety of syntax highlighters are available (eg php, xhtml, bash) that can be used in content on your site.

dpHighlight suports syntax highlighting with:

  • The Javascript based SyntaxHighlighter by Gorbatchev (including legacy code)
  • The PHP based Geshi syntax highlighting



dpHighlight text



This dpHighlighter module now provides:

  • Ability to use SyntaxHighlighter 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.


dpHighlight plugin for xarTinyMCE - syntax highlighting


dphighighlight Plugin for xarTinyMCE


Examples:

SyntaxHighlighter

Syntax: <pre class="brush:php;first-line: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.

  1. if (isset($extrainfo['itemtype'])) {
  2. $itemtype = $extrainfo['itemtype'];
  3. }
  4.  
  5. foreach ($settings as $k=>$v) {
  6. if ($modname =="dphighlight") {
  7. xarModSetVar('dphighlight', $k, $settings[$k]);
  8. } else {
  9. xarModSetVar($modname, $k.'.' . $itemtype, $settings[$k]);
  10. }
  11. }

Requirements:

  • Xarigami 1.1.8 and above, or Xaraya 1.1.x core
  • PHP 5

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. eg for pre tag and the highlight attribute used in Geshi

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 version 1.3.0

 

file releases:

last updated 25 Sep 10 21:04


useful? share it.