Jump to content

PEAR problem using Text_Highlighter


Recommended Posts

Hi,

 

I'm using a plugin for PEAR called Text_Highlighter  and was hoping for some advice as I've never used a plugin for any language before.

 

In order to have it correctly display some CSS code within a webpage (with line numbers), I have this in my webpage:



<?php
require_once "Text/Highlighter.php";
require_once "Text/Highlighter/Renderer/Html.php";
$renderer = new Text_Highlighter_Renderer_Html(array("numbers" => HL_NUMBERS_LI, "tabsize" => 4));
?>


<?php
$hiHtml =& Text_Highlighter::factory("HTML");
$hiHtml->setRenderer($renderer);
$hiCss =& Text_Highlighter::factory("CSS");
$hiCss->setRenderer($renderer);
$hiPhp =& Text_Highlighter::factory("PHP");
$hiPhp->setRenderer($renderer);
$hiDtd =& Text_Highlighter::factory("DTD");
$hiDtd->setRenderer($renderer);
$hiJava =& Text_Highlighter::factory("Java");
$hiJava->setRenderer($renderer);
$hiJavascript =& Text_Highlighter::factory("Javascript");
$hiJavascript->setRenderer($renderer);
$hiMySql =& Text_Highlighter::factory("MySQL");
$hiMySql->setRenderer($renderer);
$hiPerl =& Text_Highlighter::factory("Perl");
$hiPerl->setRenderer($renderer);
$hiPython =& Text_Highlighter::factory("Python");
$hiPython->setRenderer($renderer);
$hiRuby =& Text_Highlighter::factory("Ruby");
$hiRuby->setRenderer($renderer);
$hiSql =& Text_Highlighter::factory("SQL");
$hiSql->setRenderer($renderer);
$hiVbScript =& Text_Highlighter::factory("VBSCRIPT");
$hiVbScript->setRenderer($renderer);
$hiXml =& Text_Highlighter::factory("XML");
$hiXml->setRenderer($renderer);



?>



<?php
echo $hiCss->highlight("body {
	margin:0;
	padding:0;
	border:0;			
	width:100%;
	background:#000;
	min-width:600px;

	font-size:90%;
	background-color:black;
}
"
)
?>

 

But I find the DOCS  to the Text_Highlighter confusing.

 

I'm trying to do two things with the plugin.

 

Highlight the correctly formatted code, so that it overides my css and is coloured like it is in this thread.

 

Also I cannot highlight SQL code, neither  coloured highlighting, or line numbers display. The SQL code is formatted within the webpage, but it uses no style at all, it just uses the default black font and there are no line numbers.

 

I use this:

 

$hlSQL =& Text_Highlighter::factory("SQL");
echo $hlSQL->highlight("SELECT * FROM some_table WHERE id = 12");
?>

 

Can anyone offer some advice on this? It would be most appreciated!

Link to comment
Share on other sites

(cannot find update post)

 

 

Displaying XML code, is formatted, and takes on my site's CSS style:

 

<?php
echo $hiXml->highlight("<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>")?>

 

 

But again, the code isn't highlighted like it would be within an IDE.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.