1 #ifndef __PPRINT_H__
2 #define __PPRINT_H__
3 
4 /* pprint.h -- pretty print parse tree
5 
6    (c) 1998-2007 (W3C) MIT, ERCIM, Keio University
7    See tidy.h for the copyright notice.
8 
9    CVS Info:
10      $Author: arnaud02 $
11      $Date: 2007/02/11 09:45:08 $
12      $Revision: 1.9 $
13 
14 */
15 
16 #include "forward.h"
17 
18 /*
19   Block-level and unknown elements are printed on
20   new lines and their contents indented 2 spaces
21 
22   Inline elements are printed inline.
23 
24   Inline content is wrapped on spaces (except in
25   attribute values or preformatted text, after
26   start tags and before end tags
27 */
28 
29 #define NORMAL        0u
30 #define PREFORMATTED  1u
31 #define COMMENT       2u
32 #define ATTRIBVALUE   4u
33 #define NOWRAP        8u
34 #define CDATA         16u
35 
36 
37 /* The pretty printer keeps at most two lines of text in the
38 ** buffer before flushing output.  We need to capture the
39 ** indent state (indent level) at the _beginning_ of _each_
40 ** line, not the end of just the second line.
41 **
42 ** We must also keep track "In Attribute" and "In String"
43 ** states at the _end_ of each line,
44 */
45 
46 typedef struct _TidyIndent
47 {
48     int spaces;
49     int attrValStart;
50     int attrStringStart;
51 } TidyIndent;
52 
53 typedef struct _TidyPrintImpl
54 {
55     TidyAllocator *allocator; /* Allocator */
56 
57     uint *linebuf;
58     uint lbufsize;
59     uint linelen;
60     uint wraphere;
61 
62     uint ixInd;
63     TidyIndent indent[2];  /* Two lines worth of indent state */
64 } TidyPrintImpl;
65 
66 
67 #if 0 && SUPPORT_ASIAN_ENCODINGS
68 /* #431953 - start RJ Wraplen adjusted for smooth international ride */
69 uint CWrapLen( TidyDocImpl* doc, uint ind );
70 #endif
71 
72 void TY_(InitPrintBuf)( TidyDocImpl* doc );
73 void TY_(FreePrintBuf)( TidyDocImpl* doc );
74 
75 void TY_(PFlushLine)( TidyDocImpl* doc, uint indent );
76 
77 
78 /* print just the content of the body element.
79 ** useful when you want to reuse material from
80 ** other documents.
81 **
82 ** -- Sebastiano Vigna <vigna@dsi.unimi.it>
83 */
84 
85 void TY_(PrintBody)( TidyDocImpl* doc );       /* you can print an entire document */
86                                           /* node as body using PPrintTree() */
87 
88 void TY_(PPrintTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node );
89 
90 void TY_(PPrintXMLTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node );
91 
92 
93 #endif /* __PPRINT_H__ */
94