398
402
/* Lexer Functions
400
Node *CommentToken( Lexer *lexer );
402
405
/* choose what version to use for new doctype */
403
int HTMLVersion( TidyDocImpl* doc );
405
ctmbstr GetFPIFromVers(uint vers);
406
int TY_(HTMLVersion)( TidyDocImpl* doc );
407
408
/* everything is allowed in proprietary version of HTML */
408
409
/* this is handled here rather than in the tag/attr dicts */
410
void ConstrainVersion( TidyDocImpl* doc, uint vers );
412
Bool IsWhite(uint c);
413
Bool IsDigit(uint c);
414
Bool IsLetter(uint c);
415
Bool IsNewline(uint c);
416
Bool IsNamechar(uint c);
417
Bool IsXMLLetter(uint c);
418
Bool IsXMLNamechar(uint c);
420
Bool IsLower(uint c);
421
Bool IsUpper(uint c);
422
uint ToLower(uint c);
423
uint ToUpper(uint c);
425
char FoldCase( TidyDocImpl* doc, tmbchar c, Bool tocaps );
428
Lexer* NewLexer( TidyDocImpl* doc );
429
Bool EndOfInput( TidyDocImpl* doc );
430
void FreeLexer( TidyDocImpl* doc );
411
void TY_(ConstrainVersion)( TidyDocImpl* doc, uint vers );
413
Bool TY_(IsWhite)(uint c);
414
Bool TY_(IsDigit)(uint c);
415
Bool TY_(IsLetter)(uint c);
416
Bool TY_(IsNewline)(uint c);
417
Bool TY_(IsNamechar)(uint c);
418
Bool TY_(IsXMLLetter)(uint c);
419
Bool TY_(IsXMLNamechar)(uint c);
421
/* Bool IsLower(uint c); */
422
Bool TY_(IsUpper)(uint c);
423
uint TY_(ToLower)(uint c);
424
uint TY_(ToUpper)(uint c);
426
Lexer* TY_(NewLexer)( TidyDocImpl* doc );
427
void TY_(FreeLexer)( TidyDocImpl* doc );
432
429
/* store character c as UTF-8 encoded byte stream */
433
void AddCharToLexer( Lexer *lexer, uint c );
430
void TY_(AddCharToLexer)( Lexer *lexer, uint c );
436
433
Used for elements and text nodes
445
442
list of AttVal nodes which hold the
446
443
strings for attribute/value pairs.
448
Node* NewNode( Lexer* lexer );
445
Node* TY_(NewNode)( TidyAllocator* allocator, Lexer* lexer );
451
448
/* used to clone heading nodes when split by an <HR> */
452
Node *CloneNode( TidyDocImpl* doc, Node *element );
449
Node* TY_(CloneNode)( TidyDocImpl* doc, Node *element );
454
451
/* free node's attributes */
455
void FreeAttrs( TidyDocImpl* doc, Node *node );
452
void TY_(FreeAttrs)( TidyDocImpl* doc, Node *node );
457
454
/* doesn't repair attribute list linkage */
458
void FreeAttribute( TidyDocImpl* doc, AttVal *av );
455
void TY_(FreeAttribute)( TidyDocImpl* doc, AttVal *av );
460
457
/* detach attribute from node */
461
void DetachAttribute( Node *node, AttVal *attr );
458
void TY_(DetachAttribute)( Node *node, AttVal *attr );
463
460
/* detach attribute from node then free it
465
void RemoveAttribute( TidyDocImpl* doc, Node *node, AttVal *attr );
462
void TY_(RemoveAttribute)( TidyDocImpl* doc, Node *node, AttVal *attr );
468
465
Free document nodes by iterating through peers and recursing
469
466
through children. Set next to NULL before calling FreeNode()
470
467
to avoid freeing peer nodes. Doesn't patch up prev/next links.
472
void FreeNode( TidyDocImpl* doc, Node *node );
469
void TY_(FreeNode)( TidyDocImpl* doc, Node *node );
474
Node* TextToken( Lexer *lexer );
471
Node* TY_(TextToken)( Lexer *lexer );
476
473
/* used for creating preformatted text from Word2000 */
477
Node *NewLineNode( Lexer *lexer );
474
Node* TY_(NewLineNode)( Lexer *lexer );
479
476
/* used for adding a for Word2000 */
480
Node *NewLiteralTextNode(Lexer *lexer, ctmbstr txt );
482
Node* CommentToken(Lexer *lexer);
483
Node* GetCDATA( TidyDocImpl* doc, Node *container );
485
void AddByte( Lexer *lexer, tmbchar c );
486
void AddStringLiteral( Lexer* lexer, ctmbstr str );
487
void AddStringLiteralLen( Lexer* lexer, ctmbstr str, int len );
477
Node* TY_(NewLiteralTextNode)(Lexer *lexer, ctmbstr txt );
479
void TY_(AddStringLiteral)( Lexer* lexer, ctmbstr str );
480
/* void AddStringLiteralLen( Lexer* lexer, ctmbstr str, int len ); */
489
482
/* find element */
490
Node* FindDocType( TidyDocImpl* doc );
491
Node* FindHTML( TidyDocImpl* doc );
492
Node* FindHEAD( TidyDocImpl* doc );
493
Node* FindTITLE(TidyDocImpl* doc);
494
Node* FindBody( TidyDocImpl* doc );
495
Node* FindXmlDecl(TidyDocImpl* doc);
483
Node* TY_(FindDocType)( TidyDocImpl* doc );
484
Node* TY_(FindHTML)( TidyDocImpl* doc );
485
Node* TY_(FindHEAD)( TidyDocImpl* doc );
486
Node* TY_(FindTITLE)(TidyDocImpl* doc);
487
Node* TY_(FindBody)( TidyDocImpl* doc );
488
Node* TY_(FindXmlDecl)(TidyDocImpl* doc);
497
490
/* Returns containing block element, if any */
498
Node* FindContainer( Node* node );
491
Node* TY_(FindContainer)( Node* node );
500
493
/* add meta element for Tidy */
501
Bool AddGenerator( TidyDocImpl* doc );
503
/* examine <!DOCTYPE> to identify version */
504
uint FindGivenVersion( TidyDocImpl* doc, Node* doctype );
505
uint ApparentVersion( TidyDocImpl* doc );
508
Bool CheckDocTypeKeyWords(Lexer *lexer, Node *doctype);
510
ctmbstr HTMLVersionName( TidyDocImpl* doc );
511
ctmbstr HTMLVersionNameFromCode( uint vers, Bool isXhtml );
513
Bool SetXHTMLDocType( TidyDocImpl* doc );
494
Bool TY_(AddGenerator)( TidyDocImpl* doc );
496
uint TY_(ApparentVersion)( TidyDocImpl* doc );
498
ctmbstr TY_(HTMLVersionNameFromCode)( uint vers, Bool isXhtml );
500
Bool TY_(WarnMissingSIInEmittedDocType)( TidyDocImpl* doc );
502
Bool TY_(SetXHTMLDocType)( TidyDocImpl* doc );
516
505
/* fixup doctype if missing */
517
Bool FixDocType( TidyDocImpl* doc );
506
Bool TY_(FixDocType)( TidyDocImpl* doc );
519
508
/* ensure XML document starts with <?xml version="1.0"?> */
520
509
/* add encoding attribute if not using ASCII or UTF-8 output */
521
Bool FixXmlDecl( TidyDocImpl* doc );
523
Node* InferredTag(TidyDocImpl* doc, TidyTagId id);
525
Bool ExpectsContent(Node *node);
528
void UngetToken( TidyDocImpl* doc );
510
Bool TY_(FixXmlDecl)( TidyDocImpl* doc );
512
Node* TY_(InferredTag)(TidyDocImpl* doc, TidyTagId id);
514
void TY_(UngetToken)( TidyDocImpl* doc );
535
521
Preformatted -- white space preserved as is
536
522
IgnoreMarkup -- for CDATA elements such as script, style
538
#define IgnoreWhitespace 0
539
#define MixedContent 1
540
#define Preformatted 2
541
#define IgnoreMarkup 3
542
#define CdataContent 4
544
Node* GetToken( TidyDocImpl* doc, uint mode );
548
Bool IsValidAttrName( ctmbstr attr );
533
Node* TY_(GetToken)( TidyDocImpl* doc, GetTokenMode mode );
535
void TY_(InitMap)(void);
551
538
/* create a new attribute */
552
AttVal *NewAttribute(void);
539
AttVal* TY_(NewAttribute)( TidyDocImpl* doc );
554
541
/* create a new attribute with given name and value */
555
AttVal *NewAttributeEx( TidyDocImpl* doc, ctmbstr name, ctmbstr value,
542
AttVal* TY_(NewAttributeEx)( TidyDocImpl* doc, ctmbstr name, ctmbstr value,
558
545
/* insert attribute at the end of attribute list of a node */
559
void InsertAttributeAtEnd( Node *node, AttVal *av );
546
void TY_(InsertAttributeAtEnd)( Node *node, AttVal *av );
561
548
/* insert attribute at the start of attribute list of a node */
562
void InsertAttributeAtStart( Node *node, AttVal *av );
549
void TY_(InsertAttributeAtStart)( Node *node, AttVal *av );
564
551
/*************************************
565
552
In-line Stack functions