How to escape square brackets?
07-13-2016, 10:19 AM
Post: #1
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
How to escape square brackets?
I wonder if there is an official way of using square brackets in posts without having them interpreted as formatting tags. While there is no problem writing something like [A] or [C] (since there is no respective command) it seems to be impossible to do so with a B between square brackets because this is interpreted as the tag for bold text.

The only solution I found is using additional "bold" tags around the text:

Code:
Press [b][B][/b] to start

The result then looks like this:

Press [B] to start

But what do you do if you want an "I" in square brackets? OK, you can use the same trick with the tag for italics, but I think there must be a general solution that prevents text in square brackets to be interpreted as formatting tags.

Dieter
07-13-2016, 12:09 PM
Post: #2
 Thomas Radtke Senior Member Posts: 763 Joined: Dec 2013
RE: How to escape square brackets?
[​i]Test[/​i]
07-13-2016, 06:56 PM
Post: #3
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: How to escape square brackets?
(07-13-2016 12:09 PM)Thomas Radtke Wrote:  [​i]Test[/​i]

OK, there seems to be an invisible character between the slash and the i. Which one is it?

Dieter
07-14-2016, 05:43 AM
Post: #4
 Joe Horn Senior Member Posts: 1,721 Joined: Dec 2013
RE: How to escape square brackets?
(07-13-2016 06:56 PM)Dieter Wrote:
(07-13-2016 12:09 PM)Thomas Radtke Wrote:  [​i]Test[/​i]

OK, there seems to be an invisible character between the slash and the i. Which one is it?

Dieter

"Zero-Width Space", hex code 200B.

<0|ɸ|0>
-Joe-
07-14-2016, 12:10 PM
Post: #5
 Thomas Radtke Senior Member Posts: 763 Joined: Dec 2013
RE: How to escape square brackets?
Right, Joe.

But I agree a way to easily escape those markups would be nice.
07-15-2016, 07:54 AM
Post: #6
 EdS2 Senior Member Posts: 301 Joined: Apr 2014
RE: How to escape square brackets?
(07-14-2016 12:10 PM)Thomas Radtke Wrote:  Right, Joe.

But I agree a way to easily escape those markups would be nice.

Try this:
[i[b][/b]]Test[/i]

It should come out like this:
[i]Test[/i]

(Hat tip to Garth Wilson for the idea]
07-15-2016, 08:16 AM
Post: #7
 Thomas Radtke Senior Member Posts: 763 Joined: Dec 2013
RE: How to escape square brackets?
Nice [i]dea :-).

Empty elements are unfortunately not allowed: [i[b/]]
07-15-2016, 08:16 AM
Post: #8
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: How to escape square brackets?
(07-14-2016 05:43 AM)Joe Horn Wrote:  "Zero-Width Space", hex code 200B.

Fine. But how do I enter this? The Windows character map for Arial does not contain 200B, only 200C and 200D.
But these seem to work as well: [‍i]Test[/‍i] [A] [‍B] [C]. Is there an easier way than copying this character from the character map?

(07-15-2016 07:54 AM)EdS2 Wrote:  Try this:
[i[b][/b]]Test[/i]

It should come out like this:
[i]Test[/i]

(Hat tip to Garth Wilson for the idea]

So the idea is to include another formatting tag within the tag.
[A] [B] [C] [I]. Seems to work as well, thank you.

Dieter
07-15-2016, 09:28 AM
Post: #9
 Thomas Radtke Senior Member Posts: 763 Joined: Dec 2013
RE: How to escape square brackets?
(07-15-2016 08:16 AM)Dieter Wrote:  Is there an easier way than copying this character from the character map?
I don't know of any. There should be a way to enter unicode glyphs in a myBB conforming way with no tricks.
07-16-2016, 03:12 PM
Post: #10
 Dave Hicks Super Moderator Posts: 413 Joined: Dec 2013
RE: How to escape square brackets?
You can enter an HTML character code.

ie: zero width space is: &​#8203; (I embedded one inside itself to keep that from disappearing.)

[b]test[&​#8203;/b] produces

[b]test[​/b]
07-16-2016, 03:32 PM
Post: #11
 Dave Hicks Super Moderator Posts: 413 Joined: Dec 2013
RE: How to escape square brackets?
By the way, just typing a [b] shouldn't be a problem. ie

Press [B] to start

a[b] = j[i];

I didn't do anything special on these. Simple code-like references to [b] etc. work simply because I didn't use any closing tags. As long as you don't mix corresponding text formatting into the same post, they'll work without modifications. If you do want to use them along with bold and italic in the same post, then you'll want to sprinkle in the zero width spaces.
07-16-2016, 07:15 PM
Post: #12
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: How to escape square brackets?
(07-16-2016 03:12 PM)Dave Hicks Wrote:  You can enter an HTML character code.
ie: zero width space is: &​#8203;

Ah, that's good to know. Not only for this purpose.

(07-16-2016 03:12 PM)Dave Hicks Wrote:  test[&​#8203;/b] produces

[b]test[​/b]

As you can see here, this works fine... unless some [b]bold text follows. ;-)
Maybe the best idea is including the zero-space character both in [​b] and [/​b].

Dieter
07-16-2016, 07:37 PM
Post: #13
 Thomas Radtke Senior Member Posts: 763 Joined: Dec 2013
RE: How to escape square brackets?
(07-16-2016 03:12 PM)Dave Hicks Wrote:  You can enter an HTML character code.

ie: zero width space is: &​#8203; (I embedded one inside itself to keep that from disappearing.)
That was too easy X). Thanks!
02-13-2021, 10:19 PM
Post: #14
 Ren Junior Member Posts: 49 Joined: Mar 2016
RE: How to escape square brackets?
RE: How to escape square brackets?

Look, even when a left bracket is immediately followed by a right bracket, the two brackets do not touch.
I feel there may be ample space to escape through either the top or bottom opening between the two brackets!

B^)

10B, 10BII, 12C, 15C, 16C, 18C, 19BII, 20b, 22, 29C, 35, 41CV, 48G, 97
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)