C# Class Tidy.Core.Clean

Clean up misuse of presentation markup (c) 1998-2000 (W3C) MIT, INRIA, Keio University See Tidy.cs for the copyright notice. Derived from HTML Tidy Release 4 Aug 2000
Filters from other formats such as Microsoft Word often make excessive use of presentation markup such as font tags, B, I, and the align attribute. By applying a set of production rules, it is straight forward to transform this to use CSS. Some rules replace some of the children of an element by style properties on the element, e.g. <p><b>...</b></p> -> <p style="font-weight: bold">...</p> Such rules are applied to the element's content and then to the element itself until none of the rules more apply. Having applied all the rules to an element, it will have a style attribute with one or more properties. Other rules strip the element they apply to, replacing it by style properties on the contents, e.g. <dir><li><p>...</li></dir> -> <p style="margin-left 1em">... These rules are applied to an element before processing its content and replace the current element by the first element in the exposed content. After applying both sets of rules, you can replace the style attribute by a class value and style rule in the document head. To support this, an association of styles and class names is built. A naive approach is to rely on string matching to test when two property lists are the same. A better approach would be to first sort the properties before matching.
Mostra file Open project: r1pper/TidyNetPortable Class Usage Examples

Public Methods

Method Description
Bq2Div ( Node node ) : void
Clean ( TagCollection tt ) : System
CleanTree ( Lexer lexer, Node doc ) : void
CleanWord2000 ( Lexer lexer, Node node ) : void
DropSections ( Lexer lexer, Node node ) : void
EmFromI ( Node node ) : void
IsWord2000 ( Node root, TagCollection tt ) : bool
List2Bq ( Node node ) : void
NestedEmphasis ( Node node ) : void
PruneSection ( Lexer lexer, Node node ) : Node
PurgeAttributes ( Node node ) : void
StripSpan ( Lexer lexer, Node span ) : Node

Private Methods

Method Description
AddAlign ( Node node, string align ) : void
AddColorRule ( Lexer lexer, string selector, string color ) : void
AddFontColor ( Node node, string color ) : void
AddFontFace ( Node node, string face ) : void
AddFontSize ( Node node, string size ) : void
AddFontStyles ( Node node, AttVal av ) : void
AddProperty ( string style, string property ) : string
AddStyleProperty ( Node node, string property ) : void
BlockStyle ( Node node ) : bool
Center2Div ( Lexer lexer, Node node, MutableObject pnode ) : bool
CleanBodyAttrs ( Lexer lexer, Node body ) : void
CleanNode ( Lexer lexer, Node node ) : Node
CreatePropString ( StyleProp props ) : string
CreateProps ( StyleProp prop, string style ) : StyleProp
CreateStyleElement ( Lexer lexer, Node doc ) : void
CreateStyleProperties ( Lexer lexer, Node node ) : Node
DefineStyleRules ( Lexer lexer, Node node ) : void
Dir2Div ( Node node ) : bool
DiscardContainer ( Node element, MutableObject pnode ) : void
FindStyle ( Lexer lexer, string tag, string properties ) : string
FixNodeLinks ( Node node ) : void
Font2Span ( Lexer lexer, Node node, MutableObject pnode ) : bool
FontSize2Name ( string size ) : string
GenSymClass ( ) : string
InlineStyle ( Lexer lexer, Node node ) : bool
InsertProperty ( StyleProp props, string name, string val ) : StyleProp
MergeDivs ( Node node ) : bool
MergeProperties ( string s1, string s2 ) : string
MergeStyles ( Node node, Node child ) : void
NestedList ( Lexer lexer, Node node, MutableObject pnode ) : bool
NiceBody ( Lexer lexer, Node doc ) : bool
NormalizeSpaces ( Node node ) : void
StripOnlyChild ( Node node ) : void
Style2Rule ( Lexer lexer, Node node ) : void
TextAlign ( Node node ) : void

Method Details

Bq2Div() public method

public Bq2Div ( Node node ) : void
node Node
return void

Clean() public method

public Clean ( TagCollection tt ) : System
tt TagCollection
return System

CleanTree() public method

public CleanTree ( Lexer lexer, Node doc ) : void
lexer Lexer
doc Node
return void

CleanWord2000() public method

public CleanWord2000 ( Lexer lexer, Node node ) : void
lexer Lexer
node Node
return void

DropSections() public method

public DropSections ( Lexer lexer, Node node ) : void
lexer Lexer
node Node
return void

EmFromI() public method

public EmFromI ( Node node ) : void
node Node
return void

IsWord2000() public method

public IsWord2000 ( Node root, TagCollection tt ) : bool
root Node
tt TagCollection
return bool

List2Bq() public method

public List2Bq ( Node node ) : void
node Node
return void

NestedEmphasis() public method

public NestedEmphasis ( Node node ) : void
node Node
return void

PruneSection() public method

public PruneSection ( Lexer lexer, Node node ) : Node
lexer Lexer
node Node
return Node

PurgeAttributes() public method

public PurgeAttributes ( Node node ) : void
node Node
return void

StripSpan() public method

public StripSpan ( Lexer lexer, Node span ) : Node
lexer Lexer
span Node
return Node