Support for filters in Haml TextMate bundle

9 views
Skip to first unread message

Phrogz

unread,
Feb 22, 2010, 6:36:55 PM2/22/10
to Haml
I'd like to see the Ruby Haml bundle recognize ":markdown" and punt
over to that language for proper syntax highlighting in TextMate (or,
in my case at work, e-texteditor).

I went to go add this ("How hard can it be?") but ran into two
problems. Before sharing my work thus far, I wanted to know if anyone
has already dived deep into this and determined it to be intractable.
Can someone state with authority that a TextMate language grammar
cannot properly punt over to Markdown and overcome the issues below?

What I Did
========
At a random point in the patterns at the root of the Ruby Haml
Language Grammar, I dropped this (in JSON notation, as edited within e-
texteditor):
{
"begin" : "^(\\s*):markdown\\b",
"end" : "^(?!\\1)|^\\1\\S",
"patterns" : [
{
"include" : "text.html.markdown"
}
]
},

Problem #1: Greedy Matching
======================
For some reason, the above 'worked' (applied the markdown grammar to
just Hello World) on content line this:
%foo
:markdown
**Hello**
World

%bar

...but failed (applied the markdown grammar to the %bar line also) on
content like this:
%foo
:markdown
**Hello**
World
%bar

This problem seemed solvable, but paled in comparison to...

Problem #2: Extra Indentation
======================
In Markdown, all lines indented past a certain amount become
preformatted literal text. Of course when TextMate applies the
markdown grammar to those lines you don't get any of the syntax
highlighting you'd actually like.

Is anyone here sufficiently ninja at TextMate language grammars to
know if it's possible to use the begin/end for the pattern as above,
but then supply sub-patterns that strips off the (captured from begin
or elsewhere) whitespace and applies the Markdown grammar to just the
content that follows that whitespace on that particular line? This
wouldn't allow Markdown to do any multi-line processing, but would be
better than nothing.

dreamcat4

unread,
Feb 25, 2010, 10:45:23 AM2/25/10
to Haml

Hi,
You should get onto IRC and talk about this on the textmate channel
with Ciaren, Alan, and the other textmate conributors. They've
probably seen this before for other things (like javascript embedded
in HTML, etc).

C'mon - don't be shy now!

Reply all
Reply to author
Forward
0 new messages