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@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
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).
On 20 Jan 2014, at 2:41, Matt Neuburg wrote:
repository = { single_bold = { name = 'markup.bold.asciidoc'; begin = '*'; end = '*'; }; };
Adding to my previous reply, if a single asterisk is a user error (when not matched by a bullet list rule or bold) then another approach could be to do something like this:
single_bold = { name = 'markup.bold.asciidoc'; begin = '*'; end = '*|(\n)'; endCaptures = { 1 = { name = 'invalid.illegal.unterminated_asterisk.asciidoc'; }; }; };
Here we terminate the rule either when seeing an asterisk or seeing a newline character, and in the latter case, we scope the newline as “invalid.illegal” which, with most themes, should give it a red background.
You will get a big head start by copying the markdown grammar for things like this… also has nice ruby scripts for reformatting
On 20 Jan 2014, at 8:49 AM, Allan Odgaard mailinglist@textmate.org wrote:
On 20 Jan 2014, at 2:41, Matt Neuburg wrote:
repository = { single_bold = { name = 'markup.bold.asciidoc'; begin = '*'; end = '*'; }; };
Adding to my previous reply, if a single asterisk is a user error (when not matched by a bullet list rule or bold) then another approach could be to do something like this:
single_bold = { name = 'markup.bold.asciidoc'; begin = '*'; end = '*|(\n)'; endCaptures = { 1 = { name = 'invalid.illegal.unterminated_asterisk.asciidoc'; }; }; };
Here we terminate the rule either when seeing an asterisk or seeing a newline character, and in the latter case, we scope the newline as “invalid.illegal” which, with most themes, should give it a red background.
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
On Jan 20, 2014, at 12:40 AM, Allan Odgaard mailinglist@textmate.org wrote:
you can still use a match-rule (and then have child rules be run on “captures” from the pattern).
Oh, excellent, I'll give that a try; I didn't realize that when I wrote my message a couple of days ago on this topic, http://lists.macromates.com/textmate/2014-January/036908.html.
As always I very much appreciate these sorts of pointers. I am collecting notes for a "lessons learned" document that I hope will be useful some day! m.
-- matt neuburg, phd = matt@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