davestead's avatar

Not seeing how to do simple code blocks in markdown here

I noticed I could do a simple code block (with GitHub-type markdown) like this:

$var = 'whatever';

But if I wanted to do two or more lines, that would strip the newlines out, putting them all onto one line like this:

$var2 = 'whatever2'; $var3 = 'whatever3';

If I separate each line with two newlines, it doesn't strip out the newlines:

$var2 = 'whatever2';

$var3 = 'whatever3';

If I put them inside a block wrapped in three ticks, it separated the lines but made this giant colorful block that's a bit much for small chunks:

$var = 'whatever';
$var2 = 'whatever2';
$var3 = 'whatever3';

I'm not seeing how to just show the simple inline code formatting with just a few lines that doesn't show too few or too many newlines! Is this possible?!

0 likes
6 replies
jlrdw's avatar

At bottom of reply block:

Use Markdown with GitHub-flavored code blocks. (link)

If I put them inside a block wrapped in three ticks, it separated the lines but made this giant colorful block that's a bit much for small chunks:

That's how it's done.

1 like
Snapey's avatar

(but not the first line)

//lines of code also highlighted if indented by 4 spaces
davestead's avatar

@JLRDW - My original post is talking about the GitHub-flavored code... please re-read what I wrote as raw text:

https://imgur.com/HFHsbG2

I simply want to be able to do

line 1

line2

line3

in this type of simple code line separated by 1 newline not 0 or 2.

jlrdw's avatar

Between the back ticks just hit enter.

line1
line2
Snapey's avatar

@jlrdw he wants it without it being a code block (black background)

1 like
davestead's avatar

@JLRDW - That's the code block I was saying I was trying to avoid in code that's just a handful of lines (5 or less).

I think the issue I'm describing of each single-newline being removed is typical of GitHub-style markdown, so I'll just assume it's intended behavior... though I don't see why it's necessary, and it's definitely counter-intuitive.

Please or to participate in this conversation.