If before = IGNORE,
rep is compared starting at 1. char of text (text[0]),
else starting at 2. char of text (text[1]).
Chars after "after"-delimiter are ignored.
@param rep (in): the string to look for
@param aRepLen (in): the number of bytes in the string to look for
@param before (in): limitation before rep
@param after (in): limitation after rep
@return true, if rep is found and limitation spec is met or rep is empty
*/
PRBool ItMatchesDelimited(const PRUnichar * aInString, PRInt32 aInLength,
const PRUnichar * rep, PRInt32 aRepLen, LIMTYPE before, LIMTYPE after);
/**
@param see ItMatchesDelimited
@return Number of ItMatchesDelimited in text
*/
PRUint32 NumberOfMatches(const PRUnichar * aInString, PRInt32 aInStringLength,
const PRUnichar* rep, PRInt32 aRepLen, LIMTYPE before, LIMTYPE after);
/**
Currently only changes "<", ">" and "&". All others stay as they are.
"Char" in function name to avoid side effects with nsString(ch) constructors. @param ch (in) @param aStringToAppendto (out) - the string to append the escaped string to. */ void EscapeChar(const PRUnichar ch, nsString& aStringToAppendto); /** See EscapeChar. Escapes the string in place. */ void EscapeStr(nsString& aInString); /** Currently only reverts "<", ">" and "&". All others stay as they are.
@param aInString (in) HTML string @param aStartPos (in) start index into the buffer @param aLength (in) length of the buffer @param aOutString (out) unescaped buffer */ void UnescapeStr(const PRUnichar * aInString, PRInt32 aStartPos, PRInt32 aLength, nsString& aOutString); /** Note: I use different strategies to pass context between the functions (full text and pos vs. cutted text and col0, glphyTextLen vs. replaceBefore/-After). It makes some sense, but is hard to understand (maintain) :-(. */ /**
Note: replaceBefore + replaceAfter + 1 (for char at pos) chars in text should be replaced by outputHTML.
Note: This function should be able to process a URL on multiple lines, but currently, ScanForURLs is called for every line, so it can't.
@param text (in): includes possibly a URL @param pos (in): position in text, where either ":", "." or "@" are found @param whathasbeendone (in): What the calling ScanTXT did/has to do with the (not-linkified) text, i.e. usually the "whattodo" parameter. (Needed to calculate replaceBefore.) NOT what will be done with the content of the link. @param outputHTML (out): URL with HTML-a tag @param replaceBefore (out): Number of chars of URL before pos @param replaceAfter (out): Number of chars of URL after pos @return URL found */ PRBool FindURL(const PRUnichar * aInString, PRInt32 aInLength, const PRUint32 pos, const PRUint32 whathasbeendone, nsString& outputHTML, PRInt32& replaceBefore, PRInt32& replaceAfter); enum modetype { unknown, RFC1738, /* Check, if RFC1738, APPENDIX compliant, like "
if col0 is true,
starting with tagTXT
else
starting one char before tagTXT
@param col0 (in): tagTXT is on the beginning of the line (or paragraph).
open must be 0 then.
@param tagTXT (in): Tag in plaintext to search for, e.g. "*"
@param aTagTxtLen (in): length of tagTXT.
@param tagHTML (in): HTML-Tag to replace tagTXT with,
without "<" and ">", e.g. "strong"
@param attributeHTML (in): HTML-attribute to add to opening tagHTML,
e.g. "class=txt_star"
@param aOutString: string to APPEND the converted html into
@param open (in/out): Number of currently open tags of type tagHTML
@return Conversion succeeded
*/
PRBool StructPhraseHit(const PRUnichar * aInString, PRInt32 aInStringLength, PRBool col0,
const PRUnichar* tagTXT,
PRInt32 aTagTxtLen,
const char* tagHTML, const char* attributeHTML,
nsString& aOutputString, PRUint32& openTags);
/**
@param text (in), col0 (in): see GlyphHit
@param tagTXT (in): Smily, see also StructPhraseHit
@param imageName (in): the basename of the file that contains the image for this smilie
@param outputHTML (out): new string containing the html for the smily
@param glyphTextLen (out): see GlyphHit
*/
PRBool
SmilyHit(const PRUnichar * aInString, PRInt32 aLength, PRBool col0,
const char* tagTXT, const char* imageName,
nsString& outputHTML, PRInt32& glyphTextLen);
/**
Checks, if we can replace some chars at the start of line with prettier HTML
code.
If success is reported, replace the first glyphTextLen chars with outputHTML @param text (in): line of text possibly with Glyph.
If col0 is true,
starting with Glyph
else
starting one char before Glyph
@param col0 (in): text starts at the beginning of the line (or paragraph)
@param aOutString (out): APPENDS html for the glyph to this string
@param glyphTextLen (out): Length of original text to replace
@return see StructPhraseHit
*/
PRBool GlyphHit(const PRUnichar * aInString, PRInt32 aInLength, PRBool col0,
nsString& aOutString, PRInt32& glyphTextLen);
/**
Check if a given url should be linkified.
@param aURL (in): url to be checked on.
*/
PRBool ShouldLinkify(const nsCString& aURL);
};
// It's said, that Win32 and Mac don't like static const members
const PRInt32 mozTXTToHTMLConv_lastMode = 4;
// Needed (only) by mozTXTToHTMLConv::FindURL
const PRInt32 mozTXTToHTMLConv_numberOfModes = 4; // dito; unknown not counted
#endif