[TxMt] Re: how do I confine a begin-end pattern to within a single paragraph?

Allan Odgaard mailinglist at textmate.org
Mon Jan 20 08:40:32 UTC 2014


On 20 Jan 2014, at 2:41, Matt Neuburg wrote:

> AsciiDoc marks bold like *this*, but I don't want this to work across 
> paragraph boundaries. I've started by arbitrarily dividing the 
> document into paragraphs: […]
> […] In the repository, I also define bold; the real pattern is quite 
> involved, but let's pretend it's very simple, like this:
>
> 	repository = {
> 		single_bold = {
> 			name = 'markup.bold.asciidoc';
> 			begin = '\*';
> 			end = '\*';
> 		};
> 	};

There is no way per-se to limit a begin/end rule to another rule.

Allowing this would require backtracking which would make the parsing 
much more expensive.

In your case, I think you should use a “match” rule to match bold 
words. Alternatively you can use begin/end with a begin pattern that 
uses look-ahead to ensure the bold is terminated within the same line.

The latter though would only be an advantage if you need to have 
child-rules within the matched bold text, and even there, you can still 
use a match-rule (and then have child rules be run on “captures” 
from the pattern).


More information about the textmate mailing list