Skip to content
Snippets Groups Projects
Commit 60d1a08b authored by Brandon Frohs's avatar Brandon Frohs Committed by Marijn Haverbeke
Browse files

[markdown] Only match list items that follow a blank line.

Per Dingus.
parent c253a908
No related branches found
No related tags found
No related merge requests found
......@@ -106,6 +106,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
function blockNormal(stream, state) {
var prevLineIsList = (state.list !== false);
if (state.list !== false && state.indentationDiff >= 0) { // Continued list
if (state.indentationDiff < 4) { // Only adjust indentation if *not* a code block
state.indentation -= state.indentationDiff;
......@@ -114,7 +115,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
} else if (state.list !== false && state.indentation > 0) {
state.list = null;
state.listDepth = Math.floor(state.indentation / 4);
} else { // No longer a list
} else if (state.list !== false) { // No longer a list
state.list = false;
state.listDepth = 0;
}
......@@ -139,7 +140,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
return switchInline(stream, state, footnoteLink);
} else if (stream.match(hrRE, true)) {
return hr;
} else if (stream.match(ulRE, true) || stream.match(olRE, true)) {
} else if ((!prevLineHasContent || prevLineIsList) && (stream.match(ulRE, true) || stream.match(olRE, true))) {
state.indentation += 4;
state.list = true;
state.listDepth++;
......
......@@ -130,6 +130,11 @@
MT("blockquoteNoSpace",
"[atom >foo]");
// No blank line before blockquote
MT("blockquoteNoBlankLine",
"foo",
"[atom > bar]");
// Nested blockquote
MT("blockquoteSpace",
"[atom > foo]",
......@@ -184,6 +189,12 @@
"[variable-2 1. foo]",
"[variable-2 2. bar]");
// Lists require a preceding blank line (per Dingus)
MT("listBogus",
"foo",
"1. bar",
"2. hello");
// Formatting in lists (*)
MT("listAsteriskFormatting",
"[variable-2 * ][variable-2&em *foo*][variable-2 bar]",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment