internal void WriteTagEnd(bool emptyScopeTag) { HtmlTagIndex tagIndex = HtmlNameData.names[(int)tagNameIndex].tagIndex; if (outputState > OutputState.BeforeAttribute) { OutputAttributeEnd(); } if (tagNameIndex > HtmlNameIndex.Unknown) { output.Write('>'); lineLength++; } else { if (tagNameIndex == HtmlNameIndex._COMMENT) { output.Write("-->"); lineLength += 3; } else if (tagNameIndex == HtmlNameIndex._ASP) { output.Write("%>"); lineLength += 2; } else if (tagNameIndex == HtmlNameIndex._CONDITIONAL) { output.Write("]-->"); lineLength += 4; } else if (tagNameIndex == HtmlNameIndex.Unknown && emptyScopeTag) { output.Write(" />"); lineLength += 3; } else { output.Write('>'); lineLength++; } tagNameIndex = previousTagNameIndex; } if (isEndTag && (tagIndex == HtmlTagIndex.LI || tagIndex == HtmlTagIndex.DD || tagIndex == HtmlTagIndex.DT)) { lineLength = 0; } if (autoNewLines && literalWhitespaceNesting == 0) { HtmlDtd.TagFmt fmt = HtmlDtd.tags[(int)tagIndex].fmt; HtmlDtd.TagFill fill = HtmlDtd.tags[(int)tagIndex].fill; if ((!isEndTag && fmt.RB == HtmlDtd.FmtCode.BRK) || (isEndTag && fmt.RE == HtmlDtd.FmtCode.BRK) || (lineLength > 80 && (allowWspBeforeFollowingTag || (!isEndTag && fill.RB == HtmlDtd.FillCode.EAT) || (isEndTag && fill.RE == HtmlDtd.FillCode.EAT)))) { if (lineLength > longestLineLength) { longestLineLength = lineLength; } output.Write("\r\n"); lineLength = 0; } } if (!isEndTag && !emptyScopeTag) { HtmlDtd.Literal literal = HtmlDtd.tags[(int)tagIndex].literal; if ((byte)(literal & HtmlDtd.Literal.Tags) != 0) { literalTags = true; literalEntities = (0 != (byte)(literal & HtmlDtd.Literal.Entities)); cssEscaping = (tagIndex == HtmlTagIndex.Style); } if (HtmlDtd.tags[(int)tagIndex].contextTextType == HtmlDtd.ContextTextType.Literal) { literalWhitespaceNesting++; } } outputState = OutputState.OutsideTag; }
internal void WriteTagEnd(bool emptyScopeTag) { InternalDebug.Assert(this.outputState != OutputState.OutsideTag); InternalDebug.Assert(!this.lastWhitespace); HtmlTagIndex tagIndex = HtmlNameData.names[(int)this.tagNameIndex].tagIndex; if (this.outputState > OutputState.BeforeAttribute) { this.OutputAttributeEnd(); } if (this.tagNameIndex > HtmlNameIndex.Unknown) { this.output.Write('>'); this.lineLength++; } else { if (this.tagNameIndex == HtmlNameIndex._COMMENT) { this.output.Write("-->"); this.lineLength += 3; } else if (this.tagNameIndex == HtmlNameIndex._ASP) { this.output.Write("%>"); this.lineLength += 2; } else if (this.tagNameIndex == HtmlNameIndex._CONDITIONAL) { this.output.Write("]-->"); this.lineLength += 4; } else if (this.tagNameIndex == HtmlNameIndex.Unknown && emptyScopeTag) { this.output.Write(" />"); this.lineLength += 3; } else { this.output.Write('>'); this.lineLength++; } this.tagNameIndex = this.previousTagNameIndex; } if (this.isEndTag && (tagIndex == HtmlTagIndex.LI || tagIndex == HtmlTagIndex.DD || tagIndex == HtmlTagIndex.DT)) { this.lineLength = 0; } if (this.autoNewLines && this.literalWhitespaceNesting == 0) { HtmlDtd.TagFmt tagFmt = HtmlDtd.tags[(int)tagIndex].fmt; HtmlDtd.TagFill tagFill = HtmlDtd.tags[(int)tagIndex].fill; if ((!this.isEndTag && tagFmt.RB == HtmlDtd.FmtCode.BRK) || (this.isEndTag && tagFmt.RE == HtmlDtd.FmtCode.BRK) || (this.lineLength > 80 && (this.allowWspBeforeFollowingTag || (!this.isEndTag && tagFill.RB == HtmlDtd.FillCode.EAT) || (this.isEndTag && tagFill.RE == HtmlDtd.FillCode.EAT)))) { if (this.lineLength > this.longestLineLength) { this.longestLineLength = this.lineLength; } this.output.Write("\r\n"); this.lineLength = 0; } } if (!this.isEndTag && !emptyScopeTag) { HtmlDtd.Literal literal = HtmlDtd.tags[(int)tagIndex].literal; if (0 != (literal & HtmlDtd.Literal.Tags)) { this.literalTags = true; this.literalEntities = (0 != (literal & HtmlDtd.Literal.Entities)); this.cssEscaping = (tagIndex == HtmlTagIndex.Style); } if (HtmlDtd.tags[(int)tagIndex].contextTextType == HtmlDtd.ContextTextType.Literal) { this.literalWhitespaceNesting++; } } this.outputState = OutputState.OutsideTag; }