"); + else if(node->tag == tag_pre && + /* Tableprocessing */ + !DescendantOf(node, tag_th) && !DescendantOf(node, tag_td)) + PrintSgmlTagString(fout, mode, indent, sgmltag_type, + " "); + else if(node->tag == tag_a) { + if(sgmltag_type == SgmlTagStart) + PrintSgmlLink(fout, indent, node); + else if(sgmltag_type == SgmlTagEnd) + PrintSgmlLinkEnd(fout, indent, node); + } + /* Table would require more processing */ + else if(node->tag == tag_table) { + if(sgmltag_type == SgmlTagStart) + PrintSgmlTable(fout, indent, node); + else if(sgmltag_type == SgmlTagEnd) + PrintSgmlTableEnd(fout, indent, node); + } + else if(node->tag == tag_tr) + PrintSgmlTagString(fout, mode, indent, sgmltag_type, " "); + else if(node->tag == tag_td || node->tag == tag_th) + PrintSgmlTagString(fout, mode, indent, sgmltag_type, "
"); + else if(node->tag == tag_img) { /* This is a StartEndTag */ + if(sgmltag_type == SgmlTagStart) + PrintSgmlImage(fout, indent, node); + } + + else if(wstrcasecmp(node->element, "cite") == 0) + PrintSgmlTagString(fout, mode, indent, sgmltag_type, + " "); + /* We should distinguish tag_strong and tag_em later + haven't found proper docbook tag for */ + else if(node->tag == tag_em || node->tag == tag_strong || + wstrcasecmp(node->element, "address") == 0) { + if(sgmltag_type == SgmlTagStart) { + if(DescendantOf(node, tag_p) || DescendantOf(node, tag_pre)) + PPrintString(fout, indent, " "); + else + PPrintString(fout, indent, " "); + } + else if(sgmltag_type == SgmlTagEnd) { + if(DescendantOf(node, tag_p) || DescendantOf(node, tag_pre)) + PPrintString(fout, indent, " "); + else + PPrintString(fout, indent, "
stuff */
+ {
+ PPrintString(fout, indent, "");
+ PPrintText(fout, mode, indent, lexer, node->start, node->end);
+ PPrintString(fout, indent, " ");
+ }
+ else {
+ if(DescendantOf(node, tag_style))
+ fprintf(stderr, "PrintSgml: skipping style elements\n\n");
+ else
+ PPrintText(fout, mode, indent, lexer, node->start, node->end);
+ }
+ }
+ else if(node->type == CDATATag && EscapeCdata)
+ PPrintText(fout, mode, indent, lexer, node->start, node->end);
+ else if (node->type == CommentTag)
+ PPrintComment(fout, indent, lexer, node);
+ else if (node->type == RootNode)
+ {
+ for (content = node->content;
+ content != null;
+ content = content->next)
+ PrintSgml(fout, mode, indent, lexer, content);
+ }
+ else if (node->type == DocTypeTag)
+ PPrintDocType(fout, indent, lexer, node);
+ else if (node->type == CDATATag)
+ PPrintCDATA(fout, indent, lexer, node);
+ else if (node->type == SectionTag)
+ PPrintSection(fout, indent, lexer, node);
+ else if (node->type == AspTag ||
+ node->type == JsteTag ||
+ node->type == PhpTag )
+ PrintSgmlDefault(fout);
+ else if (node->type == ProcInsTag)
+ PPrintPI(fout, indent, lexer, node);
+ else if (node->type == XmlDecl)// && DbXml May be this is needed
+ PPrintXmlDecl(fout, indent, lexer, node);
+ else if (node->tag->model & CM_EMPTY ||
+ (node->type == StartEndTag && !xHTML))
+ {
+ if (!(node->tag->model & CM_INLINE))
+ PCondFlushLine(fout, indent);
+
+ if (MakeClean && node->tag == tag_wbr)
+ PPrintString(fout, indent, " ");
+ else
+ PrintSgmlTag(fout, mode, indent, lexer, node, SgmlTagStart);
+ }
+ else {
+ if (node->type == StartEndTag)
+ node->type = StartTag;
+
+ if (node->tag && node->tag->parser == ParsePre)
+ {
+ PCondFlushLine(fout, indent);
+
+ indent = 0;
+ PCondFlushLine(fout, indent);
+
+ PrintSgmlTag(fout, mode, indent, lexer, node, SgmlTagStart);
+ PFlushLine(fout, indent);
+
+ for (content = node->content;
+ content != null;
+ content = content->next)
+ PrintSgml(fout, (mode | PREFORMATTED | NOWRAP),
+ indent, lexer, content);
+
+ PCondFlushLine(fout, indent);
+ PrintSgmlTag(fout, mode, indent, lexer, node, SgmlTagEnd);
+ PFlushLine(fout, indent);
+
+ if (IndentContent == no && node->next != null)
+ PFlushLine(fout, indent);
+ }
+ else if (node->tag->model & CM_INLINE)
+ { PrintSgmlTag(fout, mode, indent, lexer, node, SgmlTagStart);
+
+ if (ShouldIndent(node))
+ {
+ PCondFlushLine(fout, indent);
+ indent += spaces;
+
+ for (content = node->content;
+ content != null;
+ content = content->next)
+ PrintSgml(fout, mode, indent, lexer, content);
+
+ PCondFlushLine(fout, indent);
+ indent -= spaces;
+ PCondFlushLine(fout, indent);
+ }
+ else
+ {
+
+ for (content = node->content;
+ content != null;
+ content = content->next)
+ PrintSgml(fout, mode, indent, lexer, content);
+ }
+
+ PrintSgmlTag(fout, mode, indent, lexer, node, SgmlTagEnd);
+ }
+ else
+ { PCondFlushLine(fout, indent);
+ if (SmartIndent && node->prev != null)
+ PFlushLine(fout, indent);
+
+ PrintSgmlTag(fout, mode ,indent, lexer, node, SgmlTagStart);
+ if (ShouldIndent(node))
+ PCondFlushLine(fout, indent);
+ else if (node->tag->model & CM_HTML ||
+ node->tag == tag_noframes ||
+ (node->tag->model & CM_HEAD && !(node->tag == tag_title)))
+ PFlushLine(fout, indent);
+
+ if (ShouldIndent(node))
+ { PCondFlushLine(fout, indent);
+ indent += spaces;
+
+ for (content = node->content;
+ content != null;
+ content = content->next)
+ PrintSgml(fout, mode, indent, lexer, content);
+ PCondFlushLine(fout, indent);
+ indent -= spaces;
+ PCondFlushLine(fout, indent);
+ }
+ else
+ { Node *last;
+ last = null;
+ for (content = node->content;
+ content != null;
+ content = content->next) {
+ /* kludge for naked text before block level tag */
+ if (last && !IndentContent && last->type == TextNode &&
+ content->tag && !(content->tag->model & CM_INLINE) )
+ {
+ /* PFlushLine(fout, indent); */
+ PFlushLine(fout, indent);
+ }
+
+ PrintSgml(fout, mode,
+ (ShouldIndent(node) ? indent+spaces : indent),
+ lexer, content);
+ last = content;
+ }
+ }
+ PrintSgmlTag(fout, mode, indent, lexer, node, SgmlTagEnd);
+ PFlushLine(fout, indent);
+ if (IndentContent == no &&
+ node->next != null &&
+ HideEndTags == no &&
+ (node->tag->model & (CM_BLOCK|CM_LIST|CM_DEFLIST|CM_TABLE)))
+ PFlushLine(fout, indent);
+ }
+ }
+}
+
void PPrintTree(Out *fout, uint mode, uint indent,
Lexer *lexer, Node *node)
{
@@ -2034,17 +2669,14 @@
PPrintJste(fout, indent, lexer, node);
else if (node->type == PhpTag)
PPrintPhp(fout, indent, lexer, node);
- else if ( node->tag->model & CM_EMPTY
- || (node->type == StartEndTag && !xHTML) )
+ else if (node->tag->model & CM_EMPTY || (node->type == StartEndTag && !xHTML))
{
PCondFlushLine(fout, indent);
PPrintTag(lexer, fout, mode, indent, node);
PFlushLine(fout, indent);
- /* CPR: folks don't want so much vertical spacing in XML
if (node->next)
PFlushLine(fout, indent);
- */
}
else /* some kind of container element */
{
@@ -2076,7 +2708,7 @@
PPrintTag(lexer, fout, mode, indent, node);
- if ( !mixed && node->content )
+ if (!mixed)
PFlushLine(fout, indent);
for (content = node->content;
@@ -2084,16 +2716,14 @@
content = content->next)
PPrintXMLTree(fout, mode, cindent, lexer, content);
- if ( !mixed && node->content )
+ if (!mixed)
PCondFlushLine(fout, cindent);
PPrintEndTag(fout, mode, indent, node);
PCondFlushLine(fout, indent);
- /* CPR: folks don't want so much vertical spacing in XML
if (node->next)
PFlushLine(fout, indent);
- */
}
}
--- /cise/tmp/ppadala/tidy/src/tab2space.c Wed Feb 6 04:09:37 2002
+++ src/tab2space.c Sat Jul 6 23:50:55 2002
@@ -2,7 +2,7 @@
#include
#include
-#ifndef __BEOS__
+#if !(defined(__BEOS__) || defined(linux))
typedef unsigned int uint;
#endif
typedef unsigned char byte;
--- /cise/tmp/ppadala/tidy/src/tidy.c Sun Jul 7 23:29:25 2002
+++ src/tidy.c Fri Jul 19 01:22:54 2002
@@ -1853,6 +1853,10 @@
IndentContent = yes;
SmartIndent = yes;
}
+ else if (wstrcasecmp(arg, "dbsgml") == 0)
+ DbSgml = yes;
+ else if(wstrcasecmp(arg, "dbxml") == 0)
+ DbXml = yes;
else if (wstrcasecmp(arg, "omit") == 0)
HideEndTags = yes;
else if (wstrcasecmp(arg, "upper") == 0)
@@ -2180,6 +2184,28 @@
else
{
lexer->warnings = 0;
+
+ if (DbSgml || DbXml) {
+ char *str;
+
+ if(DbSgml)
+ str = "article PUBLIC \"-//OASIS//DTD DocBook V4.1//EN\"";
+ else
+ str = "article PUBLIC \"-//OASIS//DTD DocBk XML V4.1.2 //EN\"";
+
+ EncloseBodyText = yes; /* We want those s */
+ EncloseBlockText = yes;
+ LogicalEmphasis = yes;
+ DropFontTags = yes; /* .. are not needed */
+
+ /* May be this should be decided by user */
+ QuoteMarks = yes;
+
+ doctype_mode = doctype_user;
+ /* TidyDeInit does MemFree(doctype_str) if it's != NULL */
+ doctype_str = MemAlloc(wstrlen(str));
+ wstrcpy(doctype_str, str);
+ }
document = ParseDocument(lexer);
@@ -2226,6 +2252,10 @@
{
if (xHTML)
SetXHTMLDocType(lexer, document);
+ else if(DbSgml)
+ SetSgmlDocType(lexer, document);
+ else if(DbXml)
+ SetSgmlDocType(lexer, document);
else
FixDocType(lexer, document);
@@ -2247,7 +2277,7 @@
}
/* ensure presence of initial */
- if (XmlOut && XmlPi)
+ if ((XmlOut && XmlPi) || DbXml)
FixXmlDecl(lexer, document);
/*
@@ -2381,9 +2411,12 @@
/* Feature request #434940 - fix by Dave Raggett/Ignacio Vazquez-Abrams 21 Jun 01 */
else if (BodyOnly)
PrintBody(&out, lexer, document);
- else
- PPrintTree(&out, null, 0, lexer, document);
-
+ else {
+ if(DbSgml || DbXml)
+ PrintSgml(&out, null, 0, lexer, document);
+ else
+ PPrintTree(&out, null, 0, lexer, document);
+ }
PFlushLine(&out, 0);
}