Skip to content

Commit 9ea789b

Browse files
committed
[markdown mode] Improve exiting html sub-mode on blank line
Use same logic as that in htmlBlock Issue codemirror#5451
1 parent 11dfc2f commit 9ea789b

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

mode/markdown/markdown.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,13 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
126126
// Reset state.indentedCode
127127
state.indentedCode = false;
128128
if (state.f == htmlBlock) {
129-
var htmlState = state.htmlState;
130-
while ('htmlState' in htmlState) htmlState = htmlState.htmlState; // htmlmixed -> xml
131-
if (!htmlState || !htmlState.tokenize || !htmlState.tokenize.isInBlock) {
129+
var exit = htmlModeMissing
130+
if (!exit) {
131+
var inner = CodeMirror.innerMode(htmlMode, state.htmlState)
132+
exit = inner.mode.name == "xml" && inner.state.tagStart === null &&
133+
(!inner.state.context && inner.state.tokenize.isInText)
134+
}
135+
if (exit) {
132136
state.f = inlineNormal;
133137
state.block = blockNormal;
134138
state.htmlState = null;

mode/xml/xml.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
154154
}
155155

156156
function inBlock(style, terminator) {
157-
var closure = function(stream, state) {
157+
return function(stream, state) {
158158
while (!stream.eol()) {
159159
if (stream.match(terminator)) {
160160
state.tokenize = inText;
@@ -163,9 +163,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
163163
stream.next();
164164
}
165165
return style;
166-
};
167-
closure.isInBlock = true;
168-
return closure;
166+
}
169167
}
170168

171169
function doctype(depth) {

0 commit comments

Comments
 (0)