Wanderlei Silva Posted July 11, 2009 Share Posted July 11, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/165635-pear-problem-using-text_highlighter/ Share on other sites More sharing options...
Wanderlei Silva Posted July 11, 2009 Author Share Posted July 11, 2009 (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. Quote Link to comment https://forums.phpfreaks.com/topic/165635-pear-problem-using-text_highlighter/#findComment-873759 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.