MyBB Community Forums

Full Version: [code] inside [code] = breaks
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've noticed that if you have a code inside of a code it will often break off at the first [/code] ending.

Is there a fix for this?

On our site we use staff response templates that have 'code' bits inside of them for members to copy and paste then fill out. For us we stick those in a staff board inside another code tag for safe easy keeping.

Unfortunately it breaks. Would anyone know a fix?

Example:

[code]Coding inside a code
[/code]
code tag inside another code tag is not supposed to work - that is intended.
there can be no easy fix. see also an earlier related topic
I'm having on my mind following: try to create another tag. Like [codes] [/codes] which will be outside of that code tag.
And in MyCode make it act same as code tag
You can try the DVZ Code Tags that adds Markdown syntax with nested code blocks besides parsing the default code tag (nested blocks are arguably more intuitive in Markdown).
[code]coding inside a code[/code]
(2018-02-01, 09:01 AM)Ikerepc Wrote: [ -> ]I'm having on my mind following: try to create another tag. Like [codes] [/codes] which will be outside of that code tag.
And in MyCode make it act same as code tag

Will give that a shot. Thanks for the idea.

(2018-02-01, 09:00 AM).m. Wrote: [ -> ]code tag inside another code tag is not supposed to work - that is intended.
there can be no easy fix. see also an earlier related topic

Follows the idea above, thanks for the suggestion!

(2018-02-01, 01:11 PM)Devilshakerz Wrote: [ -> ]You can try the DVZ Code Tags that adds Markdown syntax with nested code blocks besides parsing the default code tag (nested blocks are arguably more intuitive in Markdown).

Trying to avoid additional plugins, thanks though.

(2018-02-01, 06:39 PM)frostschutz Wrote: [ -> ]
[code]coding inside a code[/code]

Completely has nothing to do with what I've asked. Lol.

I've created a custom MyCode to try and do this like previous threads suggest but it is not working properly. It just spits out the bits in <code> as any other HTML and parses them instead of just giving the code.

Any ideas?

REGULAR EXPRESSION:
\[code2\](.*?)\[/code2\]

REPLACEMENT:
<div class="codeblock"><div class="title"><b>Code:</b></div><div class="body" dir="ltr"><code>$1</code></div></div>
If you don't want content to parse in a tag or it needs to be parsed in a special way, you'll need to use a plugin and hook to parse_message.