From 1f13423d3ebb2c269f68e00cd3c4705f9c141a63 Mon Sep 17 00:00:00 2001 From: Mike Samuel Date: Fri, 9 Sep 2011 00:07:40 -0700 Subject: [PATCH] exp/template/html: Grammar rules for HTML comments and special tags. Augments type context and adds grammatical rules to handle special HTML constructs: This CL does not elide comment content. I recommend we do that but have not done it in this CL. I used a codesearch tool over a codebase in another template language. Based on the below I think we should definitely recognize once that CL - // has been merged. + if d, t := tSpecialTagEnd(c, s); t != nil { + return d, t + } i := bytes.IndexAny(s, `"'/`) if i == -1 { @@ -453,8 +503,9 @@ func tJS(c context, s []byte) (context, []byte) { // tJSStr is the context transition function for the JS string states. func tJSStr(c context, s []byte) (context, []byte) { - // TODO: delegate to tSpecialTagEnd to find any once that CL - // has been merged. + if d, t := tSpecialTagEnd(c, s); t != nil { + return d, t + } quoteAndEsc := `\"` if c.state == stateJSSqStr { @@ -486,8 +537,9 @@ func tJSStr(c context, s []byte) (context, []byte) { // tJSRegexp is the context transition function for the /RegExp/ literal state. func tJSRegexp(c context, s []byte) (context, []byte) { - // TODO: delegate to tSpecialTagEnd to find any once that CL - // has been merged. + if d, t := tSpecialTagEnd(c, s); t != nil { + return d, t + } b := s inCharset := false @@ -536,7 +588,9 @@ var blockCommentEnd = []byte("*/") // tBlockCmt is the context transition function for /*comment*/ states. func tBlockCmt(c context, s []byte) (context, []byte) { - // TODO: look for ", `