Does discourse support code blocks?

Let’s see how code blocks look in discourse.

import rhinoscriptsyntax as rs
def TestSyntax( a ):
    """This is a document comment about the TestSyntax function"""
    for i in range(10):
        print i, a

Ok, no syntax highlight (yet), but at least things line up how a programmer would expect

Oh!!! oneboxing sounds like a great way to embed code

Here are some sameple gists from github

Looks like the github style code syntax works

import rhinoscriptsyntax as rs

def TestSyntax(a):
    """This is a document comment about the TestSyntax function"""
    for i in range(10):
        print i, a

It would be cool to see syntax highlight for Python & Rhinoscript some day. :smiley:

This is already supported using github wiki syntax for code block. Use the term vb for RhinoScript blocks

See the syntax highlighting section to see an example of writing a ruby code block

1 Like

Just a test:


import rhinoscriptsyntax as rs
def SelSomeCrvs():
    crvs=rs.GetObjects("Select curves",4,preselect=True,select=False)
    if not crvs: return

OK, not bad, doesn’t match the python forum’s coding nor the script editor, but very readable


Option Explicit
Sub ColorToObject()	
	Dim arrAllObjs,intObjColor,i	
	If Not IsArray(arrAllObjs) Then	Exit Sub
	Call Rhino.EnableRedraw(False)
	For i=0 To UBound(arrAllObjs)  
		intObjColor = Rhino.ObjectColor(arrAllObjs(i))
		Call Rhino.ObjectColor(arrAllObjs(i),intObjColor)	
	Call Rhino.EnableRedraw(True)	
End Sub

Call ColorToObject()

Same comment as for python - but nice and readable, that’s the important thing.

Edit: hmm, that’s odd, in the preview box I see color, but when I post, it disappears…?
Ahhh, and now it’s back… bizarre.
Oh, wait… No code box…

I definitely know that we can tweak these colors with CSS modifications. I already did something very similar when setting up the wiki

OK, thanks Steve, looking forward to it… --Mitch

@stevebaer how do I get such a colored code-box like in your post?
I can’t find a way how to do this

thx, Tobias

Markdown format that looks like

def printhi():
    print "hi"

Looks like

def printhi():
    print "hi"

Use the term vb instead of python if you want to display rhinoscript

Thanks Steve