diff options
author | Steve Spigarelli <spig@spig.net> | 2010-12-20 23:51:12 -0700 |
---|---|---|
committer | Steve Spigarelli <spig@spig.net> | 2010-12-20 23:51:12 -0700 |
commit | 12f1cdf6b1aa66f260c9730aea18a13ac6b9f873 (patch) | |
tree | c3864f7e044acd1a4df7240c43e7f9990f60be97 | |
parent | d584af251c63006a42d316bd8fac177e998ca402 (diff) | |
download | pygments-12f1cdf6b1aa66f260c9730aea18a13ac6b9f873.tar.gz |
updated test file and updated web.py to have some fixes for entity and fixed some element_content callbacks that were injecting operators instead
-rw-r--r-- | pygments/lexers/web.py | 33 | ||||
-rw-r--r-- | tests/examplefiles/test.xqy | 3 |
2 files changed, 30 insertions, 6 deletions
diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py index 602fe5e4..d95daf7b 100644 --- a/pygments/lexers/web.py +++ b/pygments/lexers/web.py @@ -1961,7 +1961,7 @@ class XQueryLexer(ExtendedRegexLexer): unprefixedname = ncname qname = "((%s)|(%s))" %(prefixedname, unprefixedname) - entityref = r'&(lt|gt|amp|quot|apos);' + entityref = r'&(lt|gt|amp|quot|apos|nbsp);' charref = r'&#[0-9]+;|&#x[0-9a-fA-F]+;' stringdouble = r'("((' + entityref + r')|(' + charref + r')|("")|([^&"]))*")' @@ -1996,6 +1996,11 @@ class XQueryLexer(ExtendedRegexLexer): ctx.stack.append(lexer.xquery_parse_state.pop()) ctx.pos = match.end() + def popstate_xmlcomment_callback(lexer, match, ctx): + yield match.start(), String.Doc, match.group(1) + ctx.stack.append(lexer.xquery_parse_state.pop()) + ctx.pos = match.end() + def popstate_kindtest_callback(lexer, match, ctx): yield match.start(), Punctuation, match.group(1) next_state = lexer.xquery_parse_state.pop() @@ -2072,12 +2077,30 @@ class XQueryLexer(ExtendedRegexLexer): lexer.xquery_parse_state.append('operator') ctx.pos = match.end() + def pushstate_element_content_processing_instruction_callback(lexer, match, ctx): + yield match.start(), String.Doc, match.group(1) + ctx.stack.append('processing_instruction') + lexer.xquery_parse_state.append('element_content') + ctx.pos = match.end() + + def pushstate_element_content_cdata_section_callback(lexer, match, ctx): + yield match.start(), String.Doc, match.group(1) + ctx.stack.append('cdata_section') + lexer.xquery_parse_state.append('element_content') + ctx.pos = match.end() + def pushstate_operator_cdata_section_callback(lexer, match, ctx): yield match.start(), String.Doc, match.group(1) ctx.stack.append('cdata_section') lexer.xquery_parse_state.append('operator') ctx.pos = match.end() + def pushstate_element_content_xmlcomment_callback(lexer, match, ctx): + yield match.start(), String.Doc, match.group(1) + ctx.stack.append('xml_comment') + lexer.xquery_parse_state.append('element_content') + ctx.pos = match.end() + def pushstate_operator_xmlcomment_callback(lexer, match, ctx): yield match.start(), String.Doc, match.group(1) ctx.stack.append('xml_comment') @@ -2296,7 +2319,7 @@ class XQueryLexer(ExtendedRegexLexer): (r'\?', Punctuation), ], 'xml_comment': [ - (r'-->', String.Doc, '#pop'), + (r'(-->)', popstate_xmlcomment_callback), (r'[^-]{1,2}', Literal), (r'\u009|\u00A|\u00D|[\u0020-\u00D7FF]|[\u00E000-\u00FFFD]|' r'[\u0010000-\u0010FFFF]', Literal), @@ -2346,9 +2369,9 @@ class XQueryLexer(ExtendedRegexLexer): 'element_content': [ (r'</', Name.Tag, 'end_tag'), (r'(\{)', pushstate_root_callback), - (r'(<!--)', pushstate_operator_xmlcomment_callback), - (r'(<\?)', pushstate_operator_processing_instruction_callback), - (r'(<!\[CDATA\[)', pushstate_operator_cdata_section_callback), + (r'(<!--)', pushstate_element_content_xmlcomment_callback), + (r'(<\?)', pushstate_element_content_processing_instruction_callback), + (r'(<!\[CDATA\[)', pushstate_element_content_cdata_section_callback), (r'(<)', pushstate_element_content_starttag_callback), (elementcontentchar, Literal), (entityref, Literal), diff --git a/tests/examplefiles/test.xqy b/tests/examplefiles/test.xqy index b55c4848..92f9d5a6 100644 --- a/tests/examplefiles/test.xqy +++ b/tests/examplefiles/test.xqy @@ -14,7 +14,7 @@ declare variable $SESSIONS as element(sess:session)* := c:sessions(); declare option sess:clear "false"; -define function whatsit($param xs:string) as xs:string { +define function whatsit($param as xs:string) as xs:string { let $var1 := 1 let $var2 := 2 return (1 + 2 div ($var1 + $var2)) @@ -132,4 +132,5 @@ return </form> </outer> } + <tr><td><!-- some commented things--> </td></tr> </html> |