MCPcopy Create free account
hub / github.com/TruthHun/BookStack / blockNormal

Function blockNormal

static/editor.md/lib/codemirror/mode/markdown/markdown.js:115–188  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

113 }
114
115 function blockNormal(stream, state) {
116
117 var sol = stream.sol();
118
119 var prevLineIsList = (state.list !== false);
120 if (state.list !== false && state.indentationDiff >= 0) { // Continued list
121 if (state.indentationDiff < 4) { // Only adjust indentation if *not* a code block
122 state.indentation -= state.indentationDiff;
123 }
124 state.list = null;
125 } else if (state.list !== false && state.indentation > 0) {
126 state.list = null;
127 state.listDepth = Math.floor(state.indentation / 4);
128 } else if (state.list !== false) { // No longer a list
129 state.list = false;
130 state.listDepth = 0;
131 }
132
133 var match = null;
134 if (state.indentationDiff >= 4) {
135 state.indentation -= 4;
136 stream.skipToEnd();
137 return code;
138 } else if (stream.eatSpace()) {
139 return null;
140 } else if (match = stream.match(atxHeaderRE)) {
141 state.header = match[0].length <= 6 ? match[0].length : 6;
142 if (modeCfg.highlightFormatting) state.formatting = "header";
143 state.f = state.inline;
144 return getType(state);
145 } else if (state.prevLineHasContent && (match = stream.match(setextHeaderRE))) {
146 state.header = match[0].charAt(0) == '=' ? 1 : 2;
147 if (modeCfg.highlightFormatting) state.formatting = "header";
148 state.f = state.inline;
149 return getType(state);
150 } else if (stream.eat('>')) {
151 state.indentation++;
152 state.quote = sol ? 1 : state.quote + 1;
153 if (modeCfg.highlightFormatting) state.formatting = "quote";
154 stream.eatSpace();
155 return getType(state);
156 } else if (stream.peek() === '[') {
157 return switchInline(stream, state, footnoteLink);
158 } else if (stream.match(hrRE, true)) {
159 return hr;
160 } else if ((!state.prevLineHasContent || prevLineIsList) && (stream.match(ulRE, false) || stream.match(olRE, false))) {
161 var listType = null;
162 if (stream.match(ulRE, true)) {
163 listType = 'ul';
164 } else {
165 stream.match(olRE, true);
166 listType = 'ol';
167 }
168 state.indentation += 4;
169 state.list = true;
170 state.listDepth++;
171 if (modeCfg.taskLists && stream.match(taskListRE, false)) {
172 state.taskList = true;

Callers

nothing calls this directly

Calls 3

switchInlineFunction · 0.85
getTypeFunction · 0.70
getModeFunction · 0.70

Tested by

no test coverage detected