What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 131 Stack Exchange communities.

I've been looking around a bit for a "verbatim" environment in the SO editor. Does such a thing exist? I see posts like the following reasonably frequently:

This is a hypothetical question. Below is my datafile and code:

this is a hypothetical datafile
it has a few lines

for word in textfile{
    parse(word).according.to.rules()
}

When editing this (hypothetical) post, I would like to split the datafile from the code because they really should be read/understood separately. I could add a line of regular text between the text-file and the code, but at times figuring out what wording to add there is pretty difficult. I'm open to any suggestions.

share|improve this question

2 Answers 2

up vote 4 down vote accepted

You mean you would like to do this?

Here is my datafile and code

this is a datafile
with a few lines of data

foreach(word in datafile)
  speak(word);

You just need to separate the two sections with two blank lines, but have some actual content on that first "blank" line (the second one must be empty, since code doesn't format properly directly after a line break).

In this example, I've used <!--> on the first of the two "blank" lines, and I think that looks best. Using &nbsp; makes the space actually look like two blank lines, and <hr> sticks a horizontal rule across.


Alternately, why not do it more like this? This version is probably a bit neater if the sections are more than just a few lines

Here is my datafile:

this is a datafile
with a few lines of data

Here is my code:

foreach(word in datafile)
  speak(word);

For more information about such things, see Editing Help.

share|improve this answer
    
I would usually do it according to your second version. Occasionally I come across a post where I just can't come up with a good line of text to put in the space between though (because of how the rest of the post is written). –  mgilson Aug 23 '12 at 13:07
    
Do you know if this magical markup language that the SO renderer uses is documented anywhere? If not, maybe that's a feature request in itself... –  mgilson Aug 23 '12 at 13:09
    
Found it! stackoverflow.com/editing-help –  Jim Aug 23 '12 at 13:13

You could try something like this:

<pre>
this is a hypothetical datafile
it has a few lines
</pre>

    for word in textfile{
        parse(word).according.to.rules()
    }

Which renders like this:

this is a hypothetical datafile
it has a few lines
for word in textfile{
    parse(word).according.to.rules()
}

The added benefit is that no syntax highlighting gets applied to your datafile. In your example that could happen since you've "formatted" it as a code block.

share|improve this answer
    
Thanks. I usually add the line of text too. I'm more concerned about cases where I just can't think of anything useful to say between the two blocks. I've seen a number of these magical markup tags in posts before. Is there a document/link anywhere which describes the tags that the SO renderer understands? –  mgilson Aug 23 '12 at 13:05
    
I've been looking for it, but I can't find anything but the occasional mention. If I find something better I'll let you know. –  Bart Aug 23 '12 at 13:08
    
Jim found it (and posted a link) above. :) Thanks! –  mgilson Aug 23 '12 at 13:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .