diff --git a/html.go b/html.go index f1a60de2..6e9f35c0 100644 --- a/html.go +++ b/html.go @@ -45,27 +45,29 @@ const ( SmartypantsLatexDashes // Enable LaTeX-style dashes (with Smartypants) SmartypantsAngledQuotes // Enable angled double quotes (with Smartypants) for double quotes rendering TOC // Generate a table of contents - - TagName = "[A-Za-z][A-Za-z0-9-]*" - AttributeName = "[a-zA-Z_:][a-zA-Z0-9:._-]*" - UnquotedValue = "[^\"'=<>`\\x00-\\x20]+" - SingleQuotedValue = "'[^']*'" - DoubleQuotedValue = "\"[^\"]*\"" - AttributeValue = "(?:" + UnquotedValue + "|" + SingleQuotedValue + "|" + DoubleQuotedValue + ")" - AttributeValueSpec = "(?:" + "\\s*=" + "\\s*" + AttributeValue + ")" - Attribute = "(?:" + "\\s+" + AttributeName + AttributeValueSpec + "?)" - OpenTag = "<" + TagName + Attribute + "*" + "\\s*/?>" - CloseTag = "</" + TagName + "\\s*[>]" - HTMLComment = "<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->" - ProcessingInstruction = "[<][?].*?[?][>]" - Declaration = "<![A-Z]+" + "\\s+[^>]*>" - CDATA = "<!\\[CDATA\\[[\\s\\S]*?\\]\\]>" - HTMLTag = "(?:" + OpenTag + "|" + CloseTag + "|" + HTMLComment + "|" + - ProcessingInstruction + "|" + Declaration + "|" + CDATA + ")" ) var ( - htmlTagRe = regexp.MustCompile("(?i)^" + HTMLTag) + htmlTagRe = regexp.MustCompile("(?i)^" + htmlTag) +) + +const ( + htmlTag = "(?:" + openTag + "|" + closeTag + "|" + htmlComment + "|" + + processingInstruction + "|" + declaration + "|" + cdata + ")" + closeTag = "</" + tagName + "\\s*[>]" + openTag = "<" + tagName + attribute + "*" + "\\s*/?>" + attribute = "(?:" + "\\s+" + attributeName + attributeValueSpec + "?)" + attributeValue = "(?:" + unquotedValue + "|" + singleQuotedValue + "|" + doubleQuotedValue + ")" + attributeValueSpec = "(?:" + "\\s*=" + "\\s*" + attributeValue + ")" + attributeName = "[a-zA-Z_:][a-zA-Z0-9:._-]*" + cdata = "<!\\[CDATA\\[[\\s\\S]*?\\]\\]>" + declaration = "<![A-Z]+" + "\\s+[^>]*>" + doubleQuotedValue = "\"[^\"]*\"" + htmlComment = "<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->" + processingInstruction = "[<][?].*?[?][>]" + singleQuotedValue = "'[^']*'" + tagName = "[A-Za-z][A-Za-z0-9-]*" + unquotedValue = "[^\"'=<>`\\x00-\\x20]+" ) // HTMLRendererParameters is a collection of supplementary parameters tweaking