I’m working on a bundle to add Markdown Extra to the stock Markdown language grammar with an injection. I have some of it working, but can’t seem to build the right regex to find the added classes syntax.
Here’s the Markdown Extra in question:
![Vagrant Logo](/images/icons/vagrant-logo.png){.image-right .image-33}When developing web sites on the Mac, we have a number of choices for serving the content and design we're working on.
I’m after the {.image-right .image-33} part and I’ve tried:
{ patterns = ( { name = 'source.yaml.front-matter'; begin = '\A-{3}'; end = '-{3}'; patterns = ( { include = 'source.yaml'; } ); }, { name = 'text.html.markdown.classes'; begin = '{'; end = '}'; }, { name = 'markup.raw.block.markdown'; begin = '^`{3}'; end = '^`{3}'; }, ); }
and
{ patterns = ( { name = 'source.yaml.front-matter'; begin = '\A-{3}'; end = '-{3}'; patterns = ( { include = 'source.yaml'; } ); }, { name = 'text.html.markdown.classes'; begin = '){'; end = '}'; }, { name = 'markup.raw.block.markdown'; begin = '^`{3}'; end = '^`{3}'; }, ); }
What did I get wrong?
Bob ------------------- Robert J. Rockefeller Richmond Hill, GA www.bobrockefeller.com
On 15 Nov 2015, at 13:46, Robert J. Rockefeller wrote:
Here’s the Markdown Extra in question:
![Vagrant Logo](/images/icons/vagrant-logo.png){.image-right .image-33}When developing web sites on the Mac, we have a number of choices for serving the content and design we're working on.
I’m after the {.image-right .image-33} part and I’ve tried: […] { name = 'text.html.markdown.classes'; begin = '){'; end = '}'; }, […] What did I get wrong?
I assume the quoted rule is what you expect to match the classes.
The problem is likely that somewhere else there is another rule matching `[«title»](«url»)` so your above rule will not get to match the last bracket in the link because it gets eaten by another rule.
You could change the regexp to use a look-behind assertion, for example:
begin = '{(?<=){)';
For performance reasons I avoid making the regexp start with the look-behind assertion.