Forum code blocks have changed

What are the new rules for code blocks ?

for instance code with empty lines gets divide into sections ?

if (operation == "sort")return Age(createddate);
date_now		= Now();when_created 	= createddate;
mins	= Age(when_created, "n");hours	= Age(when_created, "h");  // buggyhours 	= Abs(mins / 60);days	= Age(when_created, "d");weeks 	= Age(when_created, "w");months 	= Age(when_created, "m");years 	= Age(when_created, "yyyy");

It looks like you entered it like that deliberately?

If you type it as one block empty lines are no problem.

if (operation == "sort")return Age(createddate);

date_now		= Now();when_created 	= createddate;

mins	= Age(when_created, "n");hours	= Age(when_created, "h");  // buggyhours 	= Abs(mins / 60);days	= Age(when_created, "d");weeks 	= Age(when_created, "w");months 	= Age(when_created, "m");years 	= Age(when_created, "yyyy");

It was copied & pasted as one chunk. Then selected and then clicked preformatted text.

Discourse has been updated recently - for instance entering posts is different - no previews anymore and shrinking images is different.

That doesn't happen here, FWIW.

Pasted and selected:

Then if I click Preformatted Text, it's turned into a single code block:

No preview here either on Chrome 140.0.7339.81 (Official Build) (64-bit)

if (operation == "sort")return Age(createddate);

date_now = Now();when_created = createddate;

mins = Age(when_created, "n");hours = Age(when_created, "h"); // buggyhours = Abs(mins / 60);days = Age(when_created, "d");weeks = Age(when_created, "w");months = Age(when_created, "m");years = Age(when_created, "yyyy");

Edit: No preview and code block does not format

Same Chrome version I am using, so it's probably a browser extension breaking things.

I’m using latest Edge build.

Using

[code]

code here

empty line and more code

[/code]

and

code here

empty line and more code

does not appear to work either. As per

image
It was closed recently, I opened it manually.

Ah yes, if that toggle is in "rich edit" mode instead of "Markdown", you won’t get a preview and can’t use markdown, and preformatted text doesn’t work properly.

I have no idea why Discourse even added that option, and would remove it if there was a way. I have no idea why they do a lot of things lately.

That has been there for a few months, FWIW, so it's not a recent change.

I've changed the default to Markdown, which should help at least.

1 Like

That was my issue as well. Thanks for identifying and resolving!

:slight_smile: :+1: