Anybody else noticed an influx of code formatted as individual lines?

As the topic title says. I nowadays keep encountering code posted as individual lines. It's not a single instance.

E.g.

This started after the WYSIWIG composer was introduced; coincidence?

Hi @sterretje. The problem occurs through the following sequence when using the post composer in the the "rich text editor" (WYSIWYG) mode:

  1. Add non-prose content.
  2. Select the content.
  3. Click the "<CODE/>" icon on the composer toolbar.

I submitted a bug report to Discourse about this problem:

The workaround for the bug is to change the order of operations:

  1. Click the "<CODE/>" icon on the composer toolbar.
  2. Add non-prose content.

This is the order I have always suggested in the instructions I provide for posting non-prose content, because it is more simple and probably less prone to user error. However, I can see why new users would follow the other procedure while operating autonomously since, if they think of formatting at all, it is likely to be an afterthought rather than something they prepare proactively.

Due to this, as well as some other problems I noticed while I was investigating it, I have changed Arduino Forum's default composer mode from the "rich text editor" to the "Markdown editor. Hopefully that will reduce the occurrences of this problem going forward. The change to the default only affects new accounts, so for existing accounts the forum will continue to use whichever editor mode the user selected last.

5 Likes

Thanks for raising that bug, @pert

Many thanks for this

Is this sentiment only in relation to the problem @sterretje described here? Or do you have other reasons for preferring that "Markdown editor" be the default mode?

I ask because I am interested in the forum community's thoughts on this subject in general, in the context of a "rich text editor" mode that works as intended.

My current plan is to change the default mode back to "rich text editor" once Discourse fixes the bugs that currently result in an increased likelihood of poorly formatted non-prose content in posts. I explained my reasoning for using it as a default in the previous discussion related to the "rich text editor" mode:

I answered that question in the linked topic Why did the Forum functions change? - #6 by sterretje

Till now the score seems two in favour of markdown and nobody in favour of wysiwyg.

I don't think you did. This is a question of which mode should be selected by default for new users.

My interpretation of what you wrote is that you were stating which mode you prefer to use personally. That isn't really relevant because everyone is free to select whichever mode they prefer.

Besides the problems with inserting code, I don't like that wysiwyg hides from me the possibility of fine-tuning the design of the message.

Nobody know how the bugs will be fixed, often the fixes are not what users expected :slight_smile:
So we'll see.

Is it possible to make the default mode configurable for each user in the forum settings?

It isn't that deep. If the editor is changed to put a multi-line selection into a single code block, the bug is fixed. If it continues to do something different than that, then the bug is not fixed from my perspective and thus the default would not be changed back (and in fact I would likely seek to remove the "rich text editor" mode entirely).

There is no need for a setting. The forum remembers which mode you selected. So you only need to move the switch to the mode you prefer and then the composer will automatically be in that mode every time you write a post.

Again, this is only about the new user experience.

Indeed; but it (kind-of) implies that I also would prefer the markdown based composer as a newbie (if I knew that there is a choice).

When you say "as a newbie", do you mean only being new to the forum, but otherwise with all your current technical competence and diligence?

Or do you mean the average new forum user, who doesn't have any existing knowledge of Markdown or why it is important to correctly format their post, is not motivated to take the effort to gain that knowledge, and is already overwhelmed by the complexity of their Arduino projects?

That one. As I see it one needs to have some interest in Arduino stuff to start with Arduino (does not matter if it's hardware or software) and one needs to be prepared to learn. The markdown composer allows me to learn something by showing me the markdown (and the result in the preview). It might not be directly Arduino related but as a newbie with a technical interest I would definitely find it interesting.

1 Like

I t amuses me what the advice shown is when the WYSIWYG editing window is opened

It isn't wrong. You can use Markdown to format your post when using the "rich text editor".

However, in our use case where we are hoping this composer mode will serve as a more friendly option for new users, I don't think it is beneficial to mention the complex subject of Markdown support in this message.

I never said that it was wrong, just amusing, and as the message disappears as soon as you type anything it hardly matters anyway

As I have said in another topic, I don't expect many users will do anything beyond using the formatting icons in the toolbar associated with both editor options and most won't even bother with them

I have removed the mention of Markdown from the "rich text editor"'s placeholder message.

It is still there in both if you start in the Markdown editor and switch to the WYSIWYG editor. If you start in the WYSIWYG editor your new message is displayed and if you switch to Markdown you see the new message in the Markdown editor

I suspect that most users never change from one to the other or even know that there are two options available so I would leave it as it is

It is expected that it will be present in the Markdown editor. There is a dedicated "placeholder" message for each editor mode. I left the placeholder text for the Markdown editor mode unchanged because the mention of Markdown support in that message is more likely to be beneficial.

I also noticed that. This is a bug/deficiency in the Discourse framework, where the message doesn't change when you switch modes. That is actually the Markdown editor mode's placeholder text still being shown.

I agree that it is not likely to be significantly impactful.

The Discourse developers might be interested to know about it, but I don't know that I will be able to find the time to submit a bug report to them about it.

I submitted a bug report for one of the other problems I mentioned:

I suspect this bug caused the misformatted content you see here:

(note that all the compilation output is on a single line instead of having line breaks, as it did in Arduino IDE's Output panel)

Despite quite some trying, I wasn't actually able to find a way to reproduce the problem using content copied from Arduino IDE. However, I am able to reproduce it using the output from Arduino Cloud Editor's "Copy Console Output" icon, so that alone makes the bug significant to Arduino Forum.


The third problem I encountered is somewhat similar, but in the opposite direction: the "rich text editor" mode adds extra newlines to code copied from a selection in the Arduino IDE 2.x editor. For example, if you do a standard copy (not using Edit > Copy for Forum (Markdown)) this code from the IDE:

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

After pasting it into the post composer, it looks like this:

void setup() {

  // put your setup code here, to run once:



}



void loop() {

  // put your main code here, to run repeatedly:



}

All three of these problems do not occur when pasting into a code block. Likewise, they do not occur when using the Edit > Copy for Forum (Markdown) feature, since that automatically creates a code block. So they are specific to the use cases where the user either applies the code block formatting retroactively, or not at all.