PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Text » Text_Highlighter » Bug #7480

new feature: link elements to their documentation

Details

Request #7480new feature: link elements to their documentation
Submitted2006-04-25 09:02 UTC
Fromchris at phpmyforum dot de
Assignedstoyan
StatusClosed
PackageText_Highlighter
PHP Version5.1.2
OSLinux
Roadmaps(Not assigned)

Comments

[2006-04-25 09:02 UTC] chris at phpmyforum dot de

Description:
------------
This adds a new feature to the html-renderer class, which allows you to specify an documentation-url.

Here's the diff for Text/Highlighter/Renderer/Html.php:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--- Html.php 2006-04-25 10:31:06.090785512 +0200
+++ Html.php.org 2006-04-25 10:58:30.843745056 +0200
@@ -175,18 +175,7 @@
$content = str_replace("\n", $tag, $content);
}

- // link to documentation
- if (!empty($this->_options['docUrl']) && !empty($this->_options['docElements']) && in_array($class, $this->_options['docElements']))
- {
- $this->_output .= '<a href="'.sprintf($this->_options['docUrl'], $content).'"'.(!empty($this->_options['docTarget']) ? ' target="'.$this->_options['docTarget'].'"' : '').'>'.$content.'</a>';
-
- }
- // no link
- else
- {
$this->_output .= $content;
- }
-
$this->_lastClass = $class;
}

Test script:
---------------
require_once 'Text/Highlighter.php';

$hl =& Text_Highlighter::factory('PHP', array(
'docUrl' => 'http://php.net/%s',
'docTarget' => '_blank',
'docElements' => array(
'reserved',
'identifier',
),
));
echo $hl->highlight('<?php echo strlen(2); ?>');