Geshi on the forum ? Simon ? Mark ?

Monkey Archive Forums/Monkey Discussion/Geshi on the forum ? Simon ? Mark ?

Paul - Taiphoz(Posted 2012) [#1]
Hay peeps.

I am sure I asked this in Max, and at some point probably in B3D as well, and thought I would ask here as well.

For those that don't know, Geshi is a PHP module for creating syntax highlighted code on forums and websites, and I think we should get it for Monkeycoder.

If they implement it, then when you post your normal code, it will get cleaned up and colored accurately , and since I spent the morning updated my geshi install to highlight monkey code I thought I would post about it.

I have a Monkey Profile for Geshi if you need it, and an example of it working can be seen here http://dev.cruel-gaming.com/coding-conventions/ it's easy to install you guys should not have any problems with it.


simonh(Posted 2012) [#2]
Great timing! I was going to look into ading syntax highlighting as one of the next jobs to do. This looks like it would do the job perfectly.

Yes, please send us the Monkey profile, and I'll get it up and running on the site.


Paul - Taiphoz(Posted 2012) [#3]
E-Mail on its way mate.

There is a css section at the bottom where you can change the colors if mine are not suitable.


ziggy(Posted 2012) [#4]
I would this added to the site.
Also a section in the site to see all the avilable bbcodes would be great, with the youtube code and everything.


Paul - Taiphoz(Posted 2012) [#5]
you had a shot at this yet Simon ?


Tibit(Posted 2012) [#6]
Great! Nice initiative.


Aman(Posted 2012) [#7]
+1


simonh(Posted 2012) [#8]
you had a shot at this yet Simon ?

No, will take a look at the weekend.


simonh(Posted 2012) [#9]
OK, we now have syntax highlighted code!

Use bbcode and monkeycode tags.


ziggy(Posted 2012) [#10]
simonh,(as I've said on the blitzbasic forums) the text is too small to be properly readable when the tags are used. Any chance this can be fixed?


Floyd(Posted 2012) [#11]
I tried it out on one of my code snippets.

The code appears on a plain background, not in a colored box as before. It is also in a font which is smaller than the surrounding text.


Raz(Posted 2012) [#12]
Purely to see it running
[monkeycode]Import mojo

' Comments? Comments.

Class TestApp Extends App

Method OnCreate()
UpdateRate(30)
End

Method OnUpdate()

End

Method OnRender()

End

End

Function Main()
New TestApp
End
[/monkeycode]


Paul - Taiphoz(Posted 2012) [#13]
Nice work mate, there is a line number parameter in the gechi congfig's if you wana turn them on, or leave em off, its all good to me.


simonh(Posted 2012) [#14]
Think I'll leave line numbers off as it makes copying and pasting tricker.


therevills(Posted 2012) [#15]
So now we have [ code ], [ codebox ] , [ bbcode ] and [ monkeycode ]:

[ code ]
If x = 1 Then y = 10

[ codebox ]


[ bbcode ]
[bbcode]If x = 1 Then y = 10[/bbcode]
[ bbcodebox ] ' test
[bbcodebox]If x = 1 Then y = 10[/bbcodebox]

[ monkeycode ]
[monkeycode]If x = 1 Then y = 10[/monkeycode]

[ monkeycodebox ] ' test
[monkeycodebox ]If x = 1 Then y = 10[/monkeycodebox]

Thats cool :) But wouldnt it be better just to replace the code for [ code ] to run [ monkeycode ] by default?


Samah(Posted 2012) [#16]
Change [ bbcode ] to something like [ blitzcode ] or similar, so it's not confused with bbcode from other forum software.


Floyd(Posted 2012) [#17]
Here is an example with longer lines of code, clipped from http://monkeycoder.co.nz/Community/posts.php?topic=2632

Notice the "word wrap", as if this were a text document. I don't think code should do that.

[monkeycode]
Method UpdatePosition()

'update position / rotation by velocity
Self.x = Self.x + ( Self.vx * DeltaTimer.delta )
Self.y = Self.y + ( Self.vy * DeltaTimer.delta )
Self.a = Self.a + ( Self.va * DeltaTimer.delta )

'wrap position using size of asteroid to eliminate jumping
If Self.x > DeviceWidth() + Self.radius Then Self.x = Self.x - ( DeviceWidth() + ( Self.radius * 2.0 ))
If Self.y > DeviceHeight() + Self.radius Then Self.y = Self.y - ( DeviceHeight() + ( Self.radius * 2.0 ))
If Self.x < 0 - Self.radius Then Self.x = Self.x + ( DeviceWidth() + ( Self.radius * 2.0 ))
If Self.y < 0 - Self.radius Then Self.y = Self.y + ( DeviceHeight() + ( Self.radius * 2.0 ))

End Method
[/monkeycode]


Paul - Taiphoz(Posted 2012) [#18]
that should be fixable, but it will either explode the forum width to accommodate the extra length, or it will hide the overlap and people will not be able to see some of the code.

The other option is to embed the code in an iframe, and allow it 100% width, then setting the iframe to allow scroll bars.

all in all its fixable, but not a big issue.


matt(Posted 2012) [#19]
You don't have to use an iframe for that. Just set the code container to have white-space:nowrap and overflow:scroll. Two lines of CSS.


Shinkiro1(Posted 2012) [#20]
@Taiphoz
Could you share the monkey file for geshi, I would like to use it on my blog.


Paul - Taiphoz(Posted 2012) [#21]
more than happy to help out, and yeah its really nice when you show code on your own blog to have it look nice.

http://dev.cruel-gaming.com/2012/05/24/geshi-monkey/


Paul - Taiphoz(Posted 2012) [#22]
Currently trying to find my blitz max file but cant :( gona have to make it again..


Shinkiro1(Posted 2012) [#23]
Thank you.


Tibit(Posted 2012) [#24]
Great addition, but why are the old [code] and [codebox] tags not changed?

I vote for that :)