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)

sidhighwind 08-09-2007 12:14 AM

So after 2+ hours of working on this I finally found a solution, it's not very clean as you have to edit a class file from vbulletin but such is life.

This is done with version 3.6.7 PL1

open up includes/class_bbcode_alt.php

1. Replace the second foreach loop in the `vB_BbCodeParser_Wysiwyg` function on line 82 with this code:
PHP Code:

        foreach (array('code''php''html','highlight') AS $pre_tag)
        {
            if (isset(
$this->tag_list['no_option']["$pre_tag"]))
            {
                
$this->tag_list['no_option']["$pre_tag"]['callback'] = 'handle_preformatted_tag';
                unset(
$this->tag_list['no_option']["$pre_tag"]['html'], $this->tag_list['option']["$pre_tag"]['strip_space_after']);
            }

            if (isset(
$this->tag_list['option']["$pre_tag"]))
            {
                
$this->tag_list['option']["$pre_tag"]['callback'] = 'handle_preformatted_tag';
                unset(
$this->tag_list['option']["$pre_tag"]['html'], $this->tag_list['option']["$pre_tag"]['strip_space_after']);
            }
        } 

2. Replace `handle_preformatted_tag` function with this code on line 179
PHP Code:

    function handle_preformatted_tag($code)
    {
        
$current_tag =& $this->current_tag;

        if(
$current_tag['option']) {
            return 
"[$current_tag[name]=$current_tag[option]]" $this->emulate_pre_tag($code) . "[/$current_tag[name]]";
        } else {
            return 
"[$current_tag[name]]" $current_tag['option']. " "$this->emulate_pre_tag($code) . "[/$current_tag[name]]";
        }
    } 


waldbauer.com 08-10-2007 07:33 AM

Hello !

Where can i define the WIDTH of code display ?
In Firefox it looks a little bit too small -> http://www.waldbauer.com/vb/showthre...=5552#post5552

EDIT: I see the auto feature has a problem with IE, which correct size in px to use instead ?

Vertex [HW-F] 08-16-2007 08:06 AM

]Hi all!

I have successfully installed Advanced Syntax Highlighting (THX Andreas) with all the modifcations read in the posts above (THX guys).

I need to fix at least one more thing: If I use the extended editor, copy paste a colored text and use the [highlight=XXX] vb Code tag the color format (and any othe format) doesn't get delete like using the [php] vb Code tag.

example:
[highlight=vb][color=red]coloredtext[/color][/highlight]
[php]coloredtext[/php]


Now i want to fix [highlight=XXX] to work like [php], because inserting preformated code nukes the text between the [highlight] tags.

However I can't find where [php] removes the other codes. Can anyone tell me where I can find this, please.

THX for help!

Vertex [HW-F] 08-17-2007 05:31 AM

]I did it! With help from vBulletin-germany I could find the line where you need to add the code.

Simply add it to the html and php keywords in functions_wysiwyg.php.

So replace:
Code:

'#\[(html|php)\]((?>[^\[]+?|(?R)|.))*\[/\\1\]#siUe',                                // strip html from php tags
to (whatever your tagsname is, here I added highlight)
Code:

'#\[(html|php|highlight)\]((?>[^\[]+?|(?R)|.))*\[/\\1\]#siUe',                                // strip html from php tags

Dean C 10-21-2007 01:55 PM

Quote:

Originally Posted by kirupa (Post 856259)
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:

Could anyone explain exactly how to add an [actionscript] tag please? With documented steps. The information in this thread on how-to do it are very sparse :) Thanks

Coders Shack 01-22-2008 08:00 PM

Quote:

Originally Posted by James Edwards (Post 1250042)
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)

PHP Code:

    $code str_replace(array('&#'.'91'.';''&#'.'93'.';''&#'.'37'.';'), array(chr(91), chr(93), chr(37) ), $code); 

works wonders.

the browser parses the characters, so the line of code i posted should work via copy & paste

Sph1nX 03-27-2008 06:56 PM

Installed successfully on 3.6.8 pl2 =)
Last problem is, I want to make the [highlight=vb] to [vb]
If I try to use a custom bbcode like [vb] which replaces [highlight=vb]{param}[/highlight] it doesn`t work :(
Someone knows how to make this working? German/English help for me would be nice :D

xEnco 04-17-2008 03:34 PM

Hi guys, I'm using vBulletin 3.70 RC3 and installed this hack. I tried to make a vB Tag and a button for the editor.
The normal code for highlighting is [highlight=vb]My VB code[/highlight], so I made a new vB Tag with the following content: [highlight=vb]{param}[/highlight]
But the problem is when I click on the button and add my text it doesnt highlight anything and just shows [highlight=vb]My Text[/highlight]
Do you know how to fix this?

Dashman 05-20-2008 02:03 PM

Will this work with 3.7.0 ?!

waldbauer.com 06-02-2008 01:54 PM

Hello ! I recently reinstalled this plugin on 3.7.1 but my codeblocks are to width - how can i reduce the codewidthto fit my screen ?

TheRayden 07-18-2008 10:42 PM

Hey all,

I've run into a strange problem with this. As you can see on the attachement, the colored code continues after the highlight should end. Any idea what could be causing this?

FleyerShaver 07-20-2008 10:15 PM

Does this Addon work correctly with 3.7.2pl1?

DevFuture.de 08-28-2008 08:44 PM

Plugin works fine with 3.7.3.

But i am still figguring out how to get some buttons into the editor.

1) You cant use the build-in method to add the bbcode, because the 'normal' tag is just given out, no highlight will be made.

2) You cant just change the toolbar_on template within the buttonmenu, and add a new entry with _cmd_wrap0_BBCODENAME=language, because then it will be

[BBCODENAME=language][/BBCODENAME=language]

instead of



so we need to change the vbulletin_textedit.js file, because there the choise will be made what to happen with our string.

But i cant find a solution that work. Is there somebody who can help me?

Thank you very much.


Developed a Solution. Check next Post.

DevFuture.de 08-31-2008 01:19 PM

Alright, i found a solution for the Button-Problem.

Just follow the Tutorial, and you will be able to use the Highlighter with the latest vBulletin (3.7.3 i think). You maybe find other information on this, but thats the only code which works perfectly with the WYSIWYG-Editor AND the normal Codeeditor. It allows you to select already inserted Code and wraps your Selection between the Tags, instead of replacing your code.

Step 1) Download the uncompressed Javascript Package of your Customer Center

Step 2) Open the File /clientscript/vbulletin_textedit.js

Step 3) Edit the File

Search for


Code:

        /**
        * Insert Email Link
        */

(its around Line 1890, if you haven?t modified it)

after this function enter the following:

Code:

        /**
        * Insert Visual Basic .NET Quellcode [(c) 2008 Dennis Alexander Petrasch, EntwickelerGemein.de]
        */
        this.vbnet = function(e)
        {
            var selection = this.get_selection();
            return this.insert_text('[highlight=VB.net]' + selection + '[/highlight]');
        };

        /**
        *  Insert Visual C# Quellcode [(c) 2008 Dennis Alexander Petrasch, EntwickelerGemein.de]
        */
        this.csharp = function(e)
        {
            var selection = this.get_selection();
            return this.insert_text('[highlight=Csharp]' + selection + '[/highlight]');
        };

        /**
        * Insert XML Quellcode [(c) 2008 Dennis Alexander Petrasch, EntwickelerGemein.de]
        */
        this.xml = function(e)
        {
            var selection = this.get_selection();
            return this.insert_text('[highlight=XML]' + selection + '[/highlight]');
        };

You can replace the XML Csharp oder VB.net Statement, if you want to highlight another language.

Search for

Code:

case 'insertimage':
(its around Line 2633, if you already paste the content below)

Insert following Code, after the Case statement

Code:


        // (c) 2008 Dennis Alexander Petrasch [http://www.EntwickelerGemein.de]
        case 'vbnet':
                {
                    var selection = this.get_selection();
                    this.wrap_tags('highlight', 'VB.net', selection);
                    return;
                }

                case 'csharp':
                {
                    var selection = this.get_selection();
                    this.wrap_tags('highlight', 'CSharp', selection);
                    return;
                }

                case 'xml':
                {
                    var selection = this.get_selection();
                    this.wrap_tags('highlight', 'xml', selection);
                    return;
                }

Just save the File and upload it to your Server. Now you need to edit your Editor-Template in your Editor.

Step 4) Edit the editor_toolbar_on template in ACP

Select Styles and Templates, then Search for template. Enter "editor_toolbar_on" and do a search. Remember to edit the template in all your Styles!

Search for:

Code:

<if condition="$show['php_bbcode']">
                <td><div class="imagebutton" id="{$editorid}_cmd_wrap0_php"><img src="$stylevar[imgdir_editor]/php.png" width="16" height="16" alt="$vbphrase[wrap_php_tags]" /></div></td>
            </if>

Add after this:

Quote:

Optional: If you like to add a seperator, then add the following code first

Code:

<td><img src="$stylevar[imgdir_editor]/separator.gif" width="6" height="16" alt="" /></td>

Code:

<td><div class="imagebutton" id="{$editorid}_cmd_vbnet"><img src="$stylevar[imgdir_editor]/vb.png" width="16" height="16" alt="Visual Basic .NET Quellcode einf?gen" /></div></td>
<td><div class="imagebutton" id="{$editorid}_cmd_xml"><img src="$stylevar[imgdir_editor]/xml.png" width="16" height="16" alt="XML Quellcode einf?gen" /></div></td>
<td><div class="imagebutton" id="{$editorid}_cmd_csharp"><img src="$stylevar[imgdir_editor]/cs.png" width="16" height="16" alt="Visual C# Quellcode einf?gen" /></div></td>


It works fine. Additionally, you can add some Phrases and so on, but this will work as well.

Remember to create some Icons for the Editor. Use the default Resolutionof 16x16 Pixels.

Quote:

I hope you enjoy this code, and it helps you to enchance the advanced Syntax Highlighter. If you need more information on this, please ask via mail or in my German .NET Development Board:

www.EntwicklerGemein.de
or via Mail
dennis@EntwicklerGemein.de

DevFuture.de 09-24-2008 03:36 PM

There is an error while converting [ and ] - Characters. Here is the Solution:

Open the product-advhighlight.xml and find:

Code:

                        $codefind2 = array(
                                '&gt;',                // &gt; to >
                                '&lt;',                // &lt; to <
                                '&quot;',        // &quot; to ",
                                '&amp;',        // &amp; to &
                                '& #91;',    // [ to [ (remove the spacebar between & and #-Char)
                                '& #93;',    // ] to ] (remove the spacebar between & and #-Char)
                        );

and replace the text with

Code:

                        $codefind2 = array(
                                '&gt;',                // &gt; to >
                                '&lt;',                // &lt; to <
                                '&quot;',        // &quot; to ",
                                '&amp;',        // &amp; to &
                                '[',    // [ to [
                                ']',    // ] to ]
                        );

and it works well.

Xtrato 10-16-2008 02:29 PM

ok so can we change the variable of "hightlight" to like "language" or something like that?

Im trying to use WP and this to work just fine.

Example , in wordpress getti uses , <pre lang=css> and how would i make vBulletin or Wordpress hack to ether use similar post code?

thanks a bunch.

DevFuture.de 01-30-2009 12:04 PM

I still havent figured out a solution for the highlight-relacement, but it works still fine with Version 3.8.0./ 3.8.1, if you follow my instructions i postet some posts before.

Simon Lloyd 02-17-2009 10:02 AM

DevFuture.de dou you know how to get it to auto indent the code?, i'm currently trying to use it for VBA (Microsofts version of VB) and i'm using teh vb.net language as the highlighting seems closest in that, but all the code stays "as is", it doesn't capitalize or indent the code so highlighted code still looks a bit messy.

DevFuture.de 02-21-2009 08:58 AM

Hello Simon Lloyd,

I am sorry, i havent subscribed the topic, so that I just saw your entry now. I am sorry, but I dont know how to indent them. Normally this function is not provided by GeShi (afaik).

But it should worker proper, if you copy the Sourceode with indented style, and paste them into a thread. Normally it should be displayed intended then.

Simon Lloyd 02-21-2009 10:56 AM

Quote:

Originally Posted by DevFuture.de (Post 1750528)
Hello Simon Lloyd,

I am sorry, i havent subscribed the topic, so that I just saw your entry now. I am sorry, but I dont know how to indent them. Normally this function is not provided by GeShi (afaik).

But it should worker proper, if you copy the Sourceode with indented style, and paste them into a thread. Normally it should be displayed intended then.

Dev. thanks for getting back, you are right it isn't supported by geshi, however the geshi users say it has to be parsed by some other code to indent it, i know its not that simple as in VBA code the indentation is tiered, i.e (without the >'s)
Code:

For Each.....
>>>If............Then
>>>>>Do something
>>>>>>>If......then
>>>>>>>>>Do something
>>>>>>>End If
>>>End If
Next

it is possible as i have seen it at www.vbaexpress.com

eliteevil 04-17-2009 09:34 AM

Great Stuff

ti07shadow 09-27-2009 08:43 PM

this mod doesnt display the [ correctly in the highlight, it displays [ ; instead of the actual symbol.

I placed a space before the ; due to it displaying it :p


the fix above didnt work for me

Meestor_X 12-20-2009 10:29 PM

What's happened to qbnz.com?

*Edit*
The site is back, but if it disappears again, there's still the software here:
http://sourceforge.net/projects/geshi/

Meestor_X 12-20-2009 10:34 PM

Waiting with baited breath to see this mod in vb4! :)

smirnoff 12-23-2009 05:25 PM

i've just install it on 3.8.4 and work perfectly, better than all the other i've tested! amazing :D

artvs 12-27-2009 10:07 AM

I'd successfully adapt this hack for VB4. Not sure can I share my efforts with everyone?

simunaqv 12-27-2009 10:08 AM

Oh please do..

artvs 12-27-2009 10:54 AM

What to do:
1) download and import product from attachment.
2) find file /admincp/misc.php and make a backup copy of it
3)in this file find
Code:

WHERE title IN ('bbcode_quote', 'bbcode_php', 'bbcode_code', 'bbcode_html', 'bbcode_video')
replace it with
Code:

WHERE title IN ('bbcode_quote', 'bbcode_php', 'bbcode_code', 'bbcode_html', 'bbcode_video', 'bbcode_highlight')
4) find
Code:

          'bbcode_video' =>& $bbcodelist["$tlist[bbcode_video]"],
add afrer
Code:

            'bbcode_highlight' =>& $bbcodelist["$tlist[bbcode_highlight]"],
5) find
Code:

            'bbcode_video' => intval($tlist['bbcode_video_styleid']),
add after
Code:

            'bbcode_highlight' => intval($tlist['bbcode_highlight']),
5) upload this file to ftp
6) go to admin panel and rebuild post cache

Hack usage:
[ syntax = cpp ] or [ highlight = cpp ] or [ code = cpp ] (without spaces)


I also would reccomend to obtain latest version of geshi.

b6gm6n 01-26-2010 05:27 AM

fixed my no-color problem, paths were out...great mod thanks

EDAInsight 01-29-2010 01:10 PM

Can this mod be used in VB 4.x ?

erosolmi 02-07-2010 07:26 PM

I'm interested too in using this mod for vB 4.x

as soon as I will be ready I will try to apply changes suggested by artvs here above.

Thanks

Sadikb 02-13-2010 04:25 PM

Confirmed working with VB 4.0.1 according to changes suggested by artvs. Thanks mate.

JarkkoL 03-03-2010 05:55 PM

Got warning with vb4.0.2:
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in [path]/includes/class_bbcode.php(185) : eval()'d code on line 11

lightbox 03-04-2010 01:32 PM

Quote:

Originally Posted by JarkkoL (Post 1996271)
Got warning with vb4.0.2:
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in [path]/includes/class_bbcode.php(185) : eval()'d code on line 11

Same here *sigh*

JarkkoL 03-21-2010 08:58 AM

Does anyone have a patch for vb4.0.2 to fix the above problem?

Edit: Ok, I was able to fix it by adding the following two lines to the product-advhighlight.xml file in artvs attachment:
Code:

    if(!is_array($specialtemplates))
            $specialtemplates = array();

above this line:
Code:

$specialtemplates = array_merge($specialtemplates, array('bbcode_highlight','bbcode_highlight_printable'));

JarkkoL 03-21-2010 01:20 PM

I made few changes to the product-advhighlight.xml file posted by artvs to make this mod work properly with vb4.0.2. I used latest GeSHi (1.0.8.6) with this mod:

- Added the is_array() check mentioned above.

- Changed the bbcode_highlight template to use "Maximum [CODE] Lines" defined in BB Code Settings. Previous version printed all the lines to the page regardless how long code you pasted within the code-tags, while this version limits the code window height and adds vertical scrollbar for code with more lines. It's doesn't limit the height exactly to the "Maximum [CODE] Lines" (I guess because of the different fonts used in the standard vB code tag and GeSHi), but is pretty close anyway (:

- Changed GeSHi to use GESHI_HEADER_PRE_VALID instead of GESHI_HEADER_DIV. This fixes word wrapping issue in the code window, i.e. previous version wrapped long code lines while this version adds horizontal scrollbar in that case.

- Fixed typos ;)


Disclaimer: I'm newbie when it comes to php & vb modding, so use this version at your own discretion (:

the_bolo 03-22-2010 09:36 AM

Having a problem with this mod on vb4.0.2 in that whenever I rebuild post cache, my [code] blocks in posts dont show up at all and I have to revisit each post/edit and save it again to ensure the code appears.

JarkkoL 03-22-2010 01:09 PM

Strange, I tried rebuilding the post cache but don't have the problem.

AshMagic 04-15-2010 11:52 AM

I have a problem. I am running 3.8.

It installs fine and works OK.. The syntax highlighting works but it replaces the [ and ] with HTML code. Eg, & #91; This is displayed as code rather than the actual symbol. Any ideas?

golsby 04-15-2010 06:37 PM

I hacked this for VB4 and my own personal preferences, then installed it. Works great!


All times are GMT. The time now is 08:42 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.02363 seconds
  • Memory Usage 1,887KB
  • 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
  • (21)bbcode_code_printable
  • (4)bbcode_php_printable
  • (6)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