private void EmbeddedCodeHandler(MarkupParsingContext context, string code)
{
HtmlNodeType previousNodeType = _currentNodeType;
HtmlTag tag = _currentTag ?? HtmlTag.Empty;
string tagNameInLowercase = tag.NameInLowercase;
IList<HtmlAttribute> attributes = tag.Attributes;
_currentNodeType = HtmlNodeType.EmbeddedCode;
string contentType = attributes
.Where(a => a.NameInLowercase == "type")
.Select(a => a.Value)
.FirstOrDefault()
;
switch (tagNameInLowercase)
{
case "script":
if (string.IsNullOrWhiteSpace(contentType))
{
string language = attributes
.Where(a => a.NameInLowercase == "language")
.Select(a => a.Value)
.FirstOrDefault()
;
if (!string.IsNullOrWhiteSpace(language)
&& language.Trim().IgnoreCaseEquals("vbscript"))
{
contentType = VBS_CONTENT_TYPE;
}
}
ProcessEmbeddedScriptContent(context, code, contentType);
break;
case "style":
ProcessEmbeddedStyleContent(context, code, contentType);
break;
default:
throw new NotSupportedException();
}
if (_currentText.Length == 0)
{
_currentNodeType = previousNodeType;
}
}