News:

Wondering if this will always be free?  See why free is better.

Main Menu

[BETA] SMF Syntax Highlighter

Started by X3mE, February 02, 2009, 11:43:32 AM

Previous topic - Next topic

X3mE

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





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

Notes



Please post all your support questions and comments in the support thread. You can also use the Issue Tracker on the Demo Website.

Note: For issues regarding the highlight itself, it would probably be best to notify the author of the original script here. 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.


Kids, you tried your best and you failed miserably. The lesson is - never try.

My mods:
OS & Browser Detection (1.5 is out!) | Skype Profile Field | GTalk Profile Field | AllCaps Blocker | SMF Syntax Highlighter (Beta) + 2 in development!

Personal websites:
Mobilize.rs (and forum) | Lolmao.info



X3mE

Kids, you tried your best and you failed miserably. The lesson is - never try.

My mods:
OS & Browser Detection (1.5 is out!) | Skype Profile Field | GTalk Profile Field | AllCaps Blocker | SMF Syntax Highlighter (Beta) + 2 in development!

Personal websites:
Mobilize.rs (and forum) | Lolmao.info



Zyos

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)

X3mE

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.
Kids, you tried your best and you failed miserably. The lesson is - never try.

My mods:
OS & Browser Detection (1.5 is out!) | Skype Profile Field | GTalk Profile Field | AllCaps Blocker | SMF Syntax Highlighter (Beta) + 2 in development!

Personal websites:
Mobilize.rs (and forum) | Lolmao.info



karlbenson

I think this might be the same script i integrated in the summer, but ditched because of buggy parsing of php code.

Marcus Forsberg


X3mE

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 :)
Kids, you tried your best and you failed miserably. The lesson is - never try.

My mods:
OS & Browser Detection (1.5 is out!) | Skype Profile Field | GTalk Profile Field | AllCaps Blocker | SMF Syntax Highlighter (Beta) + 2 in development!

Personal websites:
Mobilize.rs (and forum) | Lolmao.info



Zyos

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!

X3mE

Kids, you tried your best and you failed miserably. The lesson is - never try.

My mods:
OS & Browser Detection (1.5 is out!) | Skype Profile Field | GTalk Profile Field | AllCaps Blocker | SMF Syntax Highlighter (Beta) + 2 in development!

Personal websites:
Mobilize.rs (and forum) | Lolmao.info



franklinrony

excelent like notepad++, line by line  :P, a question what programing languages support?
http://twitter.com/franklinrony

Entra y aprende a ser un webmaster
www.sv-blog.com
--Si pides ayuda al menos agradece el soporte recibido----

X3mE

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.
Kids, you tried your best and you failed miserably. The lesson is - never try.

My mods:
OS & Browser Detection (1.5 is out!) | Skype Profile Field | GTalk Profile Field | AllCaps Blocker | SMF Syntax Highlighter (Beta) + 2 in development!

Personal websites:
Mobilize.rs (and forum) | Lolmao.info



Zyos

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

X3mE

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.
Kids, you tried your best and you failed miserably. The lesson is - never try.

My mods:
OS & Browser Detection (1.5 is out!) | Skype Profile Field | GTalk Profile Field | AllCaps Blocker | SMF Syntax Highlighter (Beta) + 2 in development!

Personal websites:
Mobilize.rs (and forum) | Lolmao.info



Zyos

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...

X3mE

#14
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
Kids, you tried your best and you failed miserably. The lesson is - never try.

My mods:
OS & Browser Detection (1.5 is out!) | Skype Profile Field | GTalk Profile Field | AllCaps Blocker | SMF Syntax Highlighter (Beta) + 2 in development!

Personal websites:
Mobilize.rs (and forum) | Lolmao.info



Zyos

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!

ArkServer

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!

X3mE

#17
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 :).
Kids, you tried your best and you failed miserably. The lesson is - never try.

My mods:
OS & Browser Detection (1.5 is out!) | Skype Profile Field | GTalk Profile Field | AllCaps Blocker | SMF Syntax Highlighter (Beta) + 2 in development!

Personal websites:
Mobilize.rs (and forum) | Lolmao.info



Zyos


X3mE

Didn't have time to work further on it yet, I'm quite busy IRL now, will continue development from next week :)
Kids, you tried your best and you failed miserably. The lesson is - never try.

My mods:
OS & Browser Detection (1.5 is out!) | Skype Profile Field | GTalk Profile Field | AllCaps Blocker | SMF Syntax Highlighter (Beta) + 2 in development!

Personal websites:
Mobilize.rs (and forum) | Lolmao.info



Advertisement: