// Set the ErrorInfo strucutre eInfo = StructNew(); // Set the prefix for all errors eTypePrefix = "DepressedPress.DP_ParseBBML."; // e01xx is "InvalidAttribute" eInfo.e0101 = StructNew(); eInfo.e0101.Type = eTypePrefix & "InvalidAttribute"; eInfo.e0101.ErrorCode = "e0101"; eInfo.e0101.Message = "DP_ParseBBML: Attribute ""Input"" must be a String"; eInfo.e0101.Detail = "The attribute ""Input"" cannot be a complex datatype (Query, Array, Structure, etc)."; eInfo.e0102 = StructNew(); eInfo.e0102.Type = eTypePrefix & "InvalidAttribute"; eInfo.e0102.ErrorCode = "e0102"; eInfo.e0102.Message = "DP_ParseBBML: Attribute ""Input"" is Required"; eInfo.e0102.Detail = "The DP_ParseBBML tag requires string input either passed within the ""Input"" attribute or contained within a tag/end tag pair."; eInfo.e0103 = StructNew(); eInfo.e0103.Type = eTypePrefix & "InvalidAttribute"; eInfo.e0103.ErrorCode = "e0103"; eInfo.e0103.Message = "DP_ParseBBML: Attribute ""OutputVar"" must be a String"; eInfo.e0103.Detail = "The attribute ""OutputVar"" cannot be a complex datatype (Query, Array, Structure, etc)."; eInfo.e0104 = StructNew(); eInfo.e0104.Type = eTypePrefix & "InvalidAttribute"; eInfo.e0104.ErrorCode = "e0104"; eInfo.e0104.Message = "DP_ParseBBML: Attribute ""OutputVar"" must be a valid variable name"; eInfo.e0104.Detail = "The attribute ""OutputVar"" must be a string and follow the standards for ColdFusion variables."; eInfo.e0105 = StructNew(); eInfo.e0105.Type = eTypePrefix & "InvalidAttribute"; eInfo.e0105.ErrorCode = "e0105"; eInfo.e0105.Message = "DP_ParseBBML: Attribute ""ConvertSmilies"" must be Boolean"; eInfo.e0105.Detail = "The attribute ""ConvertSmilies"" must be boolean (""Yes""/""No"", ""True""/""False"", etc)."; eInfo.e0106 = StructNew(); eInfo.e0106.Type = eTypePrefix & "InvalidAttribute"; eInfo.e0106.ErrorCode = "e0106"; eInfo.e0106.Message = "DP_ParseBBML: Attribute ""ConvertHTML"" must be Boolean"; eInfo.e0106.Detail = "The attribute ""ConvertHTML"" must be boolean (""Yes""/""No"", ""True""/""False"", etc)."; eInfo.e0107 = StructNew(); eInfo.e0107.Type = eTypePrefix & "InvalidAttribute"; eInfo.e0107.ErrorCode = "e0107"; eInfo.e0107.Message = "DP_ParseBBML: Attribute ""ConvertBBML"" must be Boolean"; eInfo.e0107.Detail = "The attribute ""ConvertBBML"" must be boolean (""Yes""/""No"", ""True""/""False"", etc)."; eInfo.e0108 = StructNew(); eInfo.e0108.Type = eTypePrefix & "InvalidAttribute"; eInfo.e0108.ErrorCode = "e0108"; eInfo.e0108.Message = "DP_ParseBBML: Attribute ""ConvertSmilies"" requires ""SmileyPath"" to be set"; eInfo.e0108.Detail = "If the attribute ""ConvertSmilies"" is set to ""Yes"" then a valid path must be given for ""SmileyPath""."; eInfo.e0109 = StructNew(); eInfo.e0109.Type = eTypePrefix & "InvalidAttribute"; eInfo.e0109.ErrorCode = "e0109"; eInfo.e0109.Message = "DP_ParseBBML: Attribute ""RevertToBBML"" must be Boolean"; eInfo.e0109.Detail = "The attribute ""RevertToBBML"" must be boolean (""Yes""/""No"", ""True""/""False"", etc)."; eInfo.e0110 = StructNew(); eInfo.e0110.Type = eTypePrefix & "InvalidAttribute"; eInfo.e0110.ErrorCode = "e0110"; eInfo.e0110.Message = "DP_ParseBBML: Attribute ""UseCF_ColoredCode"" must be Boolean"; eInfo.e0110.Detail = "The attribute ""UseCF_ColoredCode"" must be boolean (""Yes""/""No"", ""True""/""False"", etc)."; eInfo.e0111 = StructNew(); eInfo.e0111.Type = eTypePrefix & "CF_ColoredCode"; eInfo.e0111.ErrorCode = "e0111"; eInfo.e0111.Message = "DP_ParseBBML: There was an unknown error attempting to utilize CF_ColoredCode"; eInfo.e0111.Detail = "An error occured while calling the supporting routine, CF_ColoredCode."; // Convert to character entities any instances of the special characters we'll be using as markers // The angle quotes substitute angle brackets Input = Replace(Input, "«", "«", "All"); Input = Replace(Input, "»", "»", "All"); // The O Graves substitute angle brackets withing in Lists Input = Replace(Input, "Ò", "Ò", "All"); Input = Replace(Input, "ò", "ò", "All"); // The O Slash replaces list items Input = Replace(Input, "Ø", "Ø", "All"); // The Section mark substitutes quotes in generated HTML Input = Replace(Input, "§", "§", "All"); // U graves/acutes are used to protect non-tag square brackets Input = Replace(Input, "Ù", "Ù", "All"); Input = Replace(Input, "Ú", "Ú", "All"); Input = Replace(Input, "ù", "ù", "All"); Input = Replace(Input, "ú", "ú", "All"); // The british Pound sign is used to mark beginings of links Input = Replace(Input, "£", "£", "All"); // Set up the complex object arrays SQLBlocks = ArrayNew(1); CodeBlocks = ArrayNew(1); // Convert BBML, if needed if ( ConvertBBML AND Find("[", Input) AND Find("]", Input) ) { // Extract SQL Blocks apply formatting CurPos=1; while (FindNoCase("[sql]", Input, CurPos) GT 0) { sSQLPos = FindNoCase("[sql]", Input, CurPos) + 5; eSQLPos = FindNoCase("[/sql]", Input, sSQLPos); if (eSQLPos EQ 0) { break; } else { CurPos = sSQLPos; }; CurSQLBlock = Mid(Input, sSQLPos, eSQLPos - sSQLPos); Input = RemoveChars(Input, sSQLPos, eSQLPos - sSQLPos); Input = Insert("***#Evaluate(ArrayLen(SQLBlocks) + 1)#***", Input, sSQLPos - 1); // Clean up quotes and angle brackets in the code CurSQLBlock = Replace(CurSQLBlock, """", """, "ALL"); CurSQLBlock = Replace(CurSQLBlock, "<", "<", "ALL"); CurSQLBlock = Replace(CurSQLBlock, ">", ">", "ALL"); // The following code submitted by Jochem van Dieten. Used with Permission. reservedWords = "ABSOLUTE|ACTION|ADD|ADMIN|AFTER|AGGREGATE|ALIAS|ALL|ALLOCATE|ALTER|AND|ANY|ARE|ARRAY|AS|ASC|ASSERTION|AT|AUTHORIZATION|AVG|BEFORE|BEGIN|BETWEEN|BINARY|BIT|BIT_LENGTH|BLOB|BOOLEAN|BOTH|BREADTH|BY|CALL|CASCADE|CASCADED|CASE|CAST|CATALOG|CHAR|CHAR_LENGTH|CHARACTER|CHARACTER_LENGTH|CHECK|CLASS|CLOB|CLOSE|COALESCE|COLLATE|COLLATION|COLUMN|COMMIT|COMPLETION|CONNECT|CONNECTION|CONSTRAINT|CONSTRAINTS|CONSTRUCTOR|CONTINUE|CONVERT|CORRESPONDING|COUNT|CREATE|CROSS|CUBE|CURRENT|CURRENT_DATE|CURRENT_PATH|CURRENT_ROLE|CURRENT_TIME|CURRENT_TIMESTAMP|CURRENT_USER|CURSOR|CYCLE|DATA|DATE|DAY|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFERRABLE|DEFERRED|DELETE|DEPTH|DEREF|DESC|DESCRIBE|DESCRIPTOR|DESTROY|DESTRUCTOR|DETERMINISTIC|DIAGNOSTICS|DICTIONARY|DISCONNECT|DISTINCT|DOMAIN|DOUBLE|DROP|DYNAMIC|EACH|ELSE|END|END-EXEC|EQUALS|ESCAPE|EVERY|EXCEPT|EXCEPTION|EXEC|EXECUTE|EXISTS|EXTERNAL|EXTRACT|FALSE|FETCH|FIRST|FLOAT|FOR|FOREIGN|FOUND|FREE|FROM|FULL|FUNCTION|GENERAL|GET|GLOBAL|GO|GOTO|GRANT|GROUP|GROUPING|HAVING|HOST|HOUR|IDENTITY|IGNORE|IMMEDIATE|IN|INDICATOR|INITIALIZE|INITIALLY|INNER|INOUT|INPUT|INSENSITIVE|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|IS|ISOLATION|ITERATE|JOIN|KEY|LANGUAGE|LARGE|LAST|LATERAL|LEADING|LEFT|LESS|LEVEL|LIKE|LIMIT|LOCAL|LOCALTIME|LOCALTIMESTAMP|LOCATOR|LOWER|MAP|MATCH|MAX|MIN|MINUTE|MODIFIES|MODIFY|MODULE|MONTH|NAMES|NATIONAL|NATURAL|NCHAR|NCLOB|NEW|NEXT|NO|NONE|NOT|NULL|NULLIF|NUMERIC|OBJECT|OCTET_LENGTH|OF|OFF|OLD|ON|ONLY|OPEN|OPERATION|OPTION|OR|ORDER|ORDINALITY|OUT|OUTER|OUTPUT|OVERLAPS|PAD|PARAMETER|PARAMETERS|PARTIAL|PATH|POSITION|POSTFIX|PRECISION|PREFIX|PREORDER|PREPARE|PRESERVE|PRIMARY|PRIOR|PRIVILEGES|PROCEDURE|PUBLIC|READ|READS|REAL|RECURSIVE|REF|REFERENCES|REFERENCING|RELATIVE|RESTRICT|RESULT|RETURN|RETURNS|REVOKE|RIGHT|ROLE|ROLLBACK|ROLLUP|ROUTINE|ROW|ROWS|SAVEPOINT|SCHEMA|SCOPE|SCROLL|SEARCH|SECOND|SECTION|SELECT|SEQUENCE|SESSION|SESSION_USER|SET|SETS|SIZE|SMALLINT|SOME|SPACE|SPECIFIC|SPECIFICTYPE|SQL|SQLEXCEPTION|SQLSTATE|SQLWARNING|START|STATE|STATEMENT|STATIC|STRUCTURE|SUBSTRING|SUM|SYSTEM_USER|TABLE|TEMPORARY|TERMINATE|THAN|THEN|TIME|TIMESTAMP|TIMEZONE_HOUR|TIMEZONE_MINUTE|TO|TRAILING|TRANSACTION|TRANSLATE|TRANSLATION|TREAT|TRIGGER|TRIM|TRUE|UNDER|UNION|UNIQUE|UNKNOWN|UNNEST|UPDATE|UPPER|USAGE|USER|USING|VALUE|VALUES|VARCHAR|VARIABLE|VARYING|VIEW|WHEN|WHENEVER|WHERE|WITH|WITHOUT|WORK|WRITE|YEAR|ZONE"; CurSQLBlock = REReplaceNoCase(REReplaceNoCase(" " & CurSQLBlock & " ","([^[:alnum:]])(#reservedWords#)([^[:alnum:]])","\1\2\3","All"),"([^[:alnum:]])(#reservedWords#)([^[:alnum:]])","\1\2\3","All"); // End of code submitted by Jochem van Dieten. CurSQLBlock = "
#Trim(CurSQLBlock)#
"; ArrayAppend(SQLBlocks, CurSQLBlock); }; // Extract Code Blocks and apply formatting if CF_ColoredCode if needed CurPos=1; while (FindNoCase("[code]", Input, CurPos) GT 0) { sCodePos = FindNoCase("[code]", Input, CurPos) + 6; eCodePos = FindNoCase("[/code]", Input, sCodePos); if (eCodePos EQ 0) { break; } else { CurPos = sCodePos; }; CurCodeBlock = Mid(Input, sCodePos, eCodePos - sCodePos); Input = RemoveChars(Input, sCodePos, eCodePos - sCodePos); if (UseCF_ColoredCode) { // The following code copyrighted by Dain Anderson, www.cfcomet.com. Used with Permission /* Pointer to Attributes.Data */ this = CurCodeBlock; /* Convert special characters so they do not get interpreted literally; italicize and boldface */ this = REReplaceNoCase(this, "&([[:alpha:]]{2,});", "«B»«I»&\1;«/I»«/B»", "ALL"); /* Convert many standalone (not within quotes) numbers to blue, ie. myValue = 0 */ this = REReplaceNoCase(this, "(gt|lt|eq|is|,|\(|\))([[:space:]]?[0-9]{1,})", "\1«FONT COLOR=BLUE»\2«/FONT»", "ALL"); /* Convert normal tags to navy blue */ this = REReplaceNoCase(this, "<(/?)((!d|b|c(e|i|od|om)|d|e|f(r|o)|h|i|k|l|m|n|o|p|q|r|s|t(e|i|t)|u|v|w|x)[^>]*)>", "«FONT COLOR=NAVY»<\1\2>«/FONT»", "ALL"); /* Convert all table-related tags to teal */ this = REReplaceNoCase(this, "<(/?)(t(a|r|d|b|f|h)([^>]*)|c(ap|ol)([^>]*))>", "«FONT COLOR=TEAL»<\1\2>«/FONT»", "ALL"); /* Convert all form-related tags to orange */ this = REReplaceNoCase(this, "<(/?)((bu|f(i|or)|i(n|s)|l(a|e)|se|op|te)([^>]*))>", "«FONT COLOR=FF8000»<\1\2>«/FONT»", "ALL"); /* Convert all tags starting with 'a' to green, since the others aren't used much and we get a speed gain */ this = REReplaceNoCase(this, "<(/?)(a[^>]*)>", "«FONT COLOR=GREEN»<\1\2>«/FONT»", "ALL"); /* Convert all image and style tags to purple */ this = REReplaceNoCase(this, "<(/?)((im[^>]*)|(sty[^>]*))>", "«FONT COLOR=PURPLE»<\1\2>«/FONT»", "ALL"); /* Convert all ColdFusion, SCRIPT and WDDX tags to maroon */ this = REReplaceNoCase(this, "<(/?)((cf[^>]*)|(sc[^>]*)|(wddx[^>]*))>", "«FONT COLOR=MAROON»<\1\2>«/FONT»", "ALL"); /* Convert all inline "//" comments to gray (revised) */ this = REReplaceNoCase(this, "([^:/]\/{2,2})([^[:cntrl:]]+)($|[[:cntrl:]])", "«FONT COLOR=GRAY»«I»\1\2«/I»«/FONT»", "ALL"); /* Convert all multi-line script comments to gray */ this = REReplaceNoCase(this, "(\/\*[^\*]*\*\/)", "«FONT COLOR=GRAY»«I»\1«/I»«/FONT»", "ALL"); /* Convert all HTML and ColdFusion comments to gray */ /* The next 10 lines of code can be replaced with the commented-out line following them, if you do care whether HTML and CFML comments contain colored markup. */ EOF = 0; BOF = 1; while(NOT EOF) { Match = REFindNoCase("", this, BOF, True); if (Match.pos[1]) { Orig = Mid(this, Match.pos[1], Match.len[1]); Chunk = REReplaceNoCase(Orig, "«(/?[^»]*)»", "", "ALL"); BOF = ((Match.pos[1] + Len(Chunk)) + 31); // 31 is the length of the FONT tags in the next line this = Replace(this, Orig, "«FONT COLOR=GRAY»«I»#Chunk#«/I»«/FONT»"); } else EOF = 1; } // Use this next line of code instead of the last 10 lines if you want (faster) // this = REReplaceNoCase(this, "()", "«FONT COLOR=GRAY»«I»\1«/I»«/FONT»", "ALL"); /* Convert all quoted values to blue */ this = REReplaceNoCase(this, """([^""]*)""", "«FONT COLOR=BLUE»""\1""«/FONT»", "ALL"); /* Convert left containers to their ASCII equivalent */ this = REReplaceNoCase(this, "<", "<", "ALL"); /* Revert all pseudo-containers back to their real values to be interpreted literally (revised) */ this = REReplaceNoCase(this, "«([^»]*)»", "<\1>", "ALL"); /* ***New Feature*** Convert all FILE and UNC paths to active links (i.e, file:///, \\server\, c:\myfile.cfm) */ this = REReplaceNoCase(this, "(((file:///)|([a-z]:\\)|(\\\\[[:alpha:]]))+(\.?[[:alnum:]\/=^@*|:~`+$%?_##& -])+)", "\1", "ALL"); /* Convert all URLs to active links (revised) */ this = REReplaceNoCase(this, "([[:alnum:]]*://[[:alnum:]\@-]*(\.[[:alnum:]][[:alnum:]-]*[[:alnum:]]\.)?[[:alnum:]]{2,}(\.?[[:alnum:]\/=^@*|:~`+$%?_##&-])+)", "\1", "ALL"); /* Convert all email addresses to active mailto's (revised) */ this = REReplaceNoCase(this, "(([[:alnum:]][[:alnum:]_.-]*)?[[:alnum:]]@[[:alnum:]][[:alnum:].-]*\.[[:alpha:]]{2,})", "\1", "ALL"); this = "
#this#
"; // The above code copyrighted by Dain Anderson, www.cfcomet.com. Used with Permission CurCodeBlock = this; } else { CurCodeBlock = HTMLCodeFormat(CurCodeBlock); }; ArrayAppend(CodeBlocks, CurCodeBlock); Input = Insert("***#ArrayLen(CodeBlocks)#***", Input, sCodePos - 1); }; // Set non-tag brackets to safe entities Input = ReReplaceNoCase(Input, "\[(/?)((\*)|(b)|(bold)|(i)|(italic)|(u)|(underline)|(s)|(strikethrough)|(sup)|(superscript)|(center)|(sub)|(subscript)|(size(=[0-9]*)?)|(color(=[##0-9A-Za-z]*)?)|(q)|(quote)|(sql)|(code)|(pre)|(preformatted)|((url|link)(=([^]]*))?)|(email(=([^]]*))?)|(img)|(image)|(list(=(1|a|A|i|I))?))\]", "ù\1\2ú", "All"); Input = Replace(Input, "[", "Ù", "All"); Input = Replace(Input, "]", "Ú", "All"); Input = Replace(Input, "ù", "[", "All"); Input = Replace(Input, "ú", "]", "All"); // Validate the [size] tag's limits MaximumFontSize = 25; MinimumFontSize = 8; CurPos = 1; while (ReFindNoCase("\[size=([0-9]*)\]", Input, CurPos) GT 0) { CurPos = ReFindNoCase("\[size=([0-9]*)\]", Input, CurPos, True); CurSize = Mid(Input, CurPos.pos[2], CurPos.Len[2]); if (CurSize GT MaximumFontSize) { Input = ReplaceNoCase(Input, "[size=#CurSize#]", "[size=#MaximumFontSize#]", "All"); }; if (CurSize LT MinimumFontSize) { Input = ReplaceNoCase(Input, "[size=#CurSize#]", "[size=#MinimumFontSize#]", "All"); }; CurPos = CurPos.pos[1] + CurPos.Len[1]; }; // Do all simple BBML conversion to psuedo HTML using "«" and "»" // The recursive loop, coupled with the regular expressions will validate for proper tag pairs and nesting do { // Set a temporary variable equal to the input - if it changes that means there was some work to be done and another pass is needed. TempInput = Input; // Convert Simple Formatting Input = ReReplaceNoCase(Input, "\[(b|bold)\]([^[]*)\[/\1\]", "«b»\2«/b»", "All"); Input = ReReplaceNoCase(Input, "\[(i|italic)\]([^[]*)\[/\1\]", "«i»\2«/i»", "All"); Input = ReReplaceNoCase(Input, "\[(u|underline)\]([^[]*)\[/\1\]", "«u»\2«/u»", "All"); Input = ReReplaceNoCase(Input, "\[(s|strikethrough)\]([^[]*)\[/\1\]", "«s»\2«/s»", "All"); Input = ReReplaceNoCase(Input, "\[(sup|superscript)\]([^[]*)\[/\1\]", "«sup»\2«/sup»", "All"); Input = ReReplaceNoCase(Input, "\[(sub|subscript)\]([^[]*)\[/\1\]", "«sub»\2«/sub»", "All"); Input = ReReplaceNoCase(Input, "\[center\]([^[]*)\[/center\]", "«div align=§center§»\1«/div»", "All"); // Convert "Color" and "Size" Input = ReReplaceNoCase(Input, "\[size=([0-9]+)\]([^[]*)\[/size(=\1)?\]", "«span style=§font-size: \1pt§»\2«/span»", "All"); Input = ReReplaceNoCase(Input, "\[color=([##0-9A-Za-z]+)\]([^[]*)\[/color(=\1)?\]", "«span style=§color: \1§»\2«/span»", "All"); // Convert Special Formatting Input = ReReplaceNoCase(Input, "\[(q|quote)\]([^[]*)\[/\1\]", "«blockquote»\2«/blockquote»", "All"); Input = ReReplaceNoCase(Input, "\[(code)\]([^[]*)\[/\1\]", "«code»\2«/code»", "All"); Input = ReReplaceNoCase(Input, "\[(sql)\]([^[]*)\[/\1\]", "«sql»\2«/sql»", "All"); Input = ReReplaceNoCase(Input, "\[(pre|preformatted)\]([^[]*)\[/\1\]", "«pre»\2«/pre»", "All"); // Convert Images Input = ReReplaceNoCase(Input, "\[(img|image)\]([^[«]*)\[/(img|image)\]", "«img src=§\2§»", "All"); // Convert Links Input = ReReplaceNoCase(Input, "\[(url|link)=([^]]*)\]([^[£]*)\[/\1\]", "£ href=§\2§»\3«/a»", "All"); Input = ReReplaceNoCase(Input, "\[(url|link)\]([^[£]*)\[/\1\]", "£ href=§\2§»\2«/a»", "All"); // Convert Email Links Input = ReReplaceNoCase(Input, "\[email=([^]]*)\]([^[£]*)\[/email\]", "£ href=§mailto:\1§»\2«/a»", "All"); Input = ReReplaceNoCase(Input, "\[email\]([^[(£]*)\[/email\]", "£ href=§mailto:\1§»\1«/a»", "All"); // Convert Lists // List brackets get replaced with "Ò" and "ò" to distingush them for validation Input = Replace(Input, "[*]", "Ø", "ALL"); Input = ReReplaceNoCase(Input, "\[list\][[:space:]]*Ø([^[]*)\[/list\]", "ÒulòØ\1Ò/ulò", "All"); Input = ReReplaceNoCase(Input, "\[list=(1|a|A|i|I)\][[:space:]]*Ø([^[]*)\[/list(=\1)?\]", "Òol type=§\1§òØ\2Ò/olò", "All"); // Clean Up lists // Add end item tags and remove line feeds and carriage returns do { bList = ReFind("Ò(ul|ol)( type=§.§)?ò", Input, 1); if ( bList NEQ 0 ) { CurPos = bList; ItemCnt = 0; Input = Insert("«", Input, CurPos); Input = RemoveChars(Input, CurPos, 1); while (true) { if ( (Mid(Input, CurPos, 1) EQ Chr(10)) OR (Mid(Input, CurPos, 1) EQ Chr(13)) ) { Input = RemoveChars(Input, CurPos, 1); CurPos = CurPos - 1; }; // Convert item tags to pseudo code and insert End item tags if ( Compare(Mid(Input, CurPos, 1), "Ø" ) EQ 0 ) { Input = RemoveChars(Input, CurPos, 1); Input = Insert("«li»", Input, CurPos - 1); ItemCnt = ItemCnt + 1; if (ItemCnt GT 1) { Input = Insert("«/li»", Input, CurPos - 1); CurPos = CurPos + 5; }; }; // When we find the beginning of the list end tag, stop if ( Compare(Mid(Input, CurPos, 1), "Ò" ) EQ 0 ) { Input = RemoveChars(Input, CurPos, 1); Input = Insert("«", Input, CurPos - 1); Input = Insert("«/li»", Input, CurPos - 1); break; }; CurPos = CurPos + 1; }; }; } while (bList NEQ 0); // Set the List tags back to psuedo-code Input = Replace(Input, "ò", "»", "ALL"); // If no changes have been made, break out of the loop - we're done! } while (TempInput NEQ Input); // Convert Orphaned List Items back to BBML code Input = Replace(Input, "Ø", "[*]", "ALL"); }; // Convert Smilies if Needed if (ConvertSmilies) { Input = ReReplace(Input, "(:(\^|')\))", "«img src=§#SmileyPath#Happy.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(:(\^|')D)", "«img src=§#SmileyPath#VeryHappy.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(:(\^|')\|)", "«img src=§#SmileyPath#Neutral.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(:(\^|')\()", "«img src=§#SmileyPath#Sad.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(L(\^|')\()", "«img src=§#SmileyPath#VerySad.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(>(\^|')\()", "«img src=§#SmileyPath#Mad.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(>(\^|')(X|x))", "«img src=§#SmileyPath#VeryMad.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(;(\^|')\))", "«img src=§#SmileyPath#Wink.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(;(\^|')\|)", "«img src=§#SmileyPath#Wincing.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(:(\^|')(o|O|0))", "«img src=§#SmileyPath#Shouting.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(=(\^|')\))", "«img src=§#SmileyPath#Interested.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(;(\^|')`)", "«img src=§#SmileyPath#ThinkingHard.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(;(\^|')d)", "«img src=§#SmileyPath#Confused.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(=(\^|')~)", "«img src=§#SmileyPath#SlightlyShocked.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(=(\^|')(o|O|0))", "«img src=§#SmileyPath#Shocked.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(=(\^|')\*)", "«img src=§#SmileyPath#Kiss.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(8(\^|')\))", "«img src=§#SmileyPath#Cool.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(:(\^|')\})", "«img src=§#SmileyPath#Drooling.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(:(\^|')(b|p))", "«img src=§#SmileyPath#StickingOutTounge.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(\{(\^|')(o|O|0))", "«img src=§#SmileyPath#Yawning.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(\{(\^|')\))", "«img src=§#SmileyPath#Sleeping.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(##(\^|')\))", "«img src=§#SmileyPath#Embarassed.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(%(\^|')\))", "«img src=§#SmileyPath#Crazy.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(B(\^|')>)", "«img src=§#SmileyPath#Evil.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "((o|O|0)(\^|')\))", "«img src=§#SmileyPath#Angelic.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(\?(\^|')\))", "«img src=§#SmileyPath#Question.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(!(\^|')\))", "«img src=§#SmileyPath#Exclamation.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); Input = ReReplace(Input, "(\$(\^|')\))", "«img src=§#SmileyPath#Idea.gif§ alt=§::\1::§ height=§15§ width=§15§ vspace=§1§ hspace=§1§»","ALL"); }; // Convert HTML, if needed if (ConvertHTML) { Input = Replace(Input, """", """, "ALL"); Input = Replace(Input, "<", "<", "ALL"); Input = Replace(Input, ">", ">", "ALL"); }; // Set up Paragraphs and breaks Input = "«p»" & Input & "«/p»"; Input = Replace(Input, "#Chr(13)##Chr(10)##Chr(13)##Chr(10)#", "«/p»«p»", "ALL"); Input = Replace(Input, "#Chr(13)##Chr(10)#", "«br»", "ALL"); // Reset non-tag brackets to brackets Input = Replace(Input, "Ù", "[", "All"); Input = Replace(Input, "Ú", "]", "All"); // Reinsert code blocks if (ArrayLen(CodeBlocks) GT 0) { for (Cnt = 1; Cnt LTE ArrayLen(CodeBlocks); Cnt = Cnt + 1) { Input = ReplaceNoCase(Input, "«code»***#Cnt#***«/code»", CodeBlocks[Cnt]); }; }; // Reinsert SQL blocks if (ArrayLen(SQLBlocks) GT 0) { for (Cnt = 1; Cnt LTE ArrayLen(SQLBlocks); Cnt = Cnt + 1) { Input = ReplaceNoCase(Input, "«sql»***#Cnt#***«/sql»", SQLBlocks[Cnt]); }; }; // Convert Psuedo-Tags to angle brackets // All code-HTML conversion must be completed by this point! Input = Replace(Input, "§", """", "ALL"); Input = Replace(Input, "«", "<", "ALL"); Input = Replace(Input, "»", ">", "ALL"); Input = Replace(Input, "£", " // Revert all simple BBML conversion to BBML do { // Set a temporary variable equal to the input - if it changes that means there was some work to be done and another pass is needed. TempInput = Input; // Revert Smilies Input = ReReplaceNoCase(Input, "]*)>", "\2", "All"); // Revert Simple Formatting Input = ReReplaceNoCase(Input, "([^<]*)", "[b]\1[/b]", "All"); Input = ReReplaceNoCase(Input, "([^<]*)", "[i]\1[/i]", "All"); Input = ReReplaceNoCase(Input, "([^<]*)", "[u]\1[/u]", "All"); Input = ReReplaceNoCase(Input, "([^<]*)", "[s]\1[/s]", "All"); Input = ReReplaceNoCase(Input, "([^<]*)", "[superscript]\1[/superscript]", "All"); Input = ReReplaceNoCase(Input, "([^<]*)", "[subscript]\1[/subscript]", "All"); // Revert "Color" and "Size" Input = ReReplaceNoCase(Input, "([^<]*)", "[size=\1]\2[/size]", "All"); Input = ReReplaceNoCase(Input, "([^<]*)", "[color=\1]\2[/color]", "All"); // Revert Special Formatting Input = ReReplaceNoCase(Input, "
([^<]*)
", "[quote]\1[/quote]", "All"); Input = ReReplaceNoCase(Input, "([^<]*)", "[code]\1[/code]", "All"); Input = ReReplaceNoCase(Input, "
([^<]*)
", "[preformatted]\1[/preformatted]", "All"); // Revert Email Links (this must be done BEFORE regular links) Input = ReReplaceNoCase(Input, "]*)"">([^<]*)", "[email=\1]\2[/email]", "All"); Input = ReReplaceNoCase(Input, "\[email=([^]]*)\]\1\[/email\]", "[email=\1]", "All"); // Revert Links Input = ReReplaceNoCase(Input, "]*)"">([^<]*)", "[url=\1]\2[/url]", "All"); Input = ReReplaceNoCase(Input, "\[url=([^]]*)\]\1\[/url\]", "[url=\1]", "All"); // Revert Images Input = ReReplaceNoCase(Input, "]*)>", "[image]\1[/image]", "All"); // Revert Lists Input = ReReplaceNoCase(Input, "
  • ([^<]*)
  • ", "[*]\1#Chr(13)##Chr(10)#", "ALL"); Input = ReReplaceNoCase(Input, "
      ([^<]*)
    ", "[list]#Chr(13)##Chr(10)#\1[/list]", "ALL"); Input = ReReplaceNoCase(Input, "
      ([^<]*)
    ", "[list=\1]#Chr(13)##Chr(10)#\2[/list]", "ALL"); // If no changes have been made, break out of the loop - we're done! } while (TempInput NEQ Input); // Set up Paragraphs and breaks Input = Replace(Input, "

    ", "#Chr(13)##Chr(10)##Chr(13)##Chr(10)#", "ALL"); Input = Replace(Input, "
    ", "#Chr(13)##Chr(10)#", "ALL"); Input = Replace(Input, "

    ", "", "ALL"); Input = Replace(Input, "

    ", "", "ALL");
    #Input#