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


C# Lexer.InferredTag方法代码示例

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


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

示例1: Parse

			public virtual void Parse(Lexer lexer, Node body, short mode)
			{
				Node node;
				bool checkstack, iswhitenode;
				
				mode = Lexer.IgnoreWhitespace;
				checkstack = true;
				TagTable tt = lexer.Options.tt;
				
				while (true)
				{
					node = lexer.GetToken(mode);
					if (node == null)
					{
						break;
					}
					if (node.Tag == body.Tag && node.Type == Node.EndTag)
					{
						body.Closed = true;
						Node.TrimSpaces(lexer, body);
						lexer.seenBodyEndTag = 1;
						mode = Lexer.IgnoreWhitespace;
						
						if (body.Parent.Tag == tt.TagNoframes)
						{
							break;
						}
						
						continue;
					}
					
					if (node.Tag == tt.TagNoframes)
					{
						if (node.Type == Node.StartTag)
						{
							Node.InsertNodeAtEnd(body, node);
							TidyNet.ParserImpl.ParseBlock.Parse(lexer, node, mode);
							continue;
						}
						
						if (node.Type == Node.EndTag && body.Parent.Tag == tt.TagNoframes)
						{
							Node.TrimSpaces(lexer, body);
							lexer.UngetToken();
							break;
						}
					}
					
					if ((node.Tag == tt.TagFrame || node.Tag == tt.TagFrameset) && body.Parent.Tag == tt.TagNoframes)
					{
						Node.TrimSpaces(lexer, body);
						lexer.UngetToken();
						break;
					}
					
					if (node.Tag == tt.TagHtml)
					{
						if (node.Type == Node.StartTag || node.Type == Node.StartEndTag)
						{
							Report.Warning(lexer, body, node, Report.DISCARDING_UNEXPECTED);
						}
						
						continue;
					}
					
					iswhitenode = false;
					
					if (node.Type == Node.TextNode && node.End <= node.Start + 1 && node.Textarray[node.Start] == (sbyte) ' ')
					{
						iswhitenode = true;
					}
					
					/* deal with comments etc. */
					if (Node.InsertMisc(body, node))
					{
						continue;
					}
					
					if (lexer.seenBodyEndTag == 1 && !iswhitenode)
					{
						++lexer.seenBodyEndTag;
						Report.Warning(lexer, body, node, Report.CONTENT_AFTER_BODY);
					}
					
					/* mixed content model permits text */
					if (node.Type == Node.TextNode)
					{
						if (iswhitenode && mode == Lexer.IgnoreWhitespace)
						{
							continue;
						}
						
						if (lexer.Options.EncloseText && !iswhitenode)
						{
							Node para;
							
							lexer.UngetToken();
							para = lexer.InferredTag("p");
							Node.InsertNodeAtEnd(body, para);
							TidyNet.ParserImpl.parseTag(lexer, para, mode);
//.........这里部分代码省略.........
开发者ID:erikzaadi,项目名称:atomsitethemes.erikzaadi.com,代码行数:101,代码来源:ParserImpl.cs

示例2: parseDocument

		/*
		HTML is the top level element
		*/
		public static Node parseDocument(Lexer lexer)
		{
			Node node, document, html;
			Node doctype = null;
			TagTable tt = lexer.Options.tt;

			document = lexer.NewNode();
			document.Type = Node.RootNode;
			
			while (true)
			{
				node = lexer.GetToken(Lexer.IgnoreWhitespace);
				if (node == null)
				{
					break;
				}
				
				/* deal with comments etc. */
				if (Node.InsertMisc(document, node))
				{
					continue;
				}
				
				if (node.Type == Node.DocTypeTag)
				{
					if (doctype == null)
					{
						Node.InsertNodeAtEnd(document, node);
						doctype = node;
					}
					else
					{
						Report.Warning(lexer, document, node, Report.DISCARDING_UNEXPECTED);
					}
					continue;
				}
				
				if (node.Type == Node.EndTag)
				{
					Report.Warning(lexer, document, node, Report.DISCARDING_UNEXPECTED); //TODO?
					continue;
				}
				
				if (node.Type != Node.StartTag || node.Tag != tt.TagHtml)
				{
					lexer.UngetToken();
					html = lexer.InferredTag("html");
				}
				else
				{
					html = node;
				}
				
				Node.InsertNodeAtEnd(document, html);
				ParseHTML.Parse(lexer, html, (short) 0); // TODO?
				break;
			}
			
			return document;
		}
开发者ID:erikzaadi,项目名称:atomsitethemes.erikzaadi.com,代码行数:63,代码来源:ParserImpl.cs

示例3: CleanWord2000

        /*
        This is a major clean up to strip out all the extra stuff you get
        when you save as web page from Word 2000. It doesn't yet know what
        to do with VML tags, but these will appear as errors unless you
        declare them as new tags, such as o:p which needs to be declared
        as inline.
        */
        public virtual void CleanWord2000(Lexer lexer, Node node)
        {
            /* used to a list from a sequence of bulletted p's */
            Node list = null;

            while (node != null)
            {
                /* discard Word's style verbiage */
                if (node.Tag == _tt.TagStyle || node.Tag == _tt.TagMeta || node.Type == Node.CommentTag)
                {
                    node = Node.DiscardElement(node);
                    continue;
                }

                /* strip out all span tags Word scatters so liberally! */
                if (node.Tag == _tt.TagSpan)
                {
                    node = StripSpan(lexer, node);
                    continue;
                }

                /* get rid of Word's xmlns attributes */
                if (node.Tag == _tt.TagHtml)
                {
                    /* check that it's a Word 2000 document */
                    if (node.GetAttrByName("xmlns:o") == null)
                    {
                        return;
                    }
                }

                if (node.Tag == _tt.TagLink)
                {
                    AttVal attr = node.GetAttrByName("rel");

                    if (attr != null && attr.Val != null && attr.Val.Equals("File-List"))
                    {
                        node = Node.DiscardElement(node);
                        continue;
                    }
                }

                /* discard empty paragraphs */
                if (node.Content == null && node.Tag == _tt.TagP)
                {
                    node = Node.DiscardElement(node);
                    continue;
                }

                if (node.Tag == _tt.TagP)
                {
                    AttVal attr = node.GetAttrByName("class");

                    /* map sequence of <p class="MsoListBullet"> to <ul>...</ul> */
                    if (attr != null && attr.Val != null && attr.Val.Equals("MsoListBullet"))
                    {
                        Node.CoerceNode(lexer, node, _tt.TagLi);

                        if (list == null || list.Tag != _tt.TagUl)
                        {
                            list = lexer.InferredTag("ul");
                            Node.InsertNodeBeforeElement(node, list);
                        }

                        PurgeAttributes(node);

                        if (node.Content != null)
                        {
                            CleanWord2000(lexer, node.Content);
                        }

                        /* remove node and append to contents of list */
                        Node.RemoveNode(node);
                        Node.InsertNodeAtEnd(list, node);
                        node = list.Next;
                    }
                    else if (attr != null && attr.Val != null && attr.Val.Equals("Code"))
                    {
                        /* map sequence of <p class="Code"> to <pre>...</pre> */
                        Node br = lexer.NewLineNode();
                        NormalizeSpaces(lexer, node);

                        if (list == null || list.Tag != _tt.TagPre)
                        {
                            list = lexer.InferredTag("pre");
                            Node.InsertNodeBeforeElement(node, list);
                        }

                        /* remove node and append to contents of list */
                        Node.RemoveNode(node);
                        Node.InsertNodeAtEnd(list, node);
                        StripSpan(lexer, node);
                        Node.InsertNodeAtEnd(list, br);
//.........这里部分代码省略.........
开发者ID:AlfieJ,项目名称:TidyNet,代码行数:101,代码来源:Clean.cs

示例4: FixEmptyRow

        /*
        if a table row is empty then insert an empty cell
        this practice is consistent with browser behavior
        and avoids potential problems with row spanning cells
        */
        public static void FixEmptyRow(Lexer lexer, Node row)
        {
            Node cell;

            if (row.Content == null)
            {
                cell = lexer.InferredTag("td");
                InsertNodeAtEnd(row, cell);
                Report.Warning(lexer, row, cell, Report.MISSING_STARTTAG);
            }
        }
开发者ID:AlfieJ,项目名称:TidyNet,代码行数:16,代码来源:Node.cs

示例5: TrimEmptyElement

        public static void TrimEmptyElement(Lexer lexer, Node element)
        {
            TagTable tt = lexer.Options.tt;

            if (lexer.CanPrune(element))
            {
                if (element.Type != TextNode)
                {
                    Report.Warning(lexer, element, null, Report.TRIM_EMPTY_ELEMENT);
                }

                DiscardElement(element);
            }
            else if (element.Tag == tt.TagP && element.Content == null && lexer.Options.DropEmptyElements == true)
            {
                /* replace <p></p> by <br><br> to preserve formatting */
                Node node = lexer.InferredTag("br");
                Node.CoerceNode(lexer, element, tt.TagBr);
                Node.InsertNodeAfterElement(element, node);
            }
        }
开发者ID:AlfieJ,项目名称:TidyNet,代码行数:21,代码来源:Node.cs

示例6: AddTransitionEffect

        /*
        Add meta element for page transition effect, this works on IE but not NS
        */
        public virtual void AddTransitionEffect(Lexer lexer, Node root, short effect, double duration)
        {
            Node head = root.FindHead(lexer.Options.tt);
            string transition;

            if (0 <= effect && effect <= 23)
            {
                transition = "revealTrans(Duration=" + (duration).ToString() + ",Transition=" + effect + ")";
            }
            else
            {
                transition = "blendTrans(Duration=" + (duration).ToString() + ")";
            }

            if (head != null)
            {
                Node meta = lexer.InferredTag("meta");
                meta.AddAttribute("http-equiv", "Page-Enter");
                meta.AddAttribute("content", transition);
                Node.InsertNodeAtStart(head, meta);
            }
        }
开发者ID:bgarrels,项目名称:betterpoeditor,代码行数:25,代码来源:PPrint.cs

示例7: Center2Div

        /*
        Symptom: <center>
        Action: replace <center> by <div style="text-align: center">
        */
        private bool Center2Div(Lexer lexer, Node node, MutableObject pnode)
        {
            if (node.Tag == _tt.TagCenter)
            {
                if (lexer.Options.DropFontTags)
                {
                    if (node.Content != null)
                    {
                        Node last = node.Last;
                        Node parent = node.Parent;

                        DiscardContainer(node, pnode);

                        node = lexer.InferredTag("br");

                        if (last.Next != null)
                        {
                            last.Next.Prev = node;
                        }

                        node.Next = last.Next;
                        last.Next = node;
                        node.Prev = last;

                        if (parent.Last == last)
                        {
                            parent.Last = node;
                        }

                        node.Parent = parent;
                    }
                    else
                    {
                        Node prev = node.Prev;
                        Node next = node.Next;
                        Node parent = node.Parent;
                        DiscardContainer(node, pnode);

                        node = lexer.InferredTag("br");
                        node.Next = next;
                        node.Prev = prev;
                        node.Parent = parent;

                        if (next != null)
                        {
                            next.Prev = node;
                        }
                        else
                        {
                            parent.Last = node;
                        }

                        if (prev != null)
                        {
                            prev.Next = node;
                        }
                        else
                        {
                            parent.Content = node;
                        }
                    }

                    return true;
                }
                node.Tag = _tt.TagDiv;
                node.Element = "div";
                AddStyleProperty(node, "text-align: center");
                return true;
            }

            return false;
        }
开发者ID:AlfieJ,项目名称:TidyNet,代码行数:76,代码来源:Clean.cs

示例8: CoerceNode

 public static void CoerceNode(Lexer lexer, Node node, Dict tag)
 {
     Node tmp = lexer.InferredTag(tag.Name);
     Report.Warning(lexer, node, tmp, Report.OBSOLETE_ELEMENT);
     node.Was = node.Tag;
     node.Tag = tag;
     node.Type = StartTag;
     node.Isimplicit = true;
     node.Element = tag.Name;
 }
开发者ID:AlfieJ,项目名称:TidyNet,代码行数:10,代码来源:Node.cs


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