C# Класс 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.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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

Приватные методы

Метод Описание
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

Описание методов

Bq2Div() публичный Метод

public Bq2Div ( Node node ) : void
node Node
Результат void

Clean() публичный Метод

public Clean ( TagCollection tt ) : System
tt TagCollection
Результат System

CleanTree() публичный Метод

public CleanTree ( Lexer lexer, Node doc ) : void
lexer Lexer
doc Node
Результат void

CleanWord2000() публичный Метод

public CleanWord2000 ( Lexer lexer, Node node ) : void
lexer Lexer
node Node
Результат void

DropSections() публичный Метод

public DropSections ( Lexer lexer, Node node ) : void
lexer Lexer
node Node
Результат void

EmFromI() публичный Метод

public EmFromI ( Node node ) : void
node Node
Результат void

IsWord2000() публичный Метод

public IsWord2000 ( Node root, TagCollection tt ) : bool
root Node
tt TagCollection
Результат bool

List2Bq() публичный Метод

public List2Bq ( Node node ) : void
node Node
Результат void

NestedEmphasis() публичный Метод

public NestedEmphasis ( Node node ) : void
node Node
Результат void

PruneSection() публичный Метод

public PruneSection ( Lexer lexer, Node node ) : Node
lexer Lexer
node Node
Результат Node

PurgeAttributes() публичный Метод

public PurgeAttributes ( Node node ) : void
node Node
Результат void

StripSpan() публичный Метод

public StripSpan ( Lexer lexer, Node span ) : Node
lexer Lexer
span Node
Результат Node