@@ -37,6 +37,8 @@ export default class Parser {
3737 let buildingAttributeName = false ;
3838 // Represents whether we're building the opening or closing tag.
3939 let buildingClosingTag = false ;
40+ // Represents whether we're building a code tag. Ignore bbcode inside the code tag.
41+ let buildingCode = false ;
4042 // Represents whether we're in a quote. In that case, ignore all spaces.
4143 let quoted = false ;
4244 // Represents the name of the current tag we're building.
@@ -91,7 +93,7 @@ export default class Parser {
9193 } else if ( ( [ "]" , " " , "=" ] . includes ( nextCharacter ) ) ) {
9294 // We found a character that signifies the end of the tag name.
9395 // First, we determine if it is a valid tag name.
94- if ( this . supportedTagNames . includes ( this . caseSensitive ? currentTagName : currentTagName . toLowerCase ( ) ) ) {
96+ if ( this . supportedTagNames . includes ( this . caseSensitive ? currentTagName : currentTagName . toLowerCase ( ) ) && ( ! buildingCode || currentTagName === "code" ) ) {
9597 // The tag name is valid.
9698 if ( nextCharacter === "]" ) {
9799 if ( currentTagName === "*" ) {
@@ -127,6 +129,9 @@ export default class Parser {
127129 currentStack . push ( currentTag ) ;
128130 buildingTagName = false ;
129131 buildingText = true ;
132+ if ( currentTagName . toLowerCase ( ) === "code" ) {
133+ buildingCode = true ;
134+ }
130135 currentTagName = "" ;
131136 }
132137 } else if ( nextCharacter === "=" ) {
@@ -143,7 +148,7 @@ export default class Parser {
143148 // We treat it as text.
144149 buildingText = true ;
145150 buildingTagName = false ;
146- currentText += "[" + currentTagName ;
151+ currentText += ( buildingClosingTag ? "[/" : "[" ) + currentTagName + nextCharacter ;
147152 }
148153 } else {
149154 // We're still building the tag's name.
0 commit comments