[TxMt] Re: Strange highlighting for Ruby embedded in Markdown

Stefan Daschek stefan at daschek.net
Fri Sep 11 13:46:10 UTC 2015


Am 07.09.15 um 21:59 schrieb Allan Odgaard:
> On 9 Jul 2015, at 13:30, Stefan Daschek wrote:
>
>> I added support for fenced code blocks to the Markdown bundle as
>> described in
>> https://github.com/textmate/markdown.tmbundle/issues/15#issuecomment-18321960
>>
>>
>> Then I added “meta.embedded_ruby” to the as injection scope selector
>> to the Ruby grammar.
>>
>> The result kind of works, but somehow the rule priority seems to get
>> mixed up (see screenshot).
>>
>> Any ideas how to fix this?
>
> The problem is that the ruby grammar is injected into your scope, this
> means that whenever the ruby grammar opens a new scope, the entire ruby
> grammar will also be injected into that scope, since the scope selector
> used for the injection still match.
>
> I think you can inject into `meta.embedded_ruby $` and it will only
> inject into the root of this sub-scope (due to the `$`) — during
> injection, the attribute scopes are currently ignored, which is why the
> tail anchor works.

Using `meta.embedded_ruby $` as injection grammar seems to work 
perfectly, thanks!

Would you accept a pull request for the markdown bundle to support 
fenced code blocks with embedded grammars?

The problem I see is that it would need to be accompanied by changes to 
other bundles (e.g. adding `meta.embedded_ruby $` as injection selector 
in the Ruby bundle, …).


Stefan.


More information about the textmate mailing list