@@ -122,7 +122,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
122
122
state . quote = 0 ;
123
123
// Reset state.indentedCode
124
124
state . indentedCode = false ;
125
- if ( htmlModeMissing && state . f == htmlBlock ) {
125
+ if ( state . f == htmlBlock ) {
126
126
state . f = inlineNormal ;
127
127
state . block = blockNormal ;
128
128
}
@@ -250,10 +250,17 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
250
250
}
251
251
252
252
function local ( stream , state ) {
253
- if ( state . fencedChars && stream . match ( state . fencedChars , false ) ) {
253
+ if ( state . fencedChars && stream . match ( state . fencedChars ) ) {
254
+ if ( modeCfg . highlightFormatting ) state . formatting = "code-block" ;
255
+ var returnType = getType ( state )
254
256
state . localMode = state . localState = null ;
255
- state . f = state . block = leavingLocal ;
256
- return null ;
257
+ state . block = blockNormal ;
258
+ state . f = inlineNormal ;
259
+ state . fencedChars = null ;
260
+ state . code = 0
261
+ return returnType ;
262
+ } else if ( state . fencedChars && stream . skipTo ( state . fencedChars ) ) {
263
+ return "comment"
257
264
} else if ( state . localMode ) {
258
265
return state . localMode . token ( stream , state . localState ) ;
259
266
} else {
@@ -265,25 +272,6 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
265
272
}
266
273
}
267
274
268
- function leavingLocal ( stream , state ) {
269
- stream . match ( state . fencedChars ) ;
270
- state . block = blockNormal ;
271
- state . f = inlineNormal ;
272
- state . fencedChars = null ;
273
- if ( state . math === - 1 ) {
274
- state . formatting = "math" ;
275
- state . math = 1
276
- var returnType = getType ( state ) ;
277
- state . math = 0
278
- return returnType ;
279
- }
280
- if ( modeCfg . highlightFormatting ) state . formatting = "code-block" ;
281
- state . code = 1
282
- var returnType = getType ( state ) ;
283
- state . code = 0
284
- return returnType ;
285
- }
286
-
287
275
// Inline
288
276
function getType ( state ) {
289
277
var styles = [ ] ;
@@ -479,7 +467,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
479
467
return getType ( state ) ;
480
468
}
481
469
482
- if ( ch === '[' && state . imageMarker ) {
470
+ if ( ch === '[' && state . imageMarker && stream . match ( / [ ^ \] ] * \] ( \( . * ? \) | ? \[ . * ? \] ) / , false ) ) {
483
471
state . imageMarker = false ;
484
472
state . imageAltText = true
485
473
if ( modeCfg . highlightFormatting ) state . formatting = "image" ;
@@ -533,7 +521,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
533
521
return type + tokenTypes . linkEmail ;
534
522
}
535
523
536
- if ( ch === '<' && stream . match ( / ^ ( ! - - | \w ) / , false ) ) {
524
+ if ( ch === '<' && stream . match ( / ^ ( ! - - | [ a - z ] + (?: \s + [ a - z _ : . \- ] + (?: \s * = \s * [ ^ > ] + ) ? ) * \s * > ) / i , false ) ) {
537
525
var end = stream . string . indexOf ( ">" , stream . pos ) ;
538
526
if ( end != - 1 ) {
539
527
var atts = stream . string . substring ( stream . start , end ) ;
0 commit comments