当前位置: 首页>>代码示例>>C#>>正文


C# Node.RemoveAttribute方法代码示例

本文整理汇总了C#中TidyNet.Node.RemoveAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# Node.RemoveAttribute方法的具体用法?C# Node.RemoveAttribute怎么用?C# Node.RemoveAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TidyNet.Node的用法示例。


在下文中一共展示了Node.RemoveAttribute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: url

        /*
        move presentation attribs from body to style element

        background="foo" ->  body { background-image: url(foo) }
        bgcolor="foo"    ->  body { background-color: foo }
        text="foo"       ->  body { color: foo }
        link="foo"       ->  :link { color: foo }
        vlink="foo"      ->  :visited { color: foo }
        alink="foo"      ->  :active { color: foo }
        */
        private void CleanBodyAttrs(Lexer lexer, Node body)
        {
            AttVal attr;
            string bgurl = null;
            string bgcolor = null;
            string color = null;

            attr = body.GetAttrByName("background");

            if (attr != null)
            {
                bgurl = attr.Val;
                attr.Val = null;
                body.RemoveAttribute(attr);
            }

            attr = body.GetAttrByName("bgcolor");

            if (attr != null)
            {
                bgcolor = attr.Val;
                attr.Val = null;
                body.RemoveAttribute(attr);
            }

            attr = body.GetAttrByName("text");

            if (attr != null)
            {
                color = attr.Val;
                attr.Val = null;
                body.RemoveAttribute(attr);
            }

            if (bgurl != null || bgcolor != null || color != null)
            {
                lexer.AddStringLiteral(" body {\n");

                if (bgurl != null)
                {
                    lexer.AddStringLiteral("  background-image: url(");
                    lexer.AddStringLiteral(bgurl);
                    lexer.AddStringLiteral(");\n");
                }

                if (bgcolor != null)
                {
                    lexer.AddStringLiteral("  background-color: ");
                    lexer.AddStringLiteral(bgcolor);
                    lexer.AddStringLiteral(";\n");
                }

                if (color != null)
                {
                    lexer.AddStringLiteral("  color: ");
                    lexer.AddStringLiteral(color);
                    lexer.AddStringLiteral(";\n");
                }

                lexer.AddStringLiteral(" }\n");
            }

            attr = body.GetAttrByName("link");

            if (attr != null)
            {
                AddColorRule(lexer, " :link", attr.Val);
                body.RemoveAttribute(attr);
            }

            attr = body.GetAttrByName("vlink");

            if (attr != null)
            {
                AddColorRule(lexer, " :visited", attr.Val);
                body.RemoveAttribute(attr);
            }

            attr = body.GetAttrByName("alink");

            if (attr != null)
            {
                AddColorRule(lexer, " :active", attr.Val);
                body.RemoveAttribute(attr);
            }
        }
开发者ID:AlfieJ,项目名称:TidyNet,代码行数:96,代码来源:Clean.cs

示例2: Style2Rule

        /*
        Find style attribute in node, and replace it
        by corresponding class attribute. Search for
        class in style dictionary otherwise gensym
        new class and add to dictionary.

        Assumes that node doesn't have a class attribute
        */
        private void Style2Rule(Lexer lexer, Node node)
        {
            AttVal styleattr, classattr;
            string classname;

            styleattr = node.GetAttrByName("style");

            if (styleattr != null)
            {
                classname = FindStyle(lexer, node.Element, styleattr.Val);
                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;
                    node.RemoveAttribute(styleattr);
                }
                else
                {
                    /* reuse style attribute for class attribute */
                    styleattr.Attribute = "class";
                    styleattr.Val = classname;
                }
            }
        }
开发者ID:AlfieJ,项目名称:TidyNet,代码行数:37,代码来源:Clean.cs

示例3: CleanImgAttrs

    public virtual void CleanImgAttrs(Node node)
    {
      while (node != null)
      {
        if (node.Tag == _tt.TagImg)
        {
          string style = string.Empty;

          AttVal attr = node.GetAttrByName("border");
          if (attr != null)
          {
            style += "border-width:" + attr.Val + ";";
            attr.Val = null;
            node.RemoveAttribute(attr);
          }

          attr = node.GetAttrByName("align");
          if (attr != null)
          {
            style += "float:" + attr.Val + ";";
            attr.Val = null;
            node.RemoveAttribute(attr);
          }

          attr = node.GetAttrByName("height");
          if (attr != null)
          {
            style += "height:" + attr.Val + ";";
            attr.Val = null;
            node.RemoveAttribute(attr);
          }

          attr = node.GetAttrByName("width");
          if (attr != null)
          {
            style += "width:" + attr.Val + ";";
            attr.Val = null;
            node.RemoveAttribute(attr);
          }

          //xhtml requires the alt attribute
          attr = node.GetAttrByName("alt");
          if (attr == null)
          {
            node.AddAttribute("alt", string.Empty);
          }

          attr = node.GetAttrByName("style");
          if (style.Length > 0)
          {
            if (attr != null && !string.IsNullOrEmpty(attr.Val))
            {
              style = style + attr.Val;
              attr.Val = null;
              node.RemoveAttribute(attr);
            }
            node.AddAttribute("style", style);
          } 
        }

        if (node.Content != null)
        {
          CleanImgAttrs(node.Content);
        }

        node = node.Next;
      }
    }
开发者ID:erikzaadi,项目名称:atomsitethemes.erikzaadi.com,代码行数:68,代码来源:Clean.cs

示例4: CleanTableAttrs

    public virtual void CleanTableAttrs(Node node)
    {
			while (node != null)
			{
				if (node.Tag == _tt.TagTr || node.Tag == _tt.TagTh || node.Tag == _tt.TagTd) //TODO: add tbody?
				{

      AttVal attr;
      string bgurl = null;
      string bgcolor = null;
      string height = null;
      string width = null;
      

      attr = node.GetAttrByName("background");

      if (attr != null)
      {
        bgurl = attr.Val;
        attr.Val = null;
        node.RemoveAttribute(attr);
      }

      attr = node.GetAttrByName("bgcolor");

      if (attr != null)
      {
        bgcolor = attr.Val;
        attr.Val = null;
        node.RemoveAttribute(attr);
      }

      attr = node.GetAttrByName("width");

      if (attr != null)
      {
        width = attr.Val;
        attr.Val = null;
        node.RemoveAttribute(attr);
      }

      attr = node.GetAttrByName("height");

      if (attr != null)
      {
        height = attr.Val;
        attr.Val = null;
        node.RemoveAttribute(attr);
      }

      if (bgurl != null || bgcolor != null || width != null || height != null)
      {
        string style = string.Empty;

        if (bgurl != null)
        {
          style += "background-image:url(" + bgurl + ");";
        }

        if (bgcolor != null)
        {
          style += "background-color:"+ bgcolor +";";
        }

        if (width != null)
        {
          style += "width:" + width + ";";
        }

        if (height != null)
        {
          style += "height:" + height + ";";
        }

        node.AddAttribute("style", style);
      }
        }

        if (node.Content != null)
        {
          CleanTableAttrs(node.Content);
        }
				
        node = node.Next;
      }
    }
开发者ID:erikzaadi,项目名称:atomsitethemes.erikzaadi.com,代码行数:86,代码来源:Clean.cs

示例5: CleanAnchorTarget

    public virtual void CleanAnchorTarget(Node node)
    {
      while (node != null)
      {
        if (node.Tag == _tt.TagA)
        {
          AttVal attr = node.GetAttrByName("target");
          if (attr != null)
          {
            if (attr.Val.ToLower() == "_blank")
            {
              AttVal rel = node.GetAttrByName("rel");
              if (rel == null) node.AddAttribute("rel", "external");
              else rel.Val += " external";
            }
            node.RemoveAttribute(attr);
          }
        }

        if (node.Content != null)
        {
          CleanAnchorTarget(node.Content);
        }

        node = node.Next;
      }
    }
开发者ID:erikzaadi,项目名称:atomsitethemes.erikzaadi.com,代码行数:27,代码来源:Clean.cs


注:本文中的TidyNet.Node.RemoveAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。