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
stevebaer
(Steve Baer)
May 24, 2013, 9:56pm
2
Oh!!! oneboxing sounds like a great way to embed code
(http://meta.discourse.org/t/what-is-a-onebox/4546 )
Here are some sameple gists from github
gistfile1.py
from itertools import *
def tonumberlist(s):
rc = []
def shouldtake(x):
return str.isdigit(x) or x=='.'
i = iter(s.replace(' ',''))
while True:
try:
rc.append(float(''.join(takewhile(shouldtake, i))))
This file has been truncated. show original
gistfile1.cs
public class TestDynamicCommandPlugIn : Rhino.PlugIns.PlugIn
{
// Override CreateCommands to generate your own commands on the fly
protected override void CreateCommands()
{
base.CreateCommands();
// uncomment the following to get your "private" command to work
//var cmd = new TestSecretCommand();
//Rhino.Runtime.HostUtils.RegisterDynamicCommand(this, cmd);
}
This file has been truncated. show original
stevebaer
(Steve Baer)
June 7, 2013, 6:26am
3
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
http://meta.discourse.org/t/syntax-highlighting-of-code-blocks/7242
nates
June 12, 2013, 12:33am
4
It would be cool to see syntax highlight for Python & Rhinoscript some day.
stevebaer
(Steve Baer)
June 12, 2013, 1:24am
5
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
https://help.github.com/articles/github-flavored-markdown#syntax-highlighting
1 Like
Just a test:
Python
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
VBscript
Option Explicit
Sub ColorToObject()
Dim arrAllObjs,intObjColor,i
arrAllObjs=Rhino.NormalObjects
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)
Next
Call Rhino.EnableRedraw(True)
End Sub
Call ColorToObject()
Same comment as for python - but nice and readable, that’s the important thing.
–Mitch
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…
stevebaer
(Steve Baer)
June 14, 2013, 10:09pm
7
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
tobias
June 18, 2013, 9:07pm
9
@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
stevebaer
(Steve Baer)
June 18, 2013, 9:18pm
10
Markdown format that looks like
```python
def printhi():
print "hi"
```
Looks like
def printhi():
print "hi"
Use the term vb instead of python if you want to display rhinoscript