diff -u tidy4aug00.old/config.c tidy4aug00/config.c --- tidy4aug00.old/config.c Fri Aug 4 12:21:05 2000 +++ tidy4aug00/config.c Tue Jun 19 17:13:35 2001 @@ -94,6 +94,7 @@ Bool TidyMark = yes; /* add meta element indicating tidied doc */ Bool Emacs = no; /* if true format error output for GNU Emacs */ Bool LiteralAttribs = no; /* if true attributes may use newlines */ +Bool BodyOnly = no; /* if set to yes don't generate and header */ typedef struct _lex PLex; @@ -186,6 +187,7 @@ {"doctype", {(int *)&doctype_str}, ParseDocType}, {"fix-backslash", {(int *)&FixBackslash}, ParseBool}, {"gnu-emacs", {(int *)&Emacs}, ParseBool}, + {"body-only", {(int *)&BodyOnly}, ParseBool}, /* this must be the final entry */ {0, 0, 0} diff -u tidy4aug00.old/html.h tidy4aug00/html.h --- tidy4aug00.old/html.h Fri Aug 4 12:21:05 2000 +++ tidy4aug00/html.h Tue Jun 19 17:13:35 2001 @@ -758,6 +758,7 @@ extern Bool Word2000; extern Bool Emacs; /* sasdjb 01May00 GNU Emacs error output format */ extern Bool LiteralAttribs; +extern Bool BodyOnly; /* Parser methods for tags */ diff -u tidy4aug00.old/parser.c tidy4aug00/parser.c --- tidy4aug00.old/parser.c Fri Aug 4 12:21:05 2000 +++ tidy4aug00/parser.c Tue Jun 19 17:23:26 2001 @@ -2577,6 +2577,9 @@ break; } + if ((node->tag->model & CM_HEAD) && BodyOnly) + continue; + if (node->type == TextNode) { UngetToken(lexer); @@ -2607,7 +2610,7 @@ break; } - if (node->type == StartTag || node->type == StartEndTag) + if ((node->type == StartTag || node->type == StartEndTag) && !BodyOnly) { if (node->tag == tag_title) { @@ -2636,7 +2639,7 @@ FreeNode(node); } - if (HasTitle == 0) + if ((HasTitle == 0) && !BodyOnly) { ReportWarning(lexer, head, null, MISSING_TITLE_ELEMENT); InsertNodeAtEnd(head, InferredTag(lexer, "title")); @@ -3062,7 +3065,8 @@ } head = node; - InsertNodeAtEnd(html, head); + if (!BodyOnly) + InsertNodeAtEnd(html, head); ParseHead(lexer, head, mode); for (;;) @@ -3260,8 +3264,15 @@ else html = node; - InsertNodeAtEnd(document, html); - ParseHTML(lexer, html, no); + if (!BodyOnly) + { + InsertNodeAtEnd(document, html); + ParseHTML(lexer, html, no); + } + else + { + ParseHTML(lexer, document, no); + }; break; }