MyBB Community Forums

Full Version: Named [code] tags break
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone!

A little bit ago I migrated my forums to Mybb from SMF, and I've been working on ironing out all the kinks. One of the things I've noticed is that in SMF you could name a code tag by doing:

 [code=something-or-other] 

Is there any way to re-add that functionality?

Thanks!
What is that code (tag) suppose to do? I suppose you could add a new MyCode to adapt these tags to the default
MyCode, but that depend on what your old tag was about.
Is that supposed to be like a code=language type functionality? I don't get the point of naming it in the tag otherwise.
In JIRA and Confluence, you can give a title to code snippits as well as specifying the language. As a programmer I use this functionality quite a bit. I often give the code block a title of the Java class or Oracle package. These show up as a header for the code block.

Unfortunately, in MyBB the syntax is different; code=whatever gets interpreted as whatever is the language instead of a title.
(2017-07-28, 06:08 PM)laie_techie Wrote: [ -> ]In JIRA and Confluence, you can give a title to code snippits as well as specifying the language. As a programmer I use this functionality quite a bit. I often give the code block a title of the Java class or Oracle package. These show up as a header for the code block.

Unfortunately, in MyBB the syntax is different; code=whatever gets interpreted as whatever is the language instead of a title.

Ahh I see what you're saying, thanks for the clarification. It seems to me though to be more logical if code=language, and if you wanted to name it you'd maybe add another tag like "code=language;name=myspecialclass" or something. I get that obviously SMF doesn't agree with me there but I feel like it's worth a discussion if it's something that could be integrated into core. Honestly named code tags might merit an additional thread in 1.8 suggestions because I think it's a pretty cool idea that's likely useful to a variety of boards.
Is that also related to this?
https://github.com/mybb/mybb/issues/1674

It seems that the development of the sceditor has stopped again.
So maybe better to use that. https://github.com/mybb/mybb/issues/1674...-264169279
Well I finally got around to fixing this. I just added a custom MyCode block:

EDIT: I've updated the regular expression to make sure it doesn't add a newline between the <code> tags and the code itself.

Regular Expression:
\[code\=(.*?)\](?|\n(.*?)\n|\n(.*?)|(.*?)\n|(.*?))\[\/code\]

Replacement:
<div class="codeblock">
<div class="title">$1:</div>
<div class="body" dir="ltr"><code>$2</code></div>
</div>