Skip to content

Commit 3bf60c7

Browse files
committed
Add blankLine method to mode API
So that languages in which blank lines are significant can detect them.
1 parent 2a72130 commit 3bf60c7

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/codemirror.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,6 +1633,7 @@ var CodeMirror = (function() {
16331633
highlight: function(mode, state) {
16341634
var stream = new StringStream(this.text), st = this.styles, pos = 0;
16351635
var changed = false, curWord = st[0], prevWord;
1636+
if (this.text == "" && mode.blankLine) mode.blankLine(state);
16361637
while (!stream.eol()) {
16371638
var style = mode.token(stream, state);
16381639
var substr = this.text.slice(stream.start, stream.pos);

manual.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,12 @@ <h2 id="modeapi">Writing CodeMirror Modes</h2>
625625
CSS class string, or <code>null</code> for tokens that do not have
626626
to be styled.<p>
627627

628+
<p id="blankLine">By default, blank lines are simply skipped when
629+
tokenizing a document. For languages that have significant blank
630+
lines, you can define a <code>blankLine(state)</code> method on
631+
your mode that will get called whenever a blank line is passed
632+
over, so that it can update the parser state.</p>
633+
628634
<p id="StringStream">The stream object encapsulates a line of code
629635
(tokens may never span lines) and our current position in that
630636
line. It has the following API:</p>

0 commit comments

Comments
 (0)