public override object VisitHtmlElement([NotNull] HtmlElementContext context) { var content = context.htmlContent(); var name = context.htmlTagName(0)?.GetText(); if (name == null || name.ToUpper() != "HEAD") { return(base.VisitHtmlElement(context)); } HtmlElemFactory factory = new HtmlElemFactory(); var space = new CommonToken(SEA_WS, " "); foreach (var item in files) { HtmlElementContext elem = new HtmlElementContext(content, 0); elem.AddChild(new CommonToken(TAG_OPEN, "<")); elem.AddChild(factory.CreateTagName(elem, "link")); elem.AddChild(space); var type = factory.CreateAttribute(elem, "type", "text/css"); elem.AddChild(type); elem.AddChild(space); var rel = factory.CreateAttribute(elem, "rel", "styleSheet"); elem.AddChild(rel); elem.AddChild(space); var href = factory.CreateAttribute(elem, "href", item.FileName); elem.AddChild(href); elem.AddChild(new CommonToken(TAG_SLASH_CLOSE, "/>")); content.AddChild(elem); } return(null); }
public override object VisitHtmlElement([NotNull] HtmlElementContext context) { var content = context.htmlContent(); var name = context.htmlTagName(0)?.GetText(); if (name == null || name.ToUpper() != "BODY") { return(base.VisitHtmlElement(context)); } HtmlElemFactory factory = new HtmlElemFactory(); foreach (var item in files) { HtmlElementContext elem = new HtmlElementContext(content, 0); ScriptContext script = new ScriptContext(elem, 0); script.AddChild(new CommonToken(RULE_script, "<script")); script.AddChild(new CommonToken(SEA_WS, " ")); var attribute = factory.CreateAttribute(script, "src", item.FileName); script.AddChild(attribute); script.AddChild(new CommonToken(TAG_CLOSE, ">")); script.AddChild(new HtmlContentContext(script, 0)); script.AddChild(new CommonToken(TAG_OPEN, "<")); script.AddChild(new CommonToken(TAG_SLASH, "/")); script.AddChild(factory.CreateTagName(script, "script")); script.AddChild(new CommonToken(TAG_CLOSE, ">")); elem.AddChild(script); content.AddChild(elem); } return(null); }