@@ -139,6 +139,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
139
139
140
140
function blockNormal ( stream , state ) {
141
141
var sol = stream . sol ( ) ;
142
+ var firstTokenOnLine = stream . column ( ) === state . indentation ;
142
143
var prevLineLineIsEmpty = lineIsEmpty ( state . prevLine ) ;
143
144
var prevLineIsIndentedCode = state . indentedCode ;
144
145
var prevLineIsHr = state . hr ;
@@ -182,7 +183,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
182
183
return tokenTypes . code ;
183
184
} else if ( stream . eatSpace ( ) ) {
184
185
return null ;
185
- } else if ( ( match = stream . match ( atxHeaderRE ) ) && match [ 1 ] . length <= 6 ) {
186
+ } else if ( firstTokenOnLine && state . indentation <= maxNonCodeIndentation && ( match = stream . match ( atxHeaderRE ) ) && match [ 1 ] . length <= 6 ) {
187
+ state . quote = 0 ;
186
188
state . header = match [ 1 ] . length ;
187
189
if ( modeCfg . highlightFormatting ) state . formatting = "header" ;
188
190
state . f = state . inline ;
@@ -192,11 +194,12 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
192
194
if ( modeCfg . highlightFormatting ) state . formatting = "quote" ;
193
195
stream . eatSpace ( ) ;
194
196
return getType ( state ) ;
195
- } else if ( ! isHr && ! state . quote && ( match = stream . match ( listRE ) ) ) {
197
+ } else if ( ! isHr && firstTokenOnLine && state . indentation <= maxNonCodeIndentation && ( match = stream . match ( listRE ) ) ) {
196
198
var listType = match [ 1 ] ? "ol" : "ul" ;
197
199
198
200
state . indentation = lineIndentation + stream . current ( ) . length ;
199
201
state . list = true ;
202
+ state . quote = 0 ;
200
203
201
204
// Add this list item's content's indentation to the stack
202
205
state . listStack . push ( state . indentation ) ;
@@ -207,7 +210,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
207
210
state . f = state . inline ;
208
211
if ( modeCfg . highlightFormatting ) state . formatting = [ "list" , "list-" + listType ] ;
209
212
return getType ( state ) ;
210
- } else if ( modeCfg . fencedCodeBlocks && ! state . quote && ( match = stream . match ( fencedCodeRE , true ) ) ) {
213
+ } else if ( modeCfg . fencedCodeBlocks && firstTokenOnLine && state . indentation <= maxNonCodeIndentation && ( match = stream . match ( fencedCodeRE , true ) ) ) {
214
+ state . quote = 0 ;
211
215
state . fencedChars = match [ 1 ]
212
216
// try switching mode
213
217
state . localMode = getMode ( match [ 2 ] ) ;
0 commit comments