Primarily documentation of the pprint.c/h, with some file organization and

function cleanup.
This commit is contained in:
Jim Derry 2021-08-18 17:30:36 -04:00
parent bde08388dc
commit 0fe913eb76
7 changed files with 944 additions and 674 deletions

View file

@ -158,6 +158,7 @@ typedef enum
#define CM_OBSOLETE (1 << 19) /**< Elements that are obsolete (such as "dir", "menu"). */
#define CM_NEW (1 << 20) /**< User defined elements. Used to determine how attributes without value should be printed. */
#define CM_OMITST (1 << 21) /**< Elements that cannot be omitted. */
#define CM_VOID (1 << 22) /**< Elements that are void per https://www.w3.org/TR/2011/WD-html-markup-20110113/syntax.html#syntax-elements. */
/**
@ -649,7 +650,7 @@ TY_PRIVATE int TY_(InlineDup)( TidyDocImpl* doc, Node *node );
/**
* Fefer duplicates when entering a table or other
* Defer duplicates when entering a table or other
* element where the inlines shouldn't be duplicated.
*/
TY_PRIVATE void TY_(DeferDup)( TidyDocImpl* doc );

View file

@ -1156,7 +1156,7 @@ Node* TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode )
{
/* Issue #212 - Further fix in case ParseBlock() is called with 'IgnoreWhitespace'
when such a leading space may need to be inserted before this element to
preverve the browser view */
preserve the browser view */
mode = MixedContent;
}
} /* Re-Entering */
@ -5873,7 +5873,7 @@ Node* TY_(DropEmptyElements)(TidyDocImpl* doc, Node* node)
/** MARK: TY_(InsertNodeAtStart)
* Insert node into markup tree as the firt element of content of element.
* Insert node into markup tree as the first element of content of element.
*/
void TY_(InsertNodeAtStart)(Node *element, Node *node)
{
@ -6311,14 +6311,3 @@ void TY_(ParseXMLDocument)(TidyDocImpl* doc)
if ( cfgBool(doc, TidyXmlDecl) )
TY_(FixXmlDecl)( doc );
}
/*
* local variables:
* mode: c
* indent-tabs-mode: nil
* c-basic-offset: 4
* eval: (c-set-offset 'substatement-open 0)
* end:
*/

File diff suppressed because it is too large Load diff

View file

@ -1,89 +1,143 @@
#ifndef __PPRINT_H__
#define __PPRINT_H__
/* pprint.h -- pretty print parse tree
(c) 1998-2007 (W3C) MIT, ERCIM, Keio University
See tidy.h for the copyright notice.
*/
/**************************************************************************//**
* @file
* Pretty Print the parse tree.
*
* Pretty printer for HTML and XML documents.
* - Block-level and unknown elements are printed on new lines and
* their contents indented with a user configured amount of spaces/tabs.
* - 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.
*
* @author HTACG, et al (consult git log)
*
* @copyright
* Copyright (c) 1998-2021 World Wide Web Consortium (Massachusetts
* Institute of Technology, European Research Consortium for Informatics
* and Mathematics, Keio University) and HTACG.
* @par
* All Rights Reserved.
* @par
* See `tidy.h` for the complete license.
*
* @date Additional updates: consult git log
*
******************************************************************************/
#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 0u
#define PREFORMATTED 1u
#define COMMENT 2u
#define ATTRIBVALUE 4u
#define NOWRAP 8u
#define CDATA 16u
/** @addtogroup internal_api */
/** @{ */
/* 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.
/***************************************************************************//**
** @defgroup print_h HTML and XML Pretty Printing
**
** We must also keep track "In Attribute" and "In String"
** states at the _end_ of each line,
*/
** These functions and structures form the internal API for document
** printing.
**
** @{
******************************************************************************/
/**
* This typedef represents the current pretty-printing mode, and instructs
* the printer behavior per the content currently being output.
*/
typedef enum {
NORMAL = 0u, /**< Normal output. */
PREFORMATTED = 1u, /**< Preformatted output. */
COMMENT = 2u, /**< Comment. */
ATTRIBVALUE = 4u, /**< An attribute's value. */
NOWRAP = 8u, /**< Content that should not be wrapped. */
CDATA = 16u /**< CDATA content. */
} PrettyPrintMode;
/**
* A record of the state of a single line, capturing the indent
* level, in-attribute, and in-string state of a line. Instances
* of this record are used by the pretty-printing buffer.
*
* 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;
int spaces; /**< Indent level of the line. */
int attrValStart; /**< Attribute in-value state. */
int attrStringStart; /**< Attribute in-string state. */
} TidyIndent;
/**
* The pretty-printing buffer.
*/
typedef struct _TidyPrintImpl
{
TidyAllocator *allocator; /* Allocator */
TidyAllocator *allocator; /**< Allocator */
uint *linebuf;
uint lbufsize;
uint linelen;
uint wraphere;
uint line;
uint *linebuf; /**< The line buffer proper. */
uint lbufsize; /**< Current size of the buffer. */
uint linelen; /**< Current line length. */
uint wraphere; /**< Point in the line to wrap text. */
uint line; /**< Current line. */
uint ixInd;
TidyIndent indent[2]; /* Two lines worth of indent state */
uint ixInd; /**< Index into the indent[] array. */
TidyIndent indent[2]; /**< Two lines worth of indent state */
} TidyPrintImpl;
/**
* Allocates and initializes the pretty-printing buffer for a Tidy document.
*/
TY_PRIVATE void TY_(InitPrintBuf)( TidyDocImpl* doc );
/**
* Deallocates and free a Tidy document's pretty-printing buffer.
*/
TY_PRIVATE void TY_(FreePrintBuf)( TidyDocImpl* doc );
/**
* Flushes the current buffer to the actual output sink.
*/
TY_PRIVATE void TY_(PFlushLine)( TidyDocImpl* doc, uint indent );
/* print just the content of the body element.
** useful when you want to reuse material from
** other documents.
**
** -- Sebastiano Vigna <vigna@dsi.unimi.it>
/**
* Print just the content of the HTML body element, which is useful when
* want to reuse material from other documents.
* -- Sebastiano Vigna <vigna@dsi.unimi.it>
*/
TY_PRIVATE void TY_(PrintBody)( TidyDocImpl* doc );
TY_PRIVATE void TY_(PrintBody)( TidyDocImpl* doc ); /* you can print an entire document */
/* node as body using PPrintTree() */
/**
* Print the HTML document tree for the given document using the given node
* as the root of the document. Note that you can print an entire document
* node as body using PPrintTree()
*/
TY_PRIVATE void TY_(PPrintTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node );
/**
* Print the XML document tree for the given document using the given node
* as the root of the document.
*/
TY_PRIVATE void TY_(PPrintXMLTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node );
/*\
* 20150515 - support using tabs instead of spaces
\*/
TY_PRIVATE void TY_(PPrintTabs)(void);
TY_PRIVATE void TY_(PPrintSpaces)(void);
/** @} end print_h group */
/** @} end internal_api group */
#endif /* __PPRINT_H__ */

View file

@ -176,21 +176,21 @@ static TIDY_THREAD_LOCAL Dict tag_defs[] =
{ TidyTag_ACRONYM, "acronym", VERS_ELEM_ACRONYM, &TY_(W3CAttrsFor_ACRONYM)[0], (CM_INLINE), TY_(ParseInline), NULL },
{ TidyTag_ADDRESS, "address", VERS_ELEM_ADDRESS, &TY_(W3CAttrsFor_ADDRESS)[0], (CM_BLOCK), TY_(ParseBlock), NULL },
{ TidyTag_APPLET, "applet", VERS_ELEM_APPLET, &TY_(W3CAttrsFor_APPLET)[0], (CM_OBJECT|CM_IMG|CM_INLINE|CM_PARAM), TY_(ParseBlock), NULL },
{ TidyTag_AREA, "area", VERS_ELEM_AREA, &TY_(W3CAttrsFor_AREA)[0], (CM_BLOCK|CM_EMPTY), TY_(ParseEmpty), CheckAREA },
{ TidyTag_AREA, "area", VERS_ELEM_AREA, &TY_(W3CAttrsFor_AREA)[0], (CM_BLOCK|CM_EMPTY|CM_VOID), TY_(ParseEmpty), CheckAREA },
{ TidyTag_B, "b", VERS_ELEM_B, &TY_(W3CAttrsFor_B)[0], (CM_INLINE), TY_(ParseInline), NULL },
{ TidyTag_BASE, "base", VERS_ELEM_BASE, &TY_(W3CAttrsFor_BASE)[0], (CM_HEAD|CM_EMPTY), TY_(ParseEmpty), NULL },
{ TidyTag_BASE, "base", VERS_ELEM_BASE, &TY_(W3CAttrsFor_BASE)[0], (CM_HEAD|CM_EMPTY|CM_VOID), TY_(ParseEmpty), NULL },
{ TidyTag_BASEFONT, "basefont", VERS_ELEM_BASEFONT, &TY_(W3CAttrsFor_BASEFONT)[0], (CM_INLINE|CM_EMPTY), TY_(ParseEmpty), NULL },
{ TidyTag_BDO, "bdo", VERS_ELEM_BDO, &TY_(W3CAttrsFor_BDO)[0], (CM_INLINE), TY_(ParseInline), NULL },
{ TidyTag_BIG, "big", VERS_ELEM_BIG, &TY_(W3CAttrsFor_BIG)[0], (CM_INLINE), TY_(ParseInline), NULL },
{ TidyTag_BLOCKQUOTE, "blockquote", VERS_ELEM_BLOCKQUOTE, &TY_(W3CAttrsFor_BLOCKQUOTE)[0], (CM_BLOCK), TY_(ParseBlock), NULL },
{ TidyTag_BODY, "body", VERS_ELEM_BODY, &TY_(W3CAttrsFor_BODY)[0], (CM_HTML|CM_OPT|CM_OMITST), TY_(ParseBody), NULL },
{ TidyTag_BR, "br", VERS_ELEM_BR, &TY_(W3CAttrsFor_BR)[0], (CM_INLINE|CM_EMPTY), TY_(ParseEmpty), NULL },
{ TidyTag_BR, "br", VERS_ELEM_BR, &TY_(W3CAttrsFor_BR)[0], (CM_INLINE|CM_EMPTY|CM_VOID), TY_(ParseEmpty), NULL },
{ TidyTag_BUTTON, "button", VERS_ELEM_BUTTON, &TY_(W3CAttrsFor_BUTTON)[0], (CM_INLINE), TY_(ParseInline), NULL },
{ TidyTag_CAPTION, "caption", VERS_ELEM_CAPTION, &TY_(W3CAttrsFor_CAPTION)[0], (CM_TABLE), TY_(ParseBlock), CheckCaption },
{ TidyTag_CENTER, "center", VERS_ELEM_CENTER, &TY_(W3CAttrsFor_CENTER)[0], (CM_BLOCK), TY_(ParseBlock), NULL },
{ TidyTag_CITE, "cite", VERS_ELEM_CITE, &TY_(W3CAttrsFor_CITE)[0], (CM_INLINE), TY_(ParseInline), NULL },
{ TidyTag_CODE, "code", VERS_ELEM_CODE, &TY_(W3CAttrsFor_CODE)[0], (CM_INLINE), TY_(ParseInline), NULL },
{ TidyTag_COL, "col", VERS_ELEM_COL, &TY_(W3CAttrsFor_COL)[0], (CM_TABLE|CM_EMPTY), TY_(ParseEmpty), NULL },
{ TidyTag_COL, "col", VERS_ELEM_COL, &TY_(W3CAttrsFor_COL)[0], (CM_TABLE|CM_EMPTY|CM_VOID), TY_(ParseEmpty), NULL },
{ TidyTag_COLGROUP, "colgroup", VERS_ELEM_COLGROUP, &TY_(W3CAttrsFor_COLGROUP)[0], (CM_TABLE|CM_OPT), TY_(ParseColGroup), NULL },
{ TidyTag_DD, "dd", VERS_ELEM_DD, &TY_(W3CAttrsFor_DD)[0], (CM_DEFLIST|CM_OPT|CM_NO_INDENT), TY_(ParseBlock), NULL },
{ TidyTag_DEL, "del", VERS_ELEM_DEL, &TY_(W3CAttrsFor_DEL)[0], (CM_INLINE|CM_BLOCK|CM_MIXED), TY_(ParseInline), NULL },
@ -213,24 +213,24 @@ static TIDY_THREAD_LOCAL Dict tag_defs[] =
{ TidyTag_H5, "h5", VERS_ELEM_H5, &TY_(W3CAttrsFor_H5)[0], (CM_BLOCK|CM_HEADING), TY_(ParseInline), NULL },
{ TidyTag_H6, "h6", VERS_ELEM_H6, &TY_(W3CAttrsFor_H6)[0], (CM_BLOCK|CM_HEADING), TY_(ParseInline), NULL },
{ TidyTag_HEAD, "head", VERS_ELEM_HEAD, &TY_(W3CAttrsFor_HEAD)[0], (CM_HTML|CM_OPT|CM_OMITST), TY_(ParseHead), NULL },
{ TidyTag_HR, "hr", VERS_ELEM_HR, &TY_(W3CAttrsFor_HR)[0], (CM_BLOCK|CM_EMPTY), TY_(ParseEmpty), NULL },
{ TidyTag_HR, "hr", VERS_ELEM_HR, &TY_(W3CAttrsFor_HR)[0], (CM_BLOCK|CM_EMPTY|CM_VOID), TY_(ParseEmpty), NULL },
{ TidyTag_HTML, "html", VERS_ELEM_HTML, &TY_(W3CAttrsFor_HTML)[0], (CM_HTML|CM_OPT|CM_OMITST), TY_(ParseHTML), CheckHTML },
{ TidyTag_I, "i", VERS_ELEM_I, &TY_(W3CAttrsFor_I)[0], (CM_INLINE), TY_(ParseInline), NULL },
{ TidyTag_IFRAME, "iframe", VERS_ELEM_IFRAME, &TY_(W3CAttrsFor_IFRAME)[0], (CM_INLINE), TY_(ParseBlock), NULL },
{ TidyTag_IMG, "img", VERS_ELEM_IMG, &TY_(W3CAttrsFor_IMG)[0], (CM_INLINE|CM_IMG|CM_EMPTY), TY_(ParseEmpty), CheckIMG },
{ TidyTag_INPUT, "input", VERS_ELEM_INPUT, &TY_(W3CAttrsFor_INPUT)[0], (CM_INLINE|CM_IMG|CM_EMPTY), TY_(ParseEmpty), NULL },
{ TidyTag_IMG, "img", VERS_ELEM_IMG, &TY_(W3CAttrsFor_IMG)[0], (CM_INLINE|CM_IMG|CM_EMPTY|CM_VOID), TY_(ParseEmpty), CheckIMG },
{ TidyTag_INPUT, "input", VERS_ELEM_INPUT, &TY_(W3CAttrsFor_INPUT)[0], (CM_INLINE|CM_IMG|CM_EMPTY|CM_VOID), TY_(ParseEmpty), NULL },
{ TidyTag_INS, "ins", VERS_ELEM_INS, &TY_(W3CAttrsFor_INS)[0], (CM_INLINE|CM_BLOCK|CM_MIXED), TY_(ParseInline), NULL },
{ TidyTag_ISINDEX, "isindex", VERS_ELEM_ISINDEX, &TY_(W3CAttrsFor_ISINDEX)[0], (CM_BLOCK|CM_EMPTY), TY_(ParseEmpty), NULL },
{ TidyTag_KBD, "kbd", VERS_ELEM_KBD, &TY_(W3CAttrsFor_KBD)[0], (CM_INLINE), TY_(ParseInline), NULL },
{ TidyTag_LABEL, "label", VERS_ELEM_LABEL, &TY_(W3CAttrsFor_LABEL)[0], (CM_INLINE), TY_(ParseInline), NULL },
{ TidyTag_LEGEND, "legend", VERS_ELEM_LEGEND, &TY_(W3CAttrsFor_LEGEND)[0], (CM_INLINE), TY_(ParseInline), NULL },
{ TidyTag_LI, "li", VERS_ELEM_LI, &TY_(W3CAttrsFor_LI)[0], (CM_LIST|CM_OPT|CM_NO_INDENT), TY_(ParseBlock), NULL },
{ TidyTag_LINK, "link", VERS_ELEM_LINK, &TY_(W3CAttrsFor_LINK)[0], (CM_HEAD|CM_BLOCK|CM_EMPTY), TY_(ParseEmpty), CheckLINK },
{ TidyTag_LINK, "link", VERS_ELEM_LINK, &TY_(W3CAttrsFor_LINK)[0], (CM_HEAD|CM_BLOCK|CM_EMPTY|CM_VOID), TY_(ParseEmpty), CheckLINK },
{ TidyTag_LISTING, "listing", VERS_ELEM_LISTING, &TY_(W3CAttrsFor_LISTING)[0], (CM_BLOCK|CM_OBSOLETE), TY_(ParsePre), NULL },
{ TidyTag_MAP, "map", VERS_ELEM_MAP, &TY_(W3CAttrsFor_MAP)[0], (CM_INLINE), TY_(ParseBlock), NULL },
{ TidyTag_MATHML, "math", VERS_ELEM_MATHML, &TY_(W3CAttrsFor_MATHML)[0], (CM_INLINE|CM_BLOCK|CM_MIXED), TY_(ParseNamespace),NULL }, /* [i_a]2 */
/* { TidyTag_MENU, "menu", VERS_ELEM_MENU, &TY_(W3CAttrsFor_MENU)[0], (CM_BLOCK|CM_OBSOLETE), TY_(ParseList), NULL }, */
{ TidyTag_META, "meta", VERS_ELEM_META, &TY_(W3CAttrsFor_META)[0], (CM_HEAD|CM_BLOCK|CM_EMPTY), TY_(ParseEmpty), NULL },
{ TidyTag_META, "meta", VERS_ELEM_META, &TY_(W3CAttrsFor_META)[0], (CM_HEAD|CM_BLOCK|CM_EMPTY|CM_VOID), TY_(ParseEmpty), NULL },
{ TidyTag_NOFRAMES, "noframes", VERS_ELEM_NOFRAMES, &TY_(W3CAttrsFor_NOFRAMES)[0], (CM_BLOCK|CM_FRAMES), TY_(ParseNoFrames), NULL },
{ TidyTag_NOSCRIPT, "noscript", VERS_ELEM_NOSCRIPT, &TY_(W3CAttrsFor_NOSCRIPT)[0], (CM_HEAD|CM_BLOCK|CM_INLINE|CM_MIXED), TY_(ParseBlock), NULL },
{ TidyTag_OBJECT, "object", VERS_ELEM_OBJECT, &TY_(W3CAttrsFor_OBJECT)[0], (CM_OBJECT|CM_IMG|CM_INLINE|CM_PARAM), TY_(ParseBlock), NULL },
@ -238,7 +238,7 @@ static TIDY_THREAD_LOCAL Dict tag_defs[] =
{ TidyTag_OPTGROUP, "optgroup", VERS_ELEM_OPTGROUP, &TY_(W3CAttrsFor_OPTGROUP)[0], (CM_FIELD|CM_OPT), TY_(ParseOptGroup), NULL },
{ TidyTag_OPTION, "option", VERS_ELEM_OPTION, &TY_(W3CAttrsFor_OPTION)[0], (CM_FIELD|CM_OPT), TY_(ParseText), NULL },
{ TidyTag_P, "p", VERS_ELEM_P, &TY_(W3CAttrsFor_P)[0], (CM_BLOCK|CM_OPT), TY_(ParseInline), NULL },
{ TidyTag_PARAM, "param", VERS_ELEM_PARAM, &TY_(W3CAttrsFor_PARAM)[0], (CM_INLINE|CM_EMPTY), TY_(ParseEmpty), NULL },
{ TidyTag_PARAM, "param", VERS_ELEM_PARAM, &TY_(W3CAttrsFor_PARAM)[0], (CM_INLINE|CM_EMPTY|CM_VOID), TY_(ParseEmpty), NULL },
{ TidyTag_PICTURE, "picture", VERS_ELEM_PICTURE, &TY_(W3CAttrsFor_PICTURE)[0], (CM_INLINE), TY_(ParseInline), NULL }, /* Issue #151 html5 */
{ TidyTag_PLAINTEXT, "plaintext", VERS_ELEM_PLAINTEXT, &TY_(W3CAttrsFor_PLAINTEXT)[0], (CM_BLOCK|CM_OBSOLETE), TY_(ParsePre), NULL },
{ TidyTag_PRE, "pre", VERS_ELEM_PRE, &TY_(W3CAttrsFor_PRE)[0], (CM_BLOCK), TY_(ParsePre), NULL },
@ -300,19 +300,19 @@ static TIDY_THREAD_LOCAL Dict tag_defs[] =
{ TidyTag_AUDIO, "audio", VERS_ELEM_AUDIO, &TY_(W3CAttrsFor_AUDIO)[0], (CM_BLOCK|CM_INLINE), TY_(ParseBlock), NULL },
{ TidyTag_BDI, "bdi", VERS_ELEM_BDI, &TY_(W3CAttrsFor_BDI)[0], (CM_INLINE), TY_(ParseInline), NULL },
{ TidyTag_CANVAS, "canvas", VERS_ELEM_CANVAS, &TY_(W3CAttrsFor_CANVAS)[0], (CM_BLOCK), TY_(ParseBlock), NULL },
{ TidyTag_COMMAND, "command", VERS_ELEM_COMMAND, &TY_(W3CAttrsFor_COMMAND)[0], (CM_HEAD|CM_INLINE|CM_EMPTY), TY_(ParseEmpty), NULL },
{ TidyTag_COMMAND, "command", VERS_ELEM_COMMAND, &TY_(W3CAttrsFor_COMMAND)[0], (CM_HEAD|CM_INLINE|CM_EMPTY|CM_VOID), TY_(ParseEmpty), NULL },
{ TidyTag_DATALIST, "datalist", VERS_ELEM_DATALIST, &TY_(W3CAttrsFor_DATALIST)[0], (CM_INLINE|CM_FIELD), TY_(ParseDatalist), NULL },
/* { TidyTag_DATALIST, "datalist", VERS_ELEM_DATALIST, &TY_(W3CAttrsFor_DATALIST)[0], (CM_FIELD), TY_(ParseInline), NULL },*/
{ TidyTag_DATA, "data", VERS_ELEM_DATA, &TY_(W3CAttrsFor_DATA)[0], (CM_INLINE), TY_(ParseInline), NULL },
{ TidyTag_DETAILS, "details", VERS_ELEM_DETAILS, &TY_(W3CAttrsFor_DETAILS)[0], (CM_BLOCK), TY_(ParseBlock), NULL },
{ TidyTag_DIALOG, "dialog", VERS_ELEM_DIALOG, &TY_(W3CAttrsFor_DIALOG)[0], (CM_BLOCK), TY_(ParseBlock), NULL },
{ TidyTag_EMBED, "embed", VERS_ELEM_EMBED, &TY_(W3CAttrsFor_EMBED)[0], (CM_INLINE|CM_IMG|CM_EMPTY), TY_(ParseEmpty), NULL },
{ TidyTag_EMBED, "embed", VERS_ELEM_EMBED, &TY_(W3CAttrsFor_EMBED)[0], (CM_INLINE|CM_IMG|CM_EMPTY|CM_VOID), TY_(ParseEmpty), NULL },
{ TidyTag_FIGCAPTION, "figcaption", VERS_ELEM_FIGCAPTION, &TY_(W3CAttrsFor_FIGCAPTION)[0], (CM_BLOCK), TY_(ParseBlock), NULL },
{ TidyTag_FIGURE, "figure", VERS_ELEM_FIGURE, &TY_(W3CAttrsFor_FIGURE)[0], (CM_BLOCK), TY_(ParseBlock), NULL },
{ TidyTag_FOOTER, "footer", VERS_ELEM_FOOTER, &TY_(W3CAttrsFor_FOOTER)[0], (CM_BLOCK), TY_(ParseBlock), NULL },
{ TidyTag_HEADER, "header", VERS_ELEM_HEADER, &TY_(W3CAttrsFor_HEADER)[0], (CM_BLOCK), TY_(ParseBlock), NULL },
{ TidyTag_HGROUP, "hgroup", VERS_ELEM_HGROUP, &TY_(W3CAttrsFor_HGROUP)[0], (CM_BLOCK), TY_(ParseBlock), NULL },
{ TidyTag_KEYGEN, "keygen", VERS_ELEM_KEYGEN, &TY_(W3CAttrsFor_KEYGEN)[0], (CM_INLINE|CM_EMPTY), TY_(ParseEmpty), NULL },
{ TidyTag_KEYGEN, "keygen", VERS_ELEM_KEYGEN, &TY_(W3CAttrsFor_KEYGEN)[0], (CM_INLINE|CM_EMPTY|CM_VOID), TY_(ParseEmpty), NULL },
{ TidyTag_MAIN, "main", VERS_ELEM_MAIN, &TY_(W3CAttrsFor_MAIN)[0], (CM_BLOCK), TY_(ParseBlock), NULL },
{ TidyTag_MARK, "mark", VERS_ELEM_MARK, &TY_(W3CAttrsFor_MARK)[0], (CM_INLINE), TY_(ParseInline), NULL },
{ TidyTag_MENU, "menu", VERS_ELEM_MENU, &TY_(W3CAttrsFor_MENU)[0], (CM_BLOCK), TY_(ParseBlock), NULL },
@ -323,13 +323,13 @@ static TIDY_THREAD_LOCAL Dict tag_defs[] =
{ TidyTag_PROGRESS, "progress", VERS_ELEM_PROGRESS, &TY_(W3CAttrsFor_PROGRESS)[0], (CM_INLINE), TY_(ParseInline), NULL },
{ TidyTag_SECTION, "section", VERS_ELEM_SECTION, &TY_(W3CAttrsFor_SECTION)[0], (CM_BLOCK), TY_(ParseBlock), NULL },
{ TidyTag_SLOT, "slot", VERS_ELEM_SLOT, &TY_(W3CAttrsFor_SLOT)[0], (CM_BLOCK|CM_INLINE|CM_MIXED), TY_(ParseBlock), NULL },
{ TidyTag_SOURCE, "source", VERS_ELEM_SOURCE, &TY_(W3CAttrsFor_SOURCE)[0], (CM_BLOCK|CM_INLINE|CM_EMPTY), TY_(ParseBlock), NULL },
{ TidyTag_SOURCE, "source", VERS_ELEM_SOURCE, &TY_(W3CAttrsFor_SOURCE)[0], (CM_BLOCK|CM_INLINE|CM_EMPTY|CM_VOID), TY_(ParseBlock), NULL },
{ TidyTag_SUMMARY, "summary", VERS_ELEM_SUMMARY, &TY_(W3CAttrsFor_SUMMARY)[0], (CM_BLOCK), TY_(ParseBlock), NULL }, /* Is. #895 */
{ TidyTag_TEMPLATE, "template", VERS_ELEM_TEMPLATE, &TY_(W3CAttrsFor_TEMPLATE)[0], (CM_BLOCK|CM_HEAD), TY_(ParseBlock), NULL },
{ TidyTag_TIME, "time", VERS_ELEM_TIME, &TY_(W3CAttrsFor_TIME)[0], (CM_INLINE), TY_(ParseInline), NULL },
{ TidyTag_TRACK, "track", VERS_ELEM_TRACK, &TY_(W3CAttrsFor_TRACK)[0], (CM_BLOCK|CM_EMPTY), TY_(ParseBlock), NULL },
{ TidyTag_TRACK, "track", VERS_ELEM_TRACK, &TY_(W3CAttrsFor_TRACK)[0], (CM_BLOCK|CM_EMPTY|CM_VOID), TY_(ParseBlock), NULL },
{ TidyTag_VIDEO, "video", VERS_ELEM_VIDEO, &TY_(W3CAttrsFor_VIDEO)[0], (CM_BLOCK|CM_INLINE), TY_(ParseBlock), NULL },
{ TidyTag_WBR, "wbr", VERS_ELEM_WBR, &TY_(W3CAttrsFor_WBR)[0], (CM_INLINE|CM_EMPTY), TY_(ParseEmpty), NULL },
{ TidyTag_WBR, "wbr", VERS_ELEM_WBR, &TY_(W3CAttrsFor_WBR)[0], (CM_INLINE|CM_EMPTY|CM_VOID), TY_(ParseEmpty), NULL },
/* this must be the final entry */
{ (TidyTagId)0, NULL, 0, NULL, (0), NULL, NULL }

View file

@ -84,6 +84,8 @@ struct _TidyDocImpl
Bool HTML5Mode; /* current mode is html5 */
Bool xmlDetected; /* true if XML was used/detected */
uint indent_char; /* space or tab character, for indenting */
/* Memory allocator */
TidyAllocator* allocator;

View file

@ -2259,9 +2259,9 @@ int tidyDocSaveStream( TidyDocImpl* doc, StreamOut* out )
doc->pConfigChangeCallback = NULL;
if (ppWithTabs)
TY_(PPrintTabs)();
doc->indent_char = '\t';
else
TY_(PPrintSpaces)();
doc->indent_char = ' ';
if (escapeCDATA)
TY_(ConvertCDATANodes)(doc, &doc->root);