And here it is:
https://github.com/mattneub/AsciiDoc-TextMate-2
I would like to thank everyone (meaning Allan in particular) for so much hand-holding. I truly couldn't have done it without you.
(That's partly because, even after all this time, the state of documentation on how to write a grammar is startlingly inadequate; if I have time, I intend to write a public document providing some lessons learned.)
In conclusion I would like to repeat some suggestions about possible improvements to grammars, that would have helped me a lot:
* "exclude" in addition to the existing "include". This would allow me to include a batch of rules by a single name and then exclude the few that should _not_ be included.
* Peekahead. This is the setext problem, but it arises in a lot of areas of AsciiDoc. Despite concerns over speed and the problems of backtracking, it might be that the mere ability to examine _just the next line_ might all by itself be helpful without slowing things down too much, i.e. no, the next line is not a match for the "next" pattern, so *this* line is not a match for the "begin" pattern, and on we go to the next line.
* "include" should limit the search. You will recall that the problem I had is this (because AsciiDoc paragraphs can consist of multiple lines):
This (1) is a paragraph *consisting of multiple lines* and containing a stretch of bold.
This (2) is a paragraph with * an asterisk in it.
This (3) is another paragraph with * an asterisk in it.
Now, I can sort of pick out the paragraphs here by the fact that they are bounded by more than one return character. But if I code my "bold" rule as a begin-end rule, it picks up not only the bold in the paragraph 1 but (wrongly) a bold stretching from paragraph 2 to paragraph 3, _even if "bold" is an include within "paragraph"_. Indeed, TextMate extended the containing "paragraph" to include both 2 and 3 just in order to allow the "bold" to grow. Therefore I just had to give up and pick out neither. But what TextMate was doing here seems wrong to me and it would be nice if it wouldn't do that.
Still, what I ended up with is more than acceptable and definitely useful. Now that I can edit my books with it, I am able to move forward and adopt TextMate 2 full-time! 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