Simplemode, capturing "enter"


#1

I’m trying to implement “simple mode” for a project I’m doing. It’s working pretty nice but I would like the editor to start on “class” start on every newline. I cannot get this to work.

I’ve tried this;

        end: [
            {regex: /[.*]/, token: "nothing", next: "start" },
            {next: "start"}
        ],

All other tokens are pointing to “end” so the text after those tokens have class “nothing” and have start after an “enter” (newline). It only works when there are chars between the last string and the enter…

Anyone have an idea how to solve this?

Thx!


#2

Newlines aren’t treated like regular characters in the mode system, so there will simply be no chance to match anything between the end of line X and the start of line X + 1.

You may be able to implement your use case by matching to the end of the line as a separate group in your starting token, and assign that group a different token type (by putting an array in the token property).