本文整理汇总了C#中Tidy.Core.Node.AddAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# Node.AddAttribute方法的具体用法?C# Node.AddAttribute怎么用?C# Node.AddAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tidy.Core.Node
的用法示例。
在下文中一共展示了Node.AddAttribute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Check
public virtual void Check(Lexer lexer, Node node)
{
node.CheckUniqueAttributes(lexer);
AttVal lang = node.GetAttrByName("language");
AttVal type = node.GetAttrByName("type");
if (type == null)
{
Report.AttrError(lexer, node, "type", Report.MISSING_ATTRIBUTE);
/* check for javascript */
if (lang != null)
{
string str = lang.Val;
if (str.Length > 10)
{
str = str.Substring(0, 10);
}
if ((String.CompareOrdinal(str, "javascript") == 0) || (String.CompareOrdinal(str, "jscript") == 0))
{
node.AddAttribute("type", "text/javascript");
}
}
else
{
node.AddAttribute("type", "text/javascript");
}
}
}
示例2: FixId
/* duplicate name attribute as an id */
public virtual void FixId(Node node)
{
AttVal name = node.GetAttrByName("name");
AttVal id = node.GetAttrByName("id");
if (name != null)
{
if (id != null)
{
if (!id.Val.Equals(name.Val))
{
Report.AttrError(this, node, "name", Report.ID_NAME_MISMATCH);
}
}
else if (Options.XmlOut)
{
node.AddAttribute("id", name.Val);
}
}
}
示例3: Bq2Div
/*
Replace implicit blockquote by div with an indent
taking care to reduce nested blockquotes to a single
div with the indent set to match the nesting depth
*/
public virtual void Bq2Div(Node node)
{
while (node != null)
{
if (node.Tag == _tt.TagBlockquote && node.Isimplicit)
{
int indent = 1;
while (node.HasOneChild() && node.Content.Tag == _tt.TagBlockquote && node.Isimplicit)
{
++indent;
StripOnlyChild(node);
}
if (node.Content != null)
{
Bq2Div(node.Content);
}
string indentBuf = "margin-left: " + (2*indent).ToString() + "em";
node.Element = _tt.TagDiv.Name;
node.Tag = _tt.TagDiv;
node.AddAttribute("style", indentBuf);
}
else if (node.Content != null)
{
Bq2Div(node.Content);
}
node = node.Next;
}
}
示例4: AddClass
public static void AddClass(Node node, string classname)
{
AttVal classattr = node.GetAttrByName("class");
/*
if there already is a class attribute
then append class name after a space
*/
if (classattr != null)
{
classattr.Val = classattr.Val + " " + classname;
}
/* create new class attribute */
else
{
node.AddAttribute("class", classname);
}
}