[TxMt] how do I confine a begin-end pattern to within a single paragraph?
Matt Neuburg
matt at tidbits.com
Sun Jan 19 19:41:01 UTC 2014
I'm still trying to get started writing my bundle, but I can't even get the first two rules to work...
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:
patterns = (
{ name = 'punctuation.test';
begin = '^';
end = '$';
},
);
I've marked 'punctuation.test' as red, so I can see that this is working.
====
This is a paragraph
And this is a different paragraph
====
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 = '\*';
};
};
Now I include single_bold in my punctuation.test paragraph, by changing the patterns to look like this:
patterns = (
{ name = 'punctuation.test';
begin = '^';
end = '$';
patterns = (
{ include = '#single_bold'; },
);
},
);
This screws everything up. Yes, it works on expressions like *this*. But it also works across paragraph boundaries:
====
Like *this
it boldifies* across paragraphs.
====
That is exactly what I wanted to prevent! What is happening, as I can see from my red "punctuation.test", is that including #single_bold in punctuation.test is actually changing the meaning of punctuation.test! Instead of stopping after "Like *this", the way it did before, punctuation.test is now mysteriously extended to included multiple paragraphs.
What I want to do is give the paragraph definition _priority_ so that #single_bold only works _inside_ a paragraph; instead, including #single_bold is causing the paragraph definition to stop working correctly and is extending both itself and the paragraph definition across multiple paragraphs. How do I prevent that? Or how do I make a begin/end rule that doesn't cross line boundaries? Thanks! m.
--
matt neuburg, phd = matt at tidbits.com, http://www.apeth.net/matt/
pantes anthropoi tou eidenai oregontai phusei
Programming iOS 7! http://shop.oreilly.com/product/0636920031017.do
iOS 7 Fundamentals! http://shop.oreilly.com/product/0636920032465.do
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com
More information about the textmate
mailing list