WebMarkupMin.Core.Parsers.HtmlParser.ProcessStartTag C# (CSharp) Method

ProcessStartTag() private method

Process a start tag
private ProcessStartTag ( ) : bool
return bool
        private bool ProcessStartTag()
        {
            bool isProcessed = false;
            string content = _innerContext.SourceCode;
            int contentRemainderLength = _innerContext.RemainderLength;

            var match = _startTagRegex.Match(content, _innerContext.Position, contentRemainderLength);
            if (match.Success)
            {
                GroupCollection groups = match.Groups;
                string startTagName = groups["tagName"].Value;
                string startTagNameInLowercase = startTagName;
                if (Utils.ContainsUppercaseCharacters(startTagName))
                {
                    startTagNameInLowercase = startTagName.ToLowerInvariant();
                }

                Group invalidCharactersGroup = groups["invalidCharacters"];
                if (invalidCharactersGroup.Success)
                {
                    int invalidCharactersPosition = invalidCharactersGroup.Index;
                    int invalidCharactersOffset = invalidCharactersPosition - _innerContext.Position;

                    _innerContext.IncreasePosition(invalidCharactersOffset);

                    throw new MarkupParsingException(
                        string.Format(Strings.ErrorMessage_InvalidCharactersInStartTag, startTagName),
                        _innerContext.NodeCoordinates, _innerContext.GetSourceFragment());
                }

                string startTag = match.Value;
                bool isEmptyTag = groups["emptyTagSlash"].Success;

                Group attributesGroup = groups["attributes"];
                var attributesCoordinates = SourceCodeNodeCoordinates.Empty;
                int attributesPosition = -1;
                string attributesString = string.Empty;

                if (attributesGroup.Success)
                {
                    attributesPosition = attributesGroup.Index;
                    attributesString = attributesGroup.Value;
                }

                if (attributesPosition != -1)
                {
                    int nodePosition = _innerContext.Position;
                    SourceCodeNodeCoordinates nodeCoordinates = _innerContext.NodeCoordinates;
                    int attributesOffset = attributesPosition - nodePosition;

                    int lineBreakCount;
                    int charRemainderCount;

                    SourceCodeNavigator.CalculateLineBreakCount(content, nodePosition,
                        attributesOffset, out lineBreakCount, out charRemainderCount);

                    attributesCoordinates = SourceCodeNavigator.CalculateAbsoluteNodeCoordinates(
                        nodeCoordinates, lineBreakCount, charRemainderCount);
                }

                ParseStartTag(startTagName, startTagNameInLowercase, attributesString, attributesCoordinates,
                    isEmptyTag);

                _innerContext.IncreasePosition(startTag.Length);
                isProcessed = true;
            }

            return isProcessed;
        }