Click here to Skip to main content
15,884,237 members
Articles / Programming Languages / Visual Basic

EfTidy: The Tidy Library Wrapper

Rate me:
Please Sign up or sign in to vote.
4.91/5 (36 votes)
6 Sep 2013GPL310 min read 185K   5K   88  
A free component for HTML parsing and cleaning
#ifndef __PPRINT_H__
#define __PPRINT_H__

/* pprint.h -- pretty print parse tree  
  
   (c) 1998-2003 (W3C) MIT, ERCIM, Keio University
   See tidy.h for the copyright notice.
  
   CVS Info:
     $Author: hoehrmann $ 
     $Date: 2003/05/24 15:55:02 $ 
     $Revision: 1.4 $ 

*/

#include "forward.h"

/*
  Block-level and unknown elements are printed on
  new lines and their contents indented 2 spaces

  Inline elements are printed inline.

  Inline content is wrapped on spaces (except in
  attribute values or preformatted text, after
  start tags and before end tags
*/

#define NORMAL        0
#define PREFORMATTED  1
#define COMMENT       2
#define ATTRIBVALUE   4
#define NOWRAP        8
#define CDATA         16


/* The pretty printer keeps at most two lines of text in the
** buffer before flushing output.  We need to capture the
** indent state (indent level) at the _beginning_ of _each_
** line, not the end of just the second line.
**
** We must also keep track "In Attribute" and "In String"
** states at the _end_ of each line, 
*/

typedef struct _TidyIndent
{
    int spaces;
    int attrValStart;
    int attrStringStart;
} TidyIndent;

typedef struct _TidyPrintImpl
{
    uint *linebuf;
    uint lbufsize;
    uint linelen;
    uint wraphere;
    uint linecount;
  
    uint ixInd;
    TidyIndent indent[2];  /* Two lines worth of indent state */

} TidyPrintImpl;

void PPrintDocument( TidyDocImpl* doc );


#if SUPPORT_ASIAN_ENCODINGS
/* #431953 - start RJ Wraplen adjusted for smooth international ride */
uint CWrapLen( TidyDocImpl* doc, uint ind );
#endif

void InitPrintBuf( TidyDocImpl* doc );
void FreePrintBuf( TidyDocImpl* doc );

void PFlushLine( TidyDocImpl* doc, uint indent );
void PCondFlushLine( TidyDocImpl* doc, uint indent );

void PPrintScriptStyle( TidyDocImpl* doc, uint mode, uint indent, Node* node );

/* print just the content of the body element.
** useful when you want to reuse material from
** other documents.
** 
** -- Sebastiano Vigna <vigna@dsi.unimi.it>
*/

void PrintPreamble( TidyDocImpl* doc );   /* Between these 3, */
void PrintBody( TidyDocImpl* doc );       /* you can print an entire document */
void PrintPostamble( TidyDocImpl* doc );  /* or you can substitute another */
                                          /* node as body using PPrintTree() */

void PPrintTree( TidyDocImpl* doc, uint mode, uint indent, Node *node );

void PPrintXMLTree( TidyDocImpl* doc, uint mode, uint indent, Node *node );


#endif /* __PPRINT_H__ */

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer (Senior)
India India
He used to have biography here Smile | :) , but now he will hire someone (for free offcourse Big Grin | :-D ), Who writes his biography on his behalf Smile | :)

He is Great Fan of Mr. Johan Rosengren (his idol),Lim Bio Liong, Nishant S and DavidCrow and Believes that, he will EXCEL in his life by following there steps!!!

He started with Visual C++ then moved to C# then he become language agnostic, you give him task,tell him the language or platform, he we start immediately, if he knows the language otherwise he quickly learn it and start contributing productively

Last but not the least, For good 8 years he was Visual CPP MSMVP!

Comments and Discussions