vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   Advanced Syntax Highlighting - BBCode [highlight] (https://vborg.vbsupport.ru/showthread.php?t=93071)

garrynewman 11-13-2005 10:48 AM

Ok, finally.. for anyone wanting tags like [sql]code[/sql] and [lua]code[/lua].. here's an example for Lua..

Code:

if (!function_exists('handle_bbcode_lua'))
{
    function handle_bbcode_lua(&$parser, $code, $type)
    {
        return handle_bbcode_highlight( $parser, $code, 'lua' );
    }
}

$this->tag_list['no_option']['lua'] = array(
    'callback' => 'handle_external',
    'strip_empty' => true,
    'stop_parse' => true,
    'disable_smilies' => true,
    'disable_wordwrap' => true,
    'strip_space_after' => 1,
    'external_callback' => 'handle_bbcode_lua'
);

Just add it near the bottom of the bbcode_create hook.

Wildthinks 12-22-2005 05:59 PM

Have you any hint, where i can switch the width for bbcode code to 100%?
Thank you
thomas

kirupa 12-24-2005 03:34 PM

boofo - I was able to retain spacing by changing the code in class_bbcode.php in the includes folder:

// [HIGHLIGHT]
$tag_list['no_option']['highlight'] = array(
'html' => '<span class="highlight">%1$s</span>',
'strip_empty' => false
);

kirupa 12-24-2005 04:39 PM

Hi everyone,
Where would I add this code to enable only [as] functionality:
Code:

       
        if (!function_exists('handle_bbcode_as'))
        {
            function handle_bbcode_as(&$parser, $code, $type)
            {
                return handle_bbcode_highlight( $parser, $code, 'ActionScript' );
            }
        }
       
        $this->tag_list['no_option']['ActionScript'] = array(
            'callback' => 'handle_external',
            'strip_empty' => true,
            'stop_parse' => true,
            'disable_smilies' => true,
            'disable_wordwrap' => true,
            'strip_space_after' => 1,
            'external_callback' => 'handle_bbcode_as'
        );

I've looked everywhere, and I can't figure out where in vb 3.5.2 the above code would be included.

EDIT: Nevermind - I fixed it. I had to add it to the XML file itself. Everything works now :)

:surprised:

kirupa 12-24-2005 08:32 PM

I swear, this will be my final question!

When pasting code that has been highlighted, the vertical line spacing is no longer retained in IE. All pasted code appears in one line, and for functions containing comments, it makes the code unusable unless line breaks are manually added.

Is there a fix for that? There are examples of that problem here: http://www.kirupa.com/forum/showthread.php?p=1737670

It works well in FF though.

EDIT: I was able to modify the bbcode_highlight template to the following to fix it - though spacing seems a bit off:

[code]<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">$type $vbphrase
Code:

:</div>
        <div class="alt2" style="margin:0px; font-family:Courier New; padding:$stylevar[cellpadding]px; border:1px inset; width:$stylevar[codeblockwidth]; height:{$blockheight}px; overflow:auto"><div dir="ltr" style="text-align:left;">$code</div></pre>
</div>

:ermm:

Wildthinks 01-02-2006 03:54 PM

Hi,

seems are a little bit buggy on this:
1. Can you please change that the line number dont copied, when i copy the code. Is very strange, when you post code and the other must delete line numbers...
2. this["foo"] -> was converted to this["foo"]
I like this and have installed, but i hope the buggy items are fixed soon.

Thomas

kirupa 01-05-2006 09:58 PM

In my previous post, I fixed the IE copy/paste issue by replacing the pre tag with a div. The problem is that the code now wraps. Does anybody have a way of fixing the IE copy/paste issue while retaining no-wrapping of code?

Thanks!
Kirupa :squareeyed:

marc_t 01-11-2006 10:13 PM

Thanks!

Is working now.

marc_t 01-12-2006 07:39 AM

Works really great. Only thing is that I didn't manage to get a button to the editor. With usual vb-code this is no problem as the vb-code option allows to define a grafik. But how to do this for this hack? I searched in several forums and got no really heloing answer.

maybe here? ;)

thanks,
marc

marc_t 01-13-2006 08:23 AM

I cant figure out a little thing: A squared bracket open doesn't show up in the code. For example:

Code:

_root["ball"+i].x=100
shows up as

_root& #91;"ball"+i].x=100 (without the space between & and #)

Any help where to find the line I have to change? Checkes "actionscript.php" in the geshi folder, but with no success.

Thanks!

marc_t 01-17-2006 07:04 AM

No help? No idea? :(

Any hint?

;)

lutek 01-25-2006 08:39 PM

Quote:

Originally Posted by marc_t
No help? No idea? :(

Any hint?

;)

I have the same problem :(

marc_t 01-26-2006 08:52 AM

Would be really great to get any hint where to find the code which replaces the "["...

Thanks very much....

lutek 01-27-2006 08:56 AM

Quote:

Originally Posted by marc_t
Would be really great to get any hint where to find the code which replaces the "["...

Thanks very much....

change in file geshi/actionscript.php line
Code:

        'COMMENT_SINGLE' => array(1 => '//', 2 => '#'),
to:
Code:

        'COMMENT_SINGLE' => array(1 => '//'),

kirupa 01-28-2006 09:28 PM

When a post containing some highlighted code is edited, I am not seeing the code back in its normal form with the [highlight=foo] brackets. Instead, I am seeing the actual box with the code inside it similar to a WYSIWYG mode.

Is there a problem with using the highlighter with the full WYSIWYG mode in VB3?

Thanks,
Kirupa

marc_t 01-30-2006 07:59 AM

lutek: Great! Thanks alot!!

shabbirbhimani 02-08-2006 07:08 AM

Quote:

Originally Posted by Alphawolf83
It does not work on v3.0.7, right? ;)
Good Job!

I have made it to work with 3.0.x versions as weel and you can check that at my forums. Link in sig. You can see the running version of the same at one of the thread Query optimization. I am not sure if I can put that here or not but if you need it I can probably give it to you.

Delphiprogrammi 03-04-2006 12:17 PM

this no longer works on 3.5.4 anybody with the same problem ? i upgraded geshi then it started to stop working then downgraded it again but nope ... this just stopped working without a "reason" why

edit

i've fixed it the urls are hyperlinked again in PHP source code i liked that feature so i've played with it and got it back.It wasn't this hack it was geshi itself that changed some stuff anyway if anybody wants it give me a yell

TKlingler 03-29-2006 04:39 AM

Hello, it works great also with the new geshi version,
I have only a littel problem when I use the it so charackters of me script part will displayed wrong. As example the right text is [Setup] with the Highlighter it will dispayed as &#91Setup&#93with geshi and phpbb this works so I think it comes for the xml, but I understand not we becaues I konw nothig about php.

Pleas can anyone say me what I must do ?

northcode 04-01-2006 04:00 AM

I couldn't be bothered to track it down any further than something in the geshi line numbering (too much regex crap) but this will fix the immediate problem.

Open geshi.php and find this line

var $lexic_permissions = array(

Then scroll down a bit and comment or remove this entry from the array (setting it to false may also work, but it felt better to hit the delete key).

'NUMBERS' => true,

Tim Goss
Northcode Inc.

ffevo 04-03-2006 10:04 PM

This is a problem I am having with ALL code on my forums including the code that your modification uses. In the first attachment you will see that there is a large space at the bottom of all the code.

That was the first issue.

You will also see that all the code used with YOUR modification does not get highlighted at ALL AND is on one line. You can see that on the second attachment.

I also wanted to change the highlight colors of ALL code including PHP. I also wanted to change the default font for highlighted code from courier new to something else. I use 10px font size and courier new is just too small for 10px. I would like to change the font face NOT the size.

Delphiprogrammi 04-25-2006 02:56 PM

everytime you update Geshi it stops working ?????

PHP Code:

if (!function_exists('handle_bbcode_highlight'))
{
 function 
handle_bbcode_highlight(&$parser$code$type)
 {
  global 
$vbulletin$vbphrase$stylevar$show;
  static 
$codefind1$codereplace1$codefind2$codereplace2;
  
$code $parser->strip_front_back_whitespace($code1);
  if (!
is_array($codefind))
  {
   
$codefind1 = array(
    
'<br>',  // <br> to nothing
    
'<br />' // <br /> to nothing
   
);
   
$codereplace1 = array(
    
'',
    
''
   
);
   
$codefind2 = array(
    
'&gt;',  // &gt; to >
    
'&lt;',  // &lt; to <
    
'&quot;'// &quot; to ",
    
'&amp;'// &amp; to &
    
'[',    // [ to [
    
']',    // ] to ]
   
);
   
$codereplace2 = array(
    
'>',
    
'<',
    
'"',
    
'&',
    
'[',
    
']',
   );
  }
  
$code trim(str_replace($codefind1$codereplace1$code));
  
$blockheight $parser->fetch_block_height($code) + 18// fetch height of block element
  
$code str_replace($codefind2$codereplace2$code); // finish replacements
  
$path DIR '/includes/geshi/';
  
//$code = geshi_highlight($code, $type, $path, true);
  
$geshi = new GeSHi($code$type$path);
  
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
  
$geshi->set_url_for_keyword_group($group$url);
  
$geshi->set_link_target('_BLANK'$styles); 
  
$tabs 4;
  
$geshi->set_header_type(GESHI_HEADER_DIV);
  
$geshi->set_tab_width($tabs);
  
$code $geshi->parse_code();
  
$code preg_replace('/&amp;#([0-9]+);/''&#$1;'$code);
  
$code str_replace(array('['']'"\n"), array('['']'''), $code);
  
$template $parser->printthread 'bbcode_highlight_printthread' 'bbcode_highlight';
  eval(
'$html = "' fetch_template($template) . '";');
  return 
$html;
 }
}
$this->tag_list['option']['highlight'] = array(
 
'callback' => 'handle_external',
 
'strip_empty' => true,
 
'stop_parse' => true,
 
'disable_smilies' => true,
 
'disable_wordwrap' => true,
 
'strip_space_after' => 1,
 
'external_callback' => 'handle_bbcode_highlight'
);
require_once(
DIR '/includes/geshi.php'); 

still the php keywords are not linked :mad: damn it

blueaura 05-04-2006 02:59 PM

Any way to get this to plug into the code button? The by doign [code] example code [/ code] it would automatically replace it with [highlight=Java] example code [/ highlight].

This would be much easier for less technical forum users to work and means the admin could limit the syntax highlighting to one specific language like Java if you run a Java programming forum.

Previously I got Geshi to work on the code button but I had to hack the php code for BBcode. Nice to see a more friendly way to get Geshi in there now anyway.

ffevo: You can change fonts and colours by editing the php.php file or what ever language you are using in /incudes/geshi

Also would like to suggest the following changes
Code:

if (!is_array($codefind))
        {
            $codefind1 = array(
                '<br>',        // <br> to nothing
                '<br />'    // <br /> to nothing
            );
            $codereplace1 = array(
                '',
                ''
            );

            $codefind2 = array(
                '&gt;',        // &gt; to >
                '&lt;',        // &lt; to <
                '&quot;',    // &quot; to ",
                '&amp;',    // &amp; to &
                '& #91;',    // without the space after the &
                '& #93;',    // ] without the space after the &

            );
            $codereplace2 = array(
                '>',
                '<',
                '"',
                '&',
                '[',
                ']',
            );
        }

It sorts out the issue with square brackets.

EDIT: you can edit includes/class_bbcode.php to get the plugin to use [code] with a bit of hacking. Can't be doign with that at the moment so I'm back at my own method. The author of this mod may want to explore this though.

kirupa 05-04-2006 04:54 PM

So, basically, does the highlighter work in vBulletin 3.5.4? I recall not being able to get it to work in an earlier vB 3.5.x version, so I have delayed updating my boards because of it.

blueaura 05-04-2006 05:55 PM

Quote:

Originally Posted by kirupa
So, basically, does the highlighter work in vBulletin 3.5.4? I recall not being able to get it to work in an earlier vB 3.5.x version, so I have delayed updating my boards because of it.

Yes it works

bullzeye 07-16-2006 10:04 PM

Is there any way to change the location of Geshi? For use with other parts of our site we had a directory /lib where geshi can be found and for update work and similarity on out other parts we want to place geshi in the folder /lib/geshi. I changed the path and the require_once in the xml-file of this plugin to lib/geshi (for $path) and require_once('lib/gehsi/geshi.php'). Installation was no problem and it seems that this gets parsed correctly but there is no highlightning only a gray Background with line numbers. I hope it is possible to understand what i want.

Excuse my bad english.

StarShaper 08-16-2006 06:30 PM

Quote:

Originally Posted by bullzeye
Is there any way to change the location of Geshi?

You have to change the include path. Just edit the plugin code.

There is a problem with this product. If you do a manual cache update of all Postings all geshi Code Blocks are deleted.

zylstra 12-27-2006 08:56 AM

Quote:

Originally Posted by digitalpoint (Post 768095)
I changed it to be CODE instead of HIGHLIGHT (more natural to me) and I added a little extra to have it intercept the normal PHP and HTML tag calls. :)

digitalpoint, care to share your modification with us?

zylstra 12-27-2006 10:51 AM

When I place
Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" lang="en">
<head>
<base href="http://www.example.com/" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

inside the tags with the html4strict option I get
Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[ur l="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd[/ur l]">
<html dir="ltr" lang="en">
<head>
<base href="[ur l="http://www.example.com/"]http://www.example.com/[/ur l]" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

without the space between the "ur" and the "l". It seems that URLs are parsed into links within code blocks, but this fails inside the Geshi parsed code. How do I turn off URL parsing within code blocks?

vB.org parses URLs inside posts, but not inside code blocks. This is how I want my site to work also.

Test: http://www.example.com/

zylstra 12-27-2006 05:21 PM

I discovered that the automatic URL linking is due to the WYSIWYG interface in IE: http://www.vbulletin.com/forum/bugs3...2018&status=60 .

zylstra 12-27-2006 05:38 PM

Quote:

Originally Posted by Wildthinks (Post 854765)
Have you any hint, where i can switch the width for bbcode code to 100%?
Thank you
thomas

Well, you can change it here, Styles & Templates -> Style Manager -> StyleVars -> Sizes and Dimensions -> Code Block Width, but IE will stretch the entire page to the dimension of the code.

delaen1 01-15-2007 04:42 PM

Anyone know if this still works with 3.6.4?

Gryphon 01-18-2007 09:34 PM

Yes

Smike 03-05-2007 11:22 AM

Thank you !
How can i add a button when i reply ?

Andrijeski 04-12-2007 01:18 PM

Works fine so far, thanks :)

Florian Bernd 05-17-2007 01:06 PM

Mhh .. look at my problem:

http://img248.imageshack.us/img248/940/syntaxev0.jpg

On the next edit the spaces got lost and some chars are maleformed .. =(

James Edwards 05-18-2007 07:37 AM

I can confirm that this works in 3.6.4; you can update the range of available languages by grabbing the latest version of "geshi.php" and the "geshi" directory from the developer's site -- http://qbnz.com/highlighter/

I fixed the square bracket issue (which also happens with percentage symbols) by adding the following line to the parse_code function in geshi.php (just before "// Initialise various stuff"):

PHP Code:

$code str_replace(array('['']''%'), array('['']''%'), $code); 

(Can't get the entitities to show up unparsed - the first array of replacements should be numeric entities 91, 93 and 37)

Florian Bernd 05-20-2007 10:48 AM

Thank you .. with this line it works fine for me .. but the bug with the tabs and spacings does already exists =/ After preview or on edit all spaces and tabs bevore the commands are missing .. Any ideas?

James Edwards 05-22-2007 12:11 AM

Not yet, I'm still trying to hack a solution for that!

James Edwards 05-25-2007 03:48 AM

Okay there's a few different things contributing to the whitespace/line-break formatting problems. I had to hack quite a bit to fix all this, so I've just uploaded my edited gehsi.php -- http://www.brothercake.com/clients/geshi.zip

All the changes I made begin with a comment that says "20070518 -- brothercake". Apart from fixing these issues, I've also removed the list markup (because line-numbers were being copied into the clipboard in some browsers), while retaining fancy lines (alternate line highlighting). And I've also stripped out some of the markup it generates - everything apart from what's actually needed!

To make these changes work I also had to comment out four lines from the product (the code inside the XML file):

PHP Code:

//################################################################
//20070518 -- brothercake mod commented these lines so we can control from geshi.php directly                
// $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
// $tabs = 4;
// $geshi->set_header_type(GESHI_HEADER_DIV);
// $geshi->set_tab_width($tabs);
//################################################################ 

Hope this is useful :) It's all pretty brutal, but it works!


All times are GMT. The time now is 01:48 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01325 seconds
  • Memory Usage 1,876KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (9)bbcode_code_printable
  • (3)bbcode_php_printable
  • (7)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete