protected override void OnBeginTag(BeginTag tag) { if (tag == null) { return; } if (_firstTag) { if (!tag.NameEquals(HTMLTokens.Html)) { EmitTag(HTMLTokens.Html); } _firstTag = false; } if (!_seenHead && !TagPermittedAboveBody(tag)) { Emit("<head>"); EmitAdditionalMetaData(); Emit("</head>"); _seenHead = true; } if (tag.NameEquals(HTMLTokens.Script)) { if (!tag.Complete) { _scriptDepth++; } return; } if (tag.NameEquals(HTMLTokens.Head)) { _seenHead = true; } else if (!_seenBody && !tag.NameEquals(HTMLTokens.Body)) { if (!TagPermittedAboveBody(tag)) { EmitTag(HTMLTokens.Body); _seenBody = true; } } else if (!_seenBody && tag.NameEquals(HTMLTokens.Body)) { _seenBody = true; } if (tag.NameEquals(HTMLTokens.Base)) { if (_metaData == null || _metaData.Base == null) { return; } else { Attr href = tag.GetAttribute(HTMLTokens.Href); if (href != null) { href.Value = _metaData.Base; } } _emittedMetaData.Add(HTMLTokens.Base); } if (tag.NameEquals(HTMLTokens.Meta)) { ModifyMetaDataAsNecessary(tag); } foreach (Attr attr in tag.Attributes) { if (attr != null) { if (IsScriptAttribute(attr)) { tag.RemoveAttribute(attr.Name); } else { attr.Value = ReplaceValue(attr.Value); } } } Emit(tag.ToString()); base.OnBeginTag(tag); }