ZFGC

ZFGC.com => Feedback => Topic started by: Cassyblanca on January 04, 2010, 05:19:10 pm

Title: Syntax Highlighted [code] Tag
Post by: Cassyblanca on January 04, 2010, 05:19:10 pm
I just finished the work on an SMF mod to add syntax highlighting, compatible with SMF 1.1.x and 2.0 RC2 (probably RC1 as well, but I didn't bother testing), that works through client-side javascript, and I think it would be a nice addition to the forums.

It uses SHJS for the syntax highlighting, using a modified version of the Acid theme, and supports a good number of languages, and I'm working to create language definition files for GML and TorqueScript.

Anyway, a sample can be seen at http://minalien.com/shtest/index.php?topic=1 (http://minalien.com/shtest/index.php?topic=1), and I doubt it will have problems with the mods and work that has been done on ZFGC's templates. If it does, it'll be a trivial thing for me to get with somebody with access to add the single command to the template that'll call the necessary javascript & css files.

If you're good with it, I'll send it to whoever is going to do the installing. It works through SMF's package system, so there wont be problems there. I'm not releasing it publicly until I finish working up the Readme file and submit it to SMF's mod site.

Oh, and for people who support this:
Go to http://shjs.sourceforge.net/
On the right, preview some of the themes
Tell me which you prefer. The demo I put up shows the Acid theme, which I chose mostly because I didn't feel like searching through the rest, and nedit sucks.

Supported Languages:
Bison
C
C++
Diff
Flex,
GLSL
Haxe
HTML
Java
Java Property files
JavaScript
JavaScript w/DOM extensions
LaTeX
LDAP
Log files
M4
Makefiles
Objective CAML
Oracle
Pascal
Perl
PHP
Prolog
Python
Ruby
S-Lang
Scala
Shell
SQL
TCL
XML
Xorg conf files
Title: Re: Syntax Highlighted [code] Tag
Post by: Colbydude on January 04, 2010, 05:29:03 pm
Very nice, and a very good idea. It'll definitely be a great addition to the forum here. I'll probably add it to my forum as well once it's public. Good work.  ;)
Title: Re: Syntax Highlighted [code] Tag
Post by: Mamoruanime on January 04, 2010, 05:35:01 pm
Add Blitz and I'm sold!

(lol j/p; awesome work)
Title: Re: Syntax Highlighted [code] Tag
Post by: Cassyblanca on January 04, 2010, 05:39:00 pm
Already working on the next version, which I plan to have the following:

Admin CP
Select a default theme and default language (default language for code tags missing a language parameter)
Allow/Disallow users to select their own themes
Upload new CSS theme files

User CP
(When enabled) selecting syntax highlighting theme

But yeah, that'll be a while, because I'm too lazy and I have to re-learn most of the internal workings of SMF, since I haven't done it in ages. By a while I mean it'll probably never be finished, unless the mod's well-received by the SMF community.

Add Blitz and I'm sold!
Give me a definitive list of keywords, data types, operators, special characters, the comment delimiter, preprocessors, built-in functions that would be good to add, etc. and I'll think about it.
Title: Re: Syntax Highlighted [code] Tag
Post by: 4Sword on January 04, 2010, 08:17:51 pm
That seems really kind of awesome, although for it to be used on the forum it'd be even better if it had GML or Game Maker Language syntax. That is not so much advocacy for GML's use but a realistic observation that a lot of what would be posted in code tags here would be written in it. If you're interested the list of function names, I attached the fnames which contains functions, constants (marked with #), read-only variables (marked with *), etc.

Then again though there are probably some parts not included in that file; what comes to mind would be something like "var", "if", "else", "and", "xor", etc. that just get bolded. Otherwise the syntax is pretty similar to something like C++.
Title: Re: Syntax Highlighted [code] Tag
Post by: Mamoruanime on January 04, 2010, 08:41:14 pm
I don't imagine the actual script for the highlighting is difficult to modify though. I think more of what Ken's posting is a tag that pulls from the script here: http://shjs.sourceforge.net/. I imagine that if we installed the mod we could change the script itself :P
Title: Re: Syntax Highlighted [code] Tag
Post by: DJvenom on January 05, 2010, 01:08:33 am
(http://cache4.asset-cache.net/xc/200180355-001.jpg?v=1&c=IWSAsset&k=2&d=91F5CCEF208281FDD4296061B26DB18C278EEF972E8CE4C5B328445F487459D4EC7C5022FB410D56)
NEEEEEERRRRRD!!!!
Title: Re: Syntax Highlighted [code] Tag
Post by: Cassyblanca on January 05, 2010, 04:33:28 am
(http://cache4.asset-cache.net/xc/200180355-001.jpg?v=1&c=IWSAsset&k=2&d=91F5CCEF208281FDD4296061B26DB18C278EEF972E8CE4C5B328445F487459D4EC7C5022FB410D56)
NEEEEEERRRRRD!!!!
D:

I don't imagine the actual script for the highlighting is difficult to modify though. I think more of what Ken's posting is a tag that pulls from the script here: http://shjs.sourceforge.net/. I imagine that if we installed the mod we could change the script itself :P
Nothing is pulled from there - SHJS is included with the mod and is what powers it. The highlighting scripts are a bit more complex than usual syntax highlighters in that I have to define it with a file full of regex operations; in fact, it's exactly the same as creating a language for GNU Source-Highlight. Honestly, though, there is a different syntax highlighter that is simpler to implement new languages for, and was what I originally worked on for this mod. I'm going to jump back to working with that one, however, since I found out how to fix some of the issues I was having, and so I'll update when I have that one working. It looks sexier, too.
Title: Re: Syntax Highlighted [code] Tag
Post by: Cassyblanca on January 05, 2010, 06:34:28 am
Alright, got the new version working with SMF 2 - time to port it to SMF 1.x, and all should be good. This one will be a bit more difficult to bring into ZFGC, though, because I'm sure the template footer has changed a good bit. I'll need to get with Andrew or somebody so that I can make sure it all plays through well with Tim's wonky theme work.

New version can be previewed here: http://www.learn-torque.com/index.php?topic=1

I'll edit this message when I get the preview up on SMF 1.x

SMF 1.1.x port finished, can be seen at http://minalien.com/shtest/index.php?topic=1

Languages already supported:
Bash
C++
C#
CSS
Delphi
Groovy
Java
JavaScript
PHP
Python
Ruby
Scala
SQL
VisualBasic
XML

Working on:
BlitzBasic
GML
TorqueScript
Title: Re: Syntax Highlighted [code] Tag
Post by: benjamin.richter on January 22, 2010, 03:38:20 pm
Any chance I could get your highlighter version for my SMF 2.0RC2 Forum?
Would really like to try it out.
Title: Re: Syntax Highlighted [code] Tag
Post by: Cassyblanca on January 23, 2010, 06:56:45 pm
I suppose so. Give me a couple minutes and I'll upload the mod package to this post.

--Attached to First Post--

NOTICE: I will not be maintaining or doing any further updates to this mod. With the recent drama within SMF, I am going to be stepping toward other forum systems, possibly back to Invision Power Boards, which I particularly like due to its object-oriented source code.

Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved