Determines if the supplied chain iterator marks the start of a sequence that amounts to a legal HTML tag or anti-tag. If it does not 0 is returned and the supplied string will be empty. If the sequence has the right form, a case-insensitive lookup is performed to test the name part against all known HTML5 tags. If this finds a match the supplied string will be populated with the sequence (including the opening and closing angle brackets). The return value will then be either 1 for the tag or 2 for the anti-tag.

Return TypeFunction nameArguments
hzHtagIndAtHtmlTag(hzString&,hzChain::Iter&,)

Declared in file: hzDocument.h
Defined in file : hzDocHtml.cpp

Function Logic:

0:START 1:unknown 2:items 3:items zi 4:unknown 5:Return HTAG_IND_NULL 6:items 7:unknown 8:retval items 9:retval 10:unknown 11:items 12:unknown 13:Return HTAG_IND_NULL 14:tagname items items tf 15:unknown 16:Return HTAG_IND_NULL 17:unknown 18:items 19:unknown 20:unknown 21:items 22:unknown 23:items items 24:unknown 25:unknown 26:unknown 27:retval items items 28:unknown 29:unknown 30:Return HTAG_IND_NULL 31:tagseq 32:Return retval

Function body:

hzHtagInd AtHtmlTag (hzString& tagseq)hzChain::Iter& ci, 
{
   //  Category: Text Processing
   //  
   //  Determines if the supplied chain iterator marks the start of a sequence that amounts to a legal HTML tag or anti-tag. If it does not 0 is returned and
   //  the supplied string will be empty. If the sequence has the right form, a case-insensitive lookup is performed to test the name part against all known
   //  HTML5 tags. If this finds a match the supplied string will be populated with the sequence (including the opening and closing angle brackets). The return
   //  value will then be either 1 for the tag or 2 for the anti-tag.
   //  
   //  Arguments: 1) tagseq If a tag is found, this string reference will be populated by it.
   //     2) ci  The test chain iterator
   //  
   //  Returns: HTRULE_NULL  If the sequence is not a known HTML tag or antitag.
   //     HTRULE_PAIRED If the sequence is a HTML tag.
   //     HTRULE_SINGLE If the sequence is a HTML antitag.
   //     HTRULE_OPTION If the sequence is both a HTML tag and antitag (eg <br/>).
   _hzfunc(__func__) ;
   hzChain     W ;             //  For building tagname
   chIter      zi ;            //  Used to iterate whole tag sequence.
   hzHtagform  tf ;            //  The tag form for the found tag (if any).
   hzString    tagname ;       //  The tag name
   hzHtagInd   retval ;        //  Return value (0 invalid, 1 tag, 2 anti-tag)
   //  If tagmap not loaded, load it
   if (!s_htagNam.Count())
       InitHtml() ;
   //  Clear the supplied tag and set chain iter
   tagseq.Clear() ;
   zi = ci ;
   if (*zi != CHAR_LESS)
       return HTAG_IND_NULL ;
   zi++ ;
   if (*zi == CHAR_FWSLASH)
       { retval = HTAG_IND_ANTI ; zi++ ; }
   else
       retval = HTAG_IND_OPEN ;
   for (; !zi.eof() && IsAlpha(*zi) ; zi++)
       W.AddByte(*zi) ;
   if (!W.Size())
       return HTAG_IND_NULL ;
   tagname = W ;
   W.Clear() ;
   tagname.ToLower() ;
   tf = s_htagNam[tagname] ;
   if (tf.type == HTAG_NULL)
       return HTAG_IND_NULL ;
   //  We have a HTML tag so build the complete tag for populating tagseq
   for (zi = ci ; !zi.eof() ; zi++)
   {
       W.AddByte(*zi) ;
       if (*zi == CHAR_DQUOTE)
       {
           for (zi++ ; !zi.eof() ; zi++)
           {
               W.AddByte(*zi) ;
               if (*zi == CHAR_BKSLASH)
                   { zi++ ; W.AddByte(*zi) ; }
               if (*zi == CHAR_DQUOTE)
                   break ;
           }
           continue ;
       }
       if (*zi == CHAR_FWSLASH)
       {
           if (zi == "/>")
               { retval = HTAG_IND_SELF ; zi++ ; W.AddByte(*zi) ; }
       }
       if (*zi == CHAR_MORE)
           break ;
   }
   if (*zi != CHAR_MORE)
       return HTAG_IND_NULL ;
   tagseq = W ;
   return retval ;
}