Multi code tags, issue or I did it wrong?

Seems that multi code tags in a post does not work very well:

Here is the example of 'it' not working

[hr]
Here is the code I use for the mqtt call back


void IRAM_ATTR mqttCallback(char* topic, byte * payload, unsigned int length)
{
  memset( x_message.payload, '\0', payloadSize ); // clear payload char buffer
  x_message.topic = ""; //clear topic string buffer
  x_message.topic = topic; //store new topic
  int i = 0; // extract payload
  for ( i; i < length; i++)
  {
    x_message.payload[i] = ((char)payload[i]);
  }
  x_message.payload[i] = '\0';
  xQueueOverwrite( xQ_Message, (void *) &x_message );// send data to queue
}

Full code

memset( x_message.payload, '\0', payloadSize ); // clear payload char buffer x_message.topic = ""; //clear topic string buffer

Clears the last info received in the callback.

[code]x_message.topic = topic; //store new topic

int i = 0; // extract payload
for ( i; i < length; i++)
{
x_message.payload[i] = ((char)payload[i]);
}
x_message.payload[i] = '\0';
[/code]

Extracts the payload and topic.

  xQueueOverwrite( xQ_Message, (void *) &x_message );// send data to queue

Notifies/send the parser the new received message.

It's not about multiple code tags. The cause is the combination of putting the code tag on the same line as the code as well as having blank lines in the block.

This BBCode:

[code]foo

bar[/code]

Renders like this:

[code]foo

bar[/code]

But this BBCode:

[code]
foo

bar
[/code]

renders as expected

foo

bar

My advice is that, rather than having to find out how to deal with the differences in the handling of BBCode between the old SMF forum framework and the new Discourse framework, to abandon BBCode altogether and use the Markdown markup language instead. Markdown is increasingly becoming the universal standard, so if you take the time to learn it, you will end up finding that knowledge is useful many places, not only on forums.
https://www.markdownguide.org/extended-syntax/#fenced-code-blocks

```
x_message.topic = topic; //store new topic

int i = 0; // extract payload
for ( i; i < length; i++)
{
x_message.payload[i] = ((char)payload[i]);
}
x_message.payload[i] = ‘\0’;
```
1 Like

@pert, thank you for the info.

You're welcome.

Just checking if multiple quotes work; note that I used the quote option when selecting text. hence [quote] and [/quote]

Thanks @pert , got that page bookmarked.
Tom... :grinning: :+1: :coffee: :australia:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.