]*>)([\s\S]*?)(<\/PRE>)/gi ; } FCKCodeFormatter._ProtectData = function( outer, opener, data, closer ) { return opener + '___FCKpd___' + ( FCKCodeFormatter.ProtectedData.push( data ) - 1 ) + closer ; } FCKCodeFormatter.Format = function( html ) { if ( !this.Regex ) this.Init() ; // Protected content that remain untouched during the // process go in the following array. FCKCodeFormatter.ProtectedData = new Array() ; var sFormatted = html.replace( this.Regex.ProtectedTags, FCKCodeFormatter._ProtectData ) ; // Line breaks. sFormatted = sFormatted.replace( this.Regex.BlocksOpener, '\n$&' ) ; sFormatted = sFormatted.replace( this.Regex.BlocksCloser, '$&\n' ) ; sFormatted = sFormatted.replace( this.Regex.NewLineTags, '$&\n' ) ; sFormatted = sFormatted.replace( this.Regex.MainTags, '\n$&\n' ) ; // Indentation. var sIndentation = '' ; var asLines = sFormatted.split( this.Regex.LineSplitter ) ; sFormatted = '' ; for ( var i = 0 ; i < asLines.length ; i++ ) { var sLine = asLines[i] ; if ( sLine.length == 0 ) continue ; if ( this.Regex.DecreaseIndent.test( sLine ) ) sIndentation = sIndentation.replace( this.Regex.FormatIndentatorRemove, '' ) ; sFormatted += sIndentation + sLine + '\n' ; if ( this.Regex.IncreaseIndent.test( sLine ) ) sIndentation += FCKConfig.FormatIndentator ; } // Now we put back the protected data. for ( var j = 0 ; j < FCKCodeFormatter.ProtectedData.length ; j++ ) { var oRegex = new RegExp( '___FCKpd___' + j ) ; sFormatted = sFormatted.replace( oRegex, FCKCodeFormatter.ProtectedData[j].replace( /\$/g, '$$$$' ) ) ; } return sFormatted.Trim() ; }