Post by CampKohler (Sacramento CA) on Apr 8, 2018 7:39:37 GMT -5
Problem: Sometimes you want to give an example of BB code so that the reader can see it. For example:
is seen by the reader as:
Here is how to underline: some text.
What is needed is a way to escape the tags, that is, a way to keep them from executing, and only displaying them. Enter code tags. By placing the code inside code tags, execution of B.B. code is thus prevented:
will be seen by the reader as:
Notice how the underline tags were displayed to the reader, but they did not execute; that is to say, in this case, no underlining took place. This is known as escaping the BB code, and it works for all tags except the code tags themselves. Thus code tags can be said not to work if nested.
Now we move on to HTML entities like the characters em space and em dash (as a tiny sample of the hundreds available). When placed within code tags like this:
[ code]X — Y[ /code]
the entities for X-space-dash-space-Y should look exactly like the text between the code tags, but they don't. The entities are all converted to visible characters even though they are enclosed within code tags:
X — Y
Thus you can't show the reader everything just by using code tags.
To make the entity's markup visible to the reader, you have to write the entity as " ". This deprives the entity of it's working ampersand and prevents the entity from being converted by the browser to a visible character. This is a time-consuming pain, but there is no choice.
In summary, you can use code tags to prevent execution of BB code, but not the display of HTML entities. You must alter each entity to escape them in examples.
Note: In the above examples, the code tags, where visible, have a space inserted within to keep them from executing, because nesting code tags does not work.
Here is how to underline: [u]some text[u].
is seen by the reader as:
Here is how to underline: some text.
What is needed is a way to escape the tags, that is, a way to keep them from executing, and only displaying them. Enter code tags. By placing the code inside code tags, execution of B.B. code is thus prevented:
[ code]Here is how to underline: [u]some text[/u][ /code]
will be seen by the reader as:
Here is how to underline: [u]some text[/u].
Notice how the underline tags were displayed to the reader, but they did not execute; that is to say, in this case, no underlining took place. This is known as escaping the BB code, and it works for all tags except the code tags themselves. Thus code tags can be said not to work if nested.
Now we move on to HTML entities like the characters em space and em dash (as a tiny sample of the hundreds available). When placed within code tags like this:
[ code]X — Y[ /code]
the entities for X-space-dash-space-Y should look exactly like the text between the code tags, but they don't. The entities are all converted to visible characters even though they are enclosed within code tags:
X — Y
Thus you can't show the reader everything just by using code tags.
To make the entity's markup visible to the reader, you have to write the entity as " ". This deprives the entity of it's working ampersand and prevents the entity from being converted by the browser to a visible character. This is a time-consuming pain, but there is no choice.
In summary, you can use code tags to prevent execution of BB code, but not the display of HTML entities. You must alter each entity to escape them in examples.
Note: In the above examples, the code tags, where visible, have a space inserted within to keep them from executing, because nesting code tags does not work.