當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。