I've been wanting to try my hand at bundle writing for a few weeks, and this morning I began tinkering with what could possibly grow into a reStructuredText bundle.
The first thing I attempted to figure out was how to recognize the section titles in reStructuredText. From the language specification (http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.htm):
Sections are identified through their titles, which are marked up with adornment: "underlines" below the title text, or underlines and matching "overlines" above the title. An underline/overline is a single repeated punctuation character that begins in column 1 and forms a line extending at least as far as the right edge of the title text.
For example:
A Title -------
============= Another Title =============
Not a title -----
================================== Don't think this is a title either
==================================
It isn't clear to me how to capture these patterns with the language grammar match rules, or indeed if it is even possible with the current TextMate toolset. It doesn't seem like 'match' can work for a multi-line pattern such as any of the above, and I haven't figured out how one can use 'begin/end' to match a 2 or 3 line rule (underline or overline/underline) but exclude things which don't match.
Is it possible? I freely admit that it's been quite a few years since I've taken a compilers class (or tried to do a language-parsing type thing), so I apologize if I'm missing something obvious.
The Markdown language (which I've never personally used) has a similar underline mechanism for specifying headings, but it looks like the Markdown TextMate bundle heading rule only captures the underline and not the heading text. For example, a Markdown heading and scopes:
A heading <= meta.paragraph.markdown, text.html.markdown ========= <= markup.heading.1.markdown, text.html.markdown
Thanks for any insight!
-- Matt Anderson
Matthew Anderson wrote:
I've been wanting to try my hand at bundle writing for a few weeks, and this morning I began tinkering with what could possibly grow into a reStructuredText bundle.
Matthew,
FYI, you may want to look at the reStructuredText bundle here: http://anon:anon@macromates.com/svn/Bundles/trunk/Bundles/reStructuredText.t...
It has support for syntax highlighting of reStructuredText, along with a couple of other features.
I think you may be out of luck with respect to multi-line matching in the grammar rules. I don't think it's supported in TextMate at this time.
Michael Henry