Skip to content
Permalink
Browse files

[simple mode addon] Support 'sol' property to force tokens to only ma…

  • Loading branch information
marijnh committed Jan 17, 2015
1 parent e53166b commit 2f162eeec682d24f5252de26474d55cff01c90db
Showing with 6 additions and 1 deletion.
  1. +1 −1 addon/mode/simple.js
  2. +5 −0 demo/simplemode.html
@@ -116,7 +116,7 @@
var curState = states[state.state];
for (var i = 0; i < curState.length; i++) {
var rule = curState[i];
var matches = stream.match(rule.regex);
var matches = (!rule.data.sol || stream.sol()) && stream.match(rule.regex);
if (matches) {
if (rule.data.next) {
state.state = rule.data.next;
@@ -74,6 +74,11 @@ <h2>Simple Mode Demo</h2>
string (since JS provides no way to find out where a group matched),
and this property must hold an array of token styles that has one
style for each matched group.</dd>
<dt><code><strong>sol</strong></code>: boolean</dt>
<dd>When true, this token will only match at the start of the line.
(The <code>^</code> regexp marker doesn't work as you'd expect in
this context because of limitations in JavaScript's RegExp
API.)</dd>
<dt><code><strong>next</strong>: string</code></dt>
<dd>When a <code>next</code> property is present, the mode will
transfer to the state named by the property when the token is

0 comments on commit 2f162ee

Please sign in to comment.
You can’t perform that action at this time.