anchor.diff:    TTextAlignment = ( taLeft,
                        taRight,
                        taCenter );
  -
  -// Returns tag pointed to by TextPointer and
  -// moves TextPointer to the first char after the tag.
  -Function ExtractTag( Var TextPointer: PChar ): TTag;
  -
  -// Returns tag ending at TextPointer
  -// (Expects textpointer is currently pointing at the >)
  -// and moves TextPointer to the first char of the tag
  -Function ExtractPreviousTag( const TextStart: PChar; Var TextPointer: PChar ): TTag;
  -function ExtractNextTextElement( TextPointer: PChar; Var NextElement: PChar ): TTextElement;
  -function ExtractPreviousTextElement( const TextStart: PChar; TextPointer: PChar; Var NextElement: PChar ): TTextElement;
  -
  -// Parse a color name or value (#hexval). Returns true if valid
  -function GetTagColor( const ColorParam: string; var Color: TfpgColor ): boolean;
  -
  -function GetTagTextAlignment( const AlignParam: string;
  -                              const Default: TTextAlignment ): TTextAlignment;
  -
  -function GetTagTextWrap( const WrapParam: string ): boolean;
  -
  -// Search within a rich text document for the given text
  -// if found, returns true, pMatch is set to the first match,
  -//   and MatchLength returns the length of the match
  -//   (which may be greater than the length of Text due to
  -//    to skipping tags)
  -// if not found, returns false, pMatch is set to nil
  -function RichTextFindString( pRichText: PChar;
  -                             const Text: string;
  -                             var pMatch: PChar;
  -                             var MatchLength: longint ): boolean;
  -
  -// Returns the start of the previous word,
  -// or the current word if pStart is in the middle of the word
  -function RichTextWordLeft( pRichText: PChar;
  -                           pStart: PChar ): PChar;
  -
  -// Returns the start of the next word.
  -function RichTextWordRight( pStart: PChar ): PChar;
  -
  -// If pStart is in the middle of a word, then
  -// returns true and sets the start and length of the word
  -function RichTextWordAt( pRichText: PChar;
  -                         pStart: PChar;
  -                         Var pWordStart: PChar;
  -                         Var WordLength: longint ): boolean;
  -
  -// Copies plaintext of richtext starting at StartP
  -// to the given buffer. Returns number of characters copied.
  -// Buffer may be nil
  -// If BufferLength is negative, it is effectively ignored
  -function CopyPlainTextToBuffer( StartP: PChar;
  -                                EndP: PChar;
  -                                Buffer: PChar;
  -                                BufferLength: longint ): longint;
  -
  -Implementation
  -
  -uses
  -//  BseDOS, // for NLS/case mapping
  -  SysUtils
  -  ,ACLStringUtility
  -  ;
   
   const
     TagStr: array[ ttInvalid .. ttEnd ] of string =
  
positive.code:       exit;
      end;
  
      if CurrentChar = DoubleQuote then
      begin
        if not InQuote then
        begin
  
negative.code:     ''
    );
  
  
  // Returns tag pointed to by TextPointer and
  // moves TextPointer to the first char after the tag.
  Function ExtractTag( Var TextPointer: PChar ): TTag;
  
  // Returns tag ending at TextPointer
  // (Expects textpointer is currently pointing at the >)
  // and moves TextPointer to the first char of the tag
  Function ExtractPreviousTag( const TextStart: PChar; Var TextPointer: PChar ): TTag;
  function ExtractNextTextElement( TextPointer: PChar; Var NextElement: PChar ): TTextElement;
  function ExtractPreviousTextElement( const TextStart: PChar; TextPointer: PChar; Var NextElement: PChar ): TTextElement;
  
  // Parse a color name or value (#hexval). Returns true if valid
  function GetTagColor( const ColorParam: string; var Color: TfpgColor ): boolean;
  
  function GetTagTextAlignment( const AlignParam: string;
                                const Default: TTextAlignment ): TTextAlignment;
  
  function GetTagTextWrap( const WrapParam: string ): boolean;
  
  // Search within a rich text document for the given text
  // if found, returns true, pMatch is set to the first match,
  //   and MatchLength returns the length of the match
  //   (which may be greater than the length of Text due to
  //    to skipping tags)
  // if not found, returns false, pMatch is set to nil
  function RichTextFindString( pRichText: PChar;
                               const Text: string;
                               var pMatch: PChar;
                               var MatchLength: longint ): boolean;
  
  // Returns the start of the previous word,
  // or the current word if pStart is in the middle of the word
  function RichTextWordLeft( pRichText: PChar;
                             pStart: PChar ): PChar;
  
  // Returns the start of the next word.
  function RichTextWordRight( pStart: PChar ): PChar;
  
  // If pStart is in the middle of a word, then
  // returns true and sets the start and length of the word
  function RichTextWordAt( pRichText: PChar;
                           pStart: PChar;
                           Var pWordStart: PChar;
                           Var WordLength: longint ): boolean;
  
  // Copies plaintext of richtext starting at StartP
  // to the given buffer. Returns number of characters copied.
  // Buffer may be nil
  // If BufferLength is negative, it is effectively ignored
  function CopyPlainTextToBuffer( StartP: PChar;
                                  EndP: PChar;
                                  Buffer: PChar;
                                  BufferLength: longint ): longint;
  
  Implementation
  
  uses
  //  BseDOS, // for NLS/case mapping
    SysUtils
    ,ACLStringUtility
    ;
  
  const
    StandardColors: array[ 0..7 ] of TStandardColor =
    (
      ( Name : 'white' ; Color: clWhite   ),
  