• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# HtmlNodeType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中HtmlNodeType的典型用法代码示例。如果您正苦于以下问题:C# HtmlNodeType类的具体用法?C# HtmlNodeType怎么用?C# HtmlNodeType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HtmlNodeType类属于命名空间,在下文中一共展示了HtmlNodeType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: FindPreviousElement

        public HtmlNode FindPreviousElement(HtmlNode node, HtmlNodeType nodeType)
        {
            if (node.PreviousSibling != null && node.PreviousSibling.NodeType == nodeType)
            {
                return node.PreviousSibling;
            }

            if (node.ParentNode != null && node.ParentNode.NodeType == nodeType)
            {
                return node.ParentNode;
            }

            // Ignoring Text elements
            if (node.PreviousSibling != null && node.PreviousSibling.NodeType == HtmlNodeType.Text)
            {
                return this.FindPreviousElement(node.PreviousSibling, nodeType);
            }

            // Ignoring Text elements
            if (node.ParentNode != null && node.ParentNode.NodeType == HtmlNodeType.Text)
            {
                return this.FindPreviousElement(node.ParentNode, nodeType);
            }

            if (node.ParentNode != null && node.ParentNode.NodeType == nodeType)
            {
                return node.ParentNode;
            }

            return null;
        }
开发者ID:hmeydac,项目名称:Homeworld,代码行数:31,代码来源:HtmlParser.cs


示例2: HtmlNode

 public HtmlNode(HtmlNodeType type, HtmlAgilityPack.HtmlDocument ownerdocument, int index)
     : base(type, ownerdocument, index)
 {
 }
开发者ID:ArjangAssadi,项目名称:HandyUtils,代码行数:4,代码来源:HtmlDocument.cs


示例3: CreateNode

 internal HtmlNode CreateNode(HtmlNodeType type)
 {
     return CreateNode(type, -1);
 }
开发者ID:tstrimple,项目名称:DiscoveryEducation,代码行数:4,代码来源:HtmlDocument.cs


示例4: HtmlNode

        /// <summary>
        /// Initializes HtmlNode, providing type, owner and where it exists in a collection
        /// </summary>
        /// <param name="type"></param>
        /// <param name="ownerdocument"></param>
        /// <param name="index"></param>
        protected HtmlNode(HtmlNodeType type, HtmlDocument ownerdocument, int index)
        {
            _nodetype = type;
            _ownerdocument = ownerdocument;
            _outerstartindex = index;

            switch (type)
            {
                case HtmlNodeType.Comment:
                    Name = HtmlNodeTypeNameComment;
                    _endnode = this;
                    break;

                case HtmlNodeType.Document:
                    Name = HtmlNodeTypeNameDocument;
                    _endnode = this;
                    break;

                case HtmlNodeType.Text:
                    Name = HtmlNodeTypeNameText;
                    _endnode = this;
                    break;
            }

            if (_ownerdocument.Openednodes != null)
            {
                if (!Closed)
                {
                    // we use the index as the key

                    // -1 means the node comes from public
                    if (-1 != index)
                    {
                        _ownerdocument.Openednodes.Add(index, this);
                    }
                }
            }

            if ((-1 != index) || (type == HtmlNodeType.Comment) || (type == HtmlNodeType.Text)) return;
            // innerhtml and outerhtml must be calculated
            _outerchanged = true;
            _innerchanged = true;
        }
开发者ID:AlexanderByndyu,项目名称:HtmlAgilityPack,代码行数:49,代码来源:HtmlNode.cs


示例5: Read

		public bool Read()
		{
			_nodeType = HtmlNodeType.None;
			_name.Length = 0;
			_value.Length = 0;
			_isEmptyElement = false;

			var attrName = new StringBuilder();
			var attrValue = new StringBuilder();

			var quoteStyle = '"';
			var customDoctype = false;
			StringBuilder entity = null;

			while (_peeker.Read())
			{
				char c = _peeker.Current;

				switch (_state)
				{
					case State.Text:
						if (c == '&')
						{
							entity = new StringBuilder();
							_state = State.Amp;
						}
						else if (c == '<')
						{
							_state = State.Lt;
							if (_value.Length > 0)
							{
								_nodeType = HtmlNodeType.Text;
								return true;
							}
						}
						else
						{
							_value.Append(c);
						}
						break;

					case State.Amp:
						if (c == ';')
						{
							_state = State.Text;
							if (entity.Length > 0)
							{
								_value.Append(DecodeEntity("&" + entity + ";"));
							}
							else
							{
								_value.Append("&");
								_value.Append(";");
							}
						}
						else if (c == '#' && entity.Length == 0)
						{
							entity.Append(c);
						}
						else if (Char.IsLetterOrDigit(c))
						{
							entity.Append(c);
						}
						else
						{
							_state = State.Text;
							_peeker.Push(c);
							if (entity.Length > 0)
							{
								_value.Append(DecodeEntity("&" + entity + ";"));
							}
							else
							{
								_value.Append("&");
							}
							entity = null;
						}
						break;

					case State.Lt:
						if (c == '/')
						{
							_state = State.ElemClose;
						}
						else if (c == '?' && _peeker.Match("xml"))
						{
							_state = State.XmlDeclaration;
							_peeker.Read(3);
						}
						else if (c == '?')
						{
							_state = State.Pi;
						}
						else if (c == '!' && _peeker.Match("--"))
						{
							_peeker.Read(2);
							_state = State.Comment;
						}
						else if (c == '!' && _peeker.Match("[CDATA["))
						{
//.........这里部分代码省略.........
开发者ID:lakshithagit,项目名称:Target-Process-Plugins,代码行数:101,代码来源:HtmlReader.cs


示例6: WriteEndElement

		protected override void WriteEndElement(TextWriter result, string name)
		{
			if (!KeepElements.Contains(name))
				return;

			_prevNodeType = HtmlNodeType.None;
			base.WriteEndElement(result, name);
		}
开发者ID:TargetProcess,项目名称:Target-Process-Plugins,代码行数:8,代码来源:CommentHtmlProcessor.cs


示例7: WriteCData

		protected override void WriteCData(TextWriter result, string value)
		{
			_prevNodeType = HtmlNodeType.CDATA;
			base.WriteCData(result, value);
		}
开发者ID:TargetProcess,项目名称:Target-Process-Plugins,代码行数:5,代码来源:CommentHtmlProcessor.cs


示例8: EndTagHandler

        /// <summary>
        /// Start tags handler
        /// </summary>
        /// <param name="context">Markup parsing context</param>
        /// <param name="tag">HTML tag</param>
        private void EndTagHandler(MarkupParsingContext context, HtmlTag tag)
        {
            HtmlNodeType previousNodeType = _currentNodeType;
            string previousTagName;
            IList<HtmlAttribute> previousTagAttributes;
            if (_currentTag != null)
            {
                previousTagName = _currentTag.Name;
                previousTagAttributes = _currentTag.Attributes;
            }
            else
            {
                previousTagName = string.Empty;
                previousTagAttributes = new List<HtmlAttribute>();
            }
            string previousText = _currentText;

            _currentNodeType = HtmlNodeType.EndTag;
            _currentTag = tag;
            _currentText = string.Empty;

            string tagName = tag.Name;
            HtmlTagFlags tagFlags = tag.Flags;

            WhitespaceMinificationMode whitespaceMinificationMode = _settings.WhitespaceMinificationMode;
            if (whitespaceMinificationMode != WhitespaceMinificationMode.None)
            {
                if (_tagsWithNotRemovableWhitespaceQueue.Count == 0 && !tagFlags.EmbeddedCode)
                {
                    // Processing of whitespace, that followed before the end tag
                    bool allowTrimEnd = false;
                    if (tagFlags.Invisible)
                    {
                        allowTrimEnd = true;
                    }
                    else
                    {
                        if (whitespaceMinificationMode == WhitespaceMinificationMode.Medium)
                        {
                            allowTrimEnd = tagFlags.Block;
                        }
                        else if (whitespaceMinificationMode == WhitespaceMinificationMode.Aggressive)
                        {
                            allowTrimEnd = (tagFlags.Block || tagFlags.Inline || tagFlags.InlineBlock);
                        }
                    }

                    if (allowTrimEnd)
                    {
                        TrimEndLastBufferItem();
                    }
                }

                // Check if current tag is in a whitespace queue
                if (_tagsWithNotRemovableWhitespaceQueue.Count > 0 && tagName == _tagsWithNotRemovableWhitespaceQueue.Last())
                {
                    _tagsWithNotRemovableWhitespaceQueue.Dequeue();
                }
            }

            if (_settings.RemoveOptionalEndTags
                && (previousNodeType == HtmlNodeType.EndTag
                    || (previousTagName != tagName && string.IsNullOrWhiteSpace(previousText)))
                && !IsSafeOptionalEndTag(previousTagName))
            {

                if (CanRemoveOptionalTagByParentTagName(previousTagName, tagName))
                {
                    RemoveLastEndTagFromBuffer(previousTagName);
                }
            }

            bool isElementEmpty = (string.IsNullOrWhiteSpace(previousText) && previousTagName == tagName
                && previousNodeType != HtmlNodeType.EndTag);
            if (_settings.RemoveTagsWithoutContent && isElementEmpty
                && CanRemoveTagWithoutContent(previousTagName, previousTagAttributes))
            {
                // Remove last "element" from buffer, return
                if (RemoveLastStartTagFromBuffer(tagName))
                {
                    FlushBuffer();
                    return;
                }
            }

            if (_settings.RemoveOptionalEndTags && tagFlags.OptionalEndTag && IsSafeOptionalEndTag(tagName))
            {
                // Leave only start tag in buffer
                FlushBuffer();
                return;
            }

            // Add end tag to buffer
            _buffer.Add("</");
            _buffer.Add(tagName);
//.........这里部分代码省略.........
开发者ID:jinzesudawei,项目名称:WebMarkupMin,代码行数:101,代码来源:GenericHtmlMinifier.cs


示例9: IfConditionalCommentHandler

        /// <summary>
        /// If conditional comments handler
        /// </summary>
        /// <param name="context">Markup parsing context</param>
        /// <param name="htmlConditionalComment">Conditional comment</param>
        private void IfConditionalCommentHandler(MarkupParsingContext context,
			HtmlConditionalComment htmlConditionalComment)
        {
            _currentNodeType = HtmlNodeType.IfConditionalComment;
            HtmlConditionalCommentType htmlConditionalCommentType = htmlConditionalComment.Type;

            string startPart;
            string endPart;

            switch (htmlConditionalCommentType)
            {
                case HtmlConditionalCommentType.Hidden:
                    startPart = "<!--[if ";
                    endPart = "]>";

                    break;
                case HtmlConditionalCommentType.RevealedValidating:
                    startPart = "<!--[if ";
                    endPart = "]><!-->";

                    break;
                case HtmlConditionalCommentType.RevealedValidatingSimplified:
                    startPart = "<!--[if ";
                    endPart = "]>-->";

                    break;
                case HtmlConditionalCommentType.Revealed:
                    startPart = "<![if ";
                    endPart = "]>";

                    break;
                default:
                    throw new NotSupportedException();
            }

            _buffer.Add(startPart);
            _buffer.Add(htmlConditionalComment.Expression);
            _buffer.Add(endPart);
        }
开发者ID:jinzesudawei,项目名称:WebMarkupMin,代码行数:44,代码来源:GenericHtmlMinifier.cs


示例10: DoctypeHandler

        /// <summary>
        /// Document type declaration handler
        /// </summary>
        /// <param name="context">Markup parsing context</param>
        /// <param name="doctype">Document type declaration</param>
        private void DoctypeHandler(MarkupParsingContext context, string doctype)
        {
            _currentNodeType = HtmlNodeType.Doctype;

            WhitespaceMinificationMode whitespaceMinificationMode = _settings.WhitespaceMinificationMode;
            if (whitespaceMinificationMode != WhitespaceMinificationMode.None)
            {
                // Processing of whitespace, that followed before the document type declaration
                TrimEndLastBufferItem();
            }

            _buffer.Add(_settings.UseShortDoctype ? "<!DOCTYPE html>" : Utils.CollapseWhitespace(doctype));
        }
开发者ID:jinzesudawei,项目名称:WebMarkupMin,代码行数:18,代码来源:GenericHtmlMinifier.cs


示例11: EndIfConditionalCommentHandler

        /// <summary>
        /// End If conditional comments handler
        /// </summary>
        /// <param name="context">Markup parsing context</param>
        /// <param name="type">End If conditional comment type</param>
        private void EndIfConditionalCommentHandler(MarkupParsingContext context, HtmlConditionalCommentType type)
        {
            _currentNodeType = HtmlNodeType.EndIfConditionalComment;

            string endIfComment;

            switch (type)
            {
                case HtmlConditionalCommentType.Hidden:
                    endIfComment = "<![endif]-->";
                    break;
                case HtmlConditionalCommentType.RevealedValidating:
                case HtmlConditionalCommentType.RevealedValidatingSimplified:
                    endIfComment = "<!--<![endif]-->";
                    break;
                case HtmlConditionalCommentType.Revealed:
                    endIfComment = "<![endif]>";
                    break;
                default:
                    throw new NotSupportedException();
            }

            _buffer.Add(endIfComment);
        }
开发者ID:jinzesudawei,项目名称:WebMarkupMin,代码行数:29,代码来源:GenericHtmlMinifier.cs


示例12: CommentHandler

        /// <summary>
        /// Comments handler
        /// </summary>
        /// <param name="context">Markup parsing context</param>
        /// <param name="commentText">Comment text</param>
        private void CommentHandler(MarkupParsingContext context, string commentText)
        {
            _currentNodeType = HtmlNodeType.Comment;

            const int beginCommentLength = 4;
            string processedCommentText = string.Empty;

            if (_noindexCommentRegex.IsMatch(commentText))
            {
                // Processing of noindex comment
                Match noindexCommentMatch = _noindexCommentRegex.Match(commentText);
                processedCommentText = noindexCommentMatch.Groups["closingSlash"].Length > 0 ? "/noindex" : "noindex";
            }
            else if (KnockoutHelpers.IsEndContainerlessComment(commentText))
            {
                // Processing of end Knockout containerless comment
                processedCommentText = "/ko";
            }
            else if (KnockoutHelpers.IsBeginContainerlessComment(commentText))
            {
                // Processing of start Knockout containerless comment
                string koExpression = string.Empty;

                KnockoutHelpers.ParseBeginContainerlessComment(commentText,
                    (localContext, expression) =>
                    {
                        SourceCodeNodeCoordinates expressionCoordinates = localContext.NodeCoordinates;
                        expressionCoordinates.ColumnNumber += beginCommentLength;

                        koExpression = _settings.MinifyKnockoutBindingExpressions ?
                            MinifyKnockoutBindingExpression(context, expressionCoordinates, expression) : expression;
                    }
                );

                processedCommentText = "ko " + koExpression;
            }
            else if (AngularHelpers.IsCommentDirective(commentText))
            {
                // Processing of Angular comment directive
                string ngOriginalDirectiveName = string.Empty;
                string ngNormalizedDirectiveName = string.Empty;
                string ngExpression = string.Empty;

                AngularHelpers.ParseCommentDirective(commentText,
                    (localContext, originalDirectiveName, normalizedDirectiveName) =>
                    {
                        ngOriginalDirectiveName = originalDirectiveName;
                        ngNormalizedDirectiveName = normalizedDirectiveName;
                    },
                    (localContext, expression) =>
                    {
                        SourceCodeNodeCoordinates expressionCoordinates = localContext.NodeCoordinates;
                        expressionCoordinates.ColumnNumber += beginCommentLength;

                        ngExpression = expression;
                        if (_settings.MinifyAngularBindingExpressions
                            && ContainsAngularBindingExpression(ngNormalizedDirectiveName))
                        {
                            ngExpression = MinifyAngularBindingExpression(context, SourceCodeNodeCoordinates.Empty,
                                expressionCoordinates, expression);
                        }
                    }
                );

                processedCommentText = "directive:" + ngOriginalDirectiveName + " " + ngExpression;
            }
            else
            {
                if (!_settings.RemoveHtmlComments)
                {
                    processedCommentText = commentText;
                }
            }

            if (processedCommentText.Length > 0)
            {
                _buffer.Add("<!--");
                _buffer.Add(processedCommentText);
                _buffer.Add("-->");
            }
        }
开发者ID:jinzesudawei,项目名称:WebMarkupMin,代码行数:86,代码来源:GenericHtmlMinifier.cs


示例13: HtmlElementNodeBase

 protected HtmlElementNodeBase(HtmlNodeType type, HtmlDocument ownerdocument, int index)
     : base(type, ownerdocument, index)
 {
 }
开发者ID:ToFuKing,项目名称:HtmlAgilityPack,代码行数:4,代码来源:HtmlElementNodeBase.cs


示例14: SetNodeType

 protected void SetNodeType(HtmlNodeType nodeType)
 {
     this.nodeType = nodeType;
 }
开发者ID:prepare,项目名称:HTML-Renderer,代码行数:4,代码来源:DomNodes.cs


示例15: GetOuterHtml

            /// <summary>
            /// Returns the Html/Xml of the current Element up to its corresponding EndElement, unless the
            /// current Element is an empty element (e.g. ends with a /> and not just a >).  If it is an
            /// empty element, returns only the current Element.
            /// </summary>
            /// <returns>
            /// Returns a <Typ>TextReader</Typ> that gives access to the HTML (or XML as the case may be) from
            /// the current node (which must be an Element node) to the corresponding EndElement
            /// node (or the end of the file if the EndElement doesn't exist.)
            /// </returns>
            /// <remarks>
            /// After calling this method, the state of the parser will be that the current note type is "none."
            /// </remarks>
            /// <exception cref="InvalidOperationException">If the node type isn't an Element node,
            /// or the node's name is blank.</exception>
            internal TextReader GetOuterHtml()
            {
                PlainTextString name = Name;
                // the current node type must be an Element node and have a name.
                if (m_NodeType != HtmlNodeType.Element || String.IsNullOrEmpty(name)) throw new InvalidOperationException();

                // Move m_ParseWriter over to m_GetOuterHtmlWriter so everything gets copied into it, and it never
                // gets replaced (see ReadNextChar() - if m_GetOuterHtmlWriter is non-null, characters get
                // copied into it instead of m_ParseWriter.)
                m_GetOuterHtmlWriter = m_ParseWriter;
                m_ParseWriter = null;

                // Capture the rest of the current Element.  Set m_ParseMode to Skip to avoid saving
                // attribute values.
                m_ParseMode = ParseMode.Skip;
                try
                {
                    while (m_ParseState != HtmlParseState.None) Parse();
                }
                catch (EndOfStreamException)
                {
                    // do nothing
                }

                // If this isn't an empty element, find the corresponding EndElement
                if (!IsEmptyElement)
                {
                    // keep a count of Element node names equivalent to the current node name, to
                    // account for Elements of the same name that are inside the current Element,
                    // in order to stop parsing at the corrent EndElement.
                    int count = 1; // count the current Element
                    while (count > 0 && GetNextNode())
                    {
                        if (m_NodeType == HtmlNodeType.Element && 0 == String.Compare(Name, name, StringComparison.OrdinalIgnoreCase)) count++;
                        else if (m_NodeType == HtmlNodeType.EndElement && 0 == String.Compare(Name, name, StringComparison.OrdinalIgnoreCase)) count--;
                    }
                    // If there is still a count, it means GetNextNode returned false, meaning end of stream.
                    if (count == 0)
                    {
                        // make sure to finish parsing the current node
                        try
                        {
                            while (m_ParseState != HtmlParseState.None)
                            {
                                Parse();
                            }
                        }
                        catch (EndOfStreamException)
                        {
                            // do nothing
                        }
                    }
                }
                // transfer the stream writer's stream into a text reader and return it.
                m_GetOuterHtmlWriter.Flush();
                // the stream is a DetachableStream from the ReadNextChar() method
                DetachableStream detachableStream = (DetachableStream)m_GetOuterHtmlWriter.BaseStream;
                Stream stream = detachableStream.Stream; // the underlying stream
                // detach the stream from the m_GetOuterHtmlWriter
                detachableStream.Detach();
                // position the underlying stream at position 0 and hand it off to the StreamReader
                stream.Position = 0;
                StreamReader reader = new StreamReader(stream, m_GetOuterHtmlWriter.Encoding);
                m_GetOuterHtmlWriter.Dispose();
                m_GetOuterHtmlWriter = null;

                // set the current node type to "none"
                m_NodeType = HtmlNodeType.None;

                // return the reader
                return reader;
            }
开发者ID:supermuk,项目名称:iudico,代码行数:87,代码来源:HtmlTextReader.cs


示例16: StartTagHandler

        /// <summary>
        /// Start tags handler
        /// </summary>
        /// <param name="context">Markup parsing context</param>
        /// <param name="tag">HTML tag</param>
        private void StartTagHandler(MarkupParsingContext context, HtmlTag tag)
        {
            HtmlNodeType previousNodeType = _currentNodeType;
            string previousTagName = string.Empty;
            if (_currentTag != null)
            {
                previousTagName = _currentTag.Name;
            }

            if (_settings.UseMetaCharsetTag && IsMetaContentTypeTag(tag.Name, tag.Attributes))
            {
                tag = UpgradeToMetaCharsetTag(tag);
            }

            _currentNodeType = HtmlNodeType.StartTag;
            _currentTag = tag;
            _currentText = string.Empty;

            string tagName = tag.Name;
            IList<HtmlAttribute> attributes = tag.Attributes;
            HtmlTagFlags tagFlags = tag.Flags;

            // Set whitespace flags for nested tags (for example <span> within a <pre>)
            WhitespaceMinificationMode whitespaceMinificationMode = _settings.WhitespaceMinificationMode;
            if (whitespaceMinificationMode != WhitespaceMinificationMode.None)
            {
                if (_tagsWithNotRemovableWhitespaceQueue.Count == 0)
                {
                    // Processing of whitespace, that followed before the start tag
                    bool allowTrimEnd = false;
                    if (tagFlags.Invisible || tagFlags.NonIndependent)
                    {
                        allowTrimEnd = true;
                    }
                    else
                    {
                        if (whitespaceMinificationMode == WhitespaceMinificationMode.Medium
                            || whitespaceMinificationMode == WhitespaceMinificationMode.Aggressive)
                        {
                            allowTrimEnd = tagFlags.Block;
                        }
                    }

                    if (allowTrimEnd)
                    {
                        TrimEndLastBufferItem();
                    }
                }

                if (!CanMinifyWhitespace(tagName))
                {
                    _tagsWithNotRemovableWhitespaceQueue.Enqueue(tagName);
                }
            }

            if (_settings.RemoveOptionalEndTags
                && previousNodeType != HtmlNodeType.StartTag
                && !IsSafeOptionalEndTag(previousTagName))
            {
                if (CanRemoveOptionalEndTagByNextTagName(previousTagName, tagName))
                {
                    RemoveLastEndTagFromBuffer(previousTagName);
                }

                FlushBuffer();
            }

            _buffer.Add("<");
            _buffer.Add(tagName);

            int attributeCount = attributes.Count;

            for (int attributeIndex = 0; attributeIndex < attributeCount; attributeIndex++)
            {
                _buffer.Add(BuildAttributeString(context, tag, attributes[attributeIndex]));
            }

            if (tagFlags.Empty)
            {
                if (_settings.EmptyTagRenderMode == HtmlEmptyTagRenderMode.Slash)
                {
                    _buffer.Add("/");
                }
                else if (_settings.EmptyTagRenderMode == HtmlEmptyTagRenderMode.SpaceAndSlash)
                {
                    _buffer.Add(" /");
                }
            }
            _buffer.Add(">");
        }
开发者ID:jinzesudawei,项目名称:WebMarkupMin,代码行数:95,代码来源:GenericHtmlMinifier.cs


示例17: HtmlNode

        /// <summary>
        /// Initializes a new instance of the <see cref="HtmlNode"/> class.
        /// Initializes HtmlNode, providing type, owner and where it exists in a collection
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="ownerdocument">The owner document.</param>
        /// <param name="index">The index.</param>
        public HtmlNode(HtmlNodeType type, HtmlDocument ownerdocument, int index)
        {
            this.NodeType = type;
            this.OwnerDocument = ownerdocument;
            this.OuterStartIndex = index;

            switch (type)
            {
                case HtmlNodeType.Comment:
                    this.NodeName = HtmlNodeTypeNameComment;
                    this.EndNode = this;
                    break;

                case HtmlNodeType.Document:
                    this.NodeName = HtmlNodeTypeNameDocument;
                    this.EndNode = this;
                    break;

                case HtmlNodeType.Text:
                    this.NodeName = HtmlNodeTypeNameText;
                    this.EndNode = this;
                    break;
            }

            if (this.OwnerDocument.Openednodes != null)
            {
                if (!this.Closed)
                {
                    // we use the index as the key

                    // -1 means the node comes from public
                    if (-1 != index)
                    {
                        this.OwnerDocument.Openednodes.Add(index, this);
                    }
                }
            }

            if ((-1 != index) || (type == HtmlNodeType.Comment) || (type == HtmlNodeType.Text))
            {
                return;
            }

            // innerhtml and outerhtml must be calculated
            this.OuterChanged = true;
            this.InnerChanged = true;
        }
开发者ID:MGramolini,项目名称:vodca,代码行数:54,代码来源:HtmlNode.cs


示例18: TemplateTagHandler

        /// <summary>
        /// Template tags handler
        /// </summary>
        /// <param name="context">Markup parsing context</param>
        /// <param name="expression">Expression</param>
        /// <param name="startDelimiter">Start delimiter</param>
        /// <param name="endDelimiter">End delimiter</param>
        private void TemplateTagHandler(MarkupParsingContext context, string expression, string startDelimiter,
			string endDelimiter)
        {
            _currentNodeType = HtmlNodeType.TemplateTag;

            string processedExpression = expression;
            if (_settings.MinifyAngularBindingExpressions && startDelimiter == "{{" && endDelimiter == "}}")
            {
                processedExpression = MinifyAngularBindingExpression(context, expression);
            }

            _buffer.Add(startDelimiter);
            _buffer.Add(processedExpression);
            _buffer.Add(endDelimiter);
        }
开发者ID:jinzesudawei,项目名称:WebMarkupMin,代码行数:22,代码来源:GenericHtmlMinifier.cs


示例19: WriteText

		protected override void WriteText(TextWriter result, string value)
		{
			if (_prevNodeType == HtmlNodeType.Element && !string.IsNullOrEmpty(value))
			{
				value = value.TrimStart(new[] { '\r', '\n' });
			}

			if (TopTag != null)
			{
				switch (TopTag.ToLowerInvariant())
				{
					case "pre":
						string text = RewritePreText(RequiredHtmlEncode ? value.HtmlEncode() : value);
						_prevNodeType = HtmlNodeType.Text;
						result.Write(text);
						return;
				}
			}

			_prevNodeType = HtmlNodeType.Text;
			base.WriteText(result, value);
		}
开发者ID:TargetProcess,项目名称:Target-Process-Plugins,代码行数:22,代码来源:CommentHtmlProcessor.cs


示例20: TextHandler

        /// <summary>
        /// Text handler
        /// </summary>
        /// <param name="context">Markup parsing context</param>
        /// <param name="text">Text</param>
        private void TextHandler(MarkupParsingContext context, string text)
        {
            HtmlNodeType nodeType = _currentNodeType;
            string tagName;
            HtmlTagFlags tagFlags;
            IList<HtmlAttribute> attributes;
            if (_currentTag != null)
            {
                tagName = _currentTag.Name;
                tagFlags = _currentTag.Flags;
                attributes = _currentTag.Attributes;
            }
            else
            {
                tagName = string.Empty;
                tagFlags = new HtmlTagFlags();
                attributes = new List<HtmlAttribute>();
            }

            WhitespaceMinificationMode whitespaceMinificationMode = _settings.WhitespaceMinificationMode;

            if (nodeType == HtmlNodeType.StartTag && tagFlags.EmbeddedCode)
            {
                switch (tagName)
                {
                    case "script":
                    case "style":
                        string contentType = attributes
                            .Where(a => a.Name == "type")
                            .Select(a => a.Value)
                            .FirstOrDefault()
                            ;

                        if (tagName == "script")
                        {
                            if (string.IsNullOrWhiteSpace(contentType))
                            {
                                string language = attributes
                                    .Where(a => a.Name == "language")
                                    .Select(a => a.Value)
                                    .FirstOrDefault()
                                    ;

                                if (!string.IsNullOrWhiteSpace(language)
                                    && language.Trim().ToLowerInvariant() == "vbscript")
                                {
                                    contentType = VBS_CONTENT_TYPE;
                                }
                            }

                            text = ProcessEmbeddedScriptContent(context, text, contentType);
                        }
                        else if (tagName == "style")
                        {
                            text = ProcessEmbeddedStyleContent(context, text, contentType);
                        }

                        break;
                    case "svg":
                        text = ProcessEmbeddedSvgContent(context, text);
                        break;
                    case "math":
                        text = ProcessEmbeddedMathMlContent(context, text);
                        break;
                }
            }
            else
            {
                if (whitespaceMinificationMode != WhitespaceMinificationMode.None)
                {
                    if (_tagsWithNotRemovableWhitespaceQueue.Count == 0)
                    {
                        if (context.Position == 0)
                        {
                            // Processing of starting whitespace
                            text = text.TrimStart();
                        }
                        else if ((context.Position + text.Length) == context.Length)
                        {
                            // Processing of ending whitespace
                            text = text.TrimEnd();
                        }
                        else if (nodeType == HtmlNodeType.StartTag)
                        {
                            // Processing of whitespace, that followed after the start tag
                            bool allowTrimStart = false;
                            if (tagFlags.Invisible || (tagFlags.NonIndependent && tagFlags.Empty))
                            {
                                allowTrimStart = true;
                            }
                            else
                            {
                                if (whitespaceMinificationMode == WhitespaceMinificationMode.Medium)
                                {
                                    allowTrimStart = tagFlags.Block;
//.........这里部分代码省略.........
开发者ID:jinzesudawei,项目名称:WebMarkupMin,代码行数:101,代码来源:GenericHtmlMinifier.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# HtmlParseMode类代码示例发布时间:2022-05-24
下一篇:
C# HtmlMeta类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap