You are here

xbbcode_highlighter.module in Extensible BBCode 8

xbbcode_highlighter.module Provides the glue code that shows highlighter languages as xbbcode tags, and invokes the highlighter when rendering.

File

xbbcode_highlighter/xbbcode_highlighter.module
View source
<?php

/**
 * @file xbbcode_highlighter.module
 * Provides the glue code that shows highlighter languages as xbbcode tags,
 * and invokes the highlighter when rendering.
 */

/**
 * Implements hook_xbbcode_info().
 */
function xbbcode_highlighter_xbbcode_info() {
  $languages = highlighter_languages();
  foreach ($languages as $id => $info) {
    $tags[$id] = array(
      'callback' => 'xbbcode_highlighter_render',
      'description' => t('Provides syntax coloring for the %lang language. The option <em>ln</em> will print out line numbers.', array(
        '%lang' => $info->name,
      )),
      'sample' => $info->sample,
      'plain' => TRUE,
      'nocode' => TRUE,
    );
  }
  return $tags;
}

/**
 * Renders a given code tag by passing it to the highlighter.
 */
function xbbcode_highlighter_render($tag) {
  $tag->content = html_entity_decode($tag->content);
  $settings['language'] = $tag->name;
  if (isset($tag->args['indent'])) {
    $settings['tabsize'] = $tag->args['indent'];
  }
  $settings['numbers'] = $tag->option == 'ln';
  return highlighter_highlight($settings, $tag->content);
}

Functions

Namesort descending Description
xbbcode_highlighter_render Renders a given code tag by passing it to the highlighter.
xbbcode_highlighter_xbbcode_info Implements hook_xbbcode_info().