Commits

Steve Spigarelli committed 54a6f90

updated test file and updated web.py to have some fixes for   entity and fixed some element_content callbacks that were injecting operators instead

  • Participants
  • Parent commits f90ec02

Comments (0)

Files changed (2)

pygments/lexers/web.py

     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')|("")|([^&"]))*")'
         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()
         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')
             (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),
         '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),

tests/examplefiles/test.xqy

 
 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))
 	</form>
 	</outer>
 }
+  <tr><td><!-- some commented things-->&nbsp;</td></tr>
 </html>