Hello
I’m trying to create a custom mode and I started by using Simple Mode addon. Although, I’ve already noticed some of its limitation and I’d like to know if you could help me.
CodeMirror.defineSimpleMode('simplemode', {
// The start state contains the rules that are intially used
start: [
{regex: /* .*/, token: 'ul', sol: true},
{regex: /### .*/, token: 'header-3', sol: true},
{regex: /## .*/, token: 'header-2', sol: true},
{regex: /# .*/, token: 'header-1', sol: true},
{regex: /\[.*]\(.*\)/, token: 'link'},
{regex: /(#.*#)/, token: 'tag'},
{regex: /(#[\w/]+)/, token: 'tag'},
{regex: /(#\w+)/, token: 'tag'},
{regex: /::.*?(::)/, token: 'marker'},
{regex: /\*.*?(\*)/, token: 'bold'},
{regex: /\/.*?(\/)/, token: 'italic'},
{regex: /_.*?(_)/, token: 'underline'},
{regex: /-.*?-/, token: 'strikethrough'}
]
})
The first thing is that {regex: /\[.*]\(.*\)/, token: 'link'}
is not being highlighted in the following case (and some others): /test [link](https://go.com)
. I get /test [link](https:/
highlighted as an italic. How do I make the link thing to be prioritized?
The second thing: I want to nest some of the tokens, like:
*bold /this italic but still bold/*
Which is not working now.
Another thing is with the first rule: {regex: /* .*/, token: 'ul', sol: true},
. If it matches, nothing else in that sentence is going to be matched…
How should I create a Mode that accomplishes this?
Thanks