QuakeWiki
August 5, 2019

Forums

Welcome Guest

Pages: 1
Testing Code Posting
OneMadGypsyPostJuly 20, 2018, 02:54
Moderator
Posts: 307
Registered:
November 12, 2017, 00:13
Normal topicTesting Code Posting

I made it possible to post code with a little style. This was a royal pain in the ass to complete. It isn't perfect but it's way better than what we had. To use this, simply paste your code, hilight it and press the code button. If you don't want line numbers remove "linenums" from the class of the tag that appears. You'll understand what I mean after you press code. I just junked up some function from my engine as a test. If you want to give a hint to the language you are trying to post add lang-NAMEOFLANGUAGE to the class. I don't know if the shit works but, if you need a list of the possibilities just use the name of any of the js files here.

ex:
<pre class="prettyprint linenums lang-sql">
//your code
</pre>

public function addPlayerStats(fields:Object, order:Array, go:GraphicObject = null):void
{	statsboard = (go == null)?new flash.display.Sprite():go;
	var c:int = -1;
	var d:Number = 1.00;
	var str:String = "someString";
	for (var i:int = 0; i < order.length; ++i)
	{	++c;
		statsboard.addChild(fields[order[i]]);
		fields[order[i]].x = (c * fields[order[i]].width);
	}
			
	nativeStage.addChild(statsboard);
	statsboard.x = nativeStage.stageWidth - statsboard.width
}

I think it's really weird how google chose to make their parser. I've written MANY parsers and I am 100% positive I could write a very efficient regex parser that can handle most scripting languages all in one shot and do a better job. For instance, look at c:int. int is not a keyword but this parser thinks it is. Their parser is too worried about actual words and not worried enough about syntax possibilities. It's actually looking for words. I'd be looking for symbols and word/symbol combinations. I doubt I would look for a single SPECIFIC word beyond actual keywords (public, private, var, etc) ... and only because those words almost never have a symbol associated with them.

edit: Wow. I knew this syntax hilighter was breaking stuff on my site due to me having to suppress one very encompassing line of css. I thought I fixed it and then I started really looking around and I found NUMEROUS problems. I wasn't about to write css that specifically fixed like 50 different spans individually. I'm still not sure how the fuck I did it cause I feel like my new line should be breaking new things but, it doesn't seem to be.

OneMadGypsyPostJuly 20, 2018, 10:51
Moderator
Posts: 307
Registered:
November 12, 2017, 00:13
Normal topicReply To: Testing Code Posting

No line numbers test. This didn't work but it does now.

public function addPlayerStats(fields:Object, order:Array, go:GraphicObject = null):void
{	statsboard = (go == null)?new flash.display.Sprite():go;
	var c:int = -1;
	var d:Number = 1.00;
	var str:String = "someString";
	for (var i:int = 0; i < order.length; ++i)
	{	++c;
		statsboard.addChild(fields[order[i]]);
		fields[order[i]].x = (c * fields[order[i]].width);
	}
			
	nativeStage.addChild(statsboard);
	statsboard.x = nativeStage.stageWidth - statsboard.width
}
GuestPostJuly 20, 2018, 16:06
Rookie
Posts: 17
Registered:

Normal topicReply To: Testing Code Posting

Whoa, with syntax highlight and all! In my opinion code numbers should be set by default because it really helps (from communication perspective) when trying to figure out some issue in the code.

Where is the code button supposed to be? I don't see it anywhere but I'll try posting some code writing the

 tag myself:


app.listen(g.config.port, function () {
console.log('listening on port '+g.config.port);
})
OneMadGypsyPostJuly 20, 2018, 20:32
Moderator
Posts: 307
Registered:
November 12, 2017, 00:13
Normal topicReply To: Testing Code Posting

@Where is the code button supposed to be?

You must be using the visual editor, use the text one to find the code button. In the upper right above the editor bar for the input field it says visual and text. Click text. The code button is second from the right in the editor bar. IMO the visual editor is shit but it can be useful for people that aren't familiar with bbcode.

@In my opinion code numbers should be set by default

They are.

Pages: 1
Page loaded in: 0.025 seconds.