Change for Syntax Highlighter

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 1871 Views - Last Post: 30 May 2012 - 06:24 AM

Poll: Change for Syntax Highlighter (2 member(s) have cast votes)

Should the Code input get a change

  1. Yes (2 votes [100.00%])

    Percentage of vote: 100.00%

  2. No (0 votes [0.00%])

    Percentage of vote: 0.00%

Vote Guests cannot vote

#1 DanielLeone  Icon User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 177
  • Joined: 04-February 12

Change for Syntax Highlighter

Posted 26 May 2012 - 02:55 AM

Hello there,

There have been countless times during DIC that I need to copy and paste a bunch of code (not that I'm a copy/paster, but there is a time and a place). This has been immensely difficult, due to the fact that numbers and lines are included, and you have to go and edit EVERY SINGLE LINE. It becomes frustrating, and nearly easier to manually type it.

Also, when the code formats on the website, it is nearly unreadable. All the text stays one colour, comments are seen as code, and only some random words change colour, sorry not all text. It becomes even further unreadable, because you can't expand the textbox, so when lines return, it looks messy, and becomes very confusing to look at.

I know this site supports many languages, all with different syntax, but surely they could do a better job that what we currently have. I mean, we have a Web Development forum, with a bunch of experienced coders, surely they could do something better.

I don't mean to sound selfish, or arrogant, but it has really annoyed me over the past few months, and I feel that they could do something better.

Thanks in advance,
Daniel,

This post has been edited by DanielLeone: 26 May 2012 - 04:39 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Change for Syntax Highlighter

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2263
  • View blog
  • Posts: 9,467
  • Joined: 29-May 08

Re: Change for Syntax Highlighter

Posted 26 May 2012 - 04:22 AM

Quote

Also, when the code formats on the website, it is nearly unreadable. All the text stays one colour, comments are seen as code, and only some random words change colour, sorry not all text. It becomes even further unreadable, because you can't expand the textbox, so when lines return, it looks messy, and becomes very confusing to look at.


Firstly the reply box can be made bigger or smaller (look at the icons in top right).
Could you supply links / screenshots of examples please?

Dream In Code uses Alex Gorbatchev's Syntax Highlighter.
There where issues with the latest release, that made the forums worse. It does provide a mechanism to get the code with line numbers.

Good Highlighting code is hard, in particular for vb.net. You to remember the language (since VS2008) it has embedded support for xml, which obey different grammar and syntax rules. So just highlighting keywords doesn't cut it. For it to be most excellent the highlighter needs parse to code. (Roll on Project Roslyn)
In the Moderator's Forum is a thread which contains code examples to test (or screw with) the syntax highlighter.

Note in most of programming sub-forums the code highlighing used in the code tags is specific to the language used in it. On which, I think there should also be a way to override it and specify what language to use. Also useful would be way to specify which lines to highlight, because inside the code tags the other tags don't work.

Personally I think DIC should have MathJax support so we can have [ Math ][ /Math ] to render and format mathematical formulas.
Was This Post Helpful? 0
  • +
  • -

#3 DanielLeone  Icon User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 177
  • Joined: 04-February 12

Re: Change for Syntax Highlighter

Posted 26 May 2012 - 04:34 AM

Thanks for the reply AdamSpeight2008,

Ohh, never saw the view source button before (sorry).

// IXmlSerializable says you're handling the job
public class GameMap : IXmlSerializable {
	public List<char> GroundTiles { get; private set; }
	public Dictionary<char, string> Dict { get; private set; }
	public GameMap() {
		GroundTiles = new List<char>();
		Dict = new Dictionary<char,string>();
	}

	// methods needed for interface
	
	// we can ignore this one, but we must implement it
	public System.Xml.Schema.XmlSchema GetSchema() { return null; }


	// how do we want to write it?
	public void WriteXml(System.Xml.XmlWriter writer) {
		// here's the silly comma separated thing
		writer.WriteElementString("GroundTiles", string.Join(",", (from ch in GroundTiles select "" + ch).ToArray()));
		// and we'll just throw the keys in
		foreach(char key in Dict.Keys) {
			writer.WriteStartElement("TileDef");
			writer.WriteAttributeString("key", "" + key);
			writer.WriteAttributeString("desc", Dict[key]);
			writer.WriteEndElement();
		}
	}
	
	// reading back is more of a challenge
	public void ReadXml(System.Xml.XmlReader reader) {
		this.GroundTiles.Clear();
		this.Dict.Clear();
		// easier if we use an XmlDocument 
		XmlDocument doc = new XmlDocument();
		doc.Load(reader);
		// the joy of commas... this will work
		this.GroundTiles.AddRange(
			from s in doc.GetElementsByTagName("GroundTiles")[0].InnerText.Split(',')
			where s.Trim().Length > 0
			select s.Trim()[0]
		);
		
		// because TileDef are proper XML data, 
		// we don't really have to do much work here
		foreach (XmlElement ele in doc.GetElementsByTagName("TileDef")) {
			Dict.Add(ele.GetAttribute("key")[0], ele.GetAttribute("desc"));
		}
	}



Although looking better when clicking view source, looking at it straight in the browser makes it hard to summarise and get the gist of what it's doing, for me anyway.

You seem to forget how useful the colouring system is an IDE, because I mean when you look at this, it ain't pretty is it?

And you say that it uses Alex Gorbatchev SyntaxHighlighter, well how come it doesn't look like the example on the website? The demo is coloured properly, for some languages anyway, and you can highlight with or without the numbers easily. DIC doesn't seem to have that functionality.

http://alexgorbatche...er/manual/demo/

Do you see what I mean, and agree with me in general about the syntax highlighter?

Thanks,
Daniel,

This post has been edited by DanielLeone: 26 May 2012 - 04:39 AM

Was This Post Helpful? 0
  • +
  • -

#4 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2263
  • View blog
  • Posts: 9,467
  • Joined: 29-May 08

Re: Change for Syntax Highlighter

Posted 26 May 2012 - 05:02 AM

That site is using version 3.0.83, DIC is using version 2.1.382.
Was This Post Helpful? 0
  • +
  • -

#5 DanielLeone  Icon User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 177
  • Joined: 04-February 12

Re: Change for Syntax Highlighter

Posted 26 May 2012 - 05:12 AM

So why isn't it being updated? It's not like it costs anything. It is totally free!

And the version you said DIC is using is 6 versions out of date. 6!

And you still haven't said weather you agree or not ;).

If your're a forum leader and moderator, can't you request an update to an admin or something. This would probably be a simple change, with massive improvements.

Thanks,
Daniel,

This post has been edited by DanielLeone: 26 May 2012 - 05:13 AM

Was This Post Helpful? 0
  • +
  • -

#6 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,990
  • Joined: 08-June 10

Re: Change for Syntax Highlighter

Posted 26 May 2012 - 06:06 AM

View PostDanielLeone, on 26 May 2012 - 12:12 PM, said:

You seem to forget how useful the colouring system is an IDE, because I mean when you look at this, it ain't pretty is it?

And you say that it uses Alex Gorbatchev SyntaxHighlighter, well how come it doesn't look like the example on the website? The demo is coloured properly, for some languages anyway, and you can highlight with or without the numbers easily. DIC doesn't seem to have that functionality.

Like AdamSpeight2008 pointed out earlier, DIC uses different types of highlighting on different forums. In forums like this one, it uses a very generic one, which doesn't highlight C# code very accurately. I'ts more like a shell script highlighter. - If you post the example you posted here in the C# forum, it would look a lot better.

There is no one single type of highlighter that can accurately highlight all the languages used on DIC.

View PostDanielLeone, on 26 May 2012 - 12:12 PM, said:

This would probably be a simple change, with massive improvements.

Unfortunately changes like these are never simple. There is a lot of testing that needs to be done, to make sure all the browsers support it, before it can be released.

View PostDanielLeone, on 26 May 2012 - 12:12 PM, said:

So why isn't it being updated? It's not like it costs anything. It is totally free!

Just because the code is free doesn't mean it costs nothing to use. Making the change on the site takes time, and like they say: time is money :)


I don't necessarily disagree that the code highlighter could be improved, but I don't really see a problem with the current system. One thing I think would make a great difference, though, is if there was a way to specify which language to use.
Was This Post Helpful? 0
  • +
  • -

#7 DanielLeone  Icon User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 177
  • Joined: 04-February 12

Re: Change for Syntax Highlighter

Posted 26 May 2012 - 08:03 AM

Okay I agree with what you said there Atli,

So why don't they change it though?

What is the point in saying time is money? Okay, lets leave this, move on, and just deal with it. But where is the justifications in that? Why do we bother doing anything, why would Alex Gorbatchev bother updating the software multiple times, release it for free, and then expect sites to update their version.

To say time is money, is like to say, I'm not going to learn any more programming, because I can do most things with what I know, but it won't be as neat or efficient.

I don't like being mean, or discouraging, but why can't it be updated. What else is this site trying to achieve. I'll accept being wrong, if someone can give a justifiable answer, like all the admins can't be stuffed (not that that's justifiable ;)), but if there is some reason that the site can't be updated, please let me know.

But you say there has to be a lot of testing, well as I said, there has been 6 updates, surely they can just replace the files or something. Note, I have no experience in web development, so just say I'm wrong and leave it at that.

And you even had the suggestion of selecting a language. Why not implement it?

Like in the code tags do something like this :

[code language="C#"][/code]

Or similar?

Sorry to say, but your wrong about it looking different in the C# forum, it looks exactly the same.


I also found this thread (thanks to the handy Related Topics (beta)), something the site is achieving ;).

http://www.dreaminco...ax-highlighter/

It is exactly the same as what I've asked.

It seemed like it was going somewhere, and then it just ended. Why. This was a good topic, and skyhawk133 said he was going to test it, and never replied. It was a great idea about giving it to the Java Script community, but it never happened.

The current version of SyntaxHighlighter, supports 22 (I think) languages, surely that would be sufficient for this site. Any language that isn't supported, couldn't it just use one similar?


I mean, honestly, when you look at the example above, and then the example here: http://alexgorbatche...hes/csharp.html

There have been Dramatic changes. Like, completely fundamental. Surely there have been enough bug fixes by now to implement the newer version?

Don't get me wrong, this site has achieved some wonderful things, but I believe it should be focused on more functionality than aesthetics. You can see the community work that has gone into it, and how far the site has come. These is a great reward, reputation, and satisfaction system; Personal calendars and even blogs, the whole site looks aesthetically amazing!

But when you take a step back, you see some wonderful features, and a syntax highlighter out dated by a number of years. There really needs to be some logical thinking going on. After all, this a programming website, fundamentally designed for the benefit of aspiring coders. The first function, that should be of up most importance, should be the Syntax Highlighter, and in my opinion, it just isn't up to scratch, considering the available possibilities.

Thanks for reading my rant anyway,
Daniel,

This post has been edited by DanielLeone: 26 May 2012 - 08:33 AM

Was This Post Helpful? 0
  • +
  • -

#8 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,990
  • Joined: 08-June 10

Re: Change for Syntax Highlighter

Posted 26 May 2012 - 09:11 AM

View PostDanielLeone, on 26 May 2012 - 03:03 PM, said:

What is the point in saying time is money?

I only meant that the webmaster, skyhawk133, only has so much time, and on a site like this there is no doubt an endless list of maintenance, fixes and improvements that he's working on. Updating a system that actually does work (mostly) is probably not at the top of the priority list.

Of course, it's always good to hear suggestions like this. Who knows, it might just nudge the issue a bit higher on that list :)

I'd actually like to see this change as well, but there are other things I'd rather see implemented first. (Like the ability to arrange the subscribed threads list by most recent post. (**cough**))

View PostDanielLeone, on 26 May 2012 - 03:03 PM, said:

Sorry to say, but your wrong about it looking different in the C# forum, it looks exactly the same.

Are you sure about that? From where I'm sitting, they are completely different. This is how they look for, me with the C# forum on the left and the post above on the right.

Attached Image
Was This Post Helpful? 0
  • +
  • -

#9 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2872
  • View blog
  • Posts: 11,031
  • Joined: 15-July 08

Re: Change for Syntax Highlighter

Posted 26 May 2012 - 10:07 AM

The reason we haven't updated yet is because the newest version does not work with IE. The old one does, and though it's flash based, and older, it is better for us, because it works on more than one platform and browser.
Was This Post Helpful? 0
  • +
  • -

#10 DanielLeone  Icon User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 177
  • Joined: 04-February 12

Re: Change for Syntax Highlighter

Posted 26 May 2012 - 05:44 PM

Doesn't work on IE.

Ummm...

Who the hell cares, more a reason to get it ;).
Was This Post Helpful? 0
  • +
  • -

#11 DanielLeone  Icon User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 177
  • Joined: 04-February 12

Re: Change for Syntax Highlighter

Posted 26 May 2012 - 05:52 PM

Sorry can't edit and post image?

I'm thinking that maybe the current version 2.1 or something doesn't work well with Chrome, because this is my version of the code. (Proven by the fact that if you look at the right, you can see the top reputation earners).

Attached Image

Don't know what's happening there, because the version you showed me is a hell of a lot better.

Thanks,
Daniel,


Edit : May have figured it out. It's not the C# forum, it's the XNA forum. It's just that XNA primarily uses C#.

If that is the case, surely it would be easy to change the code language in the XNA forum. The only other language I've seen in that forum is VB. But as you said, you can't really get a syntax highlighter for that. So can we change the XNA forum to use C# syntax highlighter?

Thanks again,
Daniel,

This post has been edited by DanielLeone: 26 May 2012 - 07:14 PM

Was This Post Helpful? 0
  • +
  • -

#12 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,990
  • Joined: 08-June 10

Re: Change for Syntax Highlighter

Posted 26 May 2012 - 07:58 PM

View PostDanielLeone, on 27 May 2012 - 12:52 AM, said:

Edit : May have figured it out. It's not the C# forum, it's the XNA forum. It's just that XNA primarily uses C#.

If that is the case, surely it would be easy to change the code language in the XNA forum. The only other language I've seen in that forum is VB. But as you said, you can't really get a syntax highlighter for that. So can we change the XNA forum to use C# syntax highlighter?

I'll try to find out if that's possible.

In the meantime, I put together a simple userscript that should work for you. (Does here on Chrome and Firefox, at least.)

... Yea, I was bored. :P
Was This Post Helpful? 1
  • +
  • -

#13 DanielLeone  Icon User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 177
  • Joined: 04-February 12

Re: Change for Syntax Highlighter

Posted 26 May 2012 - 09:57 PM

Wow, thanks for that Alti, works a treat.

How can I tell if it's using the C# syxtax highlighter, or the userscript you gave me though?

Anyway, the code looks a LOT better.

Thanks once again,
Daniel,
Was This Post Helpful? 0
  • +
  • -

#14 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,990
  • Joined: 08-June 10

Re: Change for Syntax Highlighter

Posted 26 May 2012 - 10:03 PM

View PostDanielLeone, on 27 May 2012 - 04:57 AM, said:

How can I tell if it's using the C# syxtax highlighter, or the userscript you gave me though?

Go to the "Tools > Extensions" menu in Chrome. The userscript should be listed there if it's installed properly.
Was This Post Helpful? 0
  • +
  • -

#15 DanielLeone  Icon User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 177
  • Joined: 04-February 12

Re: Change for Syntax Highlighter

Posted 27 May 2012 - 02:46 AM

Yeah I know that part, but when will I know that I don't need it any more. Like if you actually change the XNA forum to C# syntax?

And another thing, what does the user script actually do? I've installed it, and it could be anything ;).

Thanks,
Daniel,
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2