summaryrefslogtreecommitdiff
path: root/pygments/lexers/web.py
diff options
context:
space:
mode:
Diffstat (limited to 'pygments/lexers/web.py')
-rw-r--r--pygments/lexers/web.py33
1 files changed, 28 insertions, 5 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),