[TxMt] Re: Embed lan
Martin Kühl
martin.kuehl at gmail.com
Wed Jan 24 16:35:31 UTC 2018
Hi,
On 24 January 2018 at 07:18, Huachao Mao <huachaomao at gmail.com> wrote:
> Hi all, I am new to TextMate, and not sure if it's appropriate to ask a
> question about embed language here.
>
> I have a language needs to embed JSON language syntax highlight. However,
> unlike most languages to have an specific identifier to mark the embed
> language scope like Markdown:
> ```json
> {"hello": "world}
> ```
> Here, for markdown language, the begin is ```json, and the end is ```. The
> contents between begin and end are real JSON.
> However, in my own language I just treat a line starts the { and [ as a
> JSON, since they are the begin characters of a valid JSON. And for my case,
> the end is the empty line. So the difference is that the matched line of
> begin regex also should be treat as the JSON language so that I can include
> source.json. But I don't know how to achieve this.
If I understand correctly you can do this using look-aheads, like:
{ begin = '^(?=[\[\{])';
end = '^$';
patterns = ( { include = 'source.json'; } );
}
Hope that helps,
Martin
More information about the textmate
mailing list