@@ -3,9 +3,9 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
33 var Kludges = parserConfig . htmlMode ? {
44 autoSelfClosers : { "br" : true , "img" : true , "hr" : true , "link" : true , "input" : true ,
55 "meta" : true , "col" : true , "frame" : true , "base" : true , "area" : true } ,
6- doNotIndent : { "pre" : true , "!cdata" : true } ,
6+ doNotIndent : { "pre" : true } ,
77 allowUnquoted : true
8- } : { autoSelfClosers : { } , doNotIndent : { "!cdata" : true } , allowUnquoted : false } ;
8+ } : { autoSelfClosers : { } , doNotIndent : { } , allowUnquoted : false } ;
99 var alignCDATA = parserConfig . alignCDATA ;
1010
1111 // Return variables for tokenizers
@@ -21,7 +21,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
2121 if ( ch == "<" ) {
2222 if ( stream . eat ( "!" ) ) {
2323 if ( stream . eat ( "[" ) ) {
24- if ( stream . match ( "CDATA[" ) ) return chain ( inBlock ( "atom" , "]]>" , "!cdata" ) ) ;
24+ if ( stream . match ( "CDATA[" ) ) return chain ( inBlock ( "atom" , "]]>" ) ) ;
2525 else return null ;
2626 }
2727 else if ( stream . match ( "--" ) ) return chain ( inBlock ( "comment" , "-->" ) ) ;
@@ -90,7 +90,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
9090 } ;
9191 }
9292
93- function inBlock ( style , terminator , tp ) {
93+ function inBlock ( style , terminator ) {
9494 return function ( stream , state ) {
9595 while ( ! stream . eol ( ) ) {
9696 if ( stream . match ( terminator ) ) {
@@ -99,7 +99,6 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
9999 }
100100 stream . next ( ) ;
101101 }
102- type = tp ;
103102 return style ;
104103 } ;
105104 }
@@ -148,8 +147,10 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
148147 }
149148
150149 function element ( type ) {
151- if ( type == "openTag" ) { curState . tagName = tagName ; return cont ( attributes , endtag ( curState . startOfLine ) ) ; }
152- else if ( type == "closeTag" ) {
150+ if ( type == "openTag" ) {
151+ curState . tagName = tagName ;
152+ return cont ( attributes , endtag ( curState . startOfLine ) ) ;
153+ } else if ( type == "closeTag" ) {
153154 var err = false ;
154155 if ( curState . context ) {
155156 err = curState . context . tagName != tagName ;
@@ -159,12 +160,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
159160 if ( err ) setStyle = "error" ;
160161 return cont ( endclosetag ( err ) ) ;
161162 }
162- else if ( type == "!cdata" ) {
163- if ( ! curState . context || curState . context . name != "!cdata" ) pushContext ( "!cdata" ) ;
164- if ( curState . tokenize == inText ) popContext ( ) ;
165- return cont ( ) ;
166- }
167- else return cont ( ) ;
163+ return cont ( ) ;
168164 }
169165 function endtag ( startOfLine ) {
170166 return function ( type ) {
@@ -228,7 +224,8 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
228224
229225 indent : function ( state , textAfter , fullLine ) {
230226 var context = state . context ;
231- if ( context && context . noIndent )
227+ if ( ( state . tokenize != inTag && state . tokenize != inText ) ||
228+ context && context . noIndent )
232229 return fullLine ? fullLine . match ( / ^ ( \s * ) / ) [ 0 ] . length : 0 ;
233230 if ( alignCDATA && / < ! \[ C D A T A \[ / . test ( textAfter ) ) return 0 ;
234231 if ( context && / ^ < \/ / . test ( textAfter ) )
0 commit comments