@@ -129,7 +129,7 @@ function tokenBase(stream, state) {
129129 }
130130 // quoted string
131131 else if ( ! isEQName && ( ch === '"' || ch === "'" ) )
132- return chain ( stream , state , tokenString ( ch ) ) ;
132+ return startString ( stream , state , ch ) ;
133133 // variable
134134 else if ( ch === "$" ) {
135135 return chain ( stream , state , tokenVariable ) ;
@@ -229,42 +229,29 @@ function tokenComment(stream, state) {
229229function tokenString ( quote , f ) {
230230 return function ( stream , state ) {
231231 var ch ;
232-
233- if ( isInString ( state ) && stream . current ( ) == quote ) {
234- popStateStack ( state ) ;
235- if ( f ) state . tokenize = f ;
236- return "string" ;
237- }
238-
239- pushStateStack ( state , { type : "string" , name : quote , tokenize : tokenString ( quote , f ) } ) ;
240-
241- // if we're in a string and in an XML block, allow an embedded code block
242- if ( stream . match ( "{" , false ) && isInXmlAttributeBlock ( state ) ) {
243- state . tokenize = tokenBase ;
244- return "string" ;
245- }
246-
247-
248232 while ( ch = stream . next ( ) ) {
249- if ( ch == quote ) {
233+ if ( ch == quote ) {
250234 popStateStack ( state ) ;
251- if ( f ) state . tokenize = f ;
235+ if ( f ) state . tokenize = f ;
252236 break ;
253- }
254- else {
237+ } else if ( stream . match ( "{" , false ) && isInXmlAttributeBlock ( state ) ) {
255238 // if we're in a string and in an XML block, allow an embedded code block in an attribute
256- if ( stream . match ( "{" , false ) && isInXmlAttributeBlock ( state ) ) {
257- state . tokenize = tokenBase ;
258- return "string" ;
259- }
260-
239+ pushStateStack ( state , { type : "codeblock" } ) ;
240+ state . tokenize = tokenBase ;
241+ return "string" ;
261242 }
262243 }
263244
264245 return "string" ;
265246 } ;
266247}
267248
249+ function startString ( stream , state , quote , f ) {
250+ let tokenize = tokenString ( quote , f ) ;
251+ pushStateStack ( state , { type : "string" , name : quote , tokenize } ) ;
252+ return chain ( stream , state , tokenize ) ;
253+ }
254+
268255// tokenizer for variables
269256function tokenVariable ( stream , state ) {
270257 var isVariableChar = / [ \w \$ _ - ] / ;
@@ -322,7 +309,7 @@ function tokenAttribute(stream, state) {
322309 return null ;
323310 // quoted string
324311 if ( ch == '"' || ch == "'" )
325- return chain ( stream , state , tokenString ( ch , tokenAttribute ) ) ;
312+ return startString ( stream , state , ch , tokenAttribute ) ;
326313
327314 if ( ! isInXmlAttributeBlock ( state ) )
328315 pushStateStack ( state , { type : "attribute" , tokenize : tokenAttribute } ) ;
0 commit comments