It's not important, but I wish there were a way to control the line numbers when posting code. As it is, I've never seen code that doesn't start at line 1 and count up from there, but that's not always ideal. Sometimes there is boilerplate at the top of a file that people don't need to see, and sometimes someone wants to suggest a modification to something someone else has posted. Either way it would be helpful if the line numbers could be made to match the original code even though only a part of it is being posted. It would at least be more elegant that way.

Often compiler error messages will include line numbers and that forces people to either post entire source code files to make the line numbers match, or else put the real line numbers in comments, or edit the error message to make the line number in the message match the line number in the post.

I have no idea how difficult this feature would be to add, but perhaps instead of a blank line before some code there could optionally be a notation that would change the number of the first line.

Recommended Answers

All 4 Replies

I like that idea, have thought the same thing myself on occasion. But on the otherhand people would probably not use that feature, it's nearly impossible to get them to put code in code tags let alone think of matching up line numbers with error messages.

I agree with AD here. Plus, since Markdown (the markup format used by this site) doesn't support any of this natively, we'll have to hack up the Markdown specification to our custom needs. Doable, but not really favored since the target audience percentage is very small plus it requires maintaining a Daniweb flavored Markdown format. A custom markdown format isn't bad per se (SO and Github use it); it's just that a lot of thinking has to go in to adopt something like that for Daniweb.

As an additional motivation, once you add a way to modify how code is displayed, you could keep going and make it possible to specify the language of the code so that Lisp and Scheme could have syntax highlighting that looks less terrible. I imagine some sort of simple header before the code could do both.

On that line, the Code link could become a menu that indicates the language(s) supported. But I don't know if that's even feasible or possible.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.