[TxMt] Re: Use injection scopes to disable/override existing rules
Allan Odgaard
mailinglist at textmate.org
Wed Jan 13 14:04:07 UTC 2016
On 11 Jan 2016, at 13:45, Mike McQuaid wrote:
> Another question about my GitHub Markdown bundle (which I’d like to
> propose become official when it’s good enough).
We’ve had a bunch of requests for fenced code blocks, so it would
certainly be nice with an “official” GitHub Flavored Markdown
bundle.
> The underscore handling in GitHub Flavoured Markdown
> (https://help.github.com/articles/github-flavored-markdown/#multiple-underscores-in-words)
> basically means I need to disable/override all of the existing
> underscore handling in the GitHub Markdown bundle. Is that possible
> somehow?
When you inject using the `L:` prefix then your rules run before the
root grammar’s.
So while you can’t disable the rules, you can inject your rules before
the default rules, and then match whatever they would match, so that
they never see it.
For the underscore handling, one solution could be to make a rule that
matches something like this: `_(?=\w)(?<=\w_)` (this regexp will match
underscores with word characters on both sides, but not make the word
characters part of the actual match).
Name that match something like `meta.interword-underscore.ghf-markdown`
and since your injected rule now “eats” the underscore, the default
rule will not see it, and should not go into emphasis mode for this
interword underscore.
More information about the textmate
mailing list