Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: X3mE on February 02, 2009, 11:43:32 AM

Title: [BETA] SMF Syntax Highlighter
Post by: X3mE on February 02, 2009, 11:43:32 AM
SMF Syntax Highlighter
by X3mE, version 0.1b

Description



This modification will add extra functionality to the code BBC tag, enabling syntax highlighting when a language code is passed as a parameter. For example:

[ code=langname]Some code here...[/ code]

The old-fashioned code display will still be available, if used without any parameters.

The list of supported highlighting "brushes" can be seen above the post box, as a new combo box.

Works with both SMF 1.1.7 and 2.0 Beta 4. There are no setting in the admin panel, nor database entries.

Note: This modification is still beta and hasn't been submited on the SMF Mod site yet.


Screenshot



(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fi20.photobucket.com%2Falbums%2Fb242%2Fx3me88%2FScreenshot.png&hash=afe0e99217ea057fe32845dfed03d5f13c083366)

Live Demo: http://x3me.iz.rs/index.php?board=11.0


Changelog



* Version 0.1b (02. 02. 2009.)
- Initial version for SMF 2.0 Beta 4 and SMF 1.1.7


Credits



Based on the free Syntax Highlighter 1.5.1, written by Alex Gorbatchev.
Project Home Page (http://code.google.com/p/syntaxhighlighter/)

Notes



Please post all your support questions and comments in the support thread. You can also use the Issue Tracker (http://x3me.iz.rs/index.php?project=5) on the Demo Website (http://x3me.iz.rs/).

Note: For issues regarding the highlight itself, it would probably be best to notify the author of the original script here (http://code.google.com/p/syntaxhighlighter/issues/list). You can also notify me, and I'll try to fix it myself.



Languages



Languages included:
- English (english, english-utf8)
- Serbian (serbian, serbian-utf8, serbian-utf8-lat)

To translate it to your own language, add the translation for:

$txt['SMF_Syntax_Highlighting'] = 'Syntax Highlighting';
$txt['SMF_Syntax_Highlighting_C'] = 'C';
$txt['SMF_Syntax_Highlighting_Csharp'] = 'C#';
$txt['SMF_Syntax_Highlighting_Cpp'] = 'C++';
$txt['SMF_Syntax_Highlighting_ColdFusion'] = 'ColdFusion';
$txt['SMF_Syntax_Highlighting_CSS'] = 'CSS';
$txt['SMF_Syntax_Highlighting_Delphi'] = 'Delphi';
$txt['SMF_Syntax_Highlighting_HTML'] = 'HTML';
$txt['SMF_Syntax_Highlighting_Java'] = 'Java';
$txt['SMF_Syntax_Highlighting_JavaScript'] = 'JavaScript';
$txt['SMF_Syntax_Highlighting_Pascal'] = 'Pascal';
$txt['SMF_Syntax_Highlighting_Perl'] = 'Perl';
$txt['SMF_Syntax_Highlighting_PHP'] = 'PHP';
$txt['SMF_Syntax_Highlighting_PlSQL'] = 'Pl/SQL';
$txt['SMF_Syntax_Highlighting_Python'] = 'Python';
$txt['SMF_Syntax_Highlighting_Ruby'] = 'Ruby';
$txt['SMF_Syntax_Highlighting_SQL'] = 'SQL';
$txt['SMF_Syntax_Highlighting_VB'] = 'Visual Basic';
$txt['SMF_Syntax_Highlighting_VBNET'] = 'VB .NET';
$txt['SMF_Syntax_Highlighting_XML'] = 'XML';
$txt['SMF_Syntax_Highlighting_XHTML'] = 'XHTML';


in the appropriate Modifications.language.php file. You are welcome to post your translations in the support topic.

Note: This will probably be changed (new stuff added) before the mod gets submited.


Donations



If you like this mod, please donate to support its further development. Any amount would be highly appreciated. Thank you.

(https://www.paypal.com/en_US/i/btn/btn_donateCC_LG_global.gif) (https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=2EV33MU7KLM5A&lc=GB&item_name=SMF%20modifications&item_number=smf&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG_global%2egif%3aNonHosted)
Title: Re: [BETA] SMF Syntax Highlighter
Post by: X3mE on February 02, 2009, 11:44:35 AM
Ok, I'm waiting for some feedback :)
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Zyos on February 02, 2009, 12:08:09 PM
If this has a select link to highlight code AND can display syntax with configurable colours for Microsoft INI based files (example)


[entry]
attribute = variable
attribute = variable
attribute = variable


I will literally have a womb implanted in me so I can have your babies (ok thats a bit extreme, but this is a feature I really REALLY would like)
Title: Re: [BETA] SMF Syntax Highlighter
Post by: X3mE on February 02, 2009, 12:24:44 PM
Currently there ain't a brush for ini files, but I'll try to make one. All colors are customizable, but you'll have to edit the java script sources.

I seem to have accidentally removed the Select button while modifying how the code tag works for SMF 2 :P. I'll fix that.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: karlbenson on February 02, 2009, 12:26:55 PM
I think this might be the same script i integrated in the summer, but ditched because of buggy parsing of php code.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Marcus Forsberg on February 02, 2009, 12:27:34 PM
Looks nice :)
Title: Re: [BETA] SMF Syntax Highlighter
Post by: X3mE on February 02, 2009, 12:43:23 PM
Quote from: regularexpression on February 02, 2009, 12:26:55 PM
I think this might be the same script i integrated in the summer, but ditched because of buggy parsing of php code.

TBH, I haven't tested highlighting thoroughly for various pieces of code yet, but I did see on the project home page that there are some issues with parsing "complicated" code. Should be fine for most cases, though.

Since Geshi prohibits distribution for SMF, this is the best replacement I could find (plus, it does everything on the client side :P, unlike Geshi), and I desperately needed this for one of my forums.

Quote from: Nas on February 02, 2009, 12:27:34 PM
Looks nice :)

Thanks :)
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Zyos on February 02, 2009, 01:22:21 PM
All I actually need is the code block to parse JUST ini code, with a select link next to the top of it so that people can click to highlight the whole code.

If you can provide just this, I can't see it as being too much of a trouble for you with the simplicity of the INI format and the fact the code to select I'm assuming you already have.

The reason for me wanting this is because I run a site dedicated to a particular game called Microsoft Freelancer, it makes extensive use of INI files to operate and to allow us to modify it.

Here is an example file:


[Cockpit]
mesh = cockpits\civilian\models\cv_cockpit.cmp
int_brightness = 0.500000
head_turn = 35, 15

[TurretCamera]
tether = 0.000000, 12.970000, 41.888000
yaw_rotate_speed = 2.000000
pitch_rotate_speed = 1.500000
accel_speed = 5


So you'd basically be changing the colour of [entry] and the first word of the lines that come after such as accel_speed, the = sign and then the values after, which can be both words or numbers

Unfortunately my experience in PHP is limited, so if you can add this functionality, that would be utterly fantastic!
Title: Re: [BETA] SMF Syntax Highlighter
Post by: X3mE on February 02, 2009, 01:36:18 PM
Ok, I'll see what I can do :).
Title: Re: [BETA] SMF Syntax Highlighter
Post by: franklinrony on February 02, 2009, 01:40:19 PM
excelent like notepad++, line by line  :P, a question what programing languages support?
Title: Re: [BETA] SMF Syntax Highlighter
Post by: X3mE on February 02, 2009, 02:12:55 PM
So far: C, C++, C#, ColdFusion, CSS, Delphi, HTML, Java, JavaScript, Pascal, Perl, PHP, Pl/SQL, Python, Ruby, SQL, Visual Basic, VB .NET, XML, XHTML.

The next version will include Bash, Groovy, Scala and probably INI.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Zyos on February 02, 2009, 02:21:21 PM
I'm sure you are going to have a drop down list to select the language, but for those of us running forums that may say for example only require one to be parsed, an option for a default language would be awesome, then all I need do is remove the list box.

I'm sure you are also going to make the languages themselves into seperate files so that if someone comes across a language thats missing they can add it that way.

Just some thoughts
Title: Re: [BETA] SMF Syntax Highlighter
Post by: X3mE on February 02, 2009, 02:27:06 PM
Yes, all languages are in separate files, so you can add/remove whatever you like.

There won't be any settings panel in the ACP (at least not for now), so you'd have to do what you ask manually, but it's not complicated, I'll tell you what to edit.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Zyos on February 02, 2009, 02:32:42 PM
I wasn't speaking of settings in ACP, I just meant a drop down list in the post page so if you want to say drop code in for PHP you'd just select that and press the code button, maybe the code would have something like [ code = php ]  [ /code ] once inserted, this way you could change the drop down again and click code to something else, like [ code = ini ] [ /code ].

If you get my meaning...
Title: Re: [BETA] SMF Syntax Highlighter
Post by: X3mE on February 02, 2009, 02:50:53 PM
Currently you just select the piece of code in the post box, pick a language from the drop down and the selected text is automatically surrounded with the code=selectedlang tag. No need for an extra click. When I implement INI, it'll surely be in that drop down.

If you'd prefer to have only one language highlighted, it's more appropriate to use a let's say simple image (like some other bbcodes), instead of a drop down, but you can implement it how ever you want.

Btw, it's been a while since I've played Freelancer, but definitely one of the best games ever :P
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Zyos on February 02, 2009, 03:10:34 PM
Heh, the modders of Freelancer have come up with some truly awesome stuff, the project I'm leading is designed to improve the original engine with a lot of the stuff people have come up with over the years.

In the effects department alone there have been leaps and bounds compared to the original game.

You should pop by to the site once its finished once in a while, maybe play it again, theres a nice and simple fix to microsoft shutting down the global server, the community now has its own hehe.

If you have the time, I know that you are probably extremely busy, I'm having an issue with quick reply (in another thread not too far from yours) if you could assist I would be extremely grateful, as its the only feature not working correctly at the moment :(

Looking forwards to having this syntax highlight on our forum, it's going to be a very nice touch to see syntax highlighting for freelancer modding code, especially one that people can just click [ select ] and copy into their own projects!
Title: Re: [BETA] SMF Syntax Highlighter
Post by: ArkServer on February 02, 2009, 07:06:09 PM
Quote from: X3mE on February 02, 2009, 12:43:23 PM
Quote from: regularexpression on February 02, 2009, 12:26:55 PM
I think this might be the same script i integrated in the summer, but ditched because of buggy parsing of php code.

TBH, I haven't tested highlighting thoroughly for various pieces of code yet, but I did see on the project home page that there are some issues with parsing "complicated" code. Should be fine for most cases, though.

Since Geshi prohibits distribution for SMF, this is the best replacement I could find (plus, it does everything on the client side :P, unlike Geshi), and I desperately needed this for one of my forums.

Quote from: Nas on February 02, 2009, 12:27:34 PM
Looks nice :)

Thanks :)

off topic
you sure geshi isn't allowed on SMF ? i've been running that mod for some time now on my own site here: http://javaforums.net/ and it works great but if you can't use it then i guess i have to take it down.

On topic
Nice mod!
Title: Re: [BETA] SMF Syntax Highlighter
Post by: X3mE on February 02, 2009, 07:45:45 PM
It's allowed to be used, but not allowed to be distributed, or at least something like that, I do know the mod was removed from the mod site.

Thanks :)

Regarding selecting and copying code... If you take a better look at the "box" which holds the code, there's a Copy to clipboard button. The problem is, it doesn't work very well in all browsers (it works in IE and Opera, copies line numbers in Firefox, don't know about Chrome and Safari), but I'm not sure if there's anything that can be done about that... (When will all browsers start to display all pages equally??? :P)

The Select all button is there by default in SMF 2, but I guess I could also implement it in SMF 1.1.7. The easiest way which works in all cases is to open the plain text popup window, Ctrl+A, Ctrl+C and there you have it :).
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Zyos on February 08, 2009, 07:44:59 AM
Been any updates on this?
Title: Re: [BETA] SMF Syntax Highlighter
Post by: X3mE on February 08, 2009, 08:06:43 AM
Didn't have time to work further on it yet, I'm quite busy IRL now, will continue development from next week :)
Title: Re: [BETA] SMF Syntax Highlighter
Post by: TheDisturbedOne on February 08, 2009, 12:24:05 PM
Looks good, but it is no use to my forum.  Would be GREAT in webmaster forums.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Zyos on February 08, 2009, 02:46:06 PM
Excellent, I've nearly finished my site now lol, except its missing an INI syntax highlighting feature *hint hint* lol.

Just joking, at your own pace buddy, at your own pace :D
Title: Re: [BETA] SMF Syntax Highlighter
Post by: bazzacad on March 13, 2009, 01:07:25 AM
Wow this is great.
What's the best way to add a new language? Just copy\edit one of the "shBrush???.js" files....
I want to create an AutoLISP brush.
I notice Alex Gorbatchev updated his Syntax Highlighter, does that effect your Mod?
Title: Re: [BETA] SMF Syntax Highlighter
Post by: X3mE on March 13, 2009, 07:05:02 AM
Once I find some time I will update it to Alex's new version, and add some more features. And yes, just copy/edit a shBrushXXX.js file.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Rumbaar on March 13, 2009, 05:35:17 PM
I know it's in BETA, but have you thought about submitting it to the Customize site?  Or wont it make it past the current requirements?   Looks like a great mod, that is lost at times in the see of general SMF coding threads.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: bazzacad on March 13, 2009, 11:57:58 PM
Why do these blank spaces get removed?
Title: Re: [BETA] SMF Syntax Highlighter
Post by: X3mE on March 14, 2009, 08:41:49 AM
@Rumbaar

I have been planing to do so after the release of the next version.

@bazzacad

I'm not sure :/

I suppose it's fixed in the new version of Alex's Syntax Highlighter.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: DeviDarkL on March 16, 2009, 01:15:17 PM
Great Mod ;) You really should thought about submitting it to the Customize site :D

Here is the Portuguese Translation:
<file name="$languagedir/Modifications.portuguese_pt.php" error="skip">
<operation>
<search position="end" />
<add><![CDATA[
$txt['SMF_Syntax_Highlighting'] = 'Destaque de Sintaxe';
$txt['SMF_Syntax_Highlighting_C'] = 'C';
$txt['SMF_Syntax_Highlighting_Csharp'] = 'C#';
$txt['SMF_Syntax_Highlighting_Cpp'] = 'C++';
$txt['SMF_Syntax_Highlighting_ColdFusion'] = 'ColdFusion';
$txt['SMF_Syntax_Highlighting_CSS'] = 'CSS';
$txt['SMF_Syntax_Highlighting_Delphi'] = 'Delphi';
$txt['SMF_Syntax_Highlighting_HTML'] = 'HTML';
$txt['SMF_Syntax_Highlighting_Java'] = 'Java';
$txt['SMF_Syntax_Highlighting_JavaScript'] = 'JavaScript';
$txt['SMF_Syntax_Highlighting_Pascal'] = 'Pascal';
$txt['SMF_Syntax_Highlighting_Perl'] = 'Perl';
$txt['SMF_Syntax_Highlighting_PHP'] = 'PHP';
$txt['SMF_Syntax_Highlighting_PlSQL'] = 'Pl/SQL';
$txt['SMF_Syntax_Highlighting_Python'] = 'Python';
$txt['SMF_Syntax_Highlighting_Ruby'] = 'Ruby';
$txt['SMF_Syntax_Highlighting_SQL'] = 'SQL';
$txt['SMF_Syntax_Highlighting_VB'] = 'Visual Basic';
$txt['SMF_Syntax_Highlighting_VBNET'] = 'VB .NET';
$txt['SMF_Syntax_Highlighting_XML'] = 'XML';
$txt['SMF_Syntax_Highlighting_XHTML'] = 'XHTML';
]]></add>
</operation>
</file>

<file name="$languagedir/Modifications.portuguese_pt-utf8.php" error="skip">
<operation>
<search position="end" />
<add><![CDATA[
$txt['SMF_Syntax_Highlighting'] = 'Destaque de Sintaxe';
$txt['SMF_Syntax_Highlighting_C'] = 'C';
$txt['SMF_Syntax_Highlighting_Csharp'] = 'C#';
$txt['SMF_Syntax_Highlighting_Cpp'] = 'C++';
$txt['SMF_Syntax_Highlighting_ColdFusion'] = 'ColdFusion';
$txt['SMF_Syntax_Highlighting_CSS'] = 'CSS';
$txt['SMF_Syntax_Highlighting_Delphi'] = 'Delphi';
$txt['SMF_Syntax_Highlighting_HTML'] = 'HTML';
$txt['SMF_Syntax_Highlighting_Java'] = 'Java';
$txt['SMF_Syntax_Highlighting_JavaScript'] = 'JavaScript';
$txt['SMF_Syntax_Highlighting_Pascal'] = 'Pascal';
$txt['SMF_Syntax_Highlighting_Perl'] = 'Perl';
$txt['SMF_Syntax_Highlighting_PHP'] = 'PHP';
$txt['SMF_Syntax_Highlighting_PlSQL'] = 'Pl/SQL';
$txt['SMF_Syntax_Highlighting_Python'] = 'Python';
$txt['SMF_Syntax_Highlighting_Ruby'] = 'Ruby';
$txt['SMF_Syntax_Highlighting_SQL'] = 'SQL';
$txt['SMF_Syntax_Highlighting_VB'] = 'Visual Basic';
$txt['SMF_Syntax_Highlighting_VBNET'] = 'VB .NET';
$txt['SMF_Syntax_Highlighting_XML'] = 'XML';
$txt['SMF_Syntax_Highlighting_XHTML'] = 'XHTML';
]]></add>
</operation>
</file>
Title: Re: [BETA] SMF Syntax Highlighter
Post by: rower on March 16, 2009, 03:33:12 PM
wery nice :)

Been any updates on this?
Title: Re: [BETA] SMF Syntax Highlighter
Post by: X3mE on March 16, 2009, 05:03:19 PM
Thanks DeviDarkL ;)

pimosz, I'm very busy at my faculty right now, but once I find some spare time there will be an update, and I hope that will come soon ;).
Title: Re: [BETA] SMF Syntax Highlighter
Post by: DeviDarkL on March 30, 2009, 07:04:27 PM
No problem X3mE ;)

It would be cool if BBC existed like the codes in different color that the other text ;D Just an idea of course eheh!
Title: Re: [BETA] SMF Syntax Highlighter
Post by: pery77 on April 03, 2009, 07:35:51 PM
Only work in default theme, why?
Title: Re: [BETA] SMF Syntax Highlighter
Post by: X3mE on April 03, 2009, 07:43:21 PM
You need to update your template files for your custom theme manually. This link should help you:

http://docs.simplemachines.org/index.php?topic=402
Title: Re: [BETA] SMF Syntax Highlighter
Post by: pery77 on April 04, 2009, 04:27:02 AM
thank you very much  ;)
Title: Re: [BETA] SMF Syntax Highlighter
Post by: kromonos on April 05, 2009, 06:38:37 AM
I need help with changeing Subs.php ..
what do I have to find and replace with?
Title: Re: [BETA] SMF Syntax Highlighter
Post by: X3mE on April 09, 2009, 08:34:40 PM
Unpack the installation, open the modification.xml file in a text editor (od modification_1.xml if you're using SMF 1.1.x), and find the

<file name="$sourcedir/Subs.php">

line. Under there you have to replace everything surrounded by

<search position="replace"><![CDATA[

and

]]></search>

with the text surrounded by

<add><![CDATA[

and

]]></add>

Let me know if you need any further assistance.

Title: Re: [BETA] SMF Syntax Highlighter
Post by: feline on April 10, 2009, 08:58:51 AM
Very good mod  ;)
Thanks

Fel
Title: Re: [BETA] SMF Syntax Highlighter
Post by: feline on April 10, 2009, 10:32:08 AM
Two bugs I have found ..

1.. missing global $context in Subs.php (gives errors)
corrected code:

'validate' => isset($disabled['code']) ? null : create_function('&$tag, &$data, $disabled', '
global $context;

/* We must revert all earlier parsning, we need the clean code only */
$data[0] = strtr($data[0], array(\'&#38;#91;]\'=> \'[]\', \'&#38;#91;&#38;#039;\'=> \'[&#38;#039;\', \'<br />\'=> "\n",));

$data[0] = un_htmlspecialchars($data[0]);

'),


2.. have the first line of code a tab character, then the display is not correct.
See attached image.

Fel
Title: Re: [BETA] SMF Syntax Highlighter
Post by: X3mE on April 10, 2009, 11:20:04 AM
Thanks, I'll look into that.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Axcess on April 11, 2009, 12:51:32 AM
How can i get in on the beta test?
Title: Re: [BETA] SMF Syntax Highlighter
Post by: X3mE on April 11, 2009, 08:34:40 AM
Everyone can download and test it :)

It's attached in the first post on page 1 of this topic.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: kromonos on April 12, 2009, 10:56:29 AM
Could you add a description for manual installation? .. please .. for smf1.1.8
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Axcess on April 15, 2009, 11:57:05 AM
blocks of c code with includes have a

</stdio.h> appended to them, which is not accurate. I think this is because of the
#include <stdio.h> at the beginning of the block

I'll attach a pic.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: X3mE on April 15, 2009, 12:42:02 PM
There will be an update soon, updating the background "engine" which does the highlight, I suppose many of the highlighting errors will be fixed.

Can't say exactly when, as I'm overwhelmed with studies and work obligations, but I'll do my best to find some time.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: jpaulino on April 27, 2009, 10:09:48 AM
X3mE,

Great job!

I only found a problem until now: it doesn't work with WYSIWYG editor  :(

Are you planning to include that ?
Title: Re: [BETA] SMF Syntax Highlighter
Post by: X3mE on April 27, 2009, 01:21:36 PM
What exactly is the problem with WYSIWYG?
Title: Re: [BETA] SMF Syntax Highlighter
Post by: jpaulino on April 27, 2009, 01:54:23 PM
Quote from: X3mE on April 27, 2009, 01:21:36 PM
What exactly is the problem with WYSIWYG?

Hi,

The problem is that the tags doesn't show in the editor after you select the code. It works very fine with the regular editor but with that one don't.

I got an javascript error:

QuoteWebpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 1.1.4322; InfoPath.1)
Timestamp: Mon, 27 Apr 2009 17:52:16 UTC

Message: Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus.
Line: 401
Char: 3
Code: 0
URI: http://www.-----.org/testplatform/forumteste/Themes/default/scripts/script.js?rc1


Thanks for the reply!
Title: Re: [BETA] SMF Syntax Highlighter
Post by: cut|throat on May 05, 2009, 06:38:44 AM
hi there.
this is a brilliant mod. been looking for one of these everywhere.
any chance of an update to working with 2.0 rc1?
cheers.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: X3mE on May 05, 2009, 07:24:05 AM
It is working with RC1 :)
Title: Re: [BETA] SMF Syntax Highlighter
Post by: cut|throat on June 04, 2009, 06:53:39 AM
thank you very much for this.
just to confirm, this works fine on 2.0 RC1.1 :D
brilliant mod.
i would donate but im afraid i'm pretty strapped for cash. ill donate when i can ;).

one feature request that would be great though, is for it to all be in a small scrolling box rather than all stretched out for long codes.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Daniel15 on June 06, 2009, 06:01:27 AM
Before you submit it to the mods site, I suggest you change 1.0 - 1.99.99 to 1.1 - 1.1.99 in the mod file, unless you actually *did* test with SMF 1.0 ;)
Title: Re: [BETA] SMF Syntax Highlighter
Post by: cut|throat on June 06, 2009, 08:03:50 AM
Hi I may have spotted a potential security risk or it may just be an annoying bug but it should be fixed either way.
The php code tags (possibly other web development languages too) some of the code actually displays.
Like for example text fields sometimes display etc.
Hope this helps :)
Title: Re: [BETA] SMF Syntax Highlighter
Post by: islam2hamy on June 07, 2009, 11:23:17 AM
nice mod
When it will be submited in the mod site ??

Arabic translation (utf-8) :

$txt['SMF_Syntax_Highlighting'] = 'شفرة برمجية';
$txt['SMF_Syntax_Highlighting_C'] = 'C';
$txt['SMF_Syntax_Highlighting_Csharp'] = 'C#';
$txt['SMF_Syntax_Highlighting_Cpp'] = 'C++';
$txt['SMF_Syntax_Highlighting_ColdFusion'] = 'ColdFusion';
$txt['SMF_Syntax_Highlighting_CSS'] = 'CSS';
$txt['SMF_Syntax_Highlighting_Delphi'] = 'Delphi';
$txt['SMF_Syntax_Highlighting_HTML'] = 'HTML';
$txt['SMF_Syntax_Highlighting_Java'] = 'Java';
$txt['SMF_Syntax_Highlighting_JavaScript'] = 'JavaScript';
$txt['SMF_Syntax_Highlighting_Pascal'] = 'Pascal';
$txt['SMF_Syntax_Highlighting_Perl'] = 'Perl';
$txt['SMF_Syntax_Highlighting_PHP'] = 'PHP';
$txt['SMF_Syntax_Highlighting_PlSQL'] = 'Pl/SQL';
$txt['SMF_Syntax_Highlighting_Python'] = 'Python';
$txt['SMF_Syntax_Highlighting_Ruby'] = 'Ruby';
$txt['SMF_Syntax_Highlighting_SQL'] = 'SQL';
$txt['SMF_Syntax_Highlighting_VB'] = 'Visual Basic';
$txt['SMF_Syntax_Highlighting_VBNET'] = 'VB .NET';
$txt['SMF_Syntax_Highlighting_XML'] = 'XML';
$txt['SMF_Syntax_Highlighting_XHTML'] = 'XHTML';


please before put the translation in the file be sure that the file encode is UTF-8
Title: Re: [BETA] SMF Syntax Highlighter
Post by: ViRuXe on August 23, 2009, 11:12:37 AM
Nice mod. ;)

How can we add another programming language to it?
Title: Re: [BETA] SMF Syntax Highlighter
Post by: silvios on September 08, 2009, 10:16:14 AM
Aw just the mod i was looking for. Why the ****** wouldnt gesi work with SMF, if its open sourced why wouldnt we be able to use it with this forum software?

Either way this one ur using looks nicer overall, just doesnt support as many languages
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Arantor on September 08, 2009, 10:24:47 AM
Because you need to integrate the two. GeSHi on its own doesn't have anywhere to link to SMF, so you have to add code to link the two. I just don't think it's been fully done yet.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: 青山 素子 on September 08, 2009, 11:17:17 AM
GeSHi is under the GPL, and the license interaction with SMF keeps it from being used. If the developers were to use a less restrictive license, I don't think there would be such a problem.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Dipa on October 21, 2009, 06:40:22 PM
I have a problem with operator "<"
like Axcess when have problem with include

if i want #include <name.h>
dint work
like cout<<variable<<endl;
endl error
variable error
name.h error

if i set cout<<  variable<<  endl;
works, but....can fixed that ??

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimage.gxzone.com%2Fimages%2F8%2F5%2F85117ab732c.jpg&hash=07aaaf46cd6959c39c9bf1d4767a47afb527eb2f)
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimage.gxzone.com%2Fimages%2F8%2F6%2F8668079910e.jpg&hash=2c7c32eaac502165840978fd1b68f11b97ecde2d)
Title: Re: [BETA] SMF Syntax Highlighter
Post by: MrCreatoR on October 26, 2009, 04:15:43 PM
Nice mod.
Is there a language file for AutoIt (http://autoitscript.com) syntax highlighting?

P.S
The copy link does not working in Opera browser.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: bbqau on November 11, 2009, 05:37:10 PM
Really nice customisation, works a treat for programming oriented sites :)

however my current theme seems to override how code is displayed :( on the default theme it works fine, however on anything other than SMF's default theme, the nice code block and line numbering simply do not show up. Is there a setting i am missing or some kind of configuration.

The theme i am using is DarkZ ~ http://custom.simplemachines.org/themes/index.php?lemm
Title: Re: [BETA] SMF Syntax Highlighter
Post by: wilkolak on November 14, 2009, 09:00:16 AM
Is it in development any more..?

It would be nice to see a version based on SyntaxHighlither 2.0 and running on smf 2.0 RC2
Can you do it?
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Sirius OCTeam on November 14, 2009, 06:43:06 PM
I'm into it, but still with the Syntax Highlighter 1.5.1

The Syntax Highlighter 2.1.364 is pretty hard to implement and this is some work to do.

My version 2.0a of this MOD (RC2 only) is already running on my test board, but can't find the way to implement the dropdownlist, I'm not the only one who want to put another dropdownlist to the editor, but nobody's want to tell us how to ?
http://www.simplemachines.org/community/index.php?topic=345402.0

So for the moment I must use the BBcode button with the type of code.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Arantor on November 14, 2009, 06:43:59 PM
It isn't so much that no-one wants to, more like no-one really knows outside the dev team. To my knowledge that other thread is the only place it's been discussed.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Satan911 on November 15, 2009, 08:40:00 PM
So any idea when you are going to have a new version? The one you have there seems good but I'd like something stable to put on my forum. The new forum I have working isn't going public before 1 month so if you are going to release something better within that month I'll wait. But the community I work for has more that 10 000 users and many coders who will enjoy this function if it's working properly.

Great work by the way! (and the person who developed this syntax highlighter is even greater, sorry :P)
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Sirius OCTeam on November 16, 2009, 12:00:57 AM
If you want to give it a try

Notes:
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Satan911 on November 16, 2009, 03:07:16 PM
Well I'm running RC1.2 at the moment. Guess I should update to RC2 but I have a lot of mods installed. I'll contact you later maybe.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: wilkolak on November 19, 2009, 08:17:30 PM
2.xx doesn't give many more functionality. It will be nice to run it but if it is hart to implement then it isn't must have I think... Not for me for sure. ;)

I've installed your beta, and it runs. But it destroyed linebreaks in my code. Please see the attachment.
If I add html <br/> it breaks the line... but it is impossible to do in 100lines code...
Also it would be nice if you fix the < > problem.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Informatics on November 25, 2009, 10:31:35 AM
Quote from: wilkolak on November 19, 2009, 08:17:30 PM
2.xx doesn't give many more functionality. It will be nice to run it but if it is hart to implement then it isn't must have I think... Not for me for sure. ;)

I've installed your beta, and it runs. But it destroyed linebreaks in my code. Please see the attachment.
If I add html <br/> it breaks the line... but it is impossible to do in 100lines code...
Also it would be nice if you fix the < > problem.

yeah, me too.... and we should change < into &lt;and > into &gt; manually
Title: Re: [BETA] SMF Syntax Highlighter
Post by: wilkolak on March 14, 2010, 08:11:04 AM
I'm waiting too.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: t0nedef on April 01, 2010, 10:33:00 PM
Can't wait till you get this working guys, my board could really use this! ( on a side note, I've downloaded the package and seeing if I can't hack the source into shape... I'll keep you posted. So if these guys don't get it done, I'm going to do my best to ensure there is something out there )
Title: Re: [BETA] SMF Syntax Highlighter
Post by: eattheword on April 20, 2010, 03:39:58 AM
I love this mod and want to use it for a work-related site. Here's my problem: I need to support ActionScript 3.0 syntax. I have created a shBrushAS3.js brush. If I copy that to the js directory on the server and manually edit the Subs.php file to include 'shBrushAS3' in the appropriate array then everything works fine.

If I add the shBrushAS3.js to the mod's zip file and upload and install the package that way it works ok, but obviously I need to edit the install-1.x.xml file to reflect the new array value. So, if I extract the install-1.x.xml file, amend it accordingly, and put it back into the zip file, I can upload the mod, but when I try to apply it I get a "Modification parse error". Even if all I do is extract install-1.x.xml from the zip and put it back again unchanged I still get this error.

Any clues as to what I should be doing differently?

[EDIT] Ok, sussed it. It seems there is something in the way OS X zip applications which produces archives that SMF doesn't like. I fired up VMware, opened a Windows session and did the file changes using 7zip. And it worked fine.

So, anyone got any workarounds for how to modify the zip files on OS X without having to resort to opening a Windows session?

[EDIT2] And how do you integrate it with other themes? I followed the link two pages back but the page concerned doesn't seem to address this.

[EDIT3] Ok, solved it. If you want to use this mod with other themes, here's what you do. Using the theme editor in the SMF admin panel, edit the 'index.template.php' file for each theme you want to apply Syntax Highlighter to.

Find:

<title>', $context['page_title'], '</title>';


And put this beneath it:


// Syntax Highlighting javascript...
syntaxHighlightingJavascript();


Then, find Sources/Subs.php and edit that. You need to find the 'function syntaxHighlightingJavascript()' section. Inside that function replace every occurrence of
theme_url with default_theme_url. I think there were four occurrences.

And that should do it.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: prisonhunter on April 22, 2010, 04:27:11 PM
I typed [code =C++] CODE [/ code] (no spaces ofc) and why do I have this?

Thank you in advance. :)
Title: Re: [BETA] SMF Syntax Highlighter
Post by: johnny mercy on July 10, 2010, 05:50:42 AM
People I need some help!!

My version is 2.0 RC3 and when I try to install it doesn't work!! (Many tests not passed)

What should I do?
Thanks
Title: Re: [BETA] SMF Syntax Highlighter
Post by: flapjack on July 10, 2010, 08:00:44 AM
Manual Installation of Mods (http://docs.simplemachines.org/index.php?topic=402.0)
Title: Re: [BETA] SMF Syntax Highlighter
Post by: johnny mercy on July 10, 2010, 04:43:25 PM
I've tried that but I can't get it to work :S
Maybe I'm doing something wrong..

What version should I download to work with 2.0 RC3?
Thanks
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Bugo on July 10, 2010, 10:14:18 PM
Quote from: johnny mercy on July 10, 2010, 04:43:25 PM
I've tried that but I can't get it to work :S
Maybe I'm doing something wrong..

What version should I download to work with 2.0 RC3?
Thanks

Yes, it works with 2.0 RC2-RC3.

Simple paste your code between tags [ code=language] ... [/code ]
Example (w\o spacebars):
Quote[ code=xml]xml-code[/code ]
Title: Re: [BETA] SMF Syntax Highlighter
Post by: johnny mercy on July 11, 2010, 09:30:13 AM
What version should I download? Your version?

And where should I put that code? xD (i'm little noob when it comes to install mods manually)

Thanks
Title: Re: [BETA] SMF Syntax Highlighter
Post by: RockerMan on August 09, 2010, 03:49:18 PM
OK so I have installed this mod and I am just getting this...
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimg823.imageshack.us%2Fimg823%2F4476%2F79171873.jpg&hash=00335d74c5420e3585539d21d4fdaa6a355b5c2a)

Can anyone help me please?
My forum is version 2 RC3 and the link is graphics-post.com

Thanks in advance,
Mike
Title: Re: [BETA] SMF Syntax Highlighter
Post by: flapjack on August 09, 2010, 03:57:15 PM
Quote from: RockerMan on August 09, 2010, 03:49:18 PM
OK so I have installed this mod and I am just getting this...
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimg823.imageshack.us%2Fimg823%2F4476%2F79171873.jpg&hash=00335d74c5420e3585539d21d4fdaa6a355b5c2a)

Can anyone help me please?

Thanks in advance,
Mike

You can start here: How do I ask support questions the smart way? (http://docs.simplemachines.org/index.php?topic=494.0)
Title: Re: [BETA] SMF Syntax Highlighter
Post by: RockerMan on August 09, 2010, 05:33:35 PM
Dude, I only forgot the link and version....

Added it
Title: Re: [BETA] SMF Syntax Highlighter
Post by: flapjack on August 09, 2010, 05:37:54 PM
you never mentioned which version you've installed. maybe these info is not too important for you, but it's very important for people who might help you
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Scientius on August 20, 2010, 05:34:18 PM
I liked Syntax Highlighter. But please help me. I am new in SMF and I couldn't do anything. how can ı install that. Thanks :)
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Nuks on October 03, 2010, 09:20:21 PM
Information :
SMF 2.0 RC3

Hi there !

I successfully installed latest version of this mod from Bugo but i'm having some issues :

- Live news from SimpleMachines isn't displayed - in admin section.
- Version Check is working but "Current SMF version: ??" is displayed - in admin section.
- Detailed Version Check is having the same issue.

I've searched around files and it's actually this mod which is creating a mess. When i comment this in Sources/Load.php :


syntaxHighlightingJavascript();


Everything is working fine back.

Admin.js is present and working fine when i look at sources i can actually see latest news inside.

Any advice ? Thanks !
Title: Re: [BETA] SMF Syntax Highlighter
Post by: KensonPlays on October 03, 2010, 09:45:30 PM
ill download it later,

Zyos: Send me a link to the forum i own that game! I love it!
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Nuks on October 03, 2010, 09:57:50 PM
Thanks a lot Kcmartz !

For others :

I also fixed a little bug : code bbcode without parameters wasn't working.

Find this :

                'tag' => 'code',
                'type' => 'unparsed_equals_content',
                'content' => '<div class="codeheader">' . $txt['code'] . ': <a href="#" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',
                // !!! Maybe this can be simplified?


Replace with :

                'tag' => 'code',
                'type' => 'unparsed_content',
                'content' => '<div class="codeheader">' . $txt['code'] . ': <a href="#" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',
                // !!! Maybe this can be simplified?


Title: Re: [BETA] SMF Syntax Highlighter
Post by: IceXaos on October 04, 2010, 05:23:31 AM
Wow, I just put in a request for this a little bit ago.  I'll give this a try.

/e/ Nevermind, it doesn't look like this is for 2.0 RC3.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Nuks on October 04, 2010, 10:28:26 AM
It is ! You have to install by emulated RC2 fist this one :

http://www.simplemachines.org/community/index.php?topic=290024.msg2360372#msg2360372

Then this one :

http://www.simplemachines.org/community/index.php?topic=290024.msg2648453#msg2648453

I may try to merge those two in one package if you prefer (without some extra code that isnt necessary).
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Nuks on October 05, 2010, 05:16:51 AM
Lets go.

Here's my version of this mod based on Sirius OCTeam (http://www.simplemachines.org/community/index.php?action=profile;u=64930) and Bugo (http://www.simplemachines.org/community/index.php?action=profile;u=229017) version.

It fixes some problems :


And a little bit of cleaning code.

Feel free to edit/copy/distribute this, if you have any problem just post here or private message since i'm not coming often on SimpleMachine boards.

Tested on fresh install of SMF 2.0 RC3 only.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: KensonPlays on October 05, 2010, 11:25:17 AM
Quote from: Nuks on October 05, 2010, 05:16:51 AM
Lets go.

Here's my version of this mod based on Sirius OCTeam (http://www.simplemachines.org/community/index.php?action=profile;u=64930) and Bugo (http://www.simplemachines.org/community/index.php?action=profile;u=229017) version.

It fixes some problems :


  • [ code]...[ /code] without equals parameters
  • News from SimpleMachine in admin panel

And a little bit of cleaning code.

Feel free to edit/copy/distribute this, if you have any problem just post here or private message since i'm not coming often on SimpleMachine boards.

Tested on fresh install of SMF 2.0 RC3 only.
Tested on a modified SMF. Worked fine for me!
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Nuks on October 05, 2010, 11:58:23 AM
I made an update using latest Syntax Highlighter by Alex Gorbatchev. There is only one bug in preview : content between code isn't parsed. Do you mind looking at it Kcmartz ? :)


You have to uninstall 2.0 first.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: KensonPlays on October 06, 2010, 01:28:45 AM
no I don't mind, I can't do it tonite, but tomorrow morning I can!
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Nuks on October 08, 2010, 12:23:52 PM
Did you take a look  ? :)
Title: Re: [BETA] SMF Syntax Highlighter
Post by: KensonPlays on October 08, 2010, 12:51:10 PM
forgot i got busy the day i said i could, and class is over, sorry
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Jeet Chowdhury on February 05, 2011, 03:56:27 AM
which one should i use for linux shell highlight??


btw getting this error,

*    1.    Execute Modification    ./Sources/Subs-Editor.php    Test successful
      1.    Add After    ./Sources/Subs-Editor.php    Test successful
*    2.    Execute Modification    ./Sources/Subs.php    Test failed
      1.    Replace    ./Sources/Subs.php    Test failed
*    3.    Execute Modification    ./Themes/default/Post.template.php    Test failed
      1.    Add After    ./Themes/default/Post.template.php    Test failed
*    4.    Execute Modification    ./Themes/default/GenericControls.template.php    Test failed
      1.    Add After    ./Themes/default/GenericControls.template.php    Test failed
      2.    Add After    ./Themes/default/GenericControls.template.php    Test failed
*    5.    Execute Modification    ./Themes/default/scripts/editor.js    Test successful
      1.    Add After    ./Themes/default/scripts/editor.js    Test successful
   6.    Execute Modification    ./Themes/default/scripts/xml_topic.js    File not found
*    7.    Execute Modification    ./Themes/default/index.template.php    Test successful
      1.    Add Before    ./Themes/default/index.template.php    Test successful
      2.    Add Before    ./Themes/default/index.template.php    Test successful
*    8.    Execute Modification    ./Themes/default/languages/Modifications.english.php    Test successful
      1.    Add Before    ./Themes/default/languages/Modifications.english.php    Test successful
   9.    Execute Modification    ./Themes/default/languages/Modifications.english-utf8.php    Skipping file
   10.    Execute Modification    ./Themes/default/languages/Modifications.serbian.php    Skipping file
   11.    Execute Modification    ./Themes/default/languages/Modifications.serbian-utf8.php    Skipping file
   12.    Execute Modification    ./Themes/default/languages/Modifications.serbian-utf8-lat.php    Skipping file
Title: Re: [BETA] SMF Syntax Highlighter
Post by: NanoSector on February 05, 2011, 05:08:26 AM
This mod is outdated and is not compatible with the latest version.
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Jeet Chowdhury on February 22, 2011, 07:04:22 AM
which mod should i use then?
Title: Re: [BETA] SMF Syntax Highlighter
Post by: thepisu on March 07, 2011, 05:27:46 PM
Hi, there is a syntax highlighter mod, working on SMF 2.0 RC5?

Thanks
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Matthew K. on March 07, 2011, 06:12:44 PM
You are not allowed to redistribute a mod with changes you made, without permission from the mod author. Removing your attachment.
Quote from: thepisu on March 07, 2011, 06:11:05 PM
I modified "Highlight for SMF" to work in SMF 2.0 RC5. I'm attaching here if someone needs it.
I cannot find the original post / page for this mod.. sorry
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Umbus on May 09, 2011, 04:53:42 PM
To 2.0rc5 exist this?
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Bugo on May 10, 2011, 01:05:53 AM
You can try Code Highlighting (http://dragomano.ru/page/mods-for-smf-english).
Title: Re: [BETA] SMF Syntax Highlighter
Post by: carloscuev on June 08, 2012, 02:51:07 AM
any updates for SMF v2.0.2?
Title: Re: [BETA] SMF Syntax Highlighter
Post by: Adrek on June 08, 2012, 03:18:02 AM
@carloscuev, for 2.0.2 you should try this => cb|GeShi-mod (http://custom.simplemachines.org/mods/index.php?mod=3070) :)